From 412ac2c855da102f98ae541ed8bc858fe0bd4f21 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Wed, 6 Apr 2022 23:07:06 +1200 Subject: [PATCH] Attempt to open the singleInstance if passed no command parameters Also attempted to set the system tray notification popup correctly after a shortcut has been run. --- DisplayMagician/Properties/AssemblyInfo.cs | 4 ++-- DisplayMagician/ShortcutRepository.cs | 28 ++++++++++------------ DisplayMagician/SingleInstance.cs | 9 ++++++- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/DisplayMagician/Properties/AssemblyInfo.cs b/DisplayMagician/Properties/AssemblyInfo.cs index 9035efc..573bae9 100644 --- a/DisplayMagician/Properties/AssemblyInfo.cs +++ b/DisplayMagician/Properties/AssemblyInfo.cs @@ -26,8 +26,8 @@ using System.Resources; [assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")] // Version information -[assembly: AssemblyVersion("2.3.0.21")] -[assembly: AssemblyFileVersion("2.3.0.21")] +[assembly: AssemblyVersion("2.3.0.23")] +[assembly: AssemblyFileVersion("2.3.0.23")] [assembly: NeutralResourcesLanguageAttribute( "en" )] [assembly: CLSCompliant(true)] diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index 9197084..8511258 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -2038,6 +2038,19 @@ namespace DisplayMagician logger.Debug($"ShortcutRepository/RunShortcut: Shortcut did not require changing Display Profile, so no need to change it back."); } + // Reset the popup over the system tray icon to what's normal for it. + // Set the notifyIcon text with the current profile + if (myMainForm.InvokeRequired) + { + myMainForm.BeginInvoke((MethodInvoker)delegate { + myMainForm.UpdateNotifyIconText($"DisplayMagician ({ProfileRepository.CurrentProfile.Name})"); + }); + } + else + { + myMainForm.UpdateNotifyIconText($"DisplayMagician ({ProfileRepository.CurrentProfile.Name})"); + } + // And finally run the stop program we have if (shortcutToUse.StopPrograms.Count > 0) { @@ -2092,21 +2105,6 @@ namespace DisplayMagician } - - - // Reset the popup over the system tray icon to what's normal for it. - // Set the notifyIcon text with the current profile - if (myMainForm.InvokeRequired) - { - myMainForm.BeginInvoke((MethodInvoker)delegate { - myMainForm.UpdateNotifyIconText($"DisplayMagician ({ProfileRepository.CurrentProfile.Name})"); - }); - } - else - { - myMainForm.UpdateNotifyIconText($"DisplayMagician ({ProfileRepository.CurrentProfile.Name})"); - } - // If we're running DisplayMagician from a Desktop Shortcut and then shutting down again, then it will quit, leaving behind a desktop icon // We need to remove that Desktopicon to tidy up in that case. if (temporaryMainForm) diff --git a/DisplayMagician/SingleInstance.cs b/DisplayMagician/SingleInstance.cs index 31c368d..aaadb4d 100644 --- a/DisplayMagician/SingleInstance.cs +++ b/DisplayMagician/SingleInstance.cs @@ -95,7 +95,14 @@ namespace DisplayMagician } else { - logger.Warn($"SingleInstance/executeAnActionCallback: Other DisplayMagician instance didn't provide any commandline arguments at all. THat's not supposed to happen."); + logger.Warn($"SingleInstance/executeAnActionCallback: Other DisplayMagician instance didn't provide any commandline arguments at all so bringing the topmost window to the foreground."); + foreach (Form aForm in Application.OpenForms) + { + if (aForm.TopMost) + { + aForm.Activate(); + } + } } }