Font size custom

pull/3187/head
2dust 2 years ago
parent 7989d5180b
commit b9acd0ec28

@ -1,5 +1,4 @@
using System.IO;
using System.Windows.Media;
using System.Windows.Media;
using v2rayN.Handler;
namespace v2rayN.Converters

@ -77,6 +77,7 @@
public const string CommandClearMsg = "CommandClearMsg";
public const string DelayUnit = "";
public const string SpeedUnit = "";
public const int MinFontSize = 10;
public static readonly List<string> IEProxyProtocols = new List<string> {
"{ip}:{http_port}",

@ -63,6 +63,7 @@ namespace v2rayN.Mode
public string? colorPrimaryName { get; set; }
public string currentLanguage { get; set; }
public string currentFontFamily { get; set; }
public int currentFontSize { get; set; }
public bool enableDragDropSort { get; set; }
public bool doubleClick2Activate { get; set; }
public bool autoHideStartup { get; set; } = true;

@ -67,6 +67,6 @@
/// TLS fingerprint
/// </summary>
public string fp { get; set; } = string.Empty;
}
}

@ -2509,6 +2509,15 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 FontSize 的本地化字符串。
/// </summary>
public static string TbSettingsFontSize {
get {
return ResourceManager.GetString("TbSettingsFontSize", resourceCulture);
}
}
/// <summary>
/// 查找类似 Http Port 的本地化字符串。
/// </summary>
@ -2546,7 +2555,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Language 的本地化字符串。
/// 查找类似 Language(Restart) 的本地化字符串。
/// </summary>
public static string TbSettingsLanguage {
get {

@ -548,7 +548,7 @@
<value>Dark Mode</value>
</data>
<data name="TbSettingsLanguage" xml:space="preserve">
<value>Language</value>
<value>Language(Restart)</value>
</data>
<data name="menuAddServerViaClipboard" xml:space="preserve">
<value>Import bulk URL from clipboard (Ctrl+V)</value>
@ -1105,4 +1105,7 @@
<data name="TbSettingsStartBootTip" xml:space="preserve">
<value>Set this with admin privileges, get admin privileges after startup</value>
</data>
<data name="TbSettingsFontSize" xml:space="preserve">
<value>FontSize</value>
</data>
</root>

@ -548,7 +548,7 @@
<value>暗黑模式</value>
</data>
<data name="TbSettingsLanguage" xml:space="preserve">
<value>语言</value>
<value>语言(重启)</value>
</data>
<data name="menuAddServerViaClipboard" xml:space="preserve">
<value>从剪贴板导入批量URL (Ctrl+V)</value>
@ -1105,4 +1105,7 @@
<data name="TbSettingsStartBootTip" xml:space="preserve">
<value>以管理员权限设置此项,在启动后获得管理员权限</value>
</data>
<data name="TbSettingsFontSize" xml:space="preserve">
<value>字体大小</value>
</data>
</root>

@ -189,6 +189,8 @@ namespace v2rayN.ViewModels
public IObservableCollection<Swatch> Swatches => _swatches;
[Reactive]
public Swatch SelectedSwatch { get; set; }
[Reactive]
public int CurrentFontSize { get; set; }
[Reactive]
public string CurrentLanguage { get; set; }
@ -259,7 +261,7 @@ namespace v2rayN.ViewModels
x => x.EnableTun,
y => y == true)
.Subscribe(c => DoEnableTun(c));
BindingUI();
RestoreUI();
AutoHideStartup();
@ -1576,6 +1578,7 @@ namespace v2rayN.ViewModels
{
SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName);
}
CurrentFontSize = _config.uiItem.currentFontSize;
CurrentLanguage = _config.uiItem.currentLanguage;
this.WhenAnyValue(
@ -1611,6 +1614,23 @@ namespace v2rayN.ViewModels
}
});
this.WhenAnyValue(
x => x.CurrentFontSize,
y => y > 0)
.Subscribe(c =>
{
if (CurrentFontSize >= Global.MinFontSize)
{
_config.uiItem.currentFontSize = CurrentFontSize;
double size = (long)CurrentFontSize;
Application.Current.Resources["StdFontSize"] = size;
Application.Current.Resources["StdFontSize1"] = size + 2;
Application.Current.Resources["StdFontSize2"] = size + 4;
ConfigHandler.SaveConfig(ref _config);
}
});
this.WhenAnyValue(
x => x.CurrentLanguage,
y => y != null && !y.IsNullOrEmpty())

@ -261,37 +261,74 @@
HorizontalAlignment="Right"
Style="{StaticResource MaterialDesignToolForegroundPopupBox}">
<StackPanel Margin="8">
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsColorMode}" />
<ToggleButton x:Name="togDarkMode" Margin="8" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<ToggleButton
x:Name="togDarkMode"
Grid.Row="0"
Grid.Column="1"
Margin="8" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsColor}" />
<ComboBox
x:Name="cmbSwatches"
Grid.Row="1"
Grid.Column="1"
Width="100"
Margin="8"
DisplayMemberPath="Name"
Style="{StaticResource DefComboBox}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsFontSize}" />
<ComboBox
x:Name="cmbCurrentFontSize"
Grid.Row="2"
Grid.Column="1"
Width="100"
Margin="8"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsLanguage}" />
<ComboBox
x:Name="cmbCurrentLanguage"
Grid.Row="3"
Grid.Column="1"
Width="100"
Margin="8"
materialDesign:HintAssist.Hint="Language"
Style="{StaticResource DefComboBox}" />
</StackPanel>
</Grid>
</StackPanel>
</materialDesign:PopupBox>
</ToolBar>

@ -45,6 +45,11 @@ namespace v2rayN.Views
ViewModel = new MainWindowViewModel(MainSnackbar.MessageQueue!, UpdateViewHandler);
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
for (int i = Global.MinFontSize; i <= Global.MinFontSize + 8; i++)
{
cmbCurrentFontSize.Items.Add(i.ToString());
}
Global.Languages.ForEach(it =>
{
cmbCurrentLanguage.Items.Add(it);
@ -173,6 +178,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.ColorModeDark, v => v.togDarkMode.IsChecked).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.Swatches, v => v.cmbSwatches.ItemsSource).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.Text).DisposeWith(disposables);
});

Loading…
Cancel
Save