mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-03-03 00:00:55 +08:00
feat: sync high-contrast themes under the Windows OS.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Data.Core.Plugins;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform;
|
||||
using Semi.Avalonia.Demo.Views;
|
||||
|
||||
namespace Semi.Avalonia.Demo;
|
||||
@@ -28,6 +31,30 @@ public partial class App : Application
|
||||
break;
|
||||
}
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
var setting = PlatformSettings?.GetColorValues();
|
||||
if (setting?.ContrastPreference is ColorContrastPreference.High)
|
||||
{
|
||||
if (setting.AccentColor1 == Color.Parse("#8EE3F0"))
|
||||
{
|
||||
RequestedThemeVariant = SemiTheme.Aquatic;
|
||||
}
|
||||
else if (setting.AccentColor1 == Color.Parse("#903909"))
|
||||
{
|
||||
RequestedThemeVariant = SemiTheme.Desert;
|
||||
}
|
||||
else if (setting.AccentColor1 == Color.Parse("#A1BFDE"))
|
||||
{
|
||||
RequestedThemeVariant = SemiTheme.Dusk;
|
||||
}
|
||||
else if (setting.AccentColor1 == Color.Parse("#D6B4FD"))
|
||||
{
|
||||
RequestedThemeVariant = SemiTheme.NightSky;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user