diff --git a/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs b/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs index ee5aa5d3..e4860b16 100644 --- a/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs +++ b/v2rayN/v2rayN/Handler/Statistics/StatisticsSingbox.cs @@ -65,7 +65,7 @@ namespace v2rayN.Handler.Statistics 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 b1aa91fd..331ccde1 100644 --- a/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs +++ b/v2rayN/v2rayN/Handler/Statistics/StatisticsV2ray.cs @@ -53,7 +53,7 @@ namespace v2rayN.Handler.Statistics 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 ea921008..72d73d0b 100644 --- a/v2rayN/v2rayN/Models/Config.cs +++ b/v2rayN/v2rayN/Models/Config.cs @@ -18,6 +18,19 @@ namespace v2rayN.Models 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 efbf180e..6bef1ce5 100644 --- a/v2rayN/v2rayN/Models/ConfigItems.cs +++ b/v2rayN/v2rayN/Models/ConfigItems.cs @@ -130,6 +130,7 @@ namespace v2rayN.Models 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 @@ namespace v2rayN.Models 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 36d14771..ae6cd398 100644 --- a/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ClashConnectionsViewModel.cs @@ -5,6 +5,7 @@ using ReactiveUI.Fody.Helpers; using System.Reactive; using System.Reactive.Linq; using System.Windows; +using v2rayN.Enums; using v2rayN.Handler; using v2rayN.Models; @@ -84,7 +85,7 @@ namespace v2rayN.ViewModels 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 9ee8c98a..22e34cc7 100644 --- a/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ClashProxiesViewModel.cs @@ -465,7 +465,7 @@ namespace v2rayN.ViewModels 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 7eae4459..e63bf61f 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -186,6 +186,9 @@ namespace v2rayN.ViewModels [Reactive] public bool ShowClashUI { get; set; } + [Reactive] + public int TabMainSelectedIndex { get; set; } + #endregion UI #region Init @@ -404,7 +407,7 @@ namespace v2rayN.ViewModels AutoHideStartup(); _showInTaskbar = true; - _config.clashUIItem.showInTaskbar = _showInTaskbar; + _config.uiItem.showInTaskbar = _showInTaskbar; } private void Init() @@ -914,11 +917,12 @@ namespace v2rayN.ViewModels Application.Current?.Dispatcher.Invoke((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 @@ namespace v2rayN.ViewModels //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 3b0ec00a..616f8314 100644 --- a/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/ProfilesViewModel.cs @@ -222,7 +222,6 @@ namespace v2rayN.ViewModels }, canEditRemove); //Subscription - AddSubCmd = ReactiveCommand.Create(() => { EditSub(true); diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml index 58bdcbdb..cde13d4e 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 @@ namespace v2rayN.Views tabProfiles.Content ??= new ProfilesView(); tabMsgView.Content ??= new MsgView(); - tabClashUI.Content ??= new ClashProxiesView(); + tabClashProxies.Content ??= new ClashProxiesView(); + tabClashConnections.Content ??= new ClashConnectionsView(); RestoreUI(); AddHelpMenuItem();