Introduce application context

This commit is contained in:
Luis von der Eltz
2021-02-06 14:52:41 +01:00
parent 97a3efc2a6
commit fd461bb9d4
7 changed files with 114 additions and 29 deletions
+1 -21
View File
@@ -1,12 +1,9 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using DesktopNotifications;
using DesktopNotifications.FreeDesktop;
using DesktopNotifications.Windows;
using Example.Win32;
namespace Example
{
@@ -25,24 +22,7 @@ namespace Example
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
const string AppName = "DesktopNotificationsExample";
SetCurrentProcessExplicitAppUserModelID(AppName);
using var shortcut = new ShellLink
{
TargetPath = Process.GetCurrentProcess().MainModule.FileName,
Arguments = string.Empty,
AppUserModelID = AppName
};
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var startMenuPath = Path.Combine(appData, @"Microsoft\Windows\Start Menu\Programs");
var shortcutFile = Path.Combine(startMenuPath, $"{AppName}.lnk");
shortcut.Save(shortcutFile);
return new WindowsNotificationManager(AppName);
return new WindowsNotificationManager();
}
throw new PlatformNotSupportedException();