Add font size and font family select
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
ShutdownMode="OnExplicitShutdown"
|
ShutdownMode="OnExplicitShutdown"
|
||||||
StartupUri="Views/MainWindow.xaml">
|
StartupUri="Views/MainWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<materialDesign:BundledTheme
|
<materialDesign:BundledTheme
|
||||||
BaseTheme="Dark"
|
BaseTheme="Dark"
|
||||||
@@ -16,6 +16,10 @@
|
|||||||
SecondaryColor="Lime" />
|
SecondaryColor="Lime" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</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
|
<Style
|
||||||
x:Key="MyMaterialDesignNavigationRailTabItem"
|
x:Key="MyMaterialDesignNavigationRailTabItem"
|
||||||
BasedOn="{StaticResource MaterialDesignNavigationRailTabItem}"
|
BasedOn="{StaticResource MaterialDesignNavigationRailTabItem}"
|
||||||
@@ -26,37 +30,37 @@
|
|||||||
x:Key="ModuleTitle"
|
x:Key="ModuleTitle"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="16" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize4}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="TabItemTitle"
|
x:Key="TabItemTitle"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="14" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize4}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="ListItemTitle"
|
x:Key="ListItemTitle"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="13" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="ListItemSubTitle"
|
x:Key="ListItemSubTitle"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="12" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="ListItemSubTitle2"
|
x:Key="ListItemSubTitle2"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="11" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="ToolbarItem"
|
x:Key="ToolbarItem"
|
||||||
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
BasedOn="{StaticResource MaterialDesignTextBlock}"
|
||||||
TargetType="{x:Type TextBlock}">
|
TargetType="{x:Type TextBlock}">
|
||||||
<Setter Property="FontSize" Value="12" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style TargetType="{x:Type TextElement}">
|
<Style TargetType="{x:Type TextElement}">
|
||||||
<Setter Property="FontWeight" Value="Regular" />
|
<Setter Property="FontWeight" Value="Regular" />
|
||||||
@@ -82,29 +86,47 @@
|
|||||||
x:Key="ListItemCheckBox"
|
x:Key="ListItemCheckBox"
|
||||||
BasedOn="{StaticResource MaterialDesignUserForegroundCheckBox}"
|
BasedOn="{StaticResource MaterialDesignUserForegroundCheckBox}"
|
||||||
TargetType="{x:Type CheckBox}">
|
TargetType="{x:Type CheckBox}">
|
||||||
<Setter Property="FontSize" Value="12" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize2}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style x:Key="ListItemChip" TargetType="{x:Type materialDesign:Chip}">
|
<Style x:Key="ListItemChip" TargetType="{x:Type materialDesign:Chip}">
|
||||||
<Setter Property="FontSize" Value="11" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize1}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="DefButton"
|
x:Key="DefButton"
|
||||||
BasedOn="{StaticResource MaterialDesignRaisedButton}"
|
BasedOn="{StaticResource MaterialDesignRaisedButton}"
|
||||||
TargetType="{x:Type ButtonBase}">
|
TargetType="{x:Type ButtonBase}">
|
||||||
<Setter Property="FontSize" Value="14" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="DefMenu"
|
x:Key="DefMenu"
|
||||||
BasedOn="{StaticResource MaterialDesignContextMenu}"
|
BasedOn="{StaticResource MaterialDesignContextMenu}"
|
||||||
TargetType="{x:Type ContextMenu}">
|
TargetType="{x:Type ContextMenu}">
|
||||||
<Setter Property="FontSize" Value="13" />
|
<Setter Property="FontSize" Value="{DynamicResource StdFontSize3}" />
|
||||||
<Setter Property="FontFamily" Value="{x:Static conv:MaterialDesignFonts.MyFont}" />
|
<Setter Property="FontFamily" Value="{x:Static conv:MaterialDesignFonts.MyFont}" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style
|
<Style
|
||||||
x:Key="DefComboBox"
|
x:Key="DefComboBox"
|
||||||
BasedOn="{StaticResource MaterialDesignComboBox}"
|
BasedOn="{StaticResource MaterialDesignComboBox}"
|
||||||
TargetType="{x:Type ComboBox}">
|
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>
|
</Style>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using clashN.Tool;
|
using clashN.Handler;
|
||||||
|
using clashN.Mode;
|
||||||
|
using clashN.Tool;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
@@ -10,7 +12,7 @@ namespace clashN
|
|||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public static EventWaitHandle ProgramStarted;
|
public static EventWaitHandle ProgramStarted;
|
||||||
|
private static Config _config;
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
// Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
|
// Locator.CurrentMutable.RegisterViewsForViewModels(Assembly.GetCallingAssembly());
|
||||||
@@ -46,12 +48,24 @@ namespace clashN
|
|||||||
Utils.SaveLog($"clashN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
Utils.SaveLog($"clashN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
||||||
Logging.ClearLogs();
|
Logging.ClearLogs();
|
||||||
|
|
||||||
|
Init();
|
||||||
|
|
||||||
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
string lang = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
||||||
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);
|
||||||
|
|
||||||
base.OnStartup(e);
|
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)
|
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||||
{
|
{
|
||||||
Utils.SaveLog("App_DispatcherUnhandledException", e.Exception);
|
Utils.SaveLog("App_DispatcherUnhandledException", e.Exception);
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using clashN.Handler;
|
||||||
using System.IO;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace clashN.Converters
|
namespace clashN.Converters
|
||||||
@@ -10,8 +9,22 @@ namespace clashN.Converters
|
|||||||
|
|
||||||
static MaterialDesignFonts()
|
static MaterialDesignFonts()
|
||||||
{
|
{
|
||||||
var fontPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Fonts\");
|
try
|
||||||
MyFont = new FontFamily(new Uri($"file:///{fontPath}"), "./#Source Han Sans CN");
|
{
|
||||||
|
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
|
/// Icon
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string CustomIconName = "clashN.ico";
|
public const string CustomIconName = "clashN.ico";
|
||||||
|
public const int MinFontSize = 10;
|
||||||
|
|
||||||
|
|
||||||
public const string StatisticLogOverall = "StatisticLogOverall.json";
|
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> 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" };
|
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 bool colorModeDark { get; set; }
|
||||||
public string? colorPrimaryName { 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>
|
/// <summary>
|
||||||
/// 查找类似 Http Port 的本地化字符串。
|
/// 查找类似 Http Port 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -664,4 +664,13 @@
|
|||||||
<data name="TbSortingType" xml:space="preserve">
|
<data name="TbSortingType" xml:space="preserve">
|
||||||
<value>Type</value>
|
<value>Type</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
@@ -667,4 +667,13 @@
|
|||||||
<data name="TbSortingType" xml:space="preserve">
|
<data name="TbSortingType" xml:space="preserve">
|
||||||
<value>类型</value>
|
<value>类型</value>
|
||||||
</data>
|
</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>
|
</root>
|
||||||
@@ -1112,6 +1112,22 @@ namespace clashN
|
|||||||
}
|
}
|
||||||
return Path.Combine(_tempPath, filename);
|
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
|
#endregion
|
||||||
|
|
||||||
#region Log
|
#region Log
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ namespace clashN.ViewModels
|
|||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
_config = LazyConfig.Instance.GetConfig();
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
|
|
||||||
|
AutoRefreshInterval = 10;
|
||||||
|
SortingSelected = _config.uiItem.connectionsSorting;
|
||||||
|
AutoRefresh = _config.uiItem.connectionsAutoRefresh;
|
||||||
|
|
||||||
var canEditRemove = this.WhenAnyValue(
|
var canEditRemove = this.WhenAnyValue(
|
||||||
x => x.SelectedSource,
|
x => x.SelectedSource,
|
||||||
selectedSource => selectedSource != null && !selectedSource.id.IsNullOrEmpty());
|
selectedSource => selectedSource != null && !selectedSource.id.IsNullOrEmpty());
|
||||||
@@ -46,6 +50,11 @@ namespace clashN.ViewModels
|
|||||||
y => y != null && y >= 0)
|
y => y != null && y >= 0)
|
||||||
.Subscribe(c => DoSortingSelected(c));
|
.Subscribe(c => DoSortingSelected(c));
|
||||||
|
|
||||||
|
this.WhenAnyValue(
|
||||||
|
x => x.AutoRefresh,
|
||||||
|
y => y == true)
|
||||||
|
.Subscribe(c => { _config.uiItem.connectionsAutoRefresh = AutoRefresh; });
|
||||||
|
|
||||||
ConnectionCloseCmd = ReactiveCommand.Create(() =>
|
ConnectionCloseCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
ClashConnectionClose(false);
|
ClashConnectionClose(false);
|
||||||
@@ -56,10 +65,6 @@ namespace clashN.ViewModels
|
|||||||
ClashConnectionClose(true);
|
ClashConnectionClose(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
AutoRefreshInterval = 10;
|
|
||||||
SortingSelected = 4;
|
|
||||||
AutoRefresh = true;
|
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +74,10 @@ namespace clashN.ViewModels
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (SortingSelected != _config.uiItem.connectionsSorting)
|
||||||
|
{
|
||||||
|
_config.uiItem.connectionsSorting = SortingSelected;
|
||||||
|
}
|
||||||
|
|
||||||
GetClashConnections();
|
GetClashConnections();
|
||||||
}
|
}
|
||||||
@@ -128,7 +137,7 @@ namespace clashN.ViewModels
|
|||||||
model.id = item.id;
|
model.id = item.id;
|
||||||
model.network = item.metadata.network;
|
model.network = item.metadata.network;
|
||||||
model.type = item.metadata.type;
|
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);
|
var sp = (dtNow - item.start);
|
||||||
model.time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
|
model.time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
|
||||||
model.upload = item.upload;
|
model.upload = item.upload;
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ namespace clashN.ViewModels
|
|||||||
|
|
||||||
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
|
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue)
|
||||||
{
|
{
|
||||||
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
|
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(snackbarMessageQueue), typeof(NoticeHandler));
|
Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(snackbarMessageQueue), typeof(NoticeHandler));
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
|
||||||
@@ -264,12 +266,8 @@ namespace clashN.ViewModels
|
|||||||
|
|
||||||
private void Init()
|
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.BackupGuiNConfig(_config, true);
|
||||||
MainFormHandler.Instance.InitRegister(_config);
|
MainFormHandler.Instance.InitRegister(_config);
|
||||||
|
|
||||||
@@ -293,7 +291,7 @@ namespace clashN.ViewModels
|
|||||||
{
|
{
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(msg);
|
_noticeHandler?.Enqueue(msg);
|
||||||
_noticeHandler?.SendMessage(msg);
|
_noticeHandler?.SendMessage(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace clashN.ViewModels
|
|||||||
public bool AutoRefresh { get; set; }
|
public bool AutoRefresh { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool EnableTun { get; set; }
|
public bool EnableTun { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public ProxiesViewModel()
|
public ProxiesViewModel()
|
||||||
{
|
{
|
||||||
@@ -58,14 +58,15 @@ namespace clashN.ViewModels
|
|||||||
|
|
||||||
SelectedGroup = new();
|
SelectedGroup = new();
|
||||||
SelectedDetail = new();
|
SelectedDetail = new();
|
||||||
AutoRefresh = true;
|
AutoRefresh = _config.uiItem.proxiesAutoRefresh;
|
||||||
EnableTun = _config.enableTun;
|
EnableTun = _config.enableTun;
|
||||||
|
SortingSelected = _config.uiItem.proxiesSorting;
|
||||||
|
|
||||||
//GetClashProxies(true);
|
//GetClashProxies(true);
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedGroup,
|
x => x.SelectedGroup,
|
||||||
y => y != null && !y.name.IsNullOrEmpty())
|
y => y != null && !y.name.IsNullOrEmpty())
|
||||||
.Subscribe(c => RefreshProxyDetails(c));
|
.Subscribe(c => RefreshProxyDetails(c));
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SystemProxySelected,
|
x => x.SystemProxySelected,
|
||||||
@@ -87,6 +88,11 @@ namespace clashN.ViewModels
|
|||||||
y => y == true)
|
y => y == true)
|
||||||
.Subscribe(c => DoEnableTun(c));
|
.Subscribe(c => DoEnableTun(c));
|
||||||
|
|
||||||
|
this.WhenAnyValue(
|
||||||
|
x => x.AutoRefresh,
|
||||||
|
y => y == true)
|
||||||
|
.Subscribe(c => { _config.uiItem.proxiesAutoRefresh = AutoRefresh; });
|
||||||
|
|
||||||
ProxiesReloadCmd = ReactiveCommand.Create(() =>
|
ProxiesReloadCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
ProxiesReload();
|
ProxiesReload();
|
||||||
@@ -142,6 +148,10 @@ namespace clashN.ViewModels
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (SortingSelected != _config.uiItem.proxiesSorting)
|
||||||
|
{
|
||||||
|
_config.uiItem.proxiesSorting = SortingSelected;
|
||||||
|
}
|
||||||
|
|
||||||
RefreshProxyDetails(c);
|
RefreshProxyDetails(c);
|
||||||
}
|
}
|
||||||
@@ -187,9 +197,9 @@ namespace clashN.ViewModels
|
|||||||
{
|
{
|
||||||
if (_config.enableTun != EnableTun)
|
if (_config.enableTun != EnableTun)
|
||||||
{
|
{
|
||||||
_config.enableTun = EnableTun;
|
_config.enableTun = EnableTun;
|
||||||
TunModeSwitch();
|
TunModeSwitch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TunModeSwitch()
|
void TunModeSwitch()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using ReactiveUI.Validation.Helpers;
|
|||||||
using Splat;
|
using Splat;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace clashN.ViewModels
|
namespace clashN.ViewModels
|
||||||
{
|
{
|
||||||
@@ -55,6 +56,8 @@ namespace clashN.ViewModels
|
|||||||
[Reactive]
|
[Reactive]
|
||||||
public string SubConvertUrl { get; set; }
|
public string SubConvertUrl { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
|
public string currentFontFamily { get; set; }
|
||||||
|
[Reactive]
|
||||||
public bool AutoHideStartup { get; set; }
|
public bool AutoHideStartup { get; set; }
|
||||||
public ReactiveCommand<Unit, Unit> SetLoopbackCmd { get; }
|
public ReactiveCommand<Unit, Unit> SetLoopbackCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> SetGlobalHotkeyCmd { get; }
|
public ReactiveCommand<Unit, Unit> SetGlobalHotkeyCmd { get; }
|
||||||
@@ -81,6 +84,8 @@ namespace clashN.ViewModels
|
|||||||
public bool ColorModeDark { get; set; }
|
public bool ColorModeDark { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string CurrentLanguage { get; set; }
|
public string CurrentLanguage { get; set; }
|
||||||
|
[Reactive]
|
||||||
|
public int CurrentFontSize { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
|
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
|
||||||
@@ -111,6 +116,7 @@ namespace clashN.ViewModels
|
|||||||
autoUpdateSubInterval = _config.autoUpdateSubInterval;
|
autoUpdateSubInterval = _config.autoUpdateSubInterval;
|
||||||
autoDelayTestInterval = _config.autoDelayTestInterval;
|
autoDelayTestInterval = _config.autoDelayTestInterval;
|
||||||
SubConvertUrl = _config.constItem.subConvertUrl;
|
SubConvertUrl = _config.constItem.subConvertUrl;
|
||||||
|
currentFontFamily = _config.uiItem.currentFontFamily;
|
||||||
AutoHideStartup = _config.autoHideStartup;
|
AutoHideStartup = _config.autoHideStartup;
|
||||||
|
|
||||||
SetLoopbackCmd = ReactiveCommand.Create(() =>
|
SetLoopbackCmd = ReactiveCommand.Create(() =>
|
||||||
@@ -135,6 +141,7 @@ namespace clashN.ViewModels
|
|||||||
SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName);
|
SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName);
|
||||||
}
|
}
|
||||||
CurrentLanguage = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
CurrentLanguage = Utils.RegReadValue(Global.MyRegPath, Global.MyRegKeyLanguage, Global.Languages[0]);
|
||||||
|
CurrentFontSize = _config.uiItem.currentFontSize;
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.ColorModeDark,
|
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
|
//CMD
|
||||||
SaveCommand = ReactiveCommand.Create(() =>
|
SaveCommand = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
@@ -209,6 +247,7 @@ namespace clashN.ViewModels
|
|||||||
_config.autoUpdateSubInterval = autoUpdateSubInterval;
|
_config.autoUpdateSubInterval = autoUpdateSubInterval;
|
||||||
_config.autoDelayTestInterval = autoDelayTestInterval;
|
_config.autoDelayTestInterval = autoDelayTestInterval;
|
||||||
_config.constItem.subConvertUrl = SubConvertUrl;
|
_config.constItem.subConvertUrl = SubConvertUrl;
|
||||||
|
_config.uiItem.currentFontFamily = currentFontFamily;
|
||||||
_config.autoHideStartup = AutoHideStartup;
|
_config.autoHideStartup = AutoHideStartup;
|
||||||
|
|
||||||
//System proxy
|
//System proxy
|
||||||
|
|||||||
@@ -75,7 +75,8 @@
|
|||||||
EnableRowVirtualization="True"
|
EnableRowVirtualization="True"
|
||||||
GridLinesVisibility="All"
|
GridLinesVisibility="All"
|
||||||
HeadersVisibility="Column"
|
HeadersVisibility="Column"
|
||||||
IsReadOnly="True">
|
IsReadOnly="True"
|
||||||
|
Style="{StaticResource DefDataGrid}">
|
||||||
<DataGrid.ContextMenu>
|
<DataGrid.ContextMenu>
|
||||||
<ContextMenu Style="{StaticResource DefMenu}">
|
<ContextMenu Style="{StaticResource DefMenu}">
|
||||||
<MenuItem x:Name="menuConnectionClose" Header="{x:Static resx:ResUI.menuConnectionClose}" />
|
<MenuItem x:Name="menuConnectionClose" Header="{x:Static resx:ResUI.menuConnectionClose}" />
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:Views="clr-namespace:clashN.Views"
|
xmlns:Views="clr-namespace:clashN.Views"
|
||||||
|
xmlns:conv="clr-namespace:clashN.Converters"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
@@ -14,8 +15,10 @@
|
|||||||
Height="500"
|
Height="500"
|
||||||
x:TypeArguments="vms:ProfileEditViewModel"
|
x:TypeArguments="vms:ProfileEditViewModel"
|
||||||
Background="{DynamicResource MaterialDesignPaper}"
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
|
FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||||
KeyDown="GlobalHotkeySettingWindow_KeyDown"
|
KeyDown="GlobalHotkeySettingWindow_KeyDown"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
|
TextElement.FontFamily="{x:Static conv:MaterialDesignFonts.MyFont}"
|
||||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
TextOptions.TextFormattingMode="Display"
|
TextOptions.TextFormattingMode="Display"
|
||||||
TextOptions.TextRenderingMode="Auto"
|
TextOptions.TextRenderingMode="Auto"
|
||||||
@@ -68,7 +71,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
Style="{StaticResource MyOutlinedTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
@@ -85,7 +88,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
Style="{StaticResource MyOutlinedTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
@@ -102,7 +105,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
Style="{StaticResource MyOutlinedTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
@@ -118,7 +121,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
Style="{StaticResource MyOutlinedTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
@@ -134,7 +137,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}" />
|
Style="{StaticResource MyOutlinedTextBox}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
Name="txtMsg"
|
Name="txtMsg"
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
FontSize="11"
|
FontSize="{DynamicResource StdFontSize}"
|
||||||
HorizontalScrollBarVisibility="Auto"
|
HorizontalScrollBarVisibility="Auto"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
Margin="4"
|
Margin="4"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MyOutlinedTextBox}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
Margin="4"
|
Margin="4"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MyOutlinedTextBox}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
@@ -113,7 +113,7 @@
|
|||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MyOutlinedTextBox}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
<StackPanel
|
<StackPanel
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
Margin="4"
|
Margin="4"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
Style="{StaticResource MaterialDesignOutlinedTextBox}"
|
Style="{StaticResource MyOutlinedTextBox}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
@@ -165,6 +165,7 @@
|
|||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="4"
|
Margin="4"
|
||||||
materialDesign:HintAssist.Hint="Core"
|
materialDesign:HintAssist.Hint="Core"
|
||||||
|
FontSize="{DynamicResource StdFontSize2}"
|
||||||
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
|
Style="{StaticResource MaterialDesignOutlinedComboBox}" />
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
Style="{StaticResource ListItemTitle}"
|
||||||
Text="{x:Static resx:ResUI.TbPromotionInformation}"
|
Text="{x:Static resx:ResUI.TbPromotionInformation}"
|
||||||
TextWrapping="Wrap" />
|
TextWrapping="Wrap" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@@ -65,6 +66,7 @@
|
|||||||
materialDesign:ButtonProgressAssist.Value="-1"
|
materialDesign:ButtonProgressAssist.Value="-1"
|
||||||
Click="btnPromotion_Click"
|
Click="btnPromotion_Click"
|
||||||
Content="{x:Static resx:ResUI.TbPromotion}"
|
Content="{x:Static resx:ResUI.TbPromotion}"
|
||||||
|
FontSize="{DynamicResource StdFontSize2}"
|
||||||
Style="{StaticResource MaterialDesignRaisedButton}" />
|
Style="{StaticResource MaterialDesignRaisedButton}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -50,6 +50,17 @@
|
|||||||
Margin="8"
|
Margin="8"
|
||||||
materialDesign:HintAssist.Hint="Language"
|
materialDesign:HintAssist.Hint="Language"
|
||||||
Style="{StaticResource DefComboBox}" />
|
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>
|
</ToolBar>
|
||||||
</ToolBarTray>
|
</ToolBarTray>
|
||||||
@@ -98,7 +109,8 @@
|
|||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
@@ -112,7 +124,8 @@
|
|||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
@@ -126,7 +139,8 @@
|
|||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
@@ -140,7 +154,8 @@
|
|||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
@@ -182,7 +197,8 @@
|
|||||||
Grid.Row="7"
|
Grid.Row="7"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
materialDesign:HintAssist.Hint="Level" />
|
materialDesign:HintAssist.Hint="Level"
|
||||||
|
Style="{StaticResource DefComboBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
@@ -223,10 +239,12 @@
|
|||||||
<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" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
@@ -304,7 +322,8 @@
|
|||||||
Grid.Row="7"
|
Grid.Row="7"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="300"
|
Width="300"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
@@ -318,7 +337,8 @@
|
|||||||
Grid.Row="8"
|
Grid.Row="8"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Width="300"
|
Width="300"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="9"
|
Grid.Row="9"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
@@ -333,18 +353,41 @@
|
|||||||
Width="300"
|
Width="300"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
materialDesign:HintAssist.Hint="Convert Url"
|
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
|
<Button
|
||||||
x:Name="btnSetLoopback"
|
x:Name="btnSetLoopback"
|
||||||
Grid.Row="10"
|
Grid.Row="11"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
Content="{x:Static resx:ResUI.TbSettingsSetUWP}"
|
Content="{x:Static resx:ResUI.TbSettingsSetUWP}"
|
||||||
Style="{StaticResource DefButton}" />
|
Style="{StaticResource DefButton}" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="btnSetGlobalHotkey"
|
x:Name="btnSetGlobalHotkey"
|
||||||
Grid.Row="11"
|
Grid.Row="12"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
Content="{x:Static resx:ResUI.TbGlobalHotkeySetting}"
|
Content="{x:Static resx:ResUI.TbGlobalHotkeySetting}"
|
||||||
@@ -392,6 +435,7 @@
|
|||||||
AcceptsReturn="True"
|
AcceptsReturn="True"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
SpellCheck.IsEnabled="True"
|
SpellCheck.IsEnabled="True"
|
||||||
|
Style="{StaticResource DefTextBox}"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
VerticalScrollBarVisibility="Auto" />
|
VerticalScrollBarVisibility="Auto" />
|
||||||
|
|
||||||
@@ -405,7 +449,8 @@
|
|||||||
x:Name="cmbsystemProxyAdvancedProtocol"
|
x:Name="cmbsystemProxyAdvancedProtocol"
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
materialDesign:HintAssist.Hint="Protocol" />
|
materialDesign:HintAssist.Hint="Protocol"
|
||||||
|
Style="{StaticResource DefComboBox}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
Margin="8"
|
Margin="8"
|
||||||
@@ -416,7 +461,8 @@
|
|||||||
x:Name="txtPacPort"
|
x:Name="txtPacPort"
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
Width="200"
|
Width="200"
|
||||||
Margin="8" />
|
Margin="8"
|
||||||
|
Style="{StaticResource DefTextBox}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
using clashN.Handler;
|
||||||
|
using clashN.Mode;
|
||||||
using clashN.ViewModels;
|
using clashN.ViewModels;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace clashN.Views
|
namespace clashN.Views
|
||||||
{
|
{
|
||||||
@@ -9,9 +14,12 @@ namespace clashN.Views
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class SettingsView
|
public partial class SettingsView
|
||||||
{
|
{
|
||||||
|
private static Config _config;
|
||||||
|
|
||||||
public SettingsView()
|
public SettingsView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_config = LazyConfig.Instance.GetConfig();
|
||||||
ViewModel = new SettingsViewModel();
|
ViewModel = new SettingsViewModel();
|
||||||
|
|
||||||
Global.SubConvertUrls.ForEach(it =>
|
Global.SubConvertUrls.ForEach(it =>
|
||||||
@@ -31,6 +39,53 @@ namespace clashN.Views
|
|||||||
cmbLogLevel.Items.Add(it);
|
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.WhenActivated(disposables =>
|
||||||
{
|
{
|
||||||
this.Bind(ViewModel, vm => vm.MixedPort, v => v.txtMixedPort.Text).DisposeWith(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.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.ColorModeDark, v => v.togDarkMode.IsChecked).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.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.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.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);
|
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.autoUpdateSubInterval, v => v.txtautoUpdateSubInterval.Text).DisposeWith(disposables);
|
||||||
this.Bind(ViewModel, vm => vm.autoDelayTestInterval, v => v.txtautoDelayTestInterval.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.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.SetLoopbackCmd, v => v.btnSetLoopback).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.SetGlobalHotkeyCmd, v => v.btnSetGlobalHotkey).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SetGlobalHotkeyCmd, v => v.btnSetGlobalHotkey).DisposeWith(disposables);
|
||||||
|
|
||||||
|
|||||||
@@ -58,10 +58,4 @@
|
|||||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="Resources\Fonts\SourceHanSansCN-Regular.ttf">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user