mirror of https://github.com/2dust/v2rayN
Improved Desktop TrayIcon
parent
7618f9f7d4
commit
e530789739
|
@ -56,6 +56,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
//servers delete
|
||||
public ReactiveCommand<Unit, Unit> EditServerCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> RemoveServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RemoveDuplicateServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CopyServerCmd { get; }
|
||||
|
@ -66,12 +67,14 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
//servers move
|
||||
public ReactiveCommand<Unit, Unit> MoveTopCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> MoveUpCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveDownCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveBottomCmd { get; }
|
||||
|
||||
//servers ping
|
||||
public ReactiveCommand<Unit, Unit> MixedTestServerCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> TcpingServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> RealPingServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SpeedServerCmd { get; }
|
||||
|
@ -79,6 +82,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
//servers export
|
||||
public ReactiveCommand<Unit, Unit> Export2ClientConfigCmd { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Export2ClientConfigClipboardCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> Export2ShareUrlCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> Export2ShareUrlBase64Cmd { get; }
|
||||
|
@ -95,7 +99,11 @@ namespace ServiceLib.ViewModels
|
|||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
|
||||
MessageBus.Current.Listen<string>(EMsgCommand.RefreshProfiles.ToString()).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
if (_updateView != null)
|
||||
{
|
||||
MessageBus.Current.Listen<string>(EMsgCommand.RefreshProfiles.ToString())
|
||||
.Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
}
|
||||
|
||||
SelectedProfile = new();
|
||||
SelectedSub = new();
|
||||
|
|
|
@ -52,6 +52,18 @@ namespace ServiceLib.ViewModels
|
|||
[Reactive]
|
||||
public bool BlSystemProxyPac { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool BlNotSystemProxyClear { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool BlNotSystemProxySet { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool BlNotSystemProxyNothing { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public bool BlNotSystemProxyPac { get; set; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SystemProxyClearCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SystemProxySetCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SystemProxyNothingCmd { get; }
|
||||
|
@ -321,6 +333,11 @@ namespace ServiceLib.ViewModels
|
|||
BlSystemProxyNothing = (type == ESysProxyType.Unchanged);
|
||||
BlSystemProxyPac = (type == ESysProxyType.Pac);
|
||||
|
||||
BlNotSystemProxyClear = !BlSystemProxyClear;
|
||||
BlNotSystemProxySet = !BlSystemProxySet;
|
||||
BlNotSystemProxyNothing = !BlSystemProxyNothing;
|
||||
BlNotSystemProxyPac = !BlSystemProxyPac;
|
||||
|
||||
if (blChange)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
|
|
|
@ -28,21 +28,47 @@
|
|||
<TrayIcon.Icons>
|
||||
<TrayIcons>
|
||||
<TrayIcon
|
||||
Clicked="TrayIcon_Clicked"
|
||||
Command="{Binding NotifyLeftClickCmd}"
|
||||
Icon="/Assets/NotifyIcon1.ico"
|
||||
ToolTipText="v2rayN Desktop">
|
||||
ToolTipText="{Binding RunningServerToolTipText}">
|
||||
<TrayIcon.Menu>
|
||||
<NativeMenu>
|
||||
<NativeMenuItem Command="{Binding SystemProxyClearCmd}" Header="{x:Static resx:ResUI.menuSystemProxyClear}" />
|
||||
<NativeMenuItem Command="{Binding SystemProxySetCmd}" Header="{x:Static resx:ResUI.menuSystemProxySet}" />
|
||||
<NativeMenuItem Command="{Binding SystemProxyNothingCmd}" Header="{x:Static resx:ResUI.menuSystemProxyNothing}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxyClearCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxyClear}"
|
||||
IsVisible="{Binding BlNotSystemProxyClear}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxyClearCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxyClear}"
|
||||
Icon="/Assets/NotifyIcon1.ico"
|
||||
IsVisible="{Binding BlSystemProxyClear}" />
|
||||
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxySetCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxySet}"
|
||||
IsVisible="{Binding BlNotSystemProxySet}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxySetCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxySet}"
|
||||
Icon="/Assets/NotifyIcon2.ico"
|
||||
IsVisible="{Binding BlSystemProxySet}" />
|
||||
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxyNothingCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
|
||||
IsVisible="{Binding BlNotSystemProxyNothing}" />
|
||||
<NativeMenuItem
|
||||
Command="{Binding SystemProxyNothingCmd}"
|
||||
Header="{x:Static resx:ResUI.menuSystemProxyNothing}"
|
||||
Icon="/Assets/NotifyIcon3.ico"
|
||||
IsVisible="{Binding BlSystemProxyNothing}" />
|
||||
<NativeMenuItemSeparator />
|
||||
<NativeMenuItem Click="MenuAddServerViaClipboardClick" Header="{x:Static resx:ResUI.menuAddServerViaClipboard}" />
|
||||
<NativeMenuItem Header="{x:Static resx:ResUI.menuAddServerViaScan}" IsVisible="False" />
|
||||
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
|
||||
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
|
||||
<NativeMenuItemSeparator />
|
||||
<NativeMenuItem Click="TrayIcon_Clicked" Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}" />
|
||||
<NativeMenuItem Command="{Binding NotifyLeftClickCmd}" Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}" />
|
||||
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
|
||||
</NativeMenu>
|
||||
</TrayIcon.Menu>
|
||||
|
|
|
@ -74,21 +74,6 @@ public partial class App : Application
|
|||
{
|
||||
}
|
||||
|
||||
private void TrayIcon_Clicked(object? sender, EventArgs e)
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
if (desktop.MainWindow.IsVisible)
|
||||
{
|
||||
desktop.MainWindow?.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
desktop.MainWindow?.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuAddServerViaClipboardClick(object? sender, EventArgs e)
|
||||
{
|
||||
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
|
|
Loading…
Reference in New Issue