Add double-click server as active parameter

pull/3165/head
2dust 2023-01-31 16:08:26 +08:00
parent fcbc9471aa
commit d6db4f0e4c
9 changed files with 68 additions and 9 deletions

View File

@ -63,6 +63,7 @@ namespace v2rayN.Mode
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 bool enableDragDropSort { get; set; }
public bool doubleClick2Activate { get; set; }
public Dictionary<string, int> mainLvColWidth { get; set; } public Dictionary<string, int> mainLvColWidth { get; set; }
} }

View File

@ -2401,6 +2401,15 @@ namespace v2rayN.Resx {
} }
} }
/// <summary>
/// 查找类似 Double-click server make active 的本地化字符串。
/// </summary>
public static string TbSettingsDoubleClick2Activate {
get {
return ResourceManager.GetString("TbSettingsDoubleClick2Activate", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Automatically adjust column width after updating subscription 的本地化字符串。 /// 查找类似 Automatically adjust column width after updating subscription 的本地化字符串。
/// </summary> /// </summary>

View File

@ -1078,4 +1078,7 @@
<data name="menuEditServer" xml:space="preserve"> <data name="menuEditServer" xml:space="preserve">
<value>Edit Server (Ctrl+D)</value> <value>Edit Server (Ctrl+D)</value>
</data> </data>
<data name="TbSettingsDoubleClick2Activate" xml:space="preserve">
<value>Double-click server make active</value>
</data>
</root> </root>

View File

@ -1078,4 +1078,7 @@
<data name="menuEditServer" xml:space="preserve"> <data name="menuEditServer" xml:space="preserve">
<value>编辑服务器 (Ctrl+D)</value> <value>编辑服务器 (Ctrl+D)</value>
</data> </data>
<data name="TbSettingsDoubleClick2Activate" xml:space="preserve">
<value>主界面双击设为活动服务器</value>
</data>
</root> </root>

View File

@ -560,10 +560,19 @@ namespace v2rayN.ViewModels
item.totalDown = Utils.HumanFy(update.totalDown); item.totalDown = Utils.HumanFy(update.totalDown);
item.totalUp = Utils.HumanFy(update.totalUp); item.totalUp = Utils.HumanFy(update.totalUp);
if (SelectedProfile?.indexId == item.indexId)
{
var temp = Utils.DeepCopy(item);
_profileItems.Replace(item, temp);
SelectedProfile = temp;
}
else
{
_profileItems.Replace(item, Utils.DeepCopy(item)); _profileItems.Replace(item, Utils.DeepCopy(item));
} }
} }
} }
}
})); }));
} }
catch (Exception ex) catch (Exception ex)
@ -726,9 +735,17 @@ namespace v2rayN.ViewModels
_profileItems.Clear(); _profileItems.Clear();
_profileItems.AddRange(lstModel); _profileItems.AddRange(lstModel);
if (lstModel.Count > 0) if (lstModel.Count > 0)
{
var selected = lstModel.FirstOrDefault(t => t.indexId == _config.indexId);
if (selected != null)
{
SelectedProfile = selected;
}
else
{ {
SelectedProfile = lstModel[0]; SelectedProfile = lstModel[0];
} }
}
RefreshServersMenu(); RefreshServersMenu();
@ -918,7 +935,7 @@ namespace v2rayN.ViewModels
public void SetDefaultServer() public void SetDefaultServer()
{ {
if (Utils.IsNullOrEmpty(SelectedProfile.indexId)) if (Utils.IsNullOrEmpty(SelectedProfile?.indexId))
{ {
return; return;
} }

View File

@ -56,6 +56,7 @@ namespace v2rayN.ViewModels
[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 bool EnableDragDropSort { get; set; }
[Reactive] public bool DoubleClick2Activate { 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; }
@ -137,6 +138,7 @@ namespace v2rayN.ViewModels
AutoHideStartup = _config.autoHideStartup; AutoHideStartup = _config.autoHideStartup;
EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate; EnableCheckPreReleaseUpdate = _config.checkPreReleaseUpdate;
EnableDragDropSort = _config.uiItem.enableDragDropSort; EnableDragDropSort = _config.uiItem.enableDragDropSort;
DoubleClick2Activate = _config.uiItem.doubleClick2Activate;
autoUpdateInterval = _config.autoUpdateInterval; autoUpdateInterval = _config.autoUpdateInterval;
autoUpdateSubInterval = _config.autoUpdateSubInterval; autoUpdateSubInterval = _config.autoUpdateSubInterval;
trayMenuServersLimit = _config.trayMenuServersLimit; trayMenuServersLimit = _config.trayMenuServersLimit;
@ -302,6 +304,7 @@ namespace v2rayN.ViewModels
_config.autoUpdateSubInterval = autoUpdateSubInterval; _config.autoUpdateSubInterval = autoUpdateSubInterval;
_config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; _config.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate;
_config.uiItem.enableDragDropSort = EnableDragDropSort; _config.uiItem.enableDragDropSort = EnableDragDropSort;
_config.uiItem.doubleClick2Activate = DoubleClick2Activate;
_config.trayMenuServersLimit = trayMenuServersLimit; _config.trayMenuServersLimit = trayMenuServersLimit;
//systemProxy //systemProxy

View File

@ -240,9 +240,16 @@ namespace v2rayN.Views
} }
private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (_config.uiItem.doubleClick2Activate)
{
ViewModel?.SetDefaultServer();
}
else
{ {
ViewModel?.EditServer(false, EConfigType.Custom); ViewModel?.EditServer(false, EConfigType.Custom);
} }
}
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e) private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
{ {

View File

@ -419,6 +419,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" />
@ -571,16 +572,30 @@
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsDoubleClick2Activate}" />
<ToggleButton
x:Name="togDoubleClick2Activate"
Grid.Row="11"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="12"
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="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"
@ -588,13 +603,13 @@
Text="{x:Static resx:ResUI.TbSettingsAutoUpdate}" /> Text="{x:Static resx:ResUI.TbSettingsAutoUpdate}" />
<TextBox <TextBox
x:Name="txtautoUpdateSubInterval" x:Name="txtautoUpdateSubInterval"
Grid.Row="12" Grid.Row="13"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource SettingItemMargin}" /> Margin="{StaticResource SettingItemMargin}" />
<TextBlock <TextBlock
Grid.Row="13" Grid.Row="14"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource SettingItemMargin}" Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -602,7 +617,7 @@
Text="{x:Static resx:ResUI.TbSettingsTrayMenuServersLimit}" /> Text="{x:Static resx:ResUI.TbSettingsTrayMenuServersLimit}" />
<TextBox <TextBox
x:Name="txttrayMenuServersLimit" x:Name="txttrayMenuServersLimit"
Grid.Row="13" Grid.Row="14"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource SettingItemMargin}" /> Margin="{StaticResource SettingItemMargin}" />

View File

@ -88,6 +88,7 @@ namespace v2rayN.Views
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.EnableDragDropSort, v => v.togEnableDragDropSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.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);