diff --git a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml index 843f055d2..7f54f34c2 100644 --- a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml +++ b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml @@ -15,11 +15,12 @@ ContextMenuMode="PopupMenu" DoubleClickCommand="{x:Bind ToggleAllVisibilityInvokeCommand}" LeftClickCommand="{x:Bind BringToForegroundInvokeCommand}" + RightClickCommand="{x:Bind UpdateContextMenuInvokeCommand}" > - + diff --git a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs index b10b1a0fd..66145db5e 100644 --- a/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs +++ b/CollapseLauncher/XAMLs/MainApp/TrayIcon.xaml.cs @@ -2,7 +2,6 @@ using H.NotifyIcon; using Hi3Helper; using Hi3Helper.Shared.Region; -using Microsoft.UI.Xaml; using System; using System.Runtime.InteropServices; using static CollapseLauncher.InnerLauncherConfig; @@ -59,8 +58,6 @@ public TrayIcon() // Switch toggle text to see if its started with Start MainTaskbarToggle.Text = (m_appMode == AppMode.StartOnTray) ? _showApp : _hideApp; ConsoleTaskbarToggle.Text = (m_appMode == AppMode.StartOnTray) ? _showConsole : _hideConsole; - // Show visibility toggle for console if the console is enabled - if (LauncherConfig.GetAppConfigValue("EnableConsole").ToBool()) ConsoleTaskbarToggle.Visibility = Visibility.Visible; } #endregion @@ -89,6 +86,12 @@ public TrayIcon() [RelayCommand] public void BringToForegroundInvoke() => BringToForeground(); + /// + /// Update tray context menu + /// + [RelayCommand] + public void UpdateContextMenuInvoke() => UpdateContextMenu(); + /// /// Close app /// @@ -143,7 +146,7 @@ public void ToggleMainVisibility() { WindowExtensions.Show(m_window); SetForegroundWindow(mainWindowHandle); - MainTaskbarToggle.Text = _hideConsole; + MainTaskbarToggle.Text = _hideApp; LogWriteLine("Main window is shown!"); } } @@ -202,6 +205,23 @@ public void BringToForeground() ShowWindow(mainWindowHandle, 9); SetForegroundWindow(mainWindowHandle); } + + /// + /// Update tray context menu + /// + public void UpdateContextMenu() + { + // Enable visibility toggle for console if the console is enabled + if (LauncherConfig.GetAppConfigValue("EnableConsole").ToBool()) + { + ConsoleTaskbarToggle.IsEnabled = true; + } + else + { + ConsoleTaskbarToggle.IsEnabled = false; + ConsoleTaskbarToggle.Text = _hideConsole; + } + } #endregion } }