diff --git a/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs b/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs index ee5aa5d316..e4860b16dd 100644 --- a/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs +++ b/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs @@ -65,7 +65,7 @@ private async void Run() await Task.Delay(1000); try { - if (!(_config.runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo)) + if (!(_config.IsRunningCore(ECoreType.clash))) { continue; } diff --git a/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs b/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs index b1aa91fdf9..331ccde1de 100644 --- a/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs +++ b/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs @@ -53,7 +53,7 @@ private async void Run() await Task.Delay(1000); try { - if (!(_config.runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5 or ECoreType.SagerNet)) + if (!(_config.IsRunningCore(ECoreType.Xray))) { continue; } diff --git a/v2rayN/v2rayN/Models/Config.cs b/v2rayN/v2rayN/Models/Config.cs index ea9210087b..72d73d0b13 100644 --- a/v2rayN/v2rayN/Models/Config.cs +++ b/v2rayN/v2rayN/Models/Config.cs @@ -18,6 +18,19 @@ public class Config public ECoreType runningCoreType { get; set; } + public bool IsRunningCore(ECoreType type) + { + if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5 or ECoreType.SagerNet) + { + return true; + } + if (type == ECoreType.clash && runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo) + { + return true; + } + return false; + } + #endregion property #region other entities diff --git a/v2rayN/v2rayN/Models/ConfigItems.cs b/v2rayN/v2rayN/Models/ConfigItems.cs index efbf180ea0..6bef1ce5d3 100644 --- a/v2rayN/v2rayN/Models/ConfigItems.cs +++ b/v2rayN/v2rayN/Models/ConfigItems.cs @@ -130,6 +130,7 @@ public class UIItem public bool autoHideStartup { get; set; } public string mainMsgFilter { get; set; } public List mainColumnItem { get; set; } + public bool showInTaskbar { get; set; } } [Serializable] @@ -216,7 +217,6 @@ public class HysteriaItem public class ClashUIItem { public ERuleMode ruleMode { get; set; } - public bool showInTaskbar { get; set; } public bool enableIPv6 { get; set; } public bool enableMixinContent { get; set; } public int proxiesSorting { get; set; } diff --git a/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs index 36d14771a1..ae6cd39859 100644 --- a/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs @@ -5,6 +5,7 @@ using System.Reactive; using System.Reactive.Linq; using System.Windows; +using v2rayN.Enums; using v2rayN.Handler; using v2rayN.Models; @@ -84,7 +85,7 @@ private void Init() Observable.Interval(TimeSpan.FromSeconds(10)) .Subscribe(x => { - if (!(AutoRefresh && _config.clashUIItem.showInTaskbar)) + if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash))) { return; } diff --git a/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs b/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs index 9ee8c98a1f..22e34cc749 100644 --- a/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs @@ -465,7 +465,7 @@ public void DelayTestTask() Observable.Interval(TimeSpan.FromSeconds(60)) .Subscribe(x => { - if (!(AutoRefresh && _config.clashUIItem.showInTaskbar)) + if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash))) { return; } diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index 7eae44597e..e63bf61f3a 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -186,6 +186,9 @@ public class MainWindowViewModel : ReactiveObject [Reactive] public bool ShowClashUI { get; set; } + [Reactive] + public int TabMainSelectedIndex { get; set; } + #endregion UI #region Init @@ -404,7 +407,7 @@ public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, Action { BlReloadEnabled = true; - ShowClashUI = (_config.runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo); + ShowClashUI = _config.IsRunningCore(ECoreType.clash); if (ShowClashUI) { Locator.Current.GetService()?.ProxiesReload(); } + else { TabMainSelectedIndex = 0; } })); }); } @@ -1091,7 +1095,7 @@ public void ShowHideWindow(bool? blShow) //Utile.RegWriteValue(Global.MyRegPath, Utile.WindowHwndKey, Convert.ToString((long)windowHandle)); } _showInTaskbar = bl; - _config.clashUIItem.showInTaskbar = _showInTaskbar; + _config.uiItem.showInTaskbar = _showInTaskbar; } private void RestoreUI() diff --git a/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs b/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs index 3b0ec00a13..616f831433 100644 --- a/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs @@ -222,7 +222,6 @@ public ProfilesViewModel(Action updateView) }, canEditRemove); //Subscription - AddSubCmd = ReactiveCommand.Create(() => { EditSub(true); diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml index 58bdcbdbc3..cde13d4eab 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml @@ -13,52 +13,52 @@ d:DesignWidth="800" x:TypeArguments="vms:ClashConnectionsViewModel" mc:Ignorable="d"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - + - + + vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.Text).DisposeWith(disposables); - this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashUI.Visibility).DisposeWith(disposables); + this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashProxies.Visibility).DisposeWith(disposables); + this.OneWayBind(ViewModel, vm => vm.ShowClashUI, v => v.tabClashConnections.Visibility).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.TabMainSelectedIndex, v => v.tabMain.SelectedIndex).DisposeWith(disposables); }); var IsAdministrator = Utils.IsAdministrator(); @@ -152,7 +154,8 @@ public MainWindow() tabProfiles.Content ??= new ProfilesView(); tabMsgView.Content ??= new MsgView(); - tabClashUI.Content ??= new ClashProxiesView(); + tabClashProxies.Content ??= new ClashProxiesView(); + tabClashConnections.Content ??= new ClashConnectionsView(); RestoreUI(); AddHelpMenuItem();