-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tray icon component to show notifications to user
- Loading branch information
1 parent
628d87a
commit 4027e72
Showing
27 changed files
with
796 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Lanpartyseating.Desktop.Abstractions; | ||
|
||
[JsonDerivedType(typeof(ReservationStateRequest), typeDiscriminator: "sessionstaterequest")] | ||
[JsonDerivedType(typeof(ReservationStateResponse), typeDiscriminator: "sessionstateresponse")] | ||
[JsonDerivedType(typeof(TextMessage), typeDiscriminator: "textmessage")] | ||
public abstract class BaseMessage | ||
{ | ||
} |
16 changes: 16 additions & 0 deletions
16
Lanpartyseating.Desktop.Abstractions/JsonMessageSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Lanpartyseating.Desktop.Abstractions; | ||
|
||
using System.Text.Json; | ||
|
||
public static class JsonMessageSerializer | ||
{ | ||
public static T Deserialize<T>(string json) where T : BaseMessage | ||
{ | ||
return JsonSerializer.Deserialize<T>(json); | ||
} | ||
|
||
public static string Serialize(BaseMessage message) | ||
{ | ||
return JsonSerializer.Serialize(message); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Lanpartyseating.Desktop.Abstractions/Lanpartyseating.Desktop.Abstractions.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
5 changes: 5 additions & 0 deletions
5
Lanpartyseating.Desktop.Abstractions/ReservationStateRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace Lanpartyseating.Desktop.Abstractions; | ||
|
||
public class ReservationStateRequest : BaseMessage | ||
{ | ||
} |
8 changes: 8 additions & 0 deletions
8
Lanpartyseating.Desktop.Abstractions/ReservationStateResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Lanpartyseating.Desktop.Abstractions; | ||
|
||
public class ReservationStateResponse : BaseMessage | ||
{ | ||
public bool IsSessionActive { get; set; } | ||
public DateTimeOffset ReservationStart { get; set; } | ||
public DateTimeOffset ReservationEnd { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Lanpartyseating.Desktop.Abstractions; | ||
|
||
public class TextMessage : BaseMessage | ||
{ | ||
public string Content { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> | ||
<asmv3:application> | ||
<asmv3:windowsSettings> | ||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware> | ||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> | ||
</asmv3:windowsSettings> | ||
</asmv3:application> | ||
</assembly> |
29 changes: 29 additions & 0 deletions
29
Lanpartyseating.Desktop.Tray/Lanpartyseating.Desktop.Tray.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<UseWindowsForms>true</UseWindowsForms> | ||
<ApplicationIcon>trayicon.ico</ApplicationIcon> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<ApplicationManifest>ApplicationManifest.xml</ApplicationManifest> | ||
<AssemblyTitle>Otakuthon PC Gaming</AssemblyTitle> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="trayicon.ico" /> | ||
<EmbeddedResource Include="trayicon.ico" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" /> | ||
<PackageReference Include="Microsoft.WindowsAPICodePack.Shell" Version="1.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Lanpartyseating.Desktop.Abstractions\Lanpartyseating.Desktop.Abstractions.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
8 changes: 8 additions & 0 deletions
8
Lanpartyseating.Desktop.Tray/Lanpartyseating.Desktop.Tray.csproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Compile Update="Form1.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Runtime.InteropServices; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace Lanpartyseating.Desktop.Tray; | ||
|
||
static class Program | ||
{ | ||
[DllImport("shell32.dll", SetLastError = true)] | ||
static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID); | ||
|
||
static async Task Main(string[] args) | ||
{ | ||
// This code snippet uses the Shell32 API to create a shortcut and set the AppUserModelID | ||
var appUserModelId = "Otakuthon.Lanpartyseating.Desktop"; // Replace with your actual ID | ||
SetCurrentProcessExplicitAppUserModelID(appUserModelId); | ||
|
||
var hostBuilder = Host.CreateDefaultBuilder(args) | ||
.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddSingleton<TrayIcon>(); | ||
services.AddHostedService<TrayIconService>(); | ||
services.AddHostedService<ToastNotificationService>(); | ||
}); | ||
await hostBuilder.RunConsoleAsync();; | ||
} | ||
} |
Oops, something went wrong.