From ea555b45b8ff2f055388603642a2024d98408c72 Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Mon, 1 Apr 2024 11:28:25 -0700 Subject: [PATCH] force update pw icon by hide and then show it --- .../Common/PersistentWindowProcessor.cs | 7 ++++--- .../SystrayShell/HotKey.cs | 2 +- .../SystrayShell/Program.cs | 11 ++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs index 9e2cea9..e8d8d93 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs @@ -158,10 +158,11 @@ namespace PersistentWindows.Common // callbacks public delegate void CallBack(); - public CallBack showRestoreTip; - public CallBack hideRestoreTip; + public delegate void CallBackBool(bool en = true); + + public CallBack showRestoreTip; + public CallBackBool hideRestoreTip; - public delegate void CallBackBool(bool en); public CallBackBool enableRestoreSnapshotMenu; public delegate void CallBackBool2(bool en, bool en2); public CallBackBool2 enableRestoreMenu; diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs index fd34448..3df6dbf 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/HotKey.cs @@ -43,7 +43,7 @@ namespace PersistentWindows.SystrayShell User32.KeyModifier modifier = (User32.KeyModifier)((int)m.LParam & 0xFFFF); // The modifier of the hotkey that was pressed. int id = m.WParam.ToInt32(); // The id of the hotkey that was pressed. - Program.ShowRestoreTip(); + Program.HideRestoreTip(false); //hide icon Program.HideRestoreTip(); //show icon hkwin.HotKeyPressed(); return; diff --git a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs index c6f06f4..5b4aa1a 100644 --- a/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs +++ b/Ninjacrab.PersistentWindows.Solution/SystrayShell/Program.cs @@ -415,12 +415,12 @@ namespace PersistentWindows.SystrayShell } } - public static void HideRestoreTip() + public static void HideRestoreTip(bool show_icon = true) { if (systrayForm.contextMenuStripSysTray.InvokeRequired) systrayForm.contextMenuStripSysTray.BeginInvoke((Action)delegate () { - HideRestoreTip(); + HideRestoreTip(show_icon); }); else { @@ -428,7 +428,12 @@ namespace PersistentWindows.SystrayShell ni.Icon = IdleIcon; if (Gui) - ni.Visible = true; + { + if (show_icon) + ni.Visible = true; + else + ni.Visible = false; + } } }