mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 21:02:08 +08:00
1.1.3 -> 1.1.4 第26次更新
This commit is contained in:
parent
007fea343c
commit
e37ef64aca
@ -1,12 +1,17 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using Sheas_Cealer.Preses;
|
||||
using Sheas_Cealer.Wins;
|
||||
|
||||
namespace Sheas_Cealer;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e) => new MainWin(e.Args).Show();
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
_ = new SettingsPres();
|
||||
new MainWin(e.Args).Show();
|
||||
}
|
||||
|
||||
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
|
51
Consts/SettingsMultilangConst.Designer.cs
generated
51
Consts/SettingsMultilangConst.Designer.cs
generated
@ -61,7 +61,52 @@ namespace Sheas_Cealer.Consts {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Auto Theme 的本地化字符串。
|
||||
/// 查找类似 Change successfuly, restart to refresh the windows 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string _ChangeLangSuccessMsg {
|
||||
get {
|
||||
return ResourceManager.GetString("_ChangeLangSuccessMsg", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Switch Lang (中文 → En) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string LangsButtonChineseLangContent {
|
||||
get {
|
||||
return ResourceManager.GetString("LangsButtonChineseLangContent", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Switch Lang (En → Auto) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string LangsButtonEnglishLangContent {
|
||||
get {
|
||||
return ResourceManager.GetString("LangsButtonEnglishLangContent", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Switch Lang (Auto → 中文) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string LangsButtonInheritLangContent {
|
||||
get {
|
||||
return ResourceManager.GetString("LangsButtonInheritLangContent", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 点击切换界面语言 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string LangsButtonToolTip {
|
||||
get {
|
||||
return ResourceManager.GetString("LangsButtonToolTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Switch Theme (Dark → Light) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string ThemesButtonDarkThemeContent {
|
||||
get {
|
||||
@ -70,7 +115,7 @@ namespace Sheas_Cealer.Consts {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Dark Theme 的本地化字符串。
|
||||
/// 查找类似 Switch Theme (Auto → Dark) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string ThemesButtonInheritThemeContent {
|
||||
get {
|
||||
@ -79,7 +124,7 @@ namespace Sheas_Cealer.Consts {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Light Theme 的本地化字符串。
|
||||
/// 查找类似 Switch Theme (Light → Auto) 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string ThemesButtonLightThemeContent {
|
||||
get {
|
||||
|
@ -97,16 +97,31 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="LangsButtonChineseLangContent" xml:space="preserve">
|
||||
<value>Switch Lang (中文 → En)</value>
|
||||
</data>
|
||||
<data name="LangsButtonEnglishLangContent" xml:space="preserve">
|
||||
<value>Switch Lang (En → Auto)</value>
|
||||
</data>
|
||||
<data name="LangsButtonInheritLangContent" xml:space="preserve">
|
||||
<value>Switch Lang (Auto → 中文)</value>
|
||||
</data>
|
||||
<data name="LangsButtonToolTip" xml:space="preserve">
|
||||
<value>点击切换界面语言</value>
|
||||
</data>
|
||||
<data name="ThemesButtonDarkThemeContent" xml:space="preserve">
|
||||
<value>Auto Theme</value>
|
||||
<value>Switch Theme (Dark → Light)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonInheritThemeContent" xml:space="preserve">
|
||||
<value>Dark Theme</value>
|
||||
<value>Switch Theme (Auto → Dark)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonLightThemeContent" xml:space="preserve">
|
||||
<value>Light Theme</value>
|
||||
<value>Switch Theme (Light → Auto)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonToolTip" xml:space="preserve">
|
||||
<value>Click to switch themes</value>
|
||||
</data>
|
||||
<data name="_ChangeLangSuccessMsg" xml:space="preserve">
|
||||
<value>Change successfuly, restart to refresh the windows</value>
|
||||
</data>
|
||||
</root>
|
@ -97,16 +97,31 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="LangsButtonChineseLangContent" xml:space="preserve">
|
||||
<value>切换语言 (中文 → En)</value>
|
||||
</data>
|
||||
<data name="LangsButtonEnglishLangContent" xml:space="preserve">
|
||||
<value>切换语言 (En → 系统)</value>
|
||||
</data>
|
||||
<data name="LangsButtonInheritLangContent" xml:space="preserve">
|
||||
<value>切换语言 (系统 → 中文)</value>
|
||||
</data>
|
||||
<data name="LangsButtonToolTip" xml:space="preserve">
|
||||
<value>Click to switch langs</value>
|
||||
</data>
|
||||
<data name="ThemesButtonDarkThemeContent" xml:space="preserve">
|
||||
<value>亮色模式</value>
|
||||
<value>切换主题 (暗色 → 亮色)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonInheritThemeContent" xml:space="preserve">
|
||||
<value>暗色模式</value>
|
||||
<value>切换主题 (系统 → 暗色)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonLightThemeContent" xml:space="preserve">
|
||||
<value>跟随系统</value>
|
||||
<value>切换主题 (亮色 → 系统)</value>
|
||||
</data>
|
||||
<data name="ThemesButtonToolTip" xml:space="preserve">
|
||||
<value>点击切换显示主题</value>
|
||||
</data>
|
||||
<data name="_ChangeLangSuccessMsg" xml:space="preserve">
|
||||
<value>语言更改完成,重启以刷新界面</value>
|
||||
</data>
|
||||
</root>
|
20
Convs/SettingsLangsButtonContentConv.cs
Normal file
20
Convs/SettingsLangsButtonContentConv.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Sheas_Cealer.Consts;
|
||||
|
||||
namespace Sheas_Cealer.Convs;
|
||||
|
||||
internal class SettingsLangsButtonContentConv : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
bool? isEnglishLang = value as bool?;
|
||||
|
||||
return isEnglishLang.HasValue ?
|
||||
isEnglishLang.GetValueOrDefault() ? SettingsConst.LangsButtonEnglishLangContent : SettingsConst.LangsButtonChineseLangContent :
|
||||
SettingsConst.LangsButtonInheritLangContent;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
||||
}
|
@ -27,13 +27,13 @@ internal partial class GlobalPres : ObservableObject
|
||||
PaletteHelper paletteHelper = new();
|
||||
Theme newTheme = paletteHelper.GetTheme();
|
||||
|
||||
newTheme.SetBaseTheme(value.HasValue ? value.GetValueOrDefault() ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
||||
newTheme.SetBaseTheme(value.HasValue ? value.Value ? BaseTheme.Light : BaseTheme.Dark : BaseTheme.Inherit);
|
||||
paletteHelper.SetTheme(newTheme);
|
||||
|
||||
foreach (Window currentWindow in Application.Current.Windows)
|
||||
BorderThemeSetter.SetBorderTheme(currentWindow, value);
|
||||
|
||||
Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.GetValueOrDefault() ? 1 : 0 : -1);
|
||||
Settings.Default.IsLightTheme = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
Settings.Default.Save();
|
||||
}
|
||||
}
|
@ -1,3 +1,38 @@
|
||||
namespace Sheas_Cealer.Preses;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Sheas_Cealer.Props;
|
||||
|
||||
internal partial class SettingsPres : GlobalPres;
|
||||
namespace Sheas_Cealer.Preses;
|
||||
|
||||
internal partial class SettingsPres : GlobalPres
|
||||
{
|
||||
internal SettingsPres()
|
||||
{
|
||||
IsEnglishLang = Settings.Default.IsEnglishLang switch
|
||||
{
|
||||
-1 => null,
|
||||
0 => false,
|
||||
1 => true,
|
||||
_ => throw new UnreachableException()
|
||||
};
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private static bool? isEnglishLang = null;
|
||||
partial void OnIsEnglishLangChanged(bool? value)
|
||||
{
|
||||
CultureInfo newCulture = value.HasValue ? new(value.Value ? "en" : "zh") : CultureInfo.InstalledUICulture;
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = newCulture;
|
||||
|
||||
foreach (Window currentWindow in Application.Current.Windows)
|
||||
currentWindow.Language = XmlLanguage.GetLanguage(newCulture.IetfLanguageTag);
|
||||
|
||||
Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
|
||||
Settings.Default.Save();
|
||||
}
|
||||
}
|
12
Props/Settings.Designer.cs
generated
12
Props/Settings.Designer.cs
generated
@ -70,5 +70,17 @@ namespace Sheas_Cealer.Props {
|
||||
this["IsLightTheme"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("-1")]
|
||||
public sbyte IsEnglishLang {
|
||||
get {
|
||||
return ((sbyte)(this["IsEnglishLang"]));
|
||||
}
|
||||
set {
|
||||
this["IsEnglishLang"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,8 @@
|
||||
<Setting Name="IsLightTheme" Type="System.SByte" Scope="User">
|
||||
<Value Profile="(Default)">-1</Value>
|
||||
</Setting>
|
||||
<Setting Name="IsEnglishLang" Type="System.SByte" Scope="User">
|
||||
<Value Profile="(Default)">-1</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
@ -16,9 +16,6 @@ internal static partial class BorderThemeSetter
|
||||
|
||||
internal static void SetBorderTheme(Window window, bool? isLightTheme)
|
||||
{
|
||||
if (!window.IsLoaded)
|
||||
return;
|
||||
|
||||
nint isDarkTheme;
|
||||
nint desktopHwnd = nint.Zero;
|
||||
nint windowHwnd = new WindowInteropHelper(window).EnsureHandle();
|
||||
|
@ -535,7 +535,6 @@ public partial class MainWin : Window
|
||||
int nullSniNum = 0;
|
||||
|
||||
foreach (KeyValuePair<string, List<(List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp)>> cealHostRulesPair in CealHostRulesDict)
|
||||
{
|
||||
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRulesPair.Value ?? [])
|
||||
{
|
||||
string cealHostSniWithoutNull = cealHostSni ?? $"{cealHostRulesPair.Key}{(cealHostRulesPair.Value ?? []).Count + ++nullSniNum}";
|
||||
@ -553,7 +552,6 @@ public partial class MainWin : Window
|
||||
if (isValidCealHostDomainExist)
|
||||
hostResolverRules += $"MAP {cealHostSniWithoutNull} {cealHostIp},";
|
||||
}
|
||||
}
|
||||
|
||||
CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors";
|
||||
|
||||
|
@ -12,10 +12,11 @@
|
||||
KeyDown="SettingsWin_KeyDown">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="0" Margin="5" d:Content="# # # #" ToolTip="{Binding Source={x:Static consts:SettingsConst.ThemesButtonToolTip}}"
|
||||
@ -28,5 +29,16 @@
|
||||
</Binding>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button Grid.Column="1" Margin="5" d:Content="# # # #" ToolTip="{Binding Source={x:Static consts:SettingsConst.LangsButtonToolTip}}"
|
||||
Click="LangsButton_Click">
|
||||
<Button.Content>
|
||||
<Binding Path="IsEnglishLang">
|
||||
<Binding.Converter>
|
||||
<convs:SettingsLangsButtonContentConv />
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Sheas_Cealer.Consts;
|
||||
using Sheas_Cealer.Preses;
|
||||
using Sheas_Cealer.Utils;
|
||||
|
||||
@ -23,6 +24,12 @@ public partial class SettingsWin : Window
|
||||
}
|
||||
|
||||
private void ThemesButton_Click(object sender, RoutedEventArgs e) => SettingsPres!.IsLightTheme = SettingsPres.IsLightTheme.HasValue ? SettingsPres.IsLightTheme.Value ? null : true : false;
|
||||
private void LangsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SettingsPres!.IsEnglishLang = SettingsPres.IsEnglishLang.HasValue ? SettingsPres.IsEnglishLang.Value ? null : true : false;
|
||||
|
||||
MessageBox.Show(SettingsConst._ChangeLangSuccessMsg);
|
||||
}
|
||||
|
||||
private void SettingsWin_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user