From 9ec7b58f8943f1afa325d4de5d7153278bd24b3e Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sun, 23 May 2021 10:17:45 +1200 Subject: [PATCH] Fixed Game Shortcut Hotkeys Fixed the Game Shortcut hotkeys so that they work properly. Some late code changes yesterday broke them :(. Sorry for the inconvenience! Also stopped the annoying 'bing' everytime the notification toasts were created by DisplayMagician when it did things. They are now silent except for the ones that actually require your attention, which should stop it all being quite so jarring. --- DisplayMagician/Program.cs | 68 ------------------------- DisplayMagician/ShortcutRepository.cs | 34 +++++++++---- DisplayMagician/UIForms/MainForm.cs | 3 +- DisplayMagician/UIForms/ShortcutForm.cs | 5 +- 4 files changed, 29 insertions(+), 81 deletions(-) diff --git a/DisplayMagician/Program.cs b/DisplayMagician/Program.cs index 64ade01..4bfd4c1 100644 --- a/DisplayMagician/Program.cs +++ b/DisplayMagician/Program.cs @@ -732,74 +732,6 @@ namespace DisplayMagician { logger.Debug($"Program/LoadGamesInBackground: Starting"); // Now lets prepare loading all the Steam games we have installed - - /*Task loadSteamGamesTask = new Task(() => - { - // Check if Steam is installed - GameLibrary steamLibrary = SteamLibrary.GetLibrary(); - if (steamLibrary.IsGameLibraryInstalled) - { - // Load Steam library games - logger.Info($"Program/LoadGamesInBackground: Loading Installed Steam Games"); - if (!steamLibrary.LoadInstalledGames()) - { - logger.Info($"Program/LoadGamesInBackground: Cannot load installed Steam Games!"); - } - logger.Info($"Program/LoadGamesInBackground: Loaded all Installed Steam Games (found {steamLibrary.InstalledGameCount})"); - } - else - { - logger.Info($"Program/LoadGamesInBackground: Steam not installed."); - Console.WriteLine("Steam not installed."); - } - }); - - // Now lets prepare loading all the Uplay games we have installed - Task loadUplayGamesTask = new Task(() => - { - // Check if Uplay is installed - GameLibrary uplayLibrary = SteamLibrary.GetLibrary(); - if (uplayLibrary.IsGameLibraryInstalled) - { - // Load Uplay library games - logger.Info($"Program/LoadGamesInBackground: Loading Installed Uplay Games"); - if (!uplayLibrary.LoadInstalledGames()) - { - logger.Info($"Program/LoadGamesInBackground: Cannot load installed Uplay Games!"); - } - logger.Info($"Program/LoadGamesInBackground: Loaded all Installed Uplay Games (found {uplayLibrary.InstalledGameCount})"); - } - else - { - logger.Info($"Program/LoadGamesInBackground: Uplay not installed."); - Console.WriteLine("Uplay not installed."); - } - - }); - - // Now lets prepare loading all the Origin games we have installed - Task loadOriginGamesTask = new Task(() => - { - // Check if Origin is installed - GameLibrary originLibrary = SteamLibrary.GetLibrary(); - if (originLibrary.IsGameLibraryInstalled) - { - // Load Origin library games - logger.Info($"Program/LoadGamesInBackground: Loading Installed Origin Games"); - if (!originLibrary.LoadInstalledGames()) - { - logger.Info($"Program/LoadGamesInBackground: Cannot load installed Origin Games!"); - } - logger.Info($"Program/LoadGamesInBackground: Loaded all Installed Origin Games (found {originLibrary.InstalledGameCount})"); - } - else - { - logger.Info($"Program/LoadGamesInBackground: Origin not installed."); - Console.WriteLine("Origin not installed."); - } - - });*/ - Action loadSteamGamesAction = new Action(() => { // Check if Steam is installed diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index 338d653..8232d65 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -982,7 +982,8 @@ namespace DisplayMagician ToastContentBuilder tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=runningApplication", ToastActivationType.Foreground) .AddText($"Running {processNameToLookFor}", hintMaxLines: 1) - .AddText($"Waiting for all {processNameToLookFor} windows to exit..."); + .AddText($"Waiting for all {processNameToLookFor} windows to exit...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"),false,true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); ToastContent toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -990,6 +991,7 @@ namespace DisplayMagician doc.LoadXml(toastContent.GetContent()); // And create the toast notification var toast = new ToastNotification(doc); + toast.SuppressPopup = false; // Remove any other Notifications from us DesktopNotifications.DesktopNotificationManagerCompat.History.Clear(); // And then show this notification @@ -1028,7 +1030,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=stopDetected", ToastActivationType.Foreground) .AddText($"{processNameToLookFor} was closed", hintMaxLines: 1) - .AddText($"All {processNameToLookFor} processes were shutdown and changes were reverted."); + .AddText($"All {processNameToLookFor} processes were shutdown and changes were reverted.") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom doc = new XmlDocument(); @@ -1078,7 +1081,8 @@ namespace DisplayMagician ToastContentBuilder tcBuilder = new ToastContentBuilder() .AddToastActivationInfo($"notify=starting{gameLibraryToUse.GameLibraryName}", ToastActivationType.Foreground) .AddText($"Starting {gameLibraryToUse.GameLibraryName}", hintMaxLines: 1) - .AddText($"Waiting for {gameLibraryToUse.GameLibraryName} Game Library to start (and update if needed)..."); + .AddText($"Waiting for {gameLibraryToUse.GameLibraryName} Game Library to start (and update if needed)...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); ToastContent toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -1144,7 +1148,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo($"notify=updating{gameLibraryToUse.GameLibraryName}", ToastActivationType.Foreground) .AddText($"Updating {gameLibraryToUse.GameLibraryName}", hintMaxLines: 1) - .AddText($"Waiting for {gameLibraryToUse.GameLibraryName} Game Library to update itself..."); + .AddText($"Waiting for {gameLibraryToUse.GameLibraryName} Game Library to update itself...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -1193,7 +1198,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo($"notify=updating{gameToRun.Name}", ToastActivationType.Foreground) .AddText($"Updating {gameToRun.Name}", hintMaxLines: 1) - .AddText($"Waiting for {gameToRun.Name} Game to update..."); + .AddText($"Waiting for {gameToRun.Name} Game to update...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -1349,7 +1355,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=stopDetected", ToastActivationType.Foreground) .AddText($"{shortcutToUse.GameName} was closed", hintMaxLines: 1) - .AddText($"{shortcutToUse.GameName} game was exited."); + .AddText($"{shortcutToUse.GameName} game was exited.") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom doc = new XmlDocument(); @@ -1374,7 +1381,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo($"notify=running{gameLibraryToUse.GameLibraryName}Game", ToastActivationType.Foreground) .AddText($"Running {shortcutToUse.GameName}", hintMaxLines: 1) - .AddText($"Waiting for the {altGameProcessToMonitor} alternative game process to exit..."); + .AddText($"Waiting for the {altGameProcessToMonitor} alternative game process to exit...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -1409,7 +1417,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=stopDetected", ToastActivationType.Foreground) .AddText($"{altGameProcessToMonitor} was closed", hintMaxLines: 1) - .AddText($"{altGameProcessToMonitor} alternative game executable was exited."); + .AddText($"{altGameProcessToMonitor} alternative game executable was exited.") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom doc = new XmlDocument(); @@ -1438,7 +1447,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo($"notify=running{gameLibraryToUse.GameLibraryName}Game", ToastActivationType.Foreground) .AddText($"Running {shortcutToUse.GameName}", hintMaxLines: 1) - .AddText($"Waiting for the {gameLibraryToUse.GameLibraryName} Game {gameToRun.Name} to exit..."); + .AddText($"Waiting for the {gameLibraryToUse.GameLibraryName} Game {gameToRun.Name} to exit...") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); //.AddButton("Stop", ToastActivationType.Background, "notify=runningGame&action=stop"); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom @@ -1518,7 +1528,8 @@ namespace DisplayMagician tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=stopDetected", ToastActivationType.Foreground) .AddText($"{shortcutToUse.GameName} was closed", hintMaxLines: 1) - .AddText($"{shortcutToUse.GameName} game was exited."); + .AddText($"{shortcutToUse.GameName} game was exited.") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom doc = new XmlDocument(); @@ -1574,7 +1585,8 @@ namespace DisplayMagician ToastContentBuilder tcBuilder = new ToastContentBuilder() .AddToastActivationInfo("notify=minimiseStart&action=open", ToastActivationType.Foreground) .AddText("DisplayMagician is minimised", hintMaxLines: 1) - .AddButton("Open", ToastActivationType.Background, "notify=minimiseStart&action=open"); + .AddButton("Open", ToastActivationType.Background, "notify=minimiseStart&action=open") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); ToastContent toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom var doc = new XmlDocument(); diff --git a/DisplayMagician/UIForms/MainForm.cs b/DisplayMagician/UIForms/MainForm.cs index f1d8b0f..e74fdf4 100644 --- a/DisplayMagician/UIForms/MainForm.cs +++ b/DisplayMagician/UIForms/MainForm.cs @@ -224,7 +224,8 @@ namespace DisplayMagician.UIForms .AddText("DisplayMagician is still running...", hintMaxLines: 1) .AddText("DisplayMagician will wait in the background until you need it.") .AddButton("Open DisplayMagician", ToastActivationType.Background, "notify=stillRunning&action=open") - .AddButton("Exit DisplayMagician", ToastActivationType.Background, "notify=stillRunning&action=exit"); + .AddButton("Exit DisplayMagician", ToastActivationType.Background, "notify=stillRunning&action=exit") + .AddAudio(new Uri("ms-winsoundevent:Notification.Default"), false, true); ToastContent toastContent = tcBuilder.Content; // Make sure to use Windows.Data.Xml.Dom var doc = new XmlDocument(); diff --git a/DisplayMagician/UIForms/ShortcutForm.cs b/DisplayMagician/UIForms/ShortcutForm.cs index fb8d3a0..e9a58e0 100644 --- a/DisplayMagician/UIForms/ShortcutForm.cs +++ b/DisplayMagician/UIForms/ShortcutForm.cs @@ -2021,10 +2021,13 @@ namespace DisplayMagician.UIForms displayHotkeyForm.ShowDialog(this); if (displayHotkeyForm.DialogResult == DialogResult.OK) { + // If the hotkey has changed, then set the unsaved warning to true + if (!_hotkey.Equals(displayHotkeyForm.Hotkey)) + _isUnsaved = true; // now we store the Hotkey to be saved later _hotkey = displayHotkeyForm.Hotkey; // And if we get back and this is a Hotkey with a value, we need to show that in the UI - UpdateHotkeyLabel(_shortcutToEdit.Hotkey); + UpdateHotkeyLabel(_hotkey); } }