mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-10 21:57:46 +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> SubUpdateViaProxyCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
|
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> ShowWindowCmd { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> HideWindowCmd { get; }
|
||||||
|
|
||||||
#region System Proxy
|
#region System Proxy
|
||||||
|
|
||||||
|
@ -91,6 +93,9 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool EnableTun { get; set; }
|
public bool EnableTun { get; set; }
|
||||||
|
|
||||||
|
[Reactive]
|
||||||
|
public bool BlIsNonWindows { get; set; }
|
||||||
|
|
||||||
#endregion UI
|
#endregion UI
|
||||||
|
|
||||||
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
|
@ -100,6 +105,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
SelectedServer = new();
|
SelectedServer = new();
|
||||||
RunningServerToolTipText = "-";
|
RunningServerToolTipText = "-";
|
||||||
BlSystemProxyPacVisible = Utils.IsWindows();
|
BlSystemProxyPacVisible = Utils.IsWindows();
|
||||||
|
BlIsNonWindows = Utils.IsNonWindows();
|
||||||
|
|
||||||
if (_config.TunModeItem.EnableTun && AllowEnableTun())
|
if (_config.TunModeItem.EnableTun && AllowEnableTun())
|
||||||
{
|
{
|
||||||
|
@ -143,11 +149,21 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
|
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
|
||||||
await Task.CompletedTask;
|
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 () =>
|
AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
await AddServerViaClipboard();
|
await AddServerViaClipboard();
|
||||||
});
|
});
|
||||||
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
|
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
await AddServerViaScan();
|
await AddServerViaScan();
|
||||||
|
|
|
@ -32,7 +32,15 @@
|
||||||
ToolTipText="{Binding RunningServerToolTipText}">
|
ToolTipText="{Binding RunningServerToolTipText}">
|
||||||
<TrayIcon.Menu>
|
<TrayIcon.Menu>
|
||||||
<NativeMenu>
|
<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 />
|
<NativeMenuItemSeparator />
|
||||||
<NativeMenuItem
|
<NativeMenuItem
|
||||||
Command="{Binding SystemProxyClearCmd}"
|
Command="{Binding SystemProxyClearCmd}"
|
||||||
|
@ -60,8 +68,6 @@
|
||||||
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
|
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
|
||||||
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
|
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
|
||||||
<NativeMenuItemSeparator />
|
<NativeMenuItemSeparator />
|
||||||
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
|
|
||||||
<NativeMenuItemSeparator />
|
|
||||||
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
|
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
|
||||||
</NativeMenu>
|
</NativeMenu>
|
||||||
</TrayIcon.Menu>
|
</TrayIcon.Menu>
|
||||||
|
|
Loading…
Reference in a new issue