Improve the clash connection

pull/6211/head
2dust 2024-12-02 14:40:09 +08:00
parent 834e05999f
commit 9eb9898b61
4 changed files with 56 additions and 1 deletions

View File

@ -42,6 +42,23 @@
</Button.Content>
</Button>
<Button
x:Name="btnAutofitColumnWidth"
Width="30"
Height="30"
Margin="8,0"
Classes="Success"
Theme="{DynamicResource BorderlessButton}"
ToolTip.Tip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}">
<Button.Content>
<PathIcon
Width="20"
Height="20"
Data="{StaticResource building_fit}"
Foreground="{DynamicResource ButtonDefaultTertiaryForeground}" />
</Button.Content>
</Button>
<TextBlock
Margin="8,0"
VerticalAlignment="Center"

View File

@ -1,3 +1,4 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.ReactiveUI;
using Avalonia.Threading;
@ -12,6 +13,7 @@ namespace v2rayN.Desktop.Views
{
InitializeComponent();
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
this.WhenActivated(disposables =>
{
@ -42,6 +44,19 @@ namespace v2rayN.Desktop.Views
return await Task.FromResult(true);
}
private void BtnAutofitColumnWidth_Click(object? sender, RoutedEventArgs e)
{
AutofitColumnWidth();
}
private void AutofitColumnWidth()
{
foreach (var it in lstConnections.Columns)
{
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
}
}
private void btnClose_Click(object? sender, RoutedEventArgs e)
{
ViewModel?.ClashConnectionClose(false);

View File

@ -39,6 +39,16 @@
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Close" />
</Button>
<Button
x:Name="btnAutofitColumnWidth"
Width="24"
Height="24"
Margin="{StaticResource MarginLeftRight8}"
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"
ToolTip="{x:Static resx:ResUI.menuProfileAutofitColumnWidth}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowSplitVertical" />
</Button>
<TextBlock
Margin="{StaticResource MarginLeftRight8}"
VerticalAlignment="Center"
@ -56,7 +66,6 @@
BorderThickness="1"
CanUserAddRows="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
EnableRowVirtualization="True"
GridLinesVisibility="All"
HeadersVisibility="Column"

View File

@ -1,6 +1,7 @@
using ReactiveUI;
using System.Reactive.Disposables;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
namespace v2rayN.Views
@ -14,6 +15,7 @@ namespace v2rayN.Views
{
InitializeComponent();
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
this.WhenActivated(disposables =>
{
@ -45,6 +47,18 @@ namespace v2rayN.Views
return await Task.FromResult(true);
}
private void BtnAutofitColumnWidth_Click(object sender, RoutedEventArgs e)
{
AutofitColumnWidth();
}
private void AutofitColumnWidth()
{
foreach (var it in lstConnections.Columns)
{
it.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
}
}
private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
{
ViewModel?.ClashConnectionClose(false);