mirror of https://github.com/2dust/v2rayN
Using RxApp replace ViewAction
parent
058c6e4a85
commit
5a3286dad1
|
@ -32,16 +32,7 @@ public enum EViewAction
|
||||||
FullConfigTemplateWindow,
|
FullConfigTemplateWindow,
|
||||||
GlobalHotkeySettingWindow,
|
GlobalHotkeySettingWindow,
|
||||||
SubSettingWindow,
|
SubSettingWindow,
|
||||||
DispatcherSpeedTest,
|
|
||||||
DispatcherRefreshConnections,
|
|
||||||
DispatcherRefreshProxyGroups,
|
|
||||||
DispatcherProxiesDelayTest,
|
|
||||||
DispatcherStatistics,
|
|
||||||
DispatcherServerAvailability,
|
|
||||||
DispatcherReload,
|
|
||||||
DispatcherRefreshServersBiz,
|
DispatcherRefreshServersBiz,
|
||||||
DispatcherRefreshIcon,
|
DispatcherRefreshIcon,
|
||||||
DispatcherCheckUpdate,
|
|
||||||
DispatcherCheckUpdateFinished,
|
|
||||||
DispatcherShowMsg,
|
DispatcherShowMsg,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,6 @@ public static class AppEvents
|
||||||
public static readonly Subject<string> SendMsgViewRequested = new();
|
public static readonly Subject<string> SendMsgViewRequested = new();
|
||||||
|
|
||||||
public static readonly Subject<Unit> AppExitRequested = new();
|
public static readonly Subject<Unit> AppExitRequested = new();
|
||||||
|
|
||||||
|
public static readonly Subject<ServerSpeedItem> DispatcherStatisticsRequested = new();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
@ -188,7 +190,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (_lstUpdated.Count > 0 && _lstUpdated.Count(x => x.IsFinished == true) == _lstUpdated.Count)
|
if (_lstUpdated.Count > 0 && _lstUpdated.Count(x => x.IsFinished == true) == _lstUpdated.Count)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, false);
|
await UpdateFinishedSub(false);
|
||||||
await Task.Delay(2000);
|
await Task.Delay(2000);
|
||||||
await UpgradeCore();
|
await UpgradeCore();
|
||||||
|
|
||||||
|
@ -198,11 +200,20 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
await UpgradeN();
|
await UpgradeN();
|
||||||
}
|
}
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
_updateView?.Invoke(EViewAction.DispatcherCheckUpdateFinished, true);
|
await UpdateFinishedSub(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateFinishedResult(bool blReload)
|
private async Task UpdateFinishedSub(bool blReload)
|
||||||
|
{
|
||||||
|
RxApp.MainThreadScheduler.Schedule(blReload, (scheduler, blReload) =>
|
||||||
|
{
|
||||||
|
_ = UpdateFinishedResult(blReload);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateFinishedResult(bool blReload)
|
||||||
{
|
{
|
||||||
if (blReload)
|
if (blReload)
|
||||||
{
|
{
|
||||||
|
@ -299,10 +310,15 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
CoreType = coreType,
|
CoreType = coreType,
|
||||||
Remarks = msg,
|
Remarks = msg,
|
||||||
};
|
};
|
||||||
await _updateView?.Invoke(EViewAction.DispatcherCheckUpdate, item);
|
|
||||||
|
RxApp.MainThreadScheduler.Schedule(item, (scheduler, model) =>
|
||||||
|
{
|
||||||
|
_ = UpdateViewResult(model);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateViewResult(CheckUpdateModel model)
|
public async Task UpdateViewResult(CheckUpdateModel model)
|
||||||
{
|
{
|
||||||
var found = _checkUpdateModel.FirstOrDefault(t => t.CoreType == model.CoreType);
|
var found = _checkUpdateModel.FirstOrDefault(t => t.CoreType == model.CoreType);
|
||||||
if (found == null)
|
if (found == null)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
@ -64,10 +65,14 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, ret?.connections);
|
RxApp.MainThreadScheduler.Schedule(ret?.connections, (scheduler, model) =>
|
||||||
|
{
|
||||||
|
_ = RefreshConnections(model);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshConnections(List<ConnectionItem>? connections)
|
public async Task RefreshConnections(List<ConnectionItem>? connections)
|
||||||
{
|
{
|
||||||
_connectionItems.Clear();
|
_connectionItems.Clear();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Concurrency;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
@ -168,11 +170,11 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (refreshUI)
|
if (refreshUI)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
RxApp.MainThreadScheduler.Schedule(() => _ = RefreshProxyGroups());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshProxyGroups()
|
public async Task RefreshProxyGroups()
|
||||||
{
|
{
|
||||||
if (_proxies == null)
|
if (_proxies == null)
|
||||||
{
|
{
|
||||||
|
@ -380,12 +382,17 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.Name, Delay = result });
|
var model = new SpeedTestResult() { IndexId = item.Name, Delay = result };
|
||||||
|
RxApp.MainThreadScheduler.Schedule(model, (scheduler, model) =>
|
||||||
|
{
|
||||||
|
_ = ProxiesDelayTestResult(model);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProxiesDelayTestResult(SpeedTestResult result)
|
public async Task ProxiesDelayTestResult(SpeedTestResult result)
|
||||||
{
|
{
|
||||||
//UpdateHandler(false, $"{item.name}={result}");
|
//UpdateHandler(false, $"{item.name}={result}");
|
||||||
var detail = _proxyDetails.FirstOrDefault(it => it.Name == result.IndexId);
|
var detail = _proxyDetails.FirstOrDefault(it => it.Name == result.IndexId);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Concurrency;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
@ -278,19 +279,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await _updateView?.Invoke(EViewAction.DispatcherStatistics, update);
|
AppEvents.DispatcherStatisticsRequested.OnNext(update);
|
||||||
}
|
|
||||||
|
|
||||||
public void SetStatisticsResult(ServerSpeedItem update)
|
|
||||||
{
|
|
||||||
if (_config.GuiItem.DisplayRealTimeSpeed)
|
|
||||||
{
|
|
||||||
Locator.Current.GetService<StatusBarViewModel>()?.UpdateStatistics(update);
|
|
||||||
}
|
|
||||||
if (_config.GuiItem.EnableStatistics && (update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0)
|
|
||||||
{
|
|
||||||
Locator.Current.GetService<ProfilesViewModel>()?.UpdateStatistics(update);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
||||||
|
@ -578,7 +567,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
});
|
});
|
||||||
Locator.Current.GetService<StatusBarViewModel>()?.TestServerAvailability();
|
Locator.Current.GetService<StatusBarViewModel>()?.TestServerAvailability();
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
RxApp.MainThreadScheduler.Schedule(() => _ = ReloadResult());
|
||||||
|
|
||||||
BlReloadEnabled = true;
|
BlReloadEnabled = true;
|
||||||
if (_hasNextReloadJob)
|
if (_hasNextReloadJob)
|
||||||
|
@ -588,7 +577,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadResult()
|
public async Task ReloadResult()
|
||||||
{
|
{
|
||||||
// BlReloadEnabled = true;
|
// BlReloadEnabled = true;
|
||||||
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
|
@ -247,13 +248,19 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
#endregion WhenAnyValue && ReactiveCommand
|
#endregion WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
if (_updateView != null)
|
#region AppEvents
|
||||||
{
|
|
||||||
AppEvents.ProfilesRefreshRequested
|
AppEvents.ProfilesRefreshRequested
|
||||||
.AsObservable()
|
.AsObservable()
|
||||||
.ObserveOn(RxApp.MainThreadScheduler)
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
.Subscribe(async _ => await RefreshServersBiz());//.DisposeWith(_disposables);
|
.Subscribe(async _ => await RefreshServersBiz());
|
||||||
}
|
|
||||||
|
AppEvents.DispatcherStatisticsRequested
|
||||||
|
.AsObservable()
|
||||||
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
|
.Subscribe(async result => await UpdateStatistics(result));
|
||||||
|
|
||||||
|
#endregion AppEvents
|
||||||
|
|
||||||
_ = Init();
|
_ = Init();
|
||||||
}
|
}
|
||||||
|
@ -278,7 +285,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
|
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSpeedTestResult(SpeedTestResult result)
|
public async Task SetSpeedTestResult(SpeedTestResult result)
|
||||||
{
|
{
|
||||||
if (result.IndexId.IsNullOrEmpty())
|
if (result.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
@ -305,8 +312,15 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
//_profileItems.Replace(item, JsonUtils.DeepCopy(item));
|
//_profileItems.Replace(item, JsonUtils.DeepCopy(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateStatistics(ServerSpeedItem update)
|
public async Task UpdateStatistics(ServerSpeedItem update)
|
||||||
{
|
{
|
||||||
|
if (!_config.GuiItem.EnableStatistics
|
||||||
|
|| (update.ProxyUp + update.ProxyDown) <= 0
|
||||||
|
|| DateTime.Now.Second % 3 != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = _profileItems.FirstOrDefault(it => it.IndexId == update.IndexId);
|
var item = _profileItems.FirstOrDefault(it => it.IndexId == update.IndexId);
|
||||||
|
@ -753,7 +767,14 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_speedtestService ??= new SpeedtestService(_config, (SpeedTestResult result) => _updateView?.Invoke(EViewAction.DispatcherSpeedTest, result));
|
_speedtestService ??= new SpeedtestService(_config, async (SpeedTestResult result) =>
|
||||||
|
{
|
||||||
|
RxApp.MainThreadScheduler.Schedule(result, (scheduler, result) =>
|
||||||
|
{
|
||||||
|
_ = SetSpeedTestResult(result);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
|
});
|
||||||
_speedtestService?.RunLoop(actionType, lstSelected);
|
_speedtestService?.RunLoop(actionType, lstSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
@ -198,10 +199,20 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
#endregion WhenAnyValue && ReactiveCommand
|
#endregion WhenAnyValue && ReactiveCommand
|
||||||
|
|
||||||
|
#region AppEvents
|
||||||
|
|
||||||
if (updateView != null)
|
if (updateView != null)
|
||||||
{
|
{
|
||||||
InitUpdateView(updateView);
|
InitUpdateView(updateView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppEvents.DispatcherStatisticsRequested
|
||||||
|
.AsObservable()
|
||||||
|
.ObserveOn(RxApp.MainThreadScheduler)
|
||||||
|
.Subscribe(async result => await UpdateStatistics(result));
|
||||||
|
|
||||||
|
#endregion AppEvents
|
||||||
|
|
||||||
_ = Init();
|
_ = Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,15 +342,24 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, ResUI.Speedtesting);
|
await TestServerAvailabilitySub(ResUI.Speedtesting);
|
||||||
|
|
||||||
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
|
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
|
||||||
|
|
||||||
NoticeManager.Instance.SendMessageEx(msg);
|
NoticeManager.Instance.SendMessageEx(msg);
|
||||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
await TestServerAvailabilitySub(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TestServerAvailabilityResult(string msg)
|
private async Task TestServerAvailabilitySub(string msg)
|
||||||
|
{
|
||||||
|
RxApp.MainThreadScheduler.Schedule(msg, (scheduler, msg) =>
|
||||||
|
{
|
||||||
|
_ = TestServerAvailabilityResult(msg);
|
||||||
|
return Disposable.Empty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task TestServerAvailabilityResult(string msg)
|
||||||
{
|
{
|
||||||
RunningInfoDisplay = msg;
|
RunningInfoDisplay = msg;
|
||||||
}
|
}
|
||||||
|
@ -508,8 +528,13 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateStatistics(ServerSpeedItem update)
|
public async Task UpdateStatistics(ServerSpeedItem update)
|
||||||
{
|
{
|
||||||
|
if (!_config.GuiItem.DisplayRealTimeSpeed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_config.IsRunningCore(ECoreType.sing_box))
|
if (_config.IsRunningCore(ECoreType.sing_box))
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Avalonia.Threading;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace v2rayN.Desktop.Views;
|
namespace v2rayN.Desktop.Views;
|
||||||
|
@ -24,25 +23,6 @@ public partial class CheckUpdateView : ReactiveUserControl<CheckUpdateViewModel>
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherCheckUpdate:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.UpdateViewResult((CheckUpdateModel)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherCheckUpdateFinished:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.UpdateFinishedResult((bool)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ using System.Reactive.Disposables;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Avalonia.Threading;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace v2rayN.Desktop.Views;
|
namespace v2rayN.Desktop.Views;
|
||||||
|
@ -31,17 +30,6 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherRefreshConnections:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.RefreshConnections((List<ConnectionItem>?)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Avalonia.Threading;
|
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
@ -40,23 +39,6 @@ public partial class ClashProxiesView : ReactiveUserControl<ClashProxiesViewMode
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherRefreshProxyGroups:
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.RefreshProxyGroups(),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherProxiesDelayTest:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.ProxiesDelayTestResult((SpeedTestResult)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
|
||||||
{
|
{
|
||||||
ProcUtils.ProcessStart("https://github.com/2dust/v2rayN/wiki/Description-of-some-ui#%E5%AE%8C%E6%95%B4%E9%85%8D%E7%BD%AE%E6%A8%A1%E6%9D%BF%E8%AE%BE%E7%BD%AE");
|
ProcUtils.ProcessStart("https://github.com/2dust/v2rayN/wiki/Description-of-some-ui#%E5%AE%8C%E6%95%B4%E9%85%8D%E7%BD%AE%E6%A8%A1%E6%9D%BF%E8%AE%BE%E7%BD%AE");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnCancel.Focus();
|
btnCancel.Focus();
|
||||||
|
|
|
@ -135,6 +135,7 @@ public partial class GlobalHotkeySettingWindow : WindowBase<GlobalHotkeySettingV
|
||||||
|
|
||||||
return res.ToString();
|
return res.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnCancel.Focus();
|
btnCancel.Focus();
|
||||||
|
|
|
@ -222,20 +222,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
DispatcherPriority.Default);
|
DispatcherPriority.Default);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EViewAction.DispatcherStatistics:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.SetStatisticsResult((ServerSpeedItem)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherReload:
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.ReloadResult(),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.Shutdown:
|
case EViewAction.Shutdown:
|
||||||
if (obj != null && _blCloseByUser == false)
|
if (obj != null && _blCloseByUser == false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -211,6 +211,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||||
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
|
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnCancel.Focus();
|
btnCancel.Focus();
|
||||||
|
|
|
@ -183,15 +183,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||||
return false;
|
return false;
|
||||||
return await new SubEditWindow((SubItem)obj).ShowDialog<bool>(_window);
|
return await new SubEditWindow((SubItem)obj).ShowDialog<bool>(_window);
|
||||||
|
|
||||||
case EViewAction.DispatcherSpeedTest:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.SetSpeedTestResult((SpeedTestResult)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherRefreshServersBiz:
|
case EViewAction.DispatcherRefreshServersBiz:
|
||||||
Dispatcher.UIThread.Post(RefreshServersBiz, DispatcherPriority.Default);
|
Dispatcher.UIThread.Post(RefreshServersBiz, DispatcherPriority.Default);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -135,6 +135,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
btnCancel.Focus();
|
btnCancel.Focus();
|
||||||
|
|
|
@ -56,15 +56,6 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case EViewAction.DispatcherServerAvailability:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
ViewModel?.TestServerAvailabilityResult((string)obj),
|
|
||||||
DispatcherPriority.Default);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case EViewAction.DispatcherRefreshIcon:
|
case EViewAction.DispatcherRefreshIcon:
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -117,6 +117,7 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
|
||||||
menuClose_Click(null, null);
|
menuClose_Click(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
lstSubscription.Focus();
|
lstSubscription.Focus();
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace v2rayN.Views;
|
namespace v2rayN.Views;
|
||||||
|
@ -24,27 +22,6 @@ public partial class CheckUpdateView
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherCheckUpdate:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.UpdateViewResult((CheckUpdateModel)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherCheckUpdateFinished:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.UpdateFinishedResult((bool)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Threading;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
namespace v2rayN.Views;
|
namespace v2rayN.Views;
|
||||||
|
@ -33,18 +32,6 @@ public partial class ClashConnectionsView
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherRefreshConnections:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.RefreshConnections((List<ConnectionItem>?)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Threading;
|
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Splat;
|
using Splat;
|
||||||
|
|
||||||
|
@ -41,26 +39,6 @@ public partial class ClashProxiesView
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case EViewAction.DispatcherRefreshProxyGroups:
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.RefreshProxyGroups();
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherProxiesDelayTest:
|
|
||||||
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.ProxiesDelayTestResult((SpeedTestResult)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return await Task.FromResult(true);
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,22 +212,6 @@ public partial class MainWindow
|
||||||
}), DispatcherPriority.Normal);
|
}), DispatcherPriority.Normal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EViewAction.DispatcherStatistics:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.SetStatisticsResult((ServerSpeedItem)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherReload:
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.ReloadResult();
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.Shutdown:
|
case EViewAction.Shutdown:
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
Application.Current?.Dispatcher.Invoke((() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,15 +164,6 @@ public partial class ProfilesView
|
||||||
return false;
|
return false;
|
||||||
return (new SubEditWindow((SubItem)obj)).ShowDialog() ?? false;
|
return (new SubEditWindow((SubItem)obj)).ShowDialog() ?? false;
|
||||||
|
|
||||||
case EViewAction.DispatcherSpeedTest:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.SetSpeedTestResult((SpeedTestResult)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EViewAction.DispatcherRefreshServersBiz:
|
case EViewAction.DispatcherRefreshServersBiz:
|
||||||
Application.Current?.Dispatcher.Invoke(RefreshServersBiz, DispatcherPriority.Normal);
|
Application.Current?.Dispatcher.Invoke(RefreshServersBiz, DispatcherPriority.Normal);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -77,17 +77,6 @@ public partial class StatusBarView
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case EViewAction.DispatcherServerAvailability:
|
|
||||||
if (obj is null)
|
|
||||||
return false;
|
|
||||||
Application.Current?.Dispatcher.Invoke((() =>
|
|
||||||
{
|
|
||||||
ViewModel?.TestServerAvailabilityResult((string)obj);
|
|
||||||
}), DispatcherPriority.Normal);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case EViewAction.DispatcherRefreshIcon:
|
case EViewAction.DispatcherRefreshIcon:
|
||||||
Application.Current?.Dispatcher.Invoke((async () =>
|
Application.Current?.Dispatcher.Invoke((async () =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue