From 5e9c02aa68f7e8e0f638e212ee68578603dae2df Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Wed, 17 Mar 2021 21:38:16 +1300 Subject: [PATCH] Fixed the notify icon when minimised When the notifyicon was minimised we had problems as it would close the main window when trying to update the icon text. This is fixed now. --- .../UIForms/ShortcutLibraryForm.cs | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/DisplayMagician/UIForms/ShortcutLibraryForm.cs b/DisplayMagician/UIForms/ShortcutLibraryForm.cs index e9f8969..a6c06a0 100644 --- a/DisplayMagician/UIForms/ShortcutLibraryForm.cs +++ b/DisplayMagician/UIForms/ShortcutLibraryForm.cs @@ -319,19 +319,25 @@ namespace DisplayMagician.UIForms else if (_selectedShortcut.Category.Equals(ShortcutCategory.Game)) message = $"Running the {_selectedShortcut.GameName} game and waiting until you close it."; - // Create a MaskForm that will cover the ShortcutLibrary Window to lock - // the controls and inform the user that the game is running.... - MaskedForm maskedForm = MaskedForm.Show(this, message); - - // Get the MainForm so we can access the NotifyIcon on it. - MainForm mainForm = (MainForm)this.Owner; - - // Run the shortcut - ShortcutRepository.RunShortcut(_selectedShortcut, mainForm.notifyIcon); - - // Only do this if we are NOT minimised if (!Program.AppProgramSettings.MinimiseOnStart) + { + // Create a MaskForm that will cover the ShortcutLibrary Window to lock + // the controls and inform the user that the game is running.... + MaskedForm maskedForm = MaskedForm.Show(this, message); + + // Get the MainForm so we can access the NotifyIcon on it. + MainForm mainForm = (MainForm)this.Owner; + + // Run the shortcut + ShortcutRepository.RunShortcut(_selectedShortcut, mainForm.notifyIcon); + maskedForm.Close(); + } + else + { + // Run the shortcut + ShortcutRepository.RunShortcut(_selectedShortcut, Program.AppMainForm.notifyIcon); + } } private void ilv_saved_shortcuts_ItemHover(object sender, ItemHoverEventArgs e)