From 70151db91b03cf9110ea480f4a56cf54285f3ba5 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 9 Jul 2025 20:31:37 +0800 Subject: [PATCH] Add tray menu to display the main window https://github.com/2dust/v2rayN/issues/7549 --- .../ViewModels/StatusBarViewModel.cs | 22 ++++++++++++++++--- v2rayN/v2rayN.Desktop/App.axaml | 12 +++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index dfb5c854..bbc6c585 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -34,6 +34,8 @@ public class StatusBarViewModel : MyReactiveObject public ReactiveCommand SubUpdateViaProxyCmd { get; } public ReactiveCommand CopyProxyCmdToClipboardCmd { get; } public ReactiveCommand NotifyLeftClickCmd { get; } + public ReactiveCommand ShowWindowCmd { get; } + public ReactiveCommand HideWindowCmd { get; } #region System Proxy @@ -91,6 +93,9 @@ public class StatusBarViewModel : MyReactiveObject [Reactive] public bool EnableTun { get; set; } + [Reactive] + public bool BlIsNonWindows { get; set; } + #endregion UI public StatusBarViewModel(Func>? updateView) @@ -100,6 +105,7 @@ public class StatusBarViewModel : MyReactiveObject SelectedServer = new(); RunningServerToolTipText = "-"; BlSystemProxyPacVisible = Utils.IsWindows(); + BlIsNonWindows = Utils.IsNonWindows(); if (_config.TunModeItem.EnableTun && AllowEnableTun()) { @@ -143,11 +149,21 @@ public class StatusBarViewModel : MyReactiveObject Locator.Current.GetService()?.ShowHideWindow(null); await Task.CompletedTask; }); + ShowWindowCmd = ReactiveCommand.CreateFromTask(async () => + { + Locator.Current.GetService()?.ShowHideWindow(true); + await Task.CompletedTask; + }); + HideWindowCmd = ReactiveCommand.CreateFromTask(async () => + { + Locator.Current.GetService()?.ShowHideWindow(false); + await Task.CompletedTask; + }); AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () => - { - await AddServerViaClipboard(); - }); + { + await AddServerViaClipboard(); + }); AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () => { await AddServerViaScan(); diff --git a/v2rayN/v2rayN.Desktop/App.axaml b/v2rayN/v2rayN.Desktop/App.axaml index 22b10811..8b61125f 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml +++ b/v2rayN/v2rayN.Desktop/App.axaml @@ -32,7 +32,15 @@ ToolTipText="{Binding RunningServerToolTipText}"> - + + + - -