diff --git a/v2rayN/ServiceLib/Enums/EViewAction.cs b/v2rayN/ServiceLib/Enums/EViewAction.cs index bf7360e2..c4689c9a 100644 --- a/v2rayN/ServiceLib/Enums/EViewAction.cs +++ b/v2rayN/ServiceLib/Enums/EViewAction.cs @@ -32,16 +32,7 @@ public enum EViewAction FullConfigTemplateWindow, GlobalHotkeySettingWindow, SubSettingWindow, - DispatcherSpeedTest, - DispatcherRefreshConnections, - DispatcherRefreshProxyGroups, - DispatcherProxiesDelayTest, - DispatcherStatistics, - DispatcherServerAvailability, - DispatcherReload, DispatcherRefreshServersBiz, DispatcherRefreshIcon, - DispatcherCheckUpdate, - DispatcherCheckUpdateFinished, DispatcherShowMsg, } diff --git a/v2rayN/ServiceLib/Handler/AppEvents.cs b/v2rayN/ServiceLib/Handler/AppEvents.cs index 093c5259..a651365d 100644 --- a/v2rayN/ServiceLib/Handler/AppEvents.cs +++ b/v2rayN/ServiceLib/Handler/AppEvents.cs @@ -12,4 +12,6 @@ public static class AppEvents public static readonly Subject SendMsgViewRequested = new(); public static readonly Subject AppExitRequested = new(); + + public static readonly Subject DispatcherStatisticsRequested = new(); } diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index 59a3b163..c87f6737 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -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) diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index 222e1a8d..1fd9015c 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -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? connections) + public async Task RefreshConnections(List? connections) { _connectionItems.Clear(); diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 0149c0fb..531b4a8e 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -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); diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 9ea9e296..fa5dc82b 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -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()?.UpdateStatistics(update); - } - if (_config.GuiItem.EnableStatistics && (update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0) - { - Locator.Current.GetService()?.UpdateStatistics(update); - } + AppEvents.DispatcherStatisticsRequested.OnNext(update); } public async Task MyAppExitAsync(bool blWindowsShutDown) @@ -578,7 +567,7 @@ public class MainWindowViewModel : MyReactiveObject }); Locator.Current.GetService()?.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()?.ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, false); diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 49e47949..10ec4b4b 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -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()?.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); } diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 1be54da7..c89f55cb 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -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)) diff --git a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs index a8b04bfc..9567c1fd 100644 --- a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs @@ -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 private async Task 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); } } diff --git a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs index c39724eb..76a0fd1d 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ClashConnectionsView.axaml.cs @@ -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 UpdateViewHandler(EViewAction action, object? obj) { - switch (action) - { - case EViewAction.DispatcherRefreshConnections: - if (obj is null) - return false; - Dispatcher.UIThread.Post(() => - ViewModel?.RefreshConnections((List?)obj), - DispatcherPriority.Default); - break; - } - return await Task.FromResult(true); } diff --git a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs index 1b63f4f4..754dd2a1 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs @@ -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 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); } diff --git a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs index 974b2823..38f3d34c 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs @@ -50,6 +50,7 @@ public partial class FullConfigTemplateWindow : WindowBase 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) { diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index 673fc819..6a313a35 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -211,6 +211,7 @@ public partial class OptionSettingWindow : WindowBase ViewModel.destOverride = clbdestOverride.SelectedItems.Cast().ToList(); } } + private void Window_Loaded(object? sender, RoutedEventArgs e) { btnCancel.Focus(); diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 4253661b..733a2194 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -183,15 +183,6 @@ public partial class ProfilesView : ReactiveUserControl return false; return await new SubEditWindow((SubItem)obj).ShowDialog(_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; diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs index b0ff1e89..50a79d18 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs @@ -135,6 +135,7 @@ public partial class RoutingSettingWindow : WindowBase } } } + private void Window_Loaded(object? sender, RoutedEventArgs e) { btnCancel.Focus(); diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs index e4458721..d90affe2 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml.cs @@ -56,15 +56,6 @@ public partial class StatusBarView : ReactiveUserControl { 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(() => { diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs index b708f610..d563aeb1 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs @@ -117,6 +117,7 @@ public partial class SubSettingWindow : WindowBase menuClose_Click(null, null); } } + private void Window_Loaded(object? sender, RoutedEventArgs e) { lstSubscription.Focus(); diff --git a/v2rayN/v2rayN/Views/CheckUpdateView.xaml.cs b/v2rayN/v2rayN/Views/CheckUpdateView.xaml.cs index 931c5e7a..cf53fc1a 100644 --- a/v2rayN/v2rayN/Views/CheckUpdateView.xaml.cs +++ b/v2rayN/v2rayN/Views/CheckUpdateView.xaml.cs @@ -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 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); } } diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs index 18b97d2a..da1795bd 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml.cs @@ -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 UpdateViewHandler(EViewAction action, object? obj) { - switch (action) - { - case EViewAction.DispatcherRefreshConnections: - if (obj is null) - return false; - Application.Current?.Dispatcher.Invoke((() => - { - ViewModel?.RefreshConnections((List?)obj); - }), DispatcherPriority.Normal); - break; - } - return await Task.FromResult(true); } diff --git a/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs b/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs index c174a110..eff95de9 100644 --- a/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ClashProxiesView.xaml.cs @@ -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 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); } diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index 4270ce55..4c35d2e9 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -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((() => { diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index f2456b57..0248a53a 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -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; diff --git a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs index c29fbdc3..a4fcef55 100644 --- a/v2rayN/v2rayN/Views/StatusBarView.xaml.cs +++ b/v2rayN/v2rayN/Views/StatusBarView.xaml.cs @@ -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 () => {