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