diff --git a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml new file mode 100644 index 00000000..a5bcda43 --- /dev/null +++ b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml @@ -0,0 +1,96 @@ + + + \ No newline at end of file diff --git a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs new file mode 100644 index 00000000..ea1c0ddf --- /dev/null +++ b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml.cs @@ -0,0 +1,48 @@ +using Avalonia.ReactiveUI; +using Avalonia.Threading; +using ReactiveUI; +using System.Reactive.Disposables; + +namespace v2rayN.Desktop.Views +{ + public partial class CheckUpdateView : ReactiveUserControl + { + public CheckUpdateView() + { + InitializeComponent(); + + ViewModel = new CheckUpdateViewModel(UpdateViewHandler); + + this.WhenActivated(disposables => + { + this.OneWayBind(ViewModel, vm => vm.CheckUpdateItems, v => v.lstCheckUpdates.ItemsSource).DisposeWith(disposables); + + this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.CheckUpdateCmd, v => v.btnCheckUpdate).DisposeWith(disposables); + this.OneWayBind(ViewModel, vm => vm.IsCheckUpdate, v => v.btnCheckUpdate.IsEnabled).DisposeWith(disposables); + }); + } + + private async Task UpdateViewHandler(EViewAction action, object? obj) + { + switch (action) + { + case EViewAction.DispatcherCheckUpdate: + if (obj is null) return false; + Dispatcher.UIThread.Post(() => + ViewModel?.UpdateViewResult((CheckUpdateItem)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); + } + } +} \ No newline at end of file diff --git a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml index 0399ea16..d03c864f 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml @@ -104,7 +104,7 @@ diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml index 100359cf..67aa020b 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml @@ -87,16 +87,8 @@ - - - + - - - - - - diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index c35b7979..d0f31977 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -72,13 +72,7 @@ namespace v2rayN.Desktop.Views this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables); - //check update - this.BindCommand(ViewModel, vm => vm.CheckUpdateNCmd, v => v.menuCheckUpdateN).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.CheckUpdateXrayCoreCmd, v => v.menuCheckUpdateXrayCore).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.CheckUpdateClashMetaCoreCmd, v => v.menuCheckUpdateMihomoCore).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.CheckUpdateSingBoxCoreCmd, v => v.menuCheckUpdateSingBoxCore).DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoCmd, v => v.menuCheckUpdateGeo).DisposeWith(disposables); - + this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); @@ -172,6 +166,7 @@ namespace v2rayN.Desktop.Views tabClashConnections2.Content ??= new ClashConnectionsView(); } conTheme.Content ??= new ThemeSettingView(); + conCheckUpdate.Content ??= new CheckUpdateView(); RestoreUI(); AddHelpMenuItem();