Optimize connection function

This commit is contained in:
2dust
2023-01-29 09:49:45 +08:00
parent 0bc5b52d99
commit 8e9ce4126e
5 changed files with 110 additions and 74 deletions

View File

@@ -1528,6 +1528,15 @@ namespace clashN.Resx {
}
}
/// <summary>
/// 查找类似 Chain 的本地化字符串。
/// </summary>
public static string TbSortingChain {
get {
return ResourceManager.GetString("TbSortingChain", resourceCulture);
}
}
/// <summary>
/// 查找类似 Default 的本地化字符串。
/// </summary>
@@ -1564,6 +1573,15 @@ namespace clashN.Resx {
}
}
/// <summary>
/// 查找类似 Host 的本地化字符串。
/// </summary>
public static string TbSortingHost {
get {
return ResourceManager.GetString("TbSortingHost", resourceCulture);
}
}
/// <summary>
/// 查找类似 Name 的本地化字符串。
/// </summary>
@@ -1573,6 +1591,15 @@ namespace clashN.Resx {
}
}
/// <summary>
/// 查找类似 Network 的本地化字符串。
/// </summary>
public static string TbSortingNetwork {
get {
return ResourceManager.GetString("TbSortingNetwork", resourceCulture);
}
}
/// <summary>
/// 查找类似 Time 的本地化字符串。
/// </summary>
@@ -1582,6 +1609,15 @@ namespace clashN.Resx {
}
}
/// <summary>
/// 查找类似 Type 的本地化字符串。
/// </summary>
public static string TbSortingType {
get {
return ResourceManager.GetString("TbSortingType", resourceCulture);
}
}
/// <summary>
/// 查找类似 Upload Speed 的本地化字符串。
/// </summary>

View File

@@ -652,4 +652,16 @@
<data name="TbSystemProxyPac" xml:space="preserve">
<value>Pac Mode</value>
</data>
<data name="TbSortingChain" xml:space="preserve">
<value>Chain</value>
</data>
<data name="TbSortingHost" xml:space="preserve">
<value>Host</value>
</data>
<data name="TbSortingNetwork" xml:space="preserve">
<value>Network</value>
</data>
<data name="TbSortingType" xml:space="preserve">
<value>Type</value>
</data>
</root>

View File

@@ -655,4 +655,16 @@
<data name="TbSystemProxyPac" xml:space="preserve">
<value>Pac模式</value>
</data>
<data name="TbSortingChain" xml:space="preserve">
<value>路由链</value>
</data>
<data name="TbSortingHost" xml:space="preserve">
<value>主机</value>
</data>
<data name="TbSortingNetwork" xml:space="preserve">
<value>网络</value>
</data>
<data name="TbSortingType" xml:space="preserve">
<value>类型</value>
</data>
</root>

View File

@@ -133,8 +133,8 @@ namespace clashN.ViewModels
model.time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
model.upload = item.upload;
model.download = item.download;
model.uploadTraffic = $"<EFBFBD><EFBFBD> {Utils.HumanFy(item.upload)}";
model.downloadTraffic = $"<EFBFBD><EFBFBD> {Utils.HumanFy(item.download)}";
model.uploadTraffic = $"{Utils.HumanFy(item.upload)}";
model.downloadTraffic = $"{Utils.HumanFy(item.download)}";
model.elapsed = sp.ToString(@"hh\:mm\:ss");
model.chain = item.chains.Count > 0 ? item.chains[0] : String.Empty;
@@ -160,6 +160,9 @@ namespace clashN.ViewModels
case 4:
lstModel = lstModel.OrderBy(t => t.time).ToList();
break;
case 5:
lstModel = lstModel.OrderBy(t => t.host).ToList();
break;
}
_connectionItems.AddRange(lstModel);

View File

@@ -45,6 +45,7 @@
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingUpTraffic}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingDownTraffic}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingTime}" />
<ComboBoxItem Content="{x:Static resx:ResUI.TbSortingHost}" />
</ComboBox>
<Separator />
<Button x:Name="btnConnectionCloseAll" ToolTip="{x:Static resx:ResUI.menuConnectionCloseAll}">
@@ -64,83 +65,55 @@
HorizontalAlignment="Left" />
</ToolBar>
</ToolBarTray>
<ListView
<DataGrid
x:Name="lstConnections"
HorizontalContentAlignment="Stretch"
BorderThickness="0"
ItemContainerStyle="{StaticResource lvItemSelected}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListView.ContextMenu>
AutoGenerateColumns="False"
BorderThickness="1"
CanUserAddRows="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
EnableRowVirtualization="True"
GridLinesVisibility="All"
HeadersVisibility="Column"
IsReadOnly="True">
<DataGrid.ContextMenu>
<ContextMenu Style="{StaticResource DefMenu}">
<MenuItem x:Name="menuConnectionClose" Header="{x:Static resx:ResUI.menuConnectionClose}" />
<MenuItem x:Name="menuConnectionCloseAll" Header="{x:Static resx:ResUI.menuConnectionCloseAll}" />
</ContextMenu>
</ListView.ContextMenu>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<DockPanel>
<Button
x:Name="btnClose"
Margin="8,0"
Click="btnClose_Click"
Content="{materialDesign:PackIcon Kind=Close}"
DockPanel.Dock="Left"
IsEnabled="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"
Style="{StaticResource MaterialDesignFloatingActionMiniButton}" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel
Grid.Row="0"
Margin="8,0,8,0"
HorizontalAlignment="Left"
Orientation="Horizontal">
<TextBlock Style="{StaticResource ListItemSubTitle}" Text="{Binding host}" />
</StackPanel>
<StackPanel
Grid.Row="1"
HorizontalAlignment="Left"
Orientation="Horizontal">
<materialDesign:Chip
Content="{Binding network}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
<materialDesign:Chip
Content="{Binding type}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
<materialDesign:Chip
Content="{Binding chain}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
<materialDesign:Chip
Content="{Binding uploadTraffic}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
<materialDesign:Chip
Content="{Binding downloadTraffic}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
<materialDesign:Chip
Content="{Binding elapsed}"
IsEnabled="False"
Style="{StaticResource ListItemChip}" />
</StackPanel>
</Grid>
</DockPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridTextColumn
Width="300"
Binding="{Binding host}"
Header="{x:Static resx:ResUI.TbSortingHost}" />
<DataGridTextColumn
Width="100"
Binding="{Binding network}"
Header="{x:Static resx:ResUI.TbSortingNetwork}" />
<DataGridTextColumn
Width="100"
Binding="{Binding type}"
Header="{x:Static resx:ResUI.TbSortingType}" />
<DataGridTextColumn
Width="200"
Binding="{Binding chain}"
Header="{x:Static resx:ResUI.TbSortingChain}" />
<DataGridTextColumn
Width="100"
Binding="{Binding uploadTraffic}"
Header="{x:Static resx:ResUI.TbSortingUpTraffic}" />
<DataGridTextColumn
Width="100"
Binding="{Binding downloadTraffic}"
Header="{x:Static resx:ResUI.TbSortingDownTraffic}" />
<DataGridTextColumn
Width="100"
Binding="{Binding elapsed}"
Header="{x:Static resx:ResUI.TbSortingTime}" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>
</reactiveui:ReactiveUserControl>