Add font size and font family select
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
ShutdownMode="OnExplicitShutdown"
|
||||
StartupUri="Views/MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<materialDesign:BundledTheme
|
||||
BaseTheme="Dark"
|
||||
@@ -16,6 +16,10 @@
|
||||
SecondaryColor="Lime" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<system:Double x:Key="StdFontSize1">11</system:Double>
|
||||
<system:Double x:Key="StdFontSize2">12</system:Double>
|
||||
<system:Double x:Key="StdFontSize3">13</system:Double>
|
||||
<system:Double x:Key="StdFontSize4">14</system:Double>
|
||||
<Style
|
||||
x:Key="MyMaterialDesignNavigationRailTabItem"
|
||||
BasedOn="{StaticResource MaterialDesignNavigationRailTabItem}"
|
||||
@@ -26,37 +30,37 @@
|
||||
x:Key="ModuleTitle"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize4}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="TabItemTitle"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize4}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="ListItemTitle"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="ListItemSubTitle"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="ListItemSubTitle2"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="11" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="ToolbarItem"
|
||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||
TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextElement}">
|
||||
<Setter Property="FontWeight" Value="Regular" />
|
||||
@@ -82,29 +86,47 @@
|
||||
x:Key="ListItemCheckBox"
|
||||
BasedOn="{StaticResource MaterialDesignUserForegroundCheckBox}"
|
||||
TargetType="{x:Type CheckBox}">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style x:Key="ListItemChip" TargetType="{x:Type materialDesign:Chip}">
|
||||
<Setter Property="FontSize" Value="11" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DefButton"
|
||||
BasedOn="{StaticResource MaterialDesignRaisedButton}"
|
||||
TargetType="{x:Type ButtonBase}">
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DefMenu"
|
||||
BasedOn="{StaticResource MaterialDesignContextMenu}"
|
||||
TargetType="{x:Type ContextMenu}">
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||
<Setter Property="FontFamily" Value="{x:Static conv:MaterialDesignFonts.MyFont}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DefComboBox"
|
||||
BasedOn="{StaticResource MaterialDesignComboBox}"
|
||||
TargetType="{x:Type ComboBox}">
|
||||
<Setter Property="FontSize" Value="12" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DefTextBox"
|
||||
BasedOn="{StaticResource MaterialDesignTextBox}"
|
||||
TargetType="{x:Type TextBox}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="MyOutlinedTextBox"
|
||||
BasedOn="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
TargetType="{x:Type TextBox}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
<Style
|
||||
x:Key="DefDataGrid"
|
||||
BasedOn="{StaticResource MaterialDesignDataGrid}"
|
||||
TargetType="{x:Type DataGrid}">
|
||||
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using clashN.Tool;
|
||||
using clashN.Handler;
|
||||
using clashN.Mode;
|
||||
using clashN.Tool;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
@@ -10,7 +12,7 @@ namespace clashN
|
||||
public partial class App : Application
|
||||
{
|
||||
public static EventWaitHandle ProgramStarted;
|
||||
|
||||
private static Config _config;
|
||||
public App()
|
||||
{
|
||||
// Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
|
||||
@@ -46,12 +48,24 @@ namespace clashN
|
||||
Utils.SaveLog($"clashN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
||||
Logging.ClearLogs();
|
||||
|
||||
Init();
|
||||
|
||||
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
||||
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);
|
||||
|
||||
base.OnStartup(e);
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (ConfigHandler.LoadConfig(ref _config) != 0)
|
||||
{
|
||||
UI.ShowWarning($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
|
||||
Application.Current.Shutdown();
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
Utils.SaveLog("App_DispatcherUnhandledException", e.Exception);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using clashN.Handler;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace clashN.Converters
|
||||
@@ -10,8 +9,22 @@ namespace clashN.Converters
|
||||
|
||||
static MaterialDesignFonts()
|
||||
{
|
||||
var fontPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Fonts\");
|
||||
MyFont = new FontFamily(new Uri($"file:///{fontPath}"), "./#Source Han Sans CN");
|
||||
try
|
||||
{
|
||||
var fontFamily = LazyConfig.Instance.GetConfig().uiItem.currentFontFamily;
|
||||
if (!string.IsNullOrEmpty(fontFamily))
|
||||
{
|
||||
var fontPath = Utils.GetFontsPath();
|
||||
MyFont = new FontFamily(new Uri(@$"file:///{fontPath}\"), $"./#{fontFamily}");
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
if (MyFont is null)
|
||||
{
|
||||
MyFont = new FontFamily("Microsoft YaHei");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@
|
||||
/// Icon
|
||||
/// </summary>
|
||||
public const string CustomIconName = "clashN.ico";
|
||||
public const int MinFontSize = 10;
|
||||
|
||||
|
||||
public const string StatisticLogOverall = "StatisticLogOverall.json";
|
||||
@@ -108,7 +109,7 @@
|
||||
|
||||
public static readonly List<string> proxyVehicleType = new List<string> { "file", "http" };
|
||||
|
||||
public static readonly List<string> Languages = new List<string> { "zh-Hans", "en","fa-IR" };
|
||||
public static readonly List<string> Languages = new List<string> { "zh-Hans", "en", "fa-IR" };
|
||||
|
||||
public static readonly List<string> LogLevel = new List<string> { "debug", "info", "warning", "error", "silent" };
|
||||
|
||||
|
||||
@@ -197,6 +197,14 @@ namespace clashN.Mode
|
||||
|
||||
public bool colorModeDark { get; set; }
|
||||
public string? colorPrimaryName { get; set; }
|
||||
public string currentFontFamily { get; set; }
|
||||
public int currentFontSize { get; set; }
|
||||
|
||||
public int proxiesSorting { get; set; }
|
||||
public bool proxiesAutoRefresh { get; set; }
|
||||
|
||||
public int connectionsSorting { get; set; }
|
||||
public bool connectionsAutoRefresh { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
27
clashN/clashN/Resx/ResUI.Designer.cs
generated
27
clashN/clashN/Resx/ResUI.Designer.cs
generated
@@ -1384,6 +1384,33 @@ namespace clashN.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 FontFamily(Require restart) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsFontFamily {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsFontFamily", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Copy the font TTF file to the directory guiFonts, restart the settings 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsFontFamilyTip {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsFontFamilyTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 FontSize 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsFontSize {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsFontSize", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Http Port 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -664,4 +664,13 @@
|
||||
<data name="TbSortingType" xml:space="preserve">
|
||||
<value>Type</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontFamily" xml:space="preserve">
|
||||
<value>FontFamily(Require restart)</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontFamilyTip" xml:space="preserve">
|
||||
<value>Copy the font TTF file to the directory guiFonts, restart the settings</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontSize" xml:space="preserve">
|
||||
<value>FontSize</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -667,4 +667,13 @@
|
||||
<data name="TbSortingType" xml:space="preserve">
|
||||
<value>类型</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontFamily" xml:space="preserve">
|
||||
<value>当前字体(需重启)</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontFamilyTip" xml:space="preserve">
|
||||
<value>拷贝字体TTF文件到目录guiFonts,重启</value>
|
||||
</data>
|
||||
<data name="TbSettingsFontSize" xml:space="preserve">
|
||||
<value>字体大小</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1112,6 +1112,22 @@ namespace clashN
|
||||
}
|
||||
return Path.Combine(_tempPath, filename);
|
||||
}
|
||||
public static string GetFontsPath(string filename = "")
|
||||
{
|
||||
string _tempPath = Path.Combine(StartupPath(), "guiFonts");
|
||||
if (!Directory.Exists(_tempPath))
|
||||
{
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
}
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
{
|
||||
return _tempPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Path.Combine(_tempPath, filename);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Log
|
||||
|
||||
@@ -37,6 +37,10 @@ namespace clashN.ViewModels
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = LazyConfig.Instance.GetConfig();
|
||||
|
||||
AutoRefreshInterval = 10;
|
||||
SortingSelected = _config.uiItem.connectionsSorting;
|
||||
AutoRefresh = _config.uiItem.connectionsAutoRefresh;
|
||||
|
||||
var canEditRemove = this.WhenAnyValue(
|
||||
x => x.SelectedSource,
|
||||
selectedSource => selectedSource != null && !selectedSource.id.IsNullOrEmpty());
|
||||
@@ -46,6 +50,11 @@ namespace clashN.ViewModels
|
||||
y => y != null && y >= 0)
|
||||
.Subscribe(c => DoSortingSelected(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.AutoRefresh,
|
||||
y => y == true)
|
||||
.Subscribe(c => { _config.uiItem.connectionsAutoRefresh = AutoRefresh; });
|
||||
|
||||
ConnectionCloseCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ClashConnectionClose(false);
|
||||
@@ -56,10 +65,6 @@ namespace clashN.ViewModels
|
||||
ClashConnectionClose(true);
|
||||
});
|
||||
|
||||
AutoRefreshInterval = 10;
|
||||
SortingSelected = 4;
|
||||
AutoRefresh = true;
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
@@ -69,6 +74,10 @@ namespace clashN.ViewModels
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SortingSelected != _config.uiItem.connectionsSorting)
|
||||
{
|
||||
_config.uiItem.connectionsSorting = SortingSelected;
|
||||
}
|
||||
|
||||
GetClashConnections();
|
||||
}
|
||||
@@ -128,7 +137,7 @@ namespace clashN.ViewModels
|
||||
model.id = item.id;
|
||||
model.network = item.metadata.network;
|
||||
model.type = item.metadata.type;
|
||||
model.host = $"{item.metadata.host}:{item.metadata.destinationPort}";
|
||||
model.host = $"{(item.metadata.host.IsNullOrEmpty() ? item.metadata.destinationIP : item.metadata.host)}:{item.metadata.destinationPort}";
|
||||
var sp = (dtNow - item.start);
|
||||
model.time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
|
||||
model.upload = item.upload;
|
||||
|
||||
@@ -92,6 +92,8 @@ namespace clashN.ViewModels
|
||||
|
||||
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
|
||||
{
|
||||
_config = LazyConfig.Instance.GetConfig();
|
||||
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(snackbarMessageQueue), typeof(NoticeHandler));
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
@@ -264,12 +266,8 @@ namespace clashN.ViewModels
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (ConfigHandler.LoadConfig(ref _config) != 0)
|
||||
{
|
||||
UI.ShowWarning($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}<7D><><EFBFBD><EFBFBD>GUI<55><49><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>쳣,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>");
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MainFormHandler.Instance.BackupGuiNConfig(_config, true);
|
||||
MainFormHandler.Instance.InitRegister(_config);
|
||||
|
||||
@@ -293,7 +291,7 @@ namespace clashN.ViewModels
|
||||
{
|
||||
if (notify)
|
||||
{
|
||||
_noticeHandler?.Enqueue(msg);
|
||||
_noticeHandler?.Enqueue(msg);
|
||||
_noticeHandler?.SendMessage(msg);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace clashN.ViewModels
|
||||
public bool AutoRefresh { get; set; }
|
||||
[Reactive]
|
||||
public bool EnableTun { get; set; }
|
||||
|
||||
|
||||
|
||||
public ProxiesViewModel()
|
||||
{
|
||||
@@ -58,14 +58,15 @@ namespace clashN.ViewModels
|
||||
|
||||
SelectedGroup = new();
|
||||
SelectedDetail = new();
|
||||
AutoRefresh = true;
|
||||
AutoRefresh = _config.uiItem.proxiesAutoRefresh;
|
||||
EnableTun = _config.enableTun;
|
||||
SortingSelected = _config.uiItem.proxiesSorting;
|
||||
|
||||
//GetClashProxies(true);
|
||||
this.WhenAnyValue(
|
||||
x => x.SelectedGroup,
|
||||
y => y != null && !y.name.IsNullOrEmpty())
|
||||
.Subscribe(c => RefreshProxyDetails(c));
|
||||
x => x.SelectedGroup,
|
||||
y => y != null && !y.name.IsNullOrEmpty())
|
||||
.Subscribe(c => RefreshProxyDetails(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.SystemProxySelected,
|
||||
@@ -87,6 +88,11 @@ namespace clashN.ViewModels
|
||||
y => y == true)
|
||||
.Subscribe(c => DoEnableTun(c));
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.AutoRefresh,
|
||||
y => y == true)
|
||||
.Subscribe(c => { _config.uiItem.proxiesAutoRefresh = AutoRefresh; });
|
||||
|
||||
ProxiesReloadCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
ProxiesReload();
|
||||
@@ -142,6 +148,10 @@ namespace clashN.ViewModels
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SortingSelected != _config.uiItem.proxiesSorting)
|
||||
{
|
||||
_config.uiItem.proxiesSorting = SortingSelected;
|
||||
}
|
||||
|
||||
RefreshProxyDetails(c);
|
||||
}
|
||||
@@ -187,9 +197,9 @@ namespace clashN.ViewModels
|
||||
{
|
||||
if (_config.enableTun != EnableTun)
|
||||
{
|
||||
_config.enableTun = EnableTun;
|
||||
_config.enableTun = EnableTun;
|
||||
TunModeSwitch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TunModeSwitch()
|
||||
|
||||
@@ -13,6 +13,7 @@ using ReactiveUI.Validation.Helpers;
|
||||
using Splat;
|
||||
using System.IO;
|
||||
using System.Reactive;
|
||||
using System.Windows;
|
||||
|
||||
namespace clashN.ViewModels
|
||||
{
|
||||
@@ -55,6 +56,8 @@ namespace clashN.ViewModels
|
||||
[Reactive]
|
||||
public string SubConvertUrl { get; set; }
|
||||
[Reactive]
|
||||
public string currentFontFamily { get; set; }
|
||||
[Reactive]
|
||||
public bool AutoHideStartup { get; set; }
|
||||
public ReactiveCommand<Unit, Unit> SetLoopbackCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SetGlobalHotkeyCmd { get; }
|
||||
@@ -81,6 +84,8 @@ namespace clashN.ViewModels
|
||||
public bool ColorModeDark { get; set; }
|
||||
[Reactive]
|
||||
public string CurrentLanguage { get; set; }
|
||||
[Reactive]
|
||||
public int CurrentFontSize { get; set; }
|
||||
#endregion
|
||||
|
||||
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
|
||||
@@ -111,6 +116,7 @@ namespace clashN.ViewModels
|
||||
autoUpdateSubInterval = _config.autoUpdateSubInterval;
|
||||
autoDelayTestInterval = _config.autoDelayTestInterval;
|
||||
SubConvertUrl = _config.constItem.subConvertUrl;
|
||||
currentFontFamily = _config.uiItem.currentFontFamily;
|
||||
AutoHideStartup = _config.autoHideStartup;
|
||||
|
||||
SetLoopbackCmd = ReactiveCommand.Create(() =>
|
||||
@@ -135,6 +141,7 @@ namespace clashN.ViewModels
|
||||
SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName);
|
||||
}
|
||||
CurrentLanguage = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
||||
CurrentFontSize = _config.uiItem.currentFontSize;
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.ColorModeDark,
|
||||
@@ -181,6 +188,37 @@ namespace clashN.ViewModels
|
||||
}
|
||||
});
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.CurrentFontSize,
|
||||
y => y > 0)
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (_config.uiItem.colorModeDark != ColorModeDark)
|
||||
{
|
||||
_config.uiItem.colorModeDark = ColorModeDark;
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.ModifyTheme(ColorModeDark);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
}
|
||||
});
|
||||
|
||||
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["StdFontSize1"] = size;
|
||||
Application.Current.Resources["StdFontSize2"] = size + 1;
|
||||
Application.Current.Resources["StdFontSize3"] = size + 2;
|
||||
Application.Current.Resources["StdFontSize4"] = size + 3;
|
||||
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
}
|
||||
});
|
||||
|
||||
//CMD
|
||||
SaveCommand = ReactiveCommand.Create(() =>
|
||||
{
|
||||
@@ -209,6 +247,7 @@ namespace clashN.ViewModels
|
||||
_config.autoUpdateSubInterval = autoUpdateSubInterval;
|
||||
_config.autoDelayTestInterval = autoDelayTestInterval;
|
||||
_config.constItem.subConvertUrl = SubConvertUrl;
|
||||
_config.uiItem.currentFontFamily = currentFontFamily;
|
||||
_config.autoHideStartup = AutoHideStartup;
|
||||
|
||||
//System proxy
|
||||
|
||||
@@ -75,7 +75,8 @@
|
||||
EnableRowVirtualization="True"
|
||||
GridLinesVisibility="All"
|
||||
HeadersVisibility="Column"
|
||||
IsReadOnly="True">
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource DefDataGrid}">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu Style="{StaticResource DefMenu}">
|
||||
<MenuItem x:Name="menuConnectionClose" Header="{x:Static resx:ResUI.menuConnectionClose}" />
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Views="clr-namespace:clashN.Views"
|
||||
xmlns:conv="clr-namespace:clashN.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@@ -14,8 +15,10 @@
|
||||
Height="500"
|
||||
x:TypeArguments="vms:ProfileEditViewModel"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||
KeyDown="GlobalHotkeySettingWindow_KeyDown"
|
||||
ResizeMode="NoResize"
|
||||
TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
TextOptions.TextRenderingMode="Auto"
|
||||
@@ -68,7 +71,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
@@ -85,7 +88,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="3"
|
||||
@@ -102,7 +105,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
@@ -118,7 +121,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
@@ -134,7 +137,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
||||
Style="{StaticResource MyOutlinedTextBox}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<TextBox
|
||||
Name="txtMsg"
|
||||
BorderThickness="0"
|
||||
FontSize="11"
|
||||
FontSize="{DynamicResource StdFontSize}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Style="{StaticResource MyOutlinedTextBox}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
@@ -94,7 +94,7 @@
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Style="{StaticResource MyOutlinedTextBox}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
@@ -113,7 +113,7 @@
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Style="{StaticResource MyOutlinedTextBox}"
|
||||
TextWrapping="Wrap" />
|
||||
<StackPanel
|
||||
Grid.Row="3"
|
||||
@@ -149,7 +149,7 @@
|
||||
Margin="4"
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
||||
Style="{StaticResource MyOutlinedTextBox}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
@@ -165,6 +165,7 @@
|
||||
Grid.Column="1"
|
||||
Margin="4"
|
||||
materialDesign:HintAssist.Hint="Core"
|
||||
FontSize="{DynamicResource StdFontSize2}"
|
||||
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
|
||||
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ListItemTitle}"
|
||||
Text="{x:Static resx:ResUI.TbPromotionInformation}"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
@@ -65,6 +66,7 @@
|
||||
materialDesign:ButtonProgressAssist.Value="-1"
|
||||
Click="btnPromotion_Click"
|
||||
Content="{x:Static resx:ResUI.TbPromotion}"
|
||||
FontSize="{DynamicResource StdFontSize2}"
|
||||
Style="{StaticResource MaterialDesignRaisedButton}" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
@@ -50,6 +50,17 @@
|
||||
Margin="8"
|
||||
materialDesign:HintAssist.Hint="Language"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
<Separator />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarItem}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsFontSize}" />
|
||||
<ComboBox
|
||||
x:Name="cmbCurrentFontSize"
|
||||
Width="100"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
@@ -98,7 +109,8 @@
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
@@ -112,7 +124,8 @@
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="3"
|
||||
@@ -126,7 +139,8 @@
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
@@ -140,7 +154,8 @@
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
@@ -182,7 +197,8 @@
|
||||
Grid.Row="7"
|
||||
Grid.Column="1"
|
||||
Margin="8"
|
||||
materialDesign:HintAssist.Hint="Level" />
|
||||
materialDesign:HintAssist.Hint="Level"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="8"
|
||||
@@ -223,10 +239,12 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
@@ -304,7 +322,8 @@
|
||||
Grid.Row="7"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="8"
|
||||
@@ -318,7 +337,8 @@
|
||||
Grid.Row="8"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
<TextBlock
|
||||
Grid.Row="9"
|
||||
Grid.Column="0"
|
||||
@@ -333,18 +353,41 @@
|
||||
Width="300"
|
||||
Margin="8"
|
||||
materialDesign:HintAssist.Hint="Convert Url"
|
||||
IsEditable="True" />
|
||||
IsEditable="True"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="10"
|
||||
Grid.Column="0"
|
||||
Margin="8"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ListItemTitle}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsFontFamily}" />
|
||||
<ComboBox
|
||||
x:Name="cmbcurrentFontFamily"
|
||||
Grid.Row="10"
|
||||
Grid.Column="1"
|
||||
Width="300"
|
||||
Margin="8"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
<TextBlock
|
||||
Grid.Row="10"
|
||||
Grid.Column="2"
|
||||
Margin="8"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ListItemTitle}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsFontFamilyTip}" />
|
||||
|
||||
<Button
|
||||
x:Name="btnSetLoopback"
|
||||
Grid.Row="10"
|
||||
Grid.Row="11"
|
||||
Grid.Column="0"
|
||||
Margin="8"
|
||||
Content="{x:Static resx:ResUI.TbSettingsSetUWP}"
|
||||
Style="{StaticResource DefButton}" />
|
||||
<Button
|
||||
x:Name="btnSetGlobalHotkey"
|
||||
Grid.Row="11"
|
||||
Grid.Row="12"
|
||||
Grid.Column="0"
|
||||
Margin="8"
|
||||
Content="{x:Static resx:ResUI.TbGlobalHotkeySetting}"
|
||||
@@ -392,6 +435,7 @@
|
||||
AcceptsReturn="True"
|
||||
BorderThickness="1"
|
||||
SpellCheck.IsEnabled="True"
|
||||
Style="{StaticResource DefTextBox}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
|
||||
@@ -405,7 +449,8 @@
|
||||
x:Name="cmbsystemProxyAdvancedProtocol"
|
||||
Grid.Row="4"
|
||||
Margin="8"
|
||||
materialDesign:HintAssist.Hint="Protocol" />
|
||||
materialDesign:HintAssist.Hint="Protocol"
|
||||
Style="{StaticResource DefComboBox}" />
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
Margin="8"
|
||||
@@ -416,7 +461,8 @@
|
||||
x:Name="txtPacPort"
|
||||
Grid.Row="5"
|
||||
Width="200"
|
||||
Margin="8" />
|
||||
Margin="8"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
using clashN.Handler;
|
||||
using clashN.Mode;
|
||||
using clashN.ViewModels;
|
||||
using ReactiveUI;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace clashN.Views
|
||||
{
|
||||
@@ -9,9 +14,12 @@ namespace clashN.Views
|
||||
/// </summary>
|
||||
public partial class SettingsView
|
||||
{
|
||||
private static Config _config;
|
||||
|
||||
public SettingsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
_config = LazyConfig.Instance.GetConfig();
|
||||
ViewModel = new SettingsViewModel();
|
||||
|
||||
Global.SubConvertUrls.ForEach(it =>
|
||||
@@ -31,6 +39,53 @@ namespace clashN.Views
|
||||
cmbLogLevel.Items.Add(it);
|
||||
});
|
||||
|
||||
for (int i = Global.MinFontSize; i <= Global.MinFontSize + 8; i++)
|
||||
{
|
||||
cmbCurrentFontSize.Items.Add(i.ToString());
|
||||
}
|
||||
|
||||
//fill fonts
|
||||
try
|
||||
{
|
||||
var dir = new DirectoryInfo(Utils.GetFontsPath());
|
||||
var files = dir.GetFiles("*.ttf");
|
||||
var culture = "zh-cn";
|
||||
var culture2 = "en-us";
|
||||
foreach (var it in files)
|
||||
{
|
||||
var families = Fonts.GetFontFamilies(Utils.GetFontsPath(it.Name));
|
||||
foreach (FontFamily family in families)
|
||||
{
|
||||
var typefaces = family.GetTypefaces();
|
||||
foreach (Typeface typeface in typefaces)
|
||||
{
|
||||
typeface.TryGetGlyphTypeface(out GlyphTypeface glyph);
|
||||
//var fontFace = glyph.Win32FaceNames[new CultureInfo("en-us")];
|
||||
//if (!fontFace.Equals("Regular") && !fontFace.Equals("Normal"))
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
var fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture)];
|
||||
if (Utils.IsNullOrEmpty(fontFamily))
|
||||
{
|
||||
fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture2)];
|
||||
if (Utils.IsNullOrEmpty(fontFamily))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
cmbcurrentFontFamily.Items.Add(fontFamily);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utils.SaveLog("fill fonts error", ex);
|
||||
}
|
||||
cmbcurrentFontFamily.Items.Add(string.Empty);
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.MixedPort, v => v.txtMixedPort.Text).DisposeWith(disposables);
|
||||
@@ -47,6 +102,7 @@ namespace clashN.Views
|
||||
this.Bind(ViewModel, vm => vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.ColorModeDark, v => v.togDarkMode.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);
|
||||
@@ -54,6 +110,7 @@ namespace clashN.Views
|
||||
this.Bind(ViewModel, vm => vm.autoUpdateSubInterval, v => v.txtautoUpdateSubInterval.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.autoDelayTestInterval, v => v.txtautoDelayTestInterval.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.currentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SetLoopbackCmd, v => v.btnSetLoopback).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.SetGlobalHotkeyCmd, v => v.btnSetGlobalHotkey).DisposeWith(disposables);
|
||||
|
||||
|
||||
@@ -58,10 +58,4 @@
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Resources\Fonts\SourceHanSansCN-Regular.ttf">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user