mirror of
https://github.com/2dust/v2rayN.git
synced 2025-09-01 15:56:19 +00:00
parent
6ee8f03ec0
commit
dea7afcf24
3 changed files with 30 additions and 3 deletions
|
@ -14,6 +14,7 @@ using System.Text;
|
|||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using v2rayN.Base;
|
||||
using v2rayN.Handler;
|
||||
using v2rayN.Mode;
|
||||
|
@ -39,7 +40,7 @@ namespace v2rayN.ViewModels
|
|||
private readonly PaletteHelper _paletteHelper = new();
|
||||
private Dictionary<string, bool> _dicHeaderSort = new();
|
||||
private Action<string> _updateView;
|
||||
|
||||
private DispatcherTimer _clickTimer;
|
||||
#endregion
|
||||
|
||||
#region ObservableCollection
|
||||
|
@ -141,6 +142,7 @@ namespace v2rayN.ViewModels
|
|||
public bool BlReloadEnabled { get; set; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> NotifyDoubleClickCmd { get; }
|
||||
[Reactive]
|
||||
public Icon NotifyIcon { get; set; }
|
||||
[Reactive]
|
||||
|
@ -479,7 +481,12 @@ namespace v2rayN.ViewModels
|
|||
|
||||
NotifyLeftClickCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ShowHideWindow(null);
|
||||
SwitchProxyEnable();
|
||||
});
|
||||
|
||||
NotifyDoubleClickCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ShowHideWindow(null);
|
||||
});
|
||||
|
||||
//System proxy
|
||||
|
@ -1435,6 +1442,23 @@ namespace v2rayN.ViewModels
|
|||
|
||||
#region System proxy and Routings
|
||||
|
||||
public void SwitchProxyEnable()
|
||||
{
|
||||
_clickTimer?.Stop();
|
||||
_clickTimer = new DispatcherTimer(new TimeSpan(0, 0, 0,0,300), DispatcherPriority.Normal, delegate
|
||||
{
|
||||
if (_config.sysProxyType == ESysProxyType.ForcedClear)
|
||||
{
|
||||
SetListenerType(ESysProxyType.ForcedChange);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetListenerType(ESysProxyType.ForcedClear);
|
||||
}
|
||||
_clickTimer.Stop();
|
||||
}, Application.Current.Dispatcher);
|
||||
}
|
||||
|
||||
public void SetListenerType(ESysProxyType type)
|
||||
{
|
||||
if (_config.sysProxyType == type)
|
||||
|
@ -1560,6 +1584,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
public void ShowHideWindow(bool? blShow)
|
||||
{
|
||||
_clickTimer?.Stop();
|
||||
var bl = blShow ?? !Global.ShowInTaskbar;
|
||||
if (bl)
|
||||
{
|
||||
|
|
|
@ -728,7 +728,8 @@
|
|||
<tb:TaskbarIcon
|
||||
x:Name="tbNotify"
|
||||
IconSource="/v2rayN.ico"
|
||||
NoLeftClickDelay="True">
|
||||
NoLeftClickDelay="True"
|
||||
>
|
||||
<tb:TaskbarIcon.ContextMenu>
|
||||
<ContextMenu Style="{StaticResource DefContextMenu}">
|
||||
<MenuItem x:Name="menuSystemProxyClear" Height="{StaticResource MenuItemHeight}">
|
||||
|
|
|
@ -161,6 +161,7 @@ namespace v2rayN.Views
|
|||
this.OneWayBind(ViewModel, vm => vm.NotifyIcon, v => v.tbNotify.Icon).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.RunningServerToolTipText, v => v.tbNotify.ToolTipText).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.NotifyLeftClickCmd, v => v.tbNotify.LeftClickCommand).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.NotifyDoubleClickCmd, v => v.tbNotify.DoubleClickCommand).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.AppIcon, v => v.Icon).DisposeWith(disposables);
|
||||
|
||||
//status bar
|
||||
|
|
Loading…
Reference in a new issue