Added drag and drop sorting option

This commit is contained in:
2dust 2023-01-07 19:56:56 +08:00
parent 975a335538
commit 118a920e57
9 changed files with 49 additions and 11 deletions

View file

@ -60,6 +60,7 @@ namespace v2rayN.Mode
public bool colorModeDark { get; set; } public bool colorModeDark { get; set; }
public string? colorPrimaryName { get; set; } public string? colorPrimaryName { get; set; }
public string currentLanguage { get; set; } public string currentLanguage { get; set; }
public bool enableDragDropSort { get; set; }
public Dictionary<string, int> mainLvColWidth { get; set; } public Dictionary<string, int> mainLvColWidth { get; set; }
} }

View file

@ -2392,6 +2392,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Enable Server Drag Drop Sort(Require restart) 的本地化字符串。
/// </summary>
public static string TbSettingsEnableDragDropSort {
get {
return ResourceManager.GetString("TbSettingsEnableDragDropSort", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Exception 的本地化字符串。 /// 查找类似 Exception 的本地化字符串。
/// </summary> /// </summary>

View file

@ -1066,4 +1066,7 @@
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve"> <data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>Custom Template</value> <value>Custom Template</value>
</data> </data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>Enable Server Drag Drop Sort(Require restart)</value>
</data>
</root> </root>

View file

@ -851,7 +851,7 @@
<value>开机启动(可能会不成功)</value> <value>开机启动(可能会不成功)</value>
</data> </data>
<data name="TbSettingsStatistics" xml:space="preserve"> <data name="TbSettingsStatistics" xml:space="preserve">
<value>启用统计(实时网速显示,需重启)</value> <value>启用统计(实时网速显示,需重启)</value>
</data> </data>
<data name="TbSettingsStatisticsFreshRate" xml:space="preserve"> <data name="TbSettingsStatisticsFreshRate" xml:space="preserve">
<value>统计刷新频率(单位秒)</value> <value>统计刷新频率(单位秒)</value>
@ -1066,4 +1066,7 @@
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve"> <data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
<value>自定义配置模板</value> <value>自定义配置模板</value>
</data> </data>
<data name="TbSettingsEnableDragDropSort" xml:space="preserve">
<value>启用服务器拖放排序(需重启)</value>
</data>
</root> </root>

View file

@ -55,6 +55,7 @@ namespace v2rayN.ViewModels
[Reactive] public bool EnableSecurityProtocolTls13 { get; set; } [Reactive] public bool EnableSecurityProtocolTls13 { get; set; }
[Reactive] public bool AutoHideStartup { get; set; } [Reactive] public bool AutoHideStartup { get; set; }
[Reactive] public bool EnableCheckPreReleaseUpdate { get; set; } [Reactive] public bool EnableCheckPreReleaseUpdate { get; set; }
[Reactive] public bool EnableDragDropSort { get; set; }
[Reactive] public int autoUpdateInterval { get; set; } [Reactive] public int autoUpdateInterval { get; set; }
[Reactive] public int autoUpdateSubInterval { get; set; } [Reactive] public int autoUpdateSubInterval { get; set; }
[Reactive] public int trayMenuServersLimit { get; set; } [Reactive] public int trayMenuServersLimit { get; set; }
@ -135,6 +136,7 @@ namespace v2rayN.ViewModels
EnableSecurityProtocolTls13 = _config.enableSecurityProtocolTls13; EnableSecurityProtocolTls13 = _config.enableSecurityProtocolTls13;
AutoHideStartup = _config.autoHideStartup; AutoHideStartup = _config.autoHideStartup;
EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate; EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate;
EnableDragDropSort = _config.uiItem.enableDragDropSort;
autoUpdateInterval = _config.autoUpdateInterval; autoUpdateInterval = _config.autoUpdateInterval;
autoUpdateSubInterval = _config.autoUpdateSubInterval; autoUpdateSubInterval = _config.autoUpdateSubInterval;
trayMenuServersLimit = _config.trayMenuServersLimit; trayMenuServersLimit = _config.trayMenuServersLimit;
@ -299,6 +301,7 @@ namespace v2rayN.ViewModels
_config.autoUpdateInterval = autoUpdateInterval; _config.autoUpdateInterval = autoUpdateInterval;
_config.autoUpdateSubInterval = autoUpdateSubInterval; _config.autoUpdateSubInterval = autoUpdateSubInterval;
_config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; _config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
_config.uiItem.enableDragDropSort = EnableDragDropSort;
_config.trayMenuServersLimit = trayMenuServersLimit; _config.trayMenuServersLimit = trayMenuServersLimit;
//systemProxy //systemProxy

View file

@ -412,7 +412,6 @@
x:Name="lstProfiles" x:Name="lstProfiles"
Grid.Row="0" Grid.Row="0"
materialDesign:DataGridAssist.CellPadding="1,0" materialDesign:DataGridAssist.CellPadding="1,0"
AllowDrop="True"
AutoGenerateColumns="False" AutoGenerateColumns="False"
BorderThickness="1" BorderThickness="1"
CanUserAddRows="False" CanUserAddRows="False"

View file

@ -33,10 +33,14 @@ namespace v2rayN.Views
lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown; lstProfiles.PreviewKeyDown += LstProfiles_PreviewKeyDown;
lstProfiles.SelectionChanged += lstProfiles_SelectionChanged; lstProfiles.SelectionChanged += lstProfiles_SelectionChanged;
lstProfiles.LoadingRow += LstProfiles_LoadingRow; lstProfiles.LoadingRow += LstProfiles_LoadingRow;
lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown; if (_config.uiItem.enableDragDropSort)
lstProfiles.MouseMove += LstProfiles_MouseMove; {
lstProfiles.DragEnter += LstProfiles_DragEnter; lstProfiles.AllowDrop = true;
lstProfiles.Drop += LstProfiles_Drop; lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown;
lstProfiles.MouseMove += LstProfiles_MouseMove;
lstProfiles.DragEnter += LstProfiles_DragEnter;
lstProfiles.Drop += LstProfiles_Drop;
}
ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler); ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler);
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));

View file

@ -415,6 +415,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -553,16 +554,30 @@
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableDragDropSort}" />
<ToggleButton
x:Name="togEnableDragDropSort"
Grid.Row="10"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="11"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsAutoUpdateInterval}" /> Text="{x:Static resx:ResUI.TbSettingsAutoUpdateInterval}" />
<TextBox <TextBox
x:Name="txtautoUpdateInterval" x:Name="txtautoUpdateInterval"
Grid.Row="10" Grid.Row="11"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource SettingItemMargin}" /> Margin="{StaticResource SettingItemMargin}" />
<TextBlock <TextBlock
Grid.Row="11" Grid.Row="12"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -570,13 +585,13 @@
Text="{x:Static resx:ResUI.TbSettingsAutoUpdate}" /> Text="{x:Static resx:ResUI.TbSettingsAutoUpdate}" />
<TextBox <TextBox
x:Name="txtautoUpdateSubInterval" x:Name="txtautoUpdateSubInterval"
Grid.Row="11" Grid.Row="12"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource SettingItemMargin}" /> Margin="{StaticResource SettingItemMargin}" />
<TextBlock <TextBlock
Grid.Row="12" Grid.Row="13"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -584,7 +599,7 @@
Text="{x:Static resx:ResUI.TbSettingsTrayMenuServersLimit}" /> Text="{x:Static resx:ResUI.TbSettingsTrayMenuServersLimit}" />
<TextBox <TextBox
x:Name="txttrayMenuServersLimit" x:Name="txttrayMenuServersLimit"
Grid.Row="12" Grid.Row="13"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource SettingItemMargin}" /> Margin="{StaticResource SettingItemMargin}" />

View file

@ -87,6 +87,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.AutoHideStartup, v => v.togAutoHideStartup.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableCheckPreReleaseUpdate, v => v.togEnableCheckPreReleaseUpdate.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.autoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.autoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.autoUpdateSubInterval, v => v.txtautoUpdateSubInterval.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.autoUpdateSubInterval, v => v.txtautoUpdateSubInterval.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.trayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.trayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables);