1.1.3 -> 1.1.4 第55次更新

This commit is contained in:
Space Time 2024-12-13 21:25:55 +08:00
parent 67079cf9e0
commit 73de1516ea
5 changed files with 24 additions and 10 deletions

View File

@ -71,6 +71,9 @@ internal partial class MainPres : GlobalPres
}
}
[ObservableProperty]
private bool isUpstreamHostUtd = true;
[ObservableProperty]
private bool isNginxExist = File.Exists(MainConst.NginxPath);

View File

@ -12,7 +12,7 @@ namespace Sheas_Cealer.Props {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.12.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.13.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -85,7 +85,7 @@ namespace Sheas_Cealer.Props {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Red")]
[global::System.Configuration.DefaultSettingValueAttribute("244, 67, 54")]
public global::System.Drawing.Color PrimaryColor {
get {
return ((global::System.Drawing.Color)(this["PrimaryColor"]));

View File

@ -18,7 +18,7 @@
<Value Profile="(Default)">-1</Value>
</Setting>
<Setting Name="PrimaryColor" Type="System.Drawing.Color" Scope="User">
<Value Profile="(Default)">Red</Value>
<Value Profile="(Default)">244, 67, 54</Value>
</Setting>
<Setting Name="IsLightWeight" Type="System.SByte" Scope="User">
<Value Profile="(Default)">-1</Value>

View File

@ -15,17 +15,17 @@ internal static class ForegroundGenerator
double hue = GetHue(red / 255.0, green / 255.0, blue / 255.0);
double blueContrast = Math.Min(Math.Abs(hue - 206.57), 360 - Math.Abs(hue - 206.57));
double redContrast = Math.Min(Math.Abs(hue), 360 - Math.Abs(hue));
double redContrast = Math.Min(Math.Abs(hue - 4.11), 360 - Math.Abs(hue - 4.11));
return (blackContrast >= 4 && whiteContrast >= 3 ? null :
blackContrast >= whiteContrast ? Color.FromRgb(0, 0, 0) : Color.FromRgb(255, 255, 255),
blueContrast >= redContrast ? (Color)ColorConverter.ConvertFromString("#2196f3") : Color.FromRgb(255, 0, 0));
blackContrast >= whiteContrast ? Colors.Black : Colors.White,
(Color)ColorConverter.ConvertFromString(blueContrast >= redContrast ? "#2196f3" : "#f44336"));
}
private static double GammaCorrect(double component) => component <= 0.03928 ? component / 12.92 : Math.Pow((component + 0.055) / 1.055, 2.4);
private static double GetHue(double redComponent, double greenComponent, double blueComponent) =>
redComponent > greenComponent && redComponent > blueComponent ? 60 * ((greenComponent - blueComponent) / redComponent - Math.Min(greenComponent, blueComponent) + (greenComponent < blueComponent ? 6 : 0)) :
greenComponent > blueComponent && greenComponent > redComponent ? 60 * ((blueComponent - redComponent) / greenComponent - Math.Min(blueComponent, redComponent) + 2) :
blueComponent > redComponent && blueComponent > greenComponent ? 60 * ((redComponent - greenComponent) / blueComponent - Math.Min(redComponent, greenComponent) + 4) : 0;
redComponent > greenComponent && redComponent > blueComponent ? 60 * ((greenComponent - blueComponent) / (redComponent - Math.Min(greenComponent, blueComponent)) + (greenComponent < blueComponent ? 6 : 0)) :
greenComponent > blueComponent && greenComponent > redComponent ? 60 * ((blueComponent - redComponent) / (greenComponent - Math.Min(blueComponent, redComponent)) + 2) :
blueComponent > redComponent && blueComponent > greenComponent ? 60 * ((redComponent - greenComponent) / (blueComponent - Math.Min(redComponent, greenComponent)) + 4) : 0;
}

View File

@ -84,6 +84,9 @@ public partial class MainWin : Window
if (!MainPres.IsNginxRunning)
NginxStoppedCleaner.Clean();
try { UpdateUpstreamHostButton_Click(null!, null!); }
catch { }
});
}
private void MainWin_Closing(object sender, CancelEventArgs e) => Application.Current.Shutdown();
@ -418,7 +421,12 @@ public partial class MainWin : Window
catch { }
if (localUpstreamHostString == upstreamUpstreamHostString || localUpstreamHostString.ReplaceLineEndings() == upstreamUpstreamHostString.ReplaceLineEndings())
if (sender == null)
MainPres.IsUpstreamHostUtd = true;
else
MessageBox.Show(MainConst._UpstreamHostUtdMsg);
else if (sender == null)
MainPres.IsUpstreamHostUtd = false;
else
{
MessageBoxResult overrideOptionResult = MessageBox.Show(MainConst._OverrideUpstreamHostPrompt, string.Empty, MessageBoxButton.YesNoCancel);
@ -473,9 +481,12 @@ public partial class MainWin : Window
PaletteHelper paletteHelper = new();
Theme newTheme = paletteHelper.GetTheme();
Color newPrimaryColor = Color.FromRgb((byte)random.Next(256), (byte)random.Next(256), (byte)random.Next(256));
Color newSecondaryColor = random.Next(3) == 0 ? newPrimaryColor with { R = (byte)((newPrimaryColor.R + 109) % 256) } :
random.Next(2) == 0 ? newPrimaryColor with { G = (byte)((newPrimaryColor.G + 109) % 256) } : newPrimaryColor with { B = (byte)((newPrimaryColor.B + 109) % 256) };
bool isLightTheme = random.Next(2) == 0;
newTheme.SetPrimaryColor(newPrimaryColor);
newTheme.SetSecondaryColor(newSecondaryColor);
newTheme.SetBaseTheme(isLightTheme ? BaseTheme.Light : BaseTheme.Dark);
paletteHelper.SetTheme(newTheme);