Improve UI

pull/5381/head
2dust 2024-07-19 10:51:14 +08:00
parent 70ea21fca2
commit 5c070e2ca8
12 changed files with 120 additions and 98 deletions

View File

@ -65,7 +65,7 @@ namespace v2rayN.Handler.Statistics
await Task.Delay(1000); await Task.Delay(1000);
try try
{ {
if (!(_config.runningCoreType is ECoreType.sing_box or ECoreType.clash or ECoreType.clash_meta or ECoreType.mihomo)) if (!(_config.IsRunningCore(ECoreType.clash)))
{ {
continue; continue;
} }

View File

@ -53,7 +53,7 @@ namespace v2rayN.Handler.Statistics
await Task.Delay(1000); await Task.Delay(1000);
try try
{ {
if (!(_config.runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5 or ECoreType.SagerNet)) if (!(_config.IsRunningCore(ECoreType.Xray)))
{ {
continue; continue;
} }

View File

@ -18,6 +18,19 @@ namespace v2rayN.Models
public ECoreType runningCoreType { get; set; } 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 #endregion property
#region other entities #region other entities

View File

@ -130,6 +130,7 @@ namespace v2rayN.Models
public bool autoHideStartup { get; set; } public bool autoHideStartup { get; set; }
public string mainMsgFilter { get; set; } public string mainMsgFilter { get; set; }
public List<ColumnItem> mainColumnItem { get; set; } public List<ColumnItem> mainColumnItem { get; set; }
public bool showInTaskbar { get; set; }
} }
[Serializable] [Serializable]
@ -216,7 +217,6 @@ namespace v2rayN.Models
public class ClashUIItem public class ClashUIItem
{ {
public ERuleMode ruleMode { get; set; } public ERuleMode ruleMode { get; set; }
public bool showInTaskbar { get; set; }
public bool enableIPv6 { get; set; } public bool enableIPv6 { get; set; }
public bool enableMixinContent { get; set; } public bool enableMixinContent { get; set; }
public int proxiesSorting { get; set; } public int proxiesSorting { get; set; }

View File

@ -5,6 +5,7 @@ using ReactiveUI.Fody.Helpers;
using System.Reactive; using System.Reactive;
using System.Reactive.Linq; using System.Reactive.Linq;
using System.Windows; using System.Windows;
using v2rayN.Enums;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Models; using v2rayN.Models;
@ -84,7 +85,7 @@ namespace v2rayN.ViewModels
Observable.Interval(TimeSpan.FromSeconds(10)) Observable.Interval(TimeSpan.FromSeconds(10))
.Subscribe(x => .Subscribe(x =>
{ {
if (!(AutoRefresh && _config.clashUIItem.showInTaskbar)) if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash)))
{ {
return; return;
} }

View File

@ -465,7 +465,7 @@ namespace v2rayN.ViewModels
Observable.Interval(TimeSpan.FromSeconds(60)) Observable.Interval(TimeSpan.FromSeconds(60))
.Subscribe(x => .Subscribe(x =>
{ {
if (!(AutoRefresh && _config.clashUIItem.showInTaskbar)) if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.clash)))
{ {
return; return;
} }

View File

@ -186,6 +186,9 @@ namespace v2rayN.ViewModels
[Reactive] [Reactive]
public bool ShowClashUI { get; set; } public bool ShowClashUI { get; set; }
[Reactive]
public int TabMainSelectedIndex { get; set; }
#endregion UI #endregion UI
#region Init #region Init
@ -404,7 +407,7 @@ namespace v2rayN.ViewModels
AutoHideStartup(); AutoHideStartup();
_showInTaskbar = true; _showInTaskbar = true;
_config.clashUIItem.showInTaskbar = _showInTaskbar; _config.uiItem.showInTaskbar = _showInTaskbar;
} }
private void Init() private void Init()
@ -914,11 +917,12 @@ namespace v2rayN.ViewModels
Application.Current?.Dispatcher.Invoke((Action)(() => Application.Current?.Dispatcher.Invoke((Action)(() =>
{ {
BlReloadEnabled = true; 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) if (ShowClashUI)
{ {
Locator.Current.GetService<ClashProxiesViewModel>()?.ProxiesReload(); Locator.Current.GetService<ClashProxiesViewModel>()?.ProxiesReload();
} }
else { TabMainSelectedIndex = 0; }
})); }));
}); });
} }
@ -1091,7 +1095,7 @@ namespace v2rayN.ViewModels
//Utile.RegWriteValue(Global.MyRegPath, Utile.WindowHwndKey, Convert.ToString((long)windowHandle)); //Utile.RegWriteValue(Global.MyRegPath, Utile.WindowHwndKey, Convert.ToString((long)windowHandle));
} }
_showInTaskbar = bl; _showInTaskbar = bl;
_config.clashUIItem.showInTaskbar = _showInTaskbar; _config.uiItem.showInTaskbar = _showInTaskbar;
} }
private void RestoreUI() private void RestoreUI()

View File

@ -222,7 +222,6 @@ namespace v2rayN.ViewModels
}, canEditRemove); }, canEditRemove);
//Subscription //Subscription
AddSubCmd = ReactiveCommand.Create(() => AddSubCmd = ReactiveCommand.Create(() =>
{ {
EditSub(true); EditSub(true);

View File

@ -13,16 +13,16 @@
d:DesignWidth="800" d:DesignWidth="800"
x:TypeArguments="vms:ClashConnectionsViewModel" x:TypeArguments="vms:ClashConnectionsViewModel"
mc:Ignorable="d"> mc:Ignorable="d">
<DockPanel>
<ToolBarTray Margin="0,8,0,8" DockPanel.Dock="Top"> <DockPanel Margin="2">
<ToolBar ClipToBounds="True" Style="{StaticResource MaterialDesignToolBar}"> <WrapPanel
<Button Width="1" Visibility="Hidden"> Margin="8"
<materialDesign:PackIcon
Margin="0,0,8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Kind="ContentSave" /> DockPanel.Dock="Top"
</Button> Orientation="Horizontal">
<TextBlock <TextBlock
Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSorting}" /> Text="{x:Static resx:ResUI.TbSorting}" />
@ -38,18 +38,18 @@
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingTime}" /> <ComboBoxItem Content="{x:Static resx:ResUI.TbSortingTime}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingHost}" /> <ComboBoxItem Content="{x:Static resx:ResUI.TbSortingHost}" />
</ComboBox> </ComboBox>
<Separator />
<Button x:Name="btnConnectionCloseAll" ToolTip="{x:Static resx:ResUI.menuConnectionCloseAll}"> <Button
<StackPanel Orientation="Horizontal"> x:Name="btnConnectionCloseAll"
<materialDesign:PackIcon Width="30"
Margin="0,0,8,0" Height="30"
VerticalAlignment="Center" Margin="8,0"
Kind="Close" /> Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<TextBlock Style="{StaticResource ToolbarTextBlock}" Text="{x:Static resx:ResUI.menuConnectionCloseAll}" /> <materialDesign:PackIcon VerticalAlignment="Center" Kind="Close" />
</StackPanel>
</Button> </Button>
<Separator />
<TextBlock <TextBlock
Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbAutoRefresh}" /> Text="{x:Static resx:ResUI.TbAutoRefresh}" />
@ -57,8 +57,8 @@
x:Name="togAutoRefresh" x:Name="togAutoRefresh"
Margin="8" Margin="8"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
</ToolBar> </WrapPanel>
</ToolBarTray>
<DataGrid <DataGrid
x:Name="lstConnections" x:Name="lstConnections"
AutoGenerateColumns="False" AutoGenerateColumns="False"
@ -79,21 +79,21 @@
</DataGrid.ContextMenu> </DataGrid.ContextMenu>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn <DataGridTextColumn
Width="300" Width="240"
Binding="{Binding host}" Binding="{Binding host}"
Header="{x:Static resx:ResUI.TbSortingHost}" /> Header="{x:Static resx:ResUI.TbSortingHost}" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="160"
Binding="{Binding chain}"
Header="{x:Static resx:ResUI.TbSortingChain}" />
<DataGridTextColumn
Width="80"
Binding="{Binding network}" Binding="{Binding network}"
Header="{x:Static resx:ResUI.TbSortingNetwork}" /> Header="{x:Static resx:ResUI.TbSortingNetwork}" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding type}" Binding="{Binding type}"
Header="{x:Static resx:ResUI.TbSortingType}" /> Header="{x:Static resx:ResUI.TbSortingType}" />
<DataGridTextColumn
Width="200"
Binding="{Binding chain}"
Header="{x:Static resx:ResUI.TbSortingChain}" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding uploadTraffic}" Binding="{Binding uploadTraffic}"

View File

@ -25,6 +25,37 @@
VerticalAlignment="Center" VerticalAlignment="Center"
DockPanel.Dock="Top" DockPanel.Dock="Top"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.menuRulemode}" />
<ComboBox
x:Name="cmbRulemode"
Width="80"
Margin="8"
Style="{StaticResource DefComboBox}">
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeRule}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeGlobal}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeDirect}" />
</ComboBox>
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSorting}" />
<ComboBox
x:Name="cmbSorting"
Width="60"
Margin="8"
Style="{StaticResource DefComboBox}">
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDelay}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingName}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDefault}" />
</ComboBox>
<Button <Button
x:Name="menuProxiesReload" x:Name="menuProxiesReload"
Width="30" Width="30"
@ -43,37 +74,6 @@
<materialDesign:PackIcon VerticalAlignment="Center" Kind="LightningBolt" /> <materialDesign:PackIcon VerticalAlignment="Center" Kind="LightningBolt" />
</Button> </Button>
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.menuRulemode}" />
<ComboBox
x:Name="cmbRulemode"
Width="80"
Margin="8"
Style="{StaticResource DefComboBox}">
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeRule}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeGlobal}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeDirect}" />
<ComboBoxItem Content="{x:Static resx:ResUI.menuModeNothing}" />
</ComboBox>
<TextBlock
Margin="8,0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSorting}" />
<ComboBox
x:Name="cmbSorting"
Width="60"
Margin="8"
Style="{StaticResource DefComboBox}">
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDelay}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingName}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDefault}" />
</ComboBox>
<TextBlock <TextBlock
Margin="8,0" Margin="8,0"
VerticalAlignment="Center" VerticalAlignment="Center"

View File

@ -2,10 +2,8 @@
x:Class="v2rayN.Views.MainWindow" x:Class="v2rayN.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="clr-namespace:v2rayN.Base"
xmlns:conv="clr-namespace:v2rayN.Converters" xmlns:conv="clr-namespace:v2rayN.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:v2rayN.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:reactiveui="http://reactiveui.net" xmlns:reactiveui="http://reactiveui.net"
@ -476,9 +474,13 @@
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ContentControl x:Name="tabProfiles" Grid.Column="0" /> <ContentControl x:Name="tabProfiles" Grid.Column="0" />
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" /> <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<TabControl Grid.Column="2" HorizontalContentAlignment="Left"> <TabControl
x:Name="tabMain"
Grid.Column="2"
HorizontalContentAlignment="Left">
<TabItem x:Name="tabMsgView" Header="{x:Static resx:ResUI.MsgInformationTitle}" /> <TabItem x:Name="tabMsgView" Header="{x:Static resx:ResUI.MsgInformationTitle}" />
<TabItem x:Name="tabClashUI" Header="{x:Static resx:ResUI.TbProxies}" /> <TabItem x:Name="tabClashProxies" Header="{x:Static resx:ResUI.TbProxies}" />
<TabItem x:Name="tabClashConnections" Header="{x:Static resx:ResUI.TbConnections}" />
</TabControl> </TabControl>
<materialDesign:Snackbar <materialDesign:Snackbar

View File

@ -137,7 +137,9 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables); this.Bind(ViewModel, vm => 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.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.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(); var IsAdministrator = Utils.IsAdministrator();
@ -152,7 +154,8 @@ namespace v2rayN.Views
tabProfiles.Content ??= new ProfilesView(); tabProfiles.Content ??= new ProfilesView();
tabMsgView.Content ??= new MsgView(); tabMsgView.Content ??= new MsgView();
tabClashUI.Content ??= new ClashProxiesView(); tabClashProxies.Content ??= new ClashProxiesView();
tabClashConnections.Content ??= new ClashConnectionsView();
RestoreUI(); RestoreUI();
AddHelpMenuItem(); AddHelpMenuItem();