diff --git a/v2rayN/v2rayN.Desktop/GlobalUsings.cs b/v2rayN/v2rayN.Desktop/GlobalUsings.cs index 6a2f1d3b..e7499b01 100644 --- a/v2rayN/v2rayN.Desktop/GlobalUsings.cs +++ b/v2rayN/v2rayN.Desktop/GlobalUsings.cs @@ -17,13 +17,13 @@ global using Avalonia.Markup.Xaml; global using Avalonia.Media; global using Avalonia.Media.Imaging; global using Avalonia.Platform; -global using ReactiveUI.Avalonia; global using Avalonia.Styling; global using Avalonia.Threading; -global using ReactiveUI; -global using ReactiveUI.Fody.Helpers; global using DynamicData; global using MsBox.Avalonia.Enums; +global using ReactiveUI; +global using ReactiveUI.Avalonia; +global using ReactiveUI.Fody.Helpers; global using ServiceLib; global using ServiceLib.Base; global using ServiceLib.Common; diff --git a/v2rayN/v2rayN.Desktop/Views/AddGroupServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddGroupServerWindow.axaml.cs index 0430a57c..a75f0e43 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddGroupServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddGroupServerWindow.axaml.cs @@ -13,8 +13,8 @@ public partial class AddGroupServerWindow : WindowBase { InitializeComponent(); - this.Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + Loaded += Window_Loaded; + btnCancel.Click += (s, e) => Close(); lstChild.SelectionChanged += LstChild_SelectionChanged; ViewModel = new AddGroupServerViewModel(profileItem, UpdateViewHandler); @@ -32,11 +32,11 @@ public partial class AddGroupServerWindow : WindowBase switch (profileItem.ConfigType) { case EConfigType.PolicyGroup: - this.Title = ResUI.TbConfigTypePolicyGroup; + Title = ResUI.TbConfigTypePolicyGroup; break; case EConfigType.ProxyChain: - this.Title = ResUI.TbConfigTypeProxyChain; + Title = ResUI.TbConfigTypeProxyChain; gridPolicyGroup.IsVisible = false; break; } @@ -64,7 +64,7 @@ public partial class AddGroupServerWindow : WindowBase menuSelectAllChild.Click += (s, e) => lstChild.SelectAll(); // Keyboard shortcuts when focus is within grid - this.AddHandler(KeyDownEvent, AddGroupServerWindow_KeyDown, RoutingStrategies.Tunnel); + AddHandler(KeyDownEvent, AddGroupServerWindow_KeyDown, RoutingStrategies.Tunnel); lstChild.LoadingRow += LstChild_LoadingRow; } @@ -78,7 +78,7 @@ public partial class AddGroupServerWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); break; } return await Task.FromResult(true); diff --git a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs index 2e6731b7..f1624a6b 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs @@ -14,8 +14,8 @@ public partial class AddServer2Window : WindowBase { InitializeComponent(); - this.Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + Loaded += Window_Loaded; + btnCancel.Click += (s, e) => Close(); ViewModel = new AddServer2ViewModel(profileItem, UpdateViewHandler); cmbCoreType.ItemsSource = Utils.GetEnumNames().Where(t => t != ECoreType.v2rayN.ToString()).ToList().AppendEmpty(); @@ -39,7 +39,7 @@ public partial class AddServer2Window : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); break; case EViewAction.BrowseServer: diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs index 255ace75..5acf6915 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs @@ -13,8 +13,8 @@ public partial class AddServerWindow : WindowBase { InitializeComponent(); - this.Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + Loaded += Window_Loaded; + btnCancel.Click += (s, e) => Close(); cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged; cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged; btnGUID.Click += btnGUID_Click; @@ -196,7 +196,7 @@ public partial class AddServerWindow : WindowBase this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - this.Title = $"{profileItem.ConfigType}"; + Title = $"{profileItem.ConfigType}"; } private async Task UpdateViewHandler(EViewAction action, object? obj) @@ -204,7 +204,7 @@ public partial class AddServerWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); 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 9a86846b..42068af4 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml.cs @@ -7,7 +7,7 @@ public partial class ClashProxiesView : ReactiveUserControl { diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs index a37f2c14..e673a025 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs @@ -12,7 +12,7 @@ public partial class DNSSettingWindow : WindowBase _config = AppManager.Instance.Config; Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + btnCancel.Click += (s, e) => Close(); ViewModel = new DNSSettingViewModel(UpdateViewHandler); cmbRayFreedomDNSStrategy.ItemsSource = Global.DomainStrategy4Freedoms; @@ -77,7 +77,7 @@ public partial class DNSSettingWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); 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 1a8d5061..bfe0c2c5 100644 --- a/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/FullConfigTemplateWindow.axaml.cs @@ -12,7 +12,7 @@ public partial class FullConfigTemplateWindow : WindowBase this.Close(); + btnCancel.Click += (s, e) => Close(); ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler); this.WhenActivated(disposables => @@ -36,7 +36,7 @@ public partial class FullConfigTemplateWindow : WindowBase HotkeyManager.Instance.IsPause = false; - btnCancel.Click += (s, e) => this.Close(); + Closing += (s, e) => HotkeyManager.Instance.IsPause = false; + btnCancel.Click += (s, e) => Close(); this.WhenActivated(disposables => { @@ -34,7 +34,7 @@ public partial class GlobalHotkeySettingWindow : WindowBase _config = AppManager.Instance.Config; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight }; - this.KeyDown += MainWindow_KeyDown; + KeyDown += MainWindow_KeyDown; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuPromotion.Click += menuPromotion_Click; menuCheckUpdate.Click += MenuCheckUpdate_Click; @@ -153,14 +153,14 @@ public partial class MainWindow : WindowBase if (Utils.IsWindows()) { - this.Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; + Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; ThreadPool.RegisterWaitForSingleObject(Program.ProgramStarted, OnProgramStarted, null, -1, false); HotkeyManager.Instance.Init(_config, OnHotkeyHandler); } else { - this.Title = $"{Utils.GetVersion()}"; + Title = $"{Utils.GetVersion()}"; menuRebootAsAdmin.IsVisible = false; menuSettingsSetUWP.IsVisible = false; @@ -170,7 +170,7 @@ public partial class MainWindow : WindowBase if (_config.UiItem.AutoHideStartup && Utils.IsWindows()) { - this.WindowState = WindowState.Minimized; + WindowState = WindowState.Minimized; } AddHelpMenuItem(); @@ -407,27 +407,27 @@ public partial class MainWindow : WindowBase : !_config.UiItem.ShowInTaskbar); if (bl) { - this.Show(); - if (this.WindowState == WindowState.Minimized) + Show(); + if (WindowState == WindowState.Minimized) { - this.WindowState = WindowState.Normal; + WindowState = WindowState.Normal; } - this.Activate(); - this.Focus(); + Activate(); + Focus(); } else { if (Utils.IsLinux() && _config.UiItem.Hide2TrayWhenClose == false) { - this.WindowState = WindowState.Minimized; + WindowState = WindowState.Minimized; return; } - foreach (var ownedWindow in this.OwnedWindows) + foreach (var ownedWindow in OwnedWindows) { ownedWindow.Close(); } - this.Hide(); + Hide(); } _config.UiItem.ShowInTaskbar = bl; diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs index bfebcddd..dd918007 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml.cs @@ -11,7 +11,7 @@ public partial class OptionSettingWindow : WindowBase InitializeComponent(); Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + btnCancel.Click += (s, e) => Close(); _config = AppManager.Instance.Config; ViewModel = new OptionSettingViewModel(UpdateViewHandler); @@ -153,7 +153,7 @@ public partial class OptionSettingWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); break; case EViewAction.InitSettingFont: diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs index 6c3f663d..e2979244 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs @@ -13,8 +13,8 @@ public partial class RoutingRuleDetailsWindow : WindowBase this.Close(); + Loaded += Window_Loaded; + btnCancel.Click += (s, e) => Close(); clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged; clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged; @@ -61,7 +61,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase this.Close(); - this.KeyDown += RoutingRuleSettingWindow_KeyDown; + Loaded += Window_Loaded; + btnCancel.Click += (s, e) => Close(); + KeyDown += RoutingRuleSettingWindow_KeyDown; lstRules.SelectionChanged += lstRules_SelectionChanged; lstRules.DoubleTapped += LstRules_DoubleTapped; menuRuleSelectAll.Click += menuRuleSelectAll_Click; @@ -64,7 +64,7 @@ public partial class RoutingRuleSettingWindow : WindowBase InitializeComponent(); Loaded += Window_Loaded; - this.Closing += RoutingSettingWindow_Closing; - btnCancel.Click += (s, e) => this.Close(); - this.KeyDown += RoutingSettingWindow_KeyDown; + Closing += RoutingSettingWindow_Closing; + btnCancel.Click += (s, e) => Close(); + KeyDown += RoutingSettingWindow_KeyDown; lstRoutings.SelectionChanged += lstRoutings_SelectionChanged; lstRoutings.DoubleTapped += LstRoutings_DoubleTapped; menuRoutingAdvancedSelectAll.Click += menuRoutingAdvancedSelectAll_Click; @@ -48,7 +48,7 @@ public partial class RoutingSettingWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); break; case EViewAction.ShowYesNo: @@ -116,7 +116,7 @@ public partial class RoutingSettingWindow : WindowBase private void btnCancel_Click(object? sender, RoutedEventArgs e) { _manualClose = true; - this.Close(ViewModel?.IsModified); + Close(ViewModel?.IsModified); } private void RoutingSettingWindow_Closing(object? sender, WindowClosingEventArgs e) diff --git a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs index a25dcd28..9d749ba8 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs @@ -14,7 +14,7 @@ public partial class SubEditWindow : WindowBase InitializeComponent(); Loaded += Window_Loaded; - btnCancel.Click += (s, e) => this.Close(); + btnCancel.Click += (s, e) => Close(); ViewModel = new SubEditViewModel(subItem, UpdateViewHandler); @@ -45,7 +45,7 @@ public partial class SubEditWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(true); + Close(true); break; } return await Task.FromResult(true); diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs index cf0f5d75..970f5c5b 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml.cs @@ -14,8 +14,8 @@ public partial class SubSettingWindow : WindowBase menuClose.Click += menuClose_Click; Loaded += Window_Loaded; - this.Closing += SubSettingWindow_Closing; - this.KeyDown += SubSettingWindow_KeyDown; + Closing += SubSettingWindow_Closing; + KeyDown += SubSettingWindow_KeyDown; ViewModel = new SubSettingViewModel(UpdateViewHandler); lstSubscription.DoubleTapped += LstSubscription_DoubleTapped; lstSubscription.SelectionChanged += LstSubscription_SelectionChanged; @@ -37,7 +37,7 @@ public partial class SubSettingWindow : WindowBase switch (action) { case EViewAction.CloseWindow: - this.Close(); + Close(); break; case EViewAction.ShowYesNo: @@ -89,7 +89,7 @@ public partial class SubSettingWindow : WindowBase private void menuClose_Click(object? sender, RoutedEventArgs e) { _manualClose = true; - this.Close(ViewModel?.IsModified); + Close(ViewModel?.IsModified); } private void SubSettingWindow_Closing(object? sender, WindowClosingEventArgs e) diff --git a/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs index cb5182eb..6373c683 100644 --- a/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SudoPasswordInputView.axaml.cs @@ -9,7 +9,7 @@ public partial class SudoPasswordInputView : UserControl { InitializeComponent(); - this.Loaded += (s, e) => txtPassword.Focus(); + Loaded += (s, e) => txtPassword.Focus(); btnSave.Click += async (_, _) => await SavePasswordAsync();