From 340e1a6db081b0ee51a02567bbba08ab583dfdbf Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sun, 31 Oct 2021 09:50:34 +1300 Subject: [PATCH] Added additional places to refresh notification icons This should hopefully cover all the instances of when we need to update the notification icons to refresh the correct profiles and game shortcuts. --- DisplayMagician/UIForms/DisplayProfileForm.cs | 19 ++++++++++++ .../UIForms/ShortcutLibraryForm.cs | 30 +++++++++++++++---- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs index 0fa6c23..b828068 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.cs @@ -69,6 +69,12 @@ namespace DisplayMagician.UIForms { logger.Warn($"DisplayProfileForm/Apply_Click: Error applying the Profile {_selectedProfile.Name}. Unable to change the display layout."); } + + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } } @@ -124,6 +130,12 @@ namespace DisplayMagician.UIForms } + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + } private void Save_Click(object sender, EventArgs e) @@ -178,6 +190,7 @@ namespace DisplayMagician.UIForms { MessageBox.Show(ex.Message, Language.Shortcut, MessageBoxButtons.OK, MessageBoxIcon.Warning); } + } } @@ -431,6 +444,12 @@ namespace DisplayMagician.UIForms // now update the profiles image listview RefreshDisplayProfileUI(); + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + } private void ilv_saved_profiles_ItemClick(object sender, ItemClickEventArgs e) diff --git a/DisplayMagician/UIForms/ShortcutLibraryForm.cs b/DisplayMagician/UIForms/ShortcutLibraryForm.cs index 3e3b33e..19981ac 100644 --- a/DisplayMagician/UIForms/ShortcutLibraryForm.cs +++ b/DisplayMagician/UIForms/ShortcutLibraryForm.cs @@ -102,12 +102,6 @@ namespace DisplayMagician.UIForms // Restart updating the saved_profiles listview ilv_saved_shortcuts.ResumeLayout(); - // Also refresh the right-click menu (if we have a main form loaded) - if (Program.AppMainForm is Form) - { - Program.AppMainForm.RefreshNotifyIconMenus(); - } - } private ShortcutItem GetShortcutFromName(string shortcutName) @@ -207,6 +201,7 @@ namespace DisplayMagician.UIForms } catch (Exception ex) { + logger.Warn(ex, $"ShortcutLibraryForm/btn_save_Click: Exception saving shortcut to {dialog_save.FileName}."); MessageBox.Show(ex.Message, Language.Shortcut, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } @@ -282,6 +277,11 @@ namespace DisplayMagician.UIForms this.Cursor = Cursors.Default; RemoveWarningIfShortcuts(); + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } } private void btn_edit_Click(object sender, EventArgs e) @@ -328,6 +328,12 @@ namespace DisplayMagician.UIForms } this.Cursor = Cursors.Default; + + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } } } @@ -365,6 +371,12 @@ namespace DisplayMagician.UIForms ShortcutRepository.IsValidRefresh(); RefreshShortcutLibraryUI(); RemoveWarningIfShortcuts(); + + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } } private void btn_run_Click(object sender, EventArgs e) @@ -437,6 +449,12 @@ namespace DisplayMagician.UIForms lbl_mask.Visible = false; lbl_mask.SendToBack(); + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + } private void ilv_saved_shortcuts_ItemHover(object sender, ItemHoverEventArgs e)