mirror of https://github.com/2dust/v2rayN
Allow single select
parent
1242011513
commit
e6c57fcac0
|
@ -2,15 +2,15 @@
|
||||||
x:Class="v2rayN.Desktop.Views.ProfilesSelectWindow"
|
x:Class="v2rayN.Desktop.Views.ProfilesSelectWindow"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:conv="using:v2rayN.Desktop.Converters"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||||
xmlns:conv="using:v2rayN.Desktop.Converters"
|
Title="{x:Static resx:ResUI.TbSelectProfile}"
|
||||||
x:DataType="vms:ProfilesSelectViewModel"
|
|
||||||
Width="800"
|
Width="800"
|
||||||
Height="450"
|
Height="450"
|
||||||
Title="{x:Static resx:ResUI.TbSelectProfile}"
|
x:DataType="vms:ProfilesSelectViewModel"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
@ -19,15 +19,26 @@
|
||||||
|
|
||||||
<DockPanel Margin="8">
|
<DockPanel Margin="8">
|
||||||
<!-- Bottom buttons -->
|
<!-- Bottom buttons -->
|
||||||
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center" Margin="4">
|
<StackPanel
|
||||||
<Button x:Name="btnSave" Width="100" Content="{x:Static resx:ResUI.TbConfirm}" />
|
Margin="4"
|
||||||
<Button x:Name="btnCancel" Width="100" Margin="8,0" Content="{x:Static resx:ResUI.TbCancel}" />
|
HorizontalAlignment="Center"
|
||||||
|
DockPanel.Dock="Bottom"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
x:Name="btnSave"
|
||||||
|
Width="100"
|
||||||
|
Content="{x:Static resx:ResUI.TbConfirm}" />
|
||||||
|
<Button
|
||||||
|
x:Name="btnCancel"
|
||||||
|
Width="100"
|
||||||
|
Margin="8,0"
|
||||||
|
Content="{x:Static resx:ResUI.TbCancel}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<!-- Top tools -->
|
<!-- Top tools -->
|
||||||
<WrapPanel DockPanel.Dock="Top" Margin="4">
|
<WrapPanel Margin="4" DockPanel.Dock="Top">
|
||||||
<ListBox
|
<ListBox
|
||||||
x:Name="lstGroup"
|
x:Name="lstGroup"
|
||||||
Margin="4,0"
|
Margin="4,0"
|
||||||
|
@ -56,8 +67,8 @@
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
VerticalContentAlignment="Center"
|
VerticalContentAlignment="Center"
|
||||||
Watermark="{x:Static resx:ResUI.MsgServerTitle}"
|
Text="{Binding ServerFilter, Mode=TwoWay}"
|
||||||
Text="{Binding ServerFilter, Mode=TwoWay}" />
|
Watermark="{x:Static resx:ResUI.MsgServerTitle}" />
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
|
||||||
<!-- Profiles grid -->
|
<!-- Profiles grid -->
|
||||||
|
@ -70,9 +81,14 @@
|
||||||
GridLinesVisibility="All"
|
GridLinesVisibility="All"
|
||||||
HeadersVisibility="All"
|
HeadersVisibility="All"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
ItemsSource="{Binding ProfileItems}">
|
ItemsSource="{Binding ProfileItems}"
|
||||||
|
SelectionMode="Single">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Width="80" Binding="{Binding ConfigType}" Header="{x:Static resx:ResUI.LvServiceType}" Tag="ConfigType" />
|
<DataGridTextColumn
|
||||||
|
Width="80"
|
||||||
|
Binding="{Binding ConfigType}"
|
||||||
|
Header="{x:Static resx:ResUI.LvServiceType}"
|
||||||
|
Tag="ConfigType" />
|
||||||
|
|
||||||
<DataGridTemplateColumn Tag="Remarks">
|
<DataGridTemplateColumn Tag="Remarks">
|
||||||
<DataGridTemplateColumn.Header>
|
<DataGridTemplateColumn.Header>
|
||||||
|
@ -80,18 +96,38 @@
|
||||||
</DataGridTemplateColumn.Header>
|
</DataGridTemplateColumn.Header>
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal" Margin="8,0">
|
<StackPanel Margin="8,0" Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Remarks}" />
|
<TextBlock Text="{Binding Remarks}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
|
|
||||||
<DataGridTextColumn Width="120" Binding="{Binding Address}" Header="{x:Static resx:ResUI.LvAddress}" Tag="Address" />
|
<DataGridTextColumn
|
||||||
<DataGridTextColumn Width="60" Binding="{Binding Port}" Header="{x:Static resx:ResUI.LvPort}" Tag="Port" />
|
Width="120"
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding Network}" Header="{x:Static resx:ResUI.LvTransportProtocol}" Tag="Network" />
|
Binding="{Binding Address}"
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding StreamSecurity}" Header="{x:Static resx:ResUI.LvTLS}" Tag="StreamSecurity" />
|
Header="{x:Static resx:ResUI.LvAddress}"
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding SubRemarks}" Header="{x:Static resx:ResUI.LvSubscription}" Tag="SubRemarks" />
|
Tag="Address" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="60"
|
||||||
|
Binding="{Binding Port}"
|
||||||
|
Header="{x:Static resx:ResUI.LvPort}"
|
||||||
|
Tag="Port" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding Network}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTransportProtocol}"
|
||||||
|
Tag="Network" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding StreamSecurity}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTLS}"
|
||||||
|
Tag="StreamSecurity" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding SubRemarks}"
|
||||||
|
Header="{x:Static resx:ResUI.LvSubscription}"
|
||||||
|
Tag="SubRemarks" />
|
||||||
|
|
||||||
<DataGridTemplateColumn SortMemberPath="Delay" Tag="DelayVal">
|
<DataGridTemplateColumn SortMemberPath="Delay" Tag="DelayVal">
|
||||||
<DataGridTemplateColumn.Header>
|
<DataGridTemplateColumn.Header>
|
||||||
|
@ -99,17 +135,42 @@
|
||||||
</DataGridTemplateColumn.Header>
|
</DataGridTemplateColumn.Header>
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Margin="8,0" HorizontalAlignment="Right" VerticalAlignment="Center" Foreground="{Binding Delay, Converter={StaticResource DelayColorConverter}}" Text="{Binding DelayVal}" />
|
<TextBlock
|
||||||
|
Margin="8,0"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{Binding Delay, Converter={StaticResource DelayColorConverter}}"
|
||||||
|
Text="{Binding DelayVal}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
|
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding SpeedVal}" Header="{x:Static resx:ResUI.LvTestSpeed}" Tag="SpeedVal" />
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding SpeedVal}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTestSpeed}"
|
||||||
|
Tag="SpeedVal" />
|
||||||
|
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding TodayUp}" Header="{x:Static resx:ResUI.LvTodayUploadDataAmount}" Tag="TodayUp" />
|
<DataGridTextColumn
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding TodayDown}" Header="{x:Static resx:ResUI.LvTodayDownloadDataAmount}" Tag="TodayDown" />
|
Width="100"
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding TotalUp}" Header="{x:Static resx:ResUI.LvTotalUploadDataAmount}" Tag="TotalUp" />
|
Binding="{Binding TodayUp}"
|
||||||
<DataGridTextColumn Width="100" Binding="{Binding TotalDown}" Header="{x:Static resx:ResUI.LvTotalDownloadDataAmount}" Tag="TotalDown" />
|
Header="{x:Static resx:ResUI.LvTodayUploadDataAmount}"
|
||||||
|
Tag="TodayUp" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding TodayDown}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTodayDownloadDataAmount}"
|
||||||
|
Tag="TodayDown" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding TotalUp}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTotalUploadDataAmount}"
|
||||||
|
Tag="TotalUp" />
|
||||||
|
<DataGridTextColumn
|
||||||
|
Width="100"
|
||||||
|
Binding="{Binding TotalDown}"
|
||||||
|
Header="{x:Static resx:ResUI.LvTotalDownloadDataAmount}"
|
||||||
|
Tag="TotalDown" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
|
@ -49,6 +49,25 @@ public partial class ProfilesSelectWindow : ReactiveWindow<ProfilesSelectViewMod
|
||||||
btnCancel.Click += (s, e) => Close(false);
|
btnCancel.Click += (s, e) => Close(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AllowMultiSelect(bool allow)
|
||||||
|
{
|
||||||
|
if (allow)
|
||||||
|
{
|
||||||
|
lstProfiles.SelectionMode = DataGridSelectionMode.Extended;
|
||||||
|
lstProfiles.SelectedItems.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lstProfiles.SelectionMode = DataGridSelectionMode.Single;
|
||||||
|
if (lstProfiles.SelectedItems.Count > 0)
|
||||||
|
{
|
||||||
|
var first = lstProfiles.SelectedItems[0];
|
||||||
|
lstProfiles.SelectedItems.Clear();
|
||||||
|
lstProfiles.SelectedItem = first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
HeadersVisibility="All"
|
HeadersVisibility="All"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
RowHeaderWidth="40"
|
RowHeaderWidth="40"
|
||||||
|
SelectionMode="Single"
|
||||||
Style="{StaticResource DefDataGrid}">
|
Style="{StaticResource DefDataGrid}">
|
||||||
<DataGrid.InputBindings>
|
<DataGrid.InputBindings>
|
||||||
<KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Enter" />
|
<KeyBinding Command="ApplicationCommands.NotACommand" Gesture="Enter" />
|
||||||
|
|
|
@ -42,7 +42,25 @@ public partial class ProfilesSelectWindow
|
||||||
this.Bind(ViewModel, vm => vm.SelectedSub, v => v.lstGroup.SelectedItem).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.SelectedSub, v => v.lstGroup.SelectedItem).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.ServerFilter, v => v.txtServerFilter.Text).DisposeWith(disposables);
|
this.Bind(ViewModel, vm => vm.ServerFilter, v => v.txtServerFilter.Text).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AllowMultiSelect(bool allow)
|
||||||
|
{
|
||||||
|
if (allow)
|
||||||
|
{
|
||||||
|
lstProfiles.SelectionMode = DataGridSelectionMode.Extended;
|
||||||
|
lstProfiles.SelectedItems.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lstProfiles.SelectionMode = DataGridSelectionMode.Single;
|
||||||
|
if (lstProfiles.SelectedItems.Count > 0)
|
||||||
|
{
|
||||||
|
var first = lstProfiles.SelectedItems[0];
|
||||||
|
lstProfiles.SelectedItems.Clear();
|
||||||
|
lstProfiles.SelectedItem = first;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Event
|
#region Event
|
||||||
|
|
Loading…
Reference in New Issue