Improved ModifyFontSize

pull/6443/head
2dust 2025-01-04 20:42:42 +08:00
parent 3cc75cd46d
commit 626ebfe65d
2 changed files with 16 additions and 10 deletions

View File

@ -31,6 +31,7 @@ namespace v2rayN.Desktop.ViewModels
{
ModifyTheme();
ModifyFontFamily();
ModifyFontSize();
}
private void BindingUI()
@ -67,11 +68,10 @@ namespace v2rayN.Desktop.ViewModels
y => y > 0)
.Subscribe(c =>
{
if (CurrentFontSize >= Global.MinFontSize)
if (_config.UiItem.CurrentFontSize != CurrentFontSize && CurrentFontSize >= Global.MinFontSize)
{
_config.UiItem.CurrentFontSize = CurrentFontSize;
double size = CurrentFontSize;
ModifyFontSize(size);
ModifyFontSize();
ConfigHandler.SaveConfig(_config);
}
});
@ -100,8 +100,9 @@ namespace v2rayN.Desktop.ViewModels
}
}
private void ModifyFontSize(double size)
private void ModifyFontSize()
{
double size = CurrentFontSize;
Style style = new(x => Selectors.Or(
x.OfType<Button>(),
x.OfType<TextBox>(),

View File

@ -47,6 +47,7 @@ namespace v2rayN.ViewModels
private void RestoreUI()
{
ModifyTheme();
ModifyFontSize();
if (!_config.UiItem.ColorPrimaryName.IsNullOrEmpty())
{
var swatch = new SwatchesProvider().Swatches.FirstOrDefault(t => t.Name == _config.UiItem.ColorPrimaryName);
@ -121,14 +122,10 @@ namespace v2rayN.ViewModels
y => y > 0)
.Subscribe(c =>
{
if (CurrentFontSize >= Global.MinFontSize)
if (_config.UiItem.CurrentFontSize != CurrentFontSize && CurrentFontSize >= Global.MinFontSize)
{
_config.UiItem.CurrentFontSize = CurrentFontSize;
double size = (long)CurrentFontSize;
Application.Current.Resources["StdFontSize"] = size;
Application.Current.Resources["StdFontSize1"] = size + 1;
Application.Current.Resources["StdFontSize-1"] = size - 1;
ModifyFontSize();
ConfigHandler.SaveConfig(_config);
}
});
@ -158,6 +155,14 @@ namespace v2rayN.ViewModels
WindowsUtils.SetDarkBorder(Application.Current.MainWindow, isDarkTheme);
}
private void ModifyFontSize()
{
double size = (long)CurrentFontSize;
Application.Current.Resources["StdFontSize"] = size;
Application.Current.Resources["StdFontSize1"] = size + 1;
Application.Current.Resources["StdFontSize-1"] = size - 1;
}
public void ChangePrimaryColor(System.Windows.Media.Color color)
{
var theme = _paletteHelper.GetTheme();