mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-27 02:34:41 +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;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Threading;
|
||||||
using v2rayN.Base;
|
using v2rayN.Base;
|
||||||
using v2rayN.Handler;
|
using v2rayN.Handler;
|
||||||
using v2rayN.Mode;
|
using v2rayN.Mode;
|
||||||
|
|
@ -39,7 +40,7 @@ namespace v2rayN.ViewModels
|
||||||
private readonly PaletteHelper _paletteHelper = new();
|
private readonly PaletteHelper _paletteHelper = new();
|
||||||
private Dictionary<string, bool> _dicHeaderSort = new();
|
private Dictionary<string, bool> _dicHeaderSort = new();
|
||||||
private Action<string> _updateView;
|
private Action<string> _updateView;
|
||||||
|
private DispatcherTimer _clickTimer;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ObservableCollection
|
#region ObservableCollection
|
||||||
|
|
@ -141,6 +142,7 @@ namespace v2rayN.ViewModels
|
||||||
public bool BlReloadEnabled { get; set; }
|
public bool BlReloadEnabled { get; set; }
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> NotifyDoubleClickCmd { get; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public Icon NotifyIcon { get; set; }
|
public Icon NotifyIcon { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
|
|
@ -478,6 +480,11 @@ namespace v2rayN.ViewModels
|
||||||
});
|
});
|
||||||
|
|
||||||
NotifyLeftClickCmd = ReactiveCommand.Create(() =>
|
NotifyLeftClickCmd = ReactiveCommand.Create(() =>
|
||||||
|
{
|
||||||
|
SwitchProxyEnable();
|
||||||
|
});
|
||||||
|
|
||||||
|
NotifyDoubleClickCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
ShowHideWindow(null);
|
ShowHideWindow(null);
|
||||||
});
|
});
|
||||||
|
|
@ -1435,6 +1442,23 @@ namespace v2rayN.ViewModels
|
||||||
|
|
||||||
#region System proxy and Routings
|
#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)
|
public void SetListenerType(ESysProxyType type)
|
||||||
{
|
{
|
||||||
if (_config.sysProxyType == type)
|
if (_config.sysProxyType == type)
|
||||||
|
|
@ -1560,6 +1584,7 @@ namespace v2rayN.ViewModels
|
||||||
|
|
||||||
public void ShowHideWindow(bool? blShow)
|
public void ShowHideWindow(bool? blShow)
|
||||||
{
|
{
|
||||||
|
_clickTimer?.Stop();
|
||||||
var bl = blShow ?? !Global.ShowInTaskbar;
|
var bl = blShow ?? !Global.ShowInTaskbar;
|
||||||
if (bl)
|
if (bl)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,8 @@
|
||||||
<tb:TaskbarIcon
|
<tb:TaskbarIcon
|
||||||
x:Name="tbNotify"
|
x:Name="tbNotify"
|
||||||
IconSource="/v2rayN.ico"
|
IconSource="/v2rayN.ico"
|
||||||
NoLeftClickDelay="True">
|
NoLeftClickDelay="True"
|
||||||
|
>
|
||||||
<tb:TaskbarIcon.ContextMenu>
|
<tb:TaskbarIcon.ContextMenu>
|
||||||
<ContextMenu Style="{StaticResource DefContextMenu}">
|
<ContextMenu Style="{StaticResource DefContextMenu}">
|
||||||
<MenuItem x:Name="menuSystemProxyClear" Height="{StaticResource MenuItemHeight}">
|
<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.NotifyIcon, v => v.tbNotify.Icon).DisposeWith(disposables);
|
||||||
this.OneWayBind(ViewModel, vm => vm.RunningServerToolTipText, v => v.tbNotify.ToolTipText).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.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);
|
this.OneWayBind(ViewModel, vm => vm.AppIcon, v => v.Icon).DisposeWith(disposables);
|
||||||
|
|
||||||
//status bar
|
//status bar
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue