mirror of https://github.com/2dust/v2rayN
Using RxApp replace ViewAction
parent
058c6e4a85
commit
5a3286dad1
|
@ -32,16 +32,7 @@ public enum EViewAction
|
|||
FullConfigTemplateWindow,
|
||||
GlobalHotkeySettingWindow,
|
||||
SubSettingWindow,
|
||||
DispatcherSpeedTest,
|
||||
DispatcherRefreshConnections,
|
||||
DispatcherRefreshProxyGroups,
|
||||
DispatcherProxiesDelayTest,
|
||||
DispatcherStatistics,
|
||||
DispatcherServerAvailability,
|
||||
DispatcherReload,
|
||||
DispatcherRefreshServersBiz,
|
||||
DispatcherRefreshIcon,
|
||||
DispatcherCheckUpdate,
|
||||
DispatcherCheckUpdateFinished,
|
||||
DispatcherShowMsg,
|
||||
}
|
||||
|
|
|
@ -12,4 +12,6 @@ public static class AppEvents
|
|||
public static readonly Subject<string> SendMsgViewRequested = 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.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
|
@ -188,7 +190,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
|||
{
|
||||
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 UpgradeCore();
|
||||
|
||||
|
@ -198,11 +200,20 @@ public class CheckUpdateViewModel : MyReactiveObject
|
|||
await UpgradeN();
|
||||
}
|
||||
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)
|
||||
{
|
||||
|
@ -299,10 +310,15 @@ public class CheckUpdateViewModel : MyReactiveObject
|
|||
CoreType = coreType,
|
||||
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);
|
||||
if (found == null)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
|
@ -64,10 +65,14 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
|||
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();
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Reactive;
|
||||
using System.Reactive.Concurrency;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
|
@ -168,11 +170,11 @@ public class ClashProxiesViewModel : MyReactiveObject
|
|||
|
||||
if (refreshUI)
|
||||
{
|
||||
_updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
||||
RxApp.MainThreadScheduler.Schedule(() => _ = RefreshProxyGroups());
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshProxyGroups()
|
||||
public async Task RefreshProxyGroups()
|
||||
{
|
||||
if (_proxies == null)
|
||||
{
|
||||
|
@ -380,12 +382,17 @@ public class ClashProxiesViewModel : MyReactiveObject
|
|||
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;
|
||||
}
|
||||
|
||||
public void ProxiesDelayTestResult(SpeedTestResult result)
|
||||
public async Task ProxiesDelayTestResult(SpeedTestResult result)
|
||||
{
|
||||
//UpdateHandler(false, $"{item.name}={result}");
|
||||
var detail = _proxyDetails.FirstOrDefault(it => it.Name == result.IndexId);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reactive;
|
||||
using System.Reactive.Concurrency;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
|
@ -278,19 +279,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
{
|
||||
return;
|
||||
}
|
||||
await _updateView?.Invoke(EViewAction.DispatcherStatistics, 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);
|
||||
}
|
||||
AppEvents.DispatcherStatisticsRequested.OnNext(update);
|
||||
}
|
||||
|
||||
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
||||
|
@ -578,7 +567,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
});
|
||||
Locator.Current.GetService<StatusBarViewModel>()?.TestServerAvailability();
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||
RxApp.MainThreadScheduler.Schedule(() => _ = ReloadResult());
|
||||
|
||||
BlReloadEnabled = true;
|
||||
if (_hasNextReloadJob)
|
||||
|
@ -588,7 +577,7 @@ public class MainWindowViewModel : MyReactiveObject
|
|||
}
|
||||
}
|
||||
|
||||
public void ReloadResult()
|
||||
public async Task ReloadResult()
|
||||
{
|
||||
// BlReloadEnabled = true;
|
||||
//Locator.Current.GetService<StatusBarViewModel>()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using DynamicData;
|
||||
|
@ -247,13 +248,19 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
|
||||
#endregion WhenAnyValue && ReactiveCommand
|
||||
|
||||
if (_updateView != null)
|
||||
{
|
||||
AppEvents.ProfilesRefreshRequested
|
||||
#region AppEvents
|
||||
|
||||
AppEvents.ProfilesRefreshRequested
|
||||
.AsObservable()
|
||||
.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();
|
||||
}
|
||||
|
@ -278,7 +285,7 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
|
||||
}
|
||||
|
||||
public void SetSpeedTestResult(SpeedTestResult result)
|
||||
public async Task SetSpeedTestResult(SpeedTestResult result)
|
||||
{
|
||||
if (result.IndexId.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -305,8 +312,15 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
//_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
|
||||
{
|
||||
var item = _profileItems.FirstOrDefault(it => it.IndexId == update.IndexId);
|
||||
|
@ -753,7 +767,14 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Text;
|
||||
using DynamicData.Binding;
|
||||
|
@ -198,10 +199,20 @@ public class StatusBarViewModel : MyReactiveObject
|
|||
|
||||
#endregion WhenAnyValue && ReactiveCommand
|
||||
|
||||
#region AppEvents
|
||||
|
||||
if (updateView != null)
|
||||
{
|
||||
InitUpdateView(updateView);
|
||||
}
|
||||
|
||||
AppEvents.DispatcherStatisticsRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async result => await UpdateStatistics(result));
|
||||
|
||||
#endregion AppEvents
|
||||
|
||||
_ = Init();
|
||||
}
|
||||
|
||||
|
@ -331,15 +342,24 @@ public class StatusBarViewModel : MyReactiveObject
|
|||
return;
|
||||
}
|
||||
|
||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, ResUI.Speedtesting);
|
||||
await TestServerAvailabilitySub(ResUI.Speedtesting);
|
||||
|
||||
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -508,8 +528,13 @@ public class StatusBarViewModel : MyReactiveObject
|
|||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void UpdateStatistics(ServerSpeedItem update)
|
||||
public async Task UpdateStatistics(ServerSpeedItem update)
|
||||
{
|
||||
if (!_config.GuiItem.DisplayRealTimeSpeed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (_config.IsRunningCore(ECoreType.sing_box))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System.Reactive.Disposables;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
|
@ -24,25 +23,6 @@ public partial class CheckUpdateView : ReactiveUserControl<CheckUpdateViewModel>
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ using System.Reactive.Disposables;
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
|
@ -31,17 +30,6 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Reactive.Disposables;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.ReactiveUI;
|
||||
using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
|
@ -40,23 +39,6 @@ public partial class ClashProxiesView : ReactiveUserControl<ClashProxiesViewMode
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
|
|
@ -135,6 +135,7 @@ public partial class GlobalHotkeySettingWindow : WindowBase<GlobalHotkeySettingV
|
|||
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
|
|
@ -222,20 +222,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||
DispatcherPriority.Default);
|
||||
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:
|
||||
if (obj != null && _blCloseByUser == false)
|
||||
{
|
||||
|
|
|
@ -211,6 +211,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
|||
ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
|
|
@ -183,15 +183,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
|||
return false;
|
||||
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:
|
||||
Dispatcher.UIThread.Post(RefreshServersBiz, DispatcherPriority.Default);
|
||||
break;
|
||||
|
|
|
@ -135,6 +135,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
btnCancel.Focus();
|
||||
|
|
|
@ -56,15 +56,6 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
|||
{
|
||||
switch (action)
|
||||
{
|
||||
case EViewAction.DispatcherServerAvailability:
|
||||
if (obj is null)
|
||||
return false;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.TestServerAvailabilityResult((string)obj),
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
|
||||
|
||||
case EViewAction.DispatcherRefreshIcon:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
|
|
|
@ -117,6 +117,7 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
|
|||
menuClose_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
lstSubscription.Focus();
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Views;
|
||||
|
@ -24,27 +22,6 @@ public partial class CheckUpdateView
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace v2rayN.Views;
|
||||
|
@ -33,18 +32,6 @@ public partial class ClashConnectionsView
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
|
||||
|
@ -41,26 +39,6 @@ public partial class ClashProxiesView
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,22 +212,6 @@ public partial class MainWindow
|
|||
}), DispatcherPriority.Normal);
|
||||
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:
|
||||
Application.Current?.Dispatcher.Invoke((() =>
|
||||
{
|
||||
|
|
|
@ -164,15 +164,6 @@ public partial class ProfilesView
|
|||
return 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:
|
||||
Application.Current?.Dispatcher.Invoke(RefreshServersBiz, DispatcherPriority.Normal);
|
||||
break;
|
||||
|
|
|
@ -77,17 +77,6 @@ public partial class StatusBarView
|
|||
{
|
||||
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:
|
||||
Application.Current?.Dispatcher.Invoke((async () =>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue