From 3dd75b17cf53a1486b2c0537f1ee064464100d43 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 10 Aug 2024 19:20:31 +0800 Subject: [PATCH] Clean code --- v2rayN/v2rayN/Enums/EViewAction.cs | 8 ++++---- v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs | 4 ---- v2rayN/v2rayN/ViewModels/SubSettingViewModel.cs | 2 +- v2rayN/v2rayN/Views/ProfilesView.xaml.cs | 9 +-------- v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs | 6 +++--- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/v2rayN/v2rayN/Enums/EViewAction.cs b/v2rayN/v2rayN/Enums/EViewAction.cs index d52fdbf0..8160166c 100644 --- a/v2rayN/v2rayN/Enums/EViewAction.cs +++ b/v2rayN/v2rayN/Enums/EViewAction.cs @@ -2,18 +2,18 @@ { public enum EViewAction { - AdjustMainLvColWidth, - ProfilesFocus, CloseWindow, ShowYesNo, AddBatchRoutingRulesYesNo, + AdjustMainLvColWidth, + ProfilesFocus, + ShareSub, + ShareServer, SubEditWindow, - SubShare, RoutingRuleSettingWindow, RoutingRuleDetailsWindow, AddServerWindow, AddServer2Window, - ShareServer, DNSSettingWindow, RoutingSettingWindow, OptionSettingWindow, diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index 76b99e43..08a981a5 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -439,10 +439,6 @@ namespace v2rayN.ViewModels { Reload(); } - if (_config.uiItem.enableAutoAdjustMainLvColWidth) - { - _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null); - } } } diff --git a/v2rayN/v2rayN/ViewModels/SubSettingViewModel.cs b/v2rayN/v2rayN/ViewModels/SubSettingViewModel.cs index cafa7a5f..51752eab 100644 --- a/v2rayN/v2rayN/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/SubSettingViewModel.cs @@ -56,7 +56,7 @@ namespace v2rayN.ViewModels }, canEditRemove); SubShareCmd = ReactiveCommand.Create(() => { - _updateView?.Invoke(EViewAction.SubShare, SelectedSource?.url); + _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url); }, canEditRemove); } diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index 9365dbec..e22a327c 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -100,14 +100,7 @@ namespace v2rayN.Views private bool UpdateViewHandler(EViewAction action, object? obj) { - if (action == EViewAction.AdjustMainLvColWidth) - { - Application.Current.Dispatcher.Invoke(() => - { - AutofitColumnWidth(); - }); - } - else if (action == EViewAction.ProfilesFocus) + if (action == EViewAction.ProfilesFocus) { lstProfiles.Focus(); } diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs index 403ea404..44df4bed 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml.cs @@ -54,15 +54,15 @@ namespace v2rayN.Views if (obj is null) return false; return (new SubEditWindow((SubItem)obj)).ShowDialog() ?? false; } - else if (action == EViewAction.SubShare) + else if (action == EViewAction.ShareSub) { if (obj is null) return false; - SubShare((string)obj); + ShareSub((string)obj); } return true; } - private async void SubShare(string url) + private async void ShareSub(string url) { if (Utils.IsNullOrEmpty(url)) {