1.1.3 -> 1.1.4 第30次更新

This commit is contained in:
Space Time 2024-12-07 12:16:10 +08:00
parent be23d1bce8
commit c8bffaa96c
11 changed files with 170 additions and 3 deletions

33
App.config Normal file
View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Sheas_Cealer.Props.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<Sheas_Cealer.Props.Settings>
<setting name="BrowserPath" serializeAs="String">
<value />
</setting>
<setting name="UpstreamUrl" serializeAs="String">
<value />
</setting>
<setting name="ExtraArgs" serializeAs="String">
<value />
</setting>
<setting name="IsLightTheme" serializeAs="String">
<value>-1</value>
</setting>
<setting name="IsEnglishLang" serializeAs="String">
<value>-1</value>
</setting>
<setting name="PrimaryColor" serializeAs="String">
<value>Red</value>
</setting>
<setting name="IsLightWeight" serializeAs="String">
<value>-1</value>
</setting>
</Sheas_Cealer.Props.Settings>
</userSettings>
</configuration>

View File

@ -70,7 +70,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Switch Color (Fully random) 的本地化字符串。
/// 查找类似 Switch Color (Fully Random) 的本地化字符串。
/// </summary>
public static string ColorsButtonContent {
get {
@ -158,5 +158,41 @@ namespace Sheas_Cealer.Consts {
return ResourceManager.GetString("ThemesButtonToolTip", resourceCulture);
}
}
/// <summary>
/// 查找类似 Switch Weight (Bold → Light) 的本地化字符串。
/// </summary>
public static string WeightsButtonBoldWeightContent {
get {
return ResourceManager.GetString("WeightsButtonBoldWeightContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Switch Weight (Light → Regular) 的本地化字符串。
/// </summary>
public static string WeightsButtonLightWeightContent {
get {
return ResourceManager.GetString("WeightsButtonLightWeightContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Switch Weight (Regular → Bold) 的本地化字符串。
/// </summary>
public static string WeightsButtonRegularWeightContent {
get {
return ResourceManager.GetString("WeightsButtonRegularWeightContent", resourceCulture);
}
}
/// <summary>
/// 查找类似 Click to switch font weights 的本地化字符串。
/// </summary>
public static string WeightsButtonToolTip {
get {
return ResourceManager.GetString("WeightsButtonToolTip", resourceCulture);
}
}
}
}

View File

@ -98,7 +98,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ColorsButtonContent" xml:space="preserve">
<value>Switch Color (Fully random)</value>
<value>Switch Color (Fully Random)</value>
</data>
<data name="ColorsButtonToolTip" xml:space="preserve">
<value>Click to switch colors</value>
@ -127,6 +127,18 @@
<data name="ThemesButtonToolTip" xml:space="preserve">
<value>Click to switch themes</value>
</data>
<data name="WeightsButtonBoldWeightContent" xml:space="preserve">
<value>Switch Weight (Bold → Light)</value>
</data>
<data name="WeightsButtonLightWeightContent" xml:space="preserve">
<value>Switch Weight (Light → Regular)</value>
</data>
<data name="WeightsButtonRegularWeightContent" xml:space="preserve">
<value>Switch Weight (Regular → Bold)</value>
</data>
<data name="WeightsButtonToolTip" xml:space="preserve">
<value>Click to switch font weights</value>
</data>
<data name="_ChangeLangSuccessMsg" xml:space="preserve">
<value>Change successfuly, restart to refresh the windows</value>
</data>

View File

@ -127,6 +127,18 @@
<data name="ThemesButtonToolTip" xml:space="preserve">
<value>点击切换显示主题</value>
</data>
<data name="WeightsButtonBoldWeightContent" xml:space="preserve">
<value>切换字重 (粗体 → 细体)</value>
</data>
<data name="WeightsButtonLightWeightContent" xml:space="preserve">
<value>切换字重 (细体 → 标准)</value>
</data>
<data name="WeightsButtonRegularWeightContent" xml:space="preserve">
<value>切换字重 (标准 → 粗体)</value>
</data>
<data name="WeightsButtonToolTip" xml:space="preserve">
<value>点击切换字体粗细</value>
</data>
<data name="_ChangeLangSuccessMsg" xml:space="preserve">
<value>语言更改完成,重启以刷新界面</value>
</data>

View File

@ -0,0 +1,20 @@
using System;
using System.Globalization;
using System.Windows.Data;
using Sheas_Cealer.Consts;
namespace Sheas_Cealer.Convs;
internal class SettingsWeightsButtonContentConv : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool? isLightWeight = value as bool?;
return isLightWeight.HasValue ?
isLightWeight.GetValueOrDefault() ? SettingsConst.WeightsButtonLightWeightContent : SettingsConst.WeightsButtonBoldWeightContent :
SettingsConst.WeightsButtonRegularWeightContent;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
}

View File

@ -2,6 +2,7 @@
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using CommunityToolkit.Mvvm.ComponentModel;
using Sheas_Cealer.Props;
@ -19,6 +20,14 @@ internal partial class SettingsPres : GlobalPres
1 => true,
_ => throw new UnreachableException()
};
IsLightWeight = Settings.Default.IsLightWeight switch
{
-1 => null,
0 => false,
1 => true,
_ => throw new UnreachableException()
};
}
[ObservableProperty]
@ -35,4 +44,22 @@ internal partial class SettingsPres : GlobalPres
Settings.Default.IsEnglishLang = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
Settings.Default.Save();
}
[ObservableProperty]
private static bool? isLightWeight = null;
partial void OnIsLightWeightChanged(bool? value)
{
FontWeight newWeight = value.HasValue ? value.Value ? FontWeights.Light : FontWeights.Bold : FontWeights.Regular;
Style newStyle = new(typeof(Window), Application.Current.Resources["CommonWindow"] as Style);
newStyle.Setters.Add(new Setter(Window.FontWeightProperty, newWeight));
Application.Current.Resources["CommonWindow"] = newStyle;
newStyle = new(typeof(Button), Application.Current.Resources[typeof(Button)] as Style);
newStyle.Setters.Add(new Setter(Button.FontWeightProperty, newWeight));
Application.Current.Resources[typeof(Button)] = newStyle;
Settings.Default.IsLightWeight = (sbyte)(value.HasValue ? value.Value ? 1 : 0 : -1);
Settings.Default.Save();
}
}

View File

@ -94,5 +94,17 @@ namespace Sheas_Cealer.Props {
this["PrimaryColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("-1")]
public sbyte IsLightWeight {
get {
return ((sbyte)(this["IsLightWeight"]));
}
set {
this["IsLightWeight"] = value;
}
}
}
}

View File

@ -20,5 +20,8 @@
<Setting Name="PrimaryColor" Type="System.Drawing.Color" Scope="User">
<Value Profile="(Default)">Red</Value>
</Setting>
<Setting Name="IsLightWeight" Type="System.SByte" Scope="User">
<Value Profile="(Default)">-1</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -12,7 +12,7 @@ internal static class ForegroundGenerator
double blackContrast = (luminance + 0.05) / 0.05;
double whiteContrast = 1.05 / (luminance + 0.05);
return blackContrast >= 3.9 && whiteContrast >= 2.9 ? null :
return blackContrast >= 4 && whiteContrast >= 3 ? null :
blackContrast >= whiteContrast ? Color.FromRgb(0, 0, 0) : Color.FromRgb(255, 255, 255);
}

View File

@ -44,5 +44,16 @@
<Button Grid.Row="1" Grid.Column="0" Margin="5" Content="{Binding Source={x:Static consts:SettingsConst.ColorsButtonContent}}" ToolTip="{Binding Source={x:Static consts:SettingsConst.ColorsButtonToolTip}}"
Click="ColorsButton_Click" />
<Button Grid.Row="1" Grid.Column="1" Margin="5" d:Content="# # # #" ToolTip="{Binding Source={x:Static consts:SettingsConst.WeightsButtonToolTip}}"
Click="WeightsButton_Click">
<Button.Content>
<Binding Path="IsLightWeight">
<Binding.Converter>
<convs:SettingsWeightsButtonContentConv />
</Binding.Converter>
</Binding>
</Button.Content>
</Button>
</Grid>
</Window>

View File

@ -54,6 +54,7 @@ public partial class SettingsWin : Window
Settings.Default.PrimaryColor = System.Drawing.Color.FromArgb(newColor.A, newColor.R, newColor.G, newColor.B);
Settings.Default.Save();
}
private void WeightsButton_Click(object sender, RoutedEventArgs e) => SettingsPres!.IsLightWeight = SettingsPres.IsLightWeight.HasValue ? SettingsPres.IsLightWeight.Value ? null : true : false;
private void SettingsWin_KeyDown(object sender, KeyEventArgs e)
{