mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-10 13:47:48 +00:00
Add tray menu to display the main window
https://github.com/2dust/v2rayN/issues/7549
This commit is contained in:
parent
da3d4c36a9
commit
70151db91b
2 changed files with 28 additions and 6 deletions
|
@ -34,6 +34,8 @@ public class StatusBarViewModel : MyReactiveObject
|
|||
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShowWindowCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> 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<EViewAction, object?, Task<bool>>? 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<MainWindowViewModel>()?.ShowHideWindow(null);
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
ShowWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(true);
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
HideWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(false);
|
||||
await Task.CompletedTask;
|
||||
});
|
||||
|
||||
AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await AddServerViaClipboard();
|
||||
});
|
||||
{
|
||||
await AddServerViaClipboard();
|
||||
});
|
||||
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await AddServerViaScan();
|
||||
|
|
|
@ -32,7 +32,15 @@
|
|||
ToolTipText="{Binding RunningServerToolTipText}">
|
||||
<TrayIcon.Menu>
|
||||
<NativeMenu>
|
||||
<NativeMenuItem Command="{Binding NotifyLeftClickCmd}" Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding ShowWindowCmd}"
|
||||
Header="{x:Static resx:ResUI.TbDisplayGUI}"
|
||||
IsVisible="{Binding BlIsNonWindows}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding NotifyLeftClickCmd}"
|
||||
Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}"
|
||||
IsVisible="{Binding BlIsNonWindows}" />
|
||||
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
|
||||
<NativeMenuItemSeparator />
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxyClearCmd}"
|
||||
|
@ -60,8 +68,6 @@
|
|||
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
|
||||
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
|
||||
<NativeMenuItemSeparator />
|
||||
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
|
||||
<NativeMenuItemSeparator />
|
||||
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
|
||||
</NativeMenu>
|
||||
</TrayIcon.Menu>
|
||||
|
|
Loading…
Reference in a new issue