mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-17 22:56:37 +08:00
Merge pull request #527 from irihitech/sync
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;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Data.Core.Plugins;
|
using Avalonia.Data.Core.Plugins;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Platform;
|
||||||
using Semi.Avalonia.Demo.Views;
|
using Semi.Avalonia.Demo.Views;
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo;
|
namespace Semi.Avalonia.Demo;
|
||||||
@@ -28,6 +31,30 @@ public partial class App : Application
|
|||||||
break;
|
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();
|
base.OnFrameworkInitializationCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user