diff --git a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs index f836662b..cb346795 100644 --- a/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs +++ b/v2rayN/v2rayN/Converters/MaterialDesignFonts.cs @@ -1,5 +1,4 @@ -using System.IO; -using System.Windows.Media; +using System.Windows.Media; using v2rayN.Handler; namespace v2rayN.Converters diff --git a/v2rayN/v2rayN/Global.cs b/v2rayN/v2rayN/Global.cs index c29f1dd5..7cbdb836 100644 --- a/v2rayN/v2rayN/Global.cs +++ b/v2rayN/v2rayN/Global.cs @@ -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 IEProxyProtocols = new List { "{ip}:{http_port}", diff --git a/v2rayN/v2rayN/Mode/ConfigItems.cs b/v2rayN/v2rayN/Mode/ConfigItems.cs index a6f1af79..f38aef19 100644 --- a/v2rayN/v2rayN/Mode/ConfigItems.cs +++ b/v2rayN/v2rayN/Mode/ConfigItems.cs @@ -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; diff --git a/v2rayN/v2rayN/Mode/VmessQRCode.cs b/v2rayN/v2rayN/Mode/VmessQRCode.cs index 6b6dc082..d5f62c7d 100644 --- a/v2rayN/v2rayN/Mode/VmessQRCode.cs +++ b/v2rayN/v2rayN/Mode/VmessQRCode.cs @@ -67,6 +67,6 @@ /// TLS fingerprint /// public string fp { get; set; } = string.Empty; - + } } diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index 302ae041..0bceb619 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -2509,6 +2509,15 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 FontSize 的本地化字符串。 + /// + public static string TbSettingsFontSize { + get { + return ResourceManager.GetString("TbSettingsFontSize", resourceCulture); + } + } + /// /// 查找类似 Http Port 的本地化字符串。 /// @@ -2546,7 +2555,7 @@ namespace v2rayN.Resx { } /// - /// 查找类似 Language 的本地化字符串。 + /// 查找类似 Language(Restart) 的本地化字符串。 /// public static string TbSettingsLanguage { get { diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 0ab2dc69..f1a8d7d7 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -548,7 +548,7 @@ Dark Mode - Language + Language(Restart) Import bulk URL from clipboard (Ctrl+V) @@ -1105,4 +1105,7 @@ Set this with admin privileges, get admin privileges after startup + + FontSize + \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index f28f1246..43468197 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -548,7 +548,7 @@ 暗黑模式 - 语言 + 语言(重启) 从剪贴板导入批量URL (Ctrl+V) @@ -1105,4 +1105,7 @@ 以管理员权限设置此项,在启动后获得管理员权限 + + 字体大小 + \ No newline at end of file diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index f8dd66f6..58cc3650 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -189,6 +189,8 @@ namespace v2rayN.ViewModels public IObservableCollection 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()) diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index 712233fe..36724273 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -261,37 +261,74 @@ HorizontalAlignment="Right" Style="{StaticResource MaterialDesignToolForegroundPopupBox}"> - + + + + + + + + + + + - - - + + - - + + + + - + + diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index a6dc9db2..f84eac79 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -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); });