improve:主题切换
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||||
xmlns:local="clr-namespace:Ink_Canvas" FontFamily="Microsoft YaHei UI"
|
xmlns:local="clr-namespace:Ink_Canvas" FontFamily="Microsoft YaHei UI"
|
||||||
ui:ThemeManager.RequestedTheme="Light" Topmost="True" Background="Transparent"
|
Topmost="True" Background="Transparent"
|
||||||
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True" Loaded="Window_Loaded"
|
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True" Loaded="Window_Loaded"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
Title="Ink Canvas 抽奖" Height="500" Width="900">
|
Title="Ink Canvas 抽奖" Height="500" Width="900">
|
||||||
|
|||||||
@@ -82,6 +82,27 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (settings.Appearance.Theme == 0) // 浅色主题
|
||||||
|
{
|
||||||
|
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
|
||||||
|
}
|
||||||
|
else if (settings.Appearance.Theme == 1) // 深色主题
|
||||||
|
{
|
||||||
|
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
|
||||||
|
}
|
||||||
|
else // 跟随系统主题
|
||||||
|
{
|
||||||
|
bool isSystemLight = IsSystemThemeLight();
|
||||||
|
if (isSystemLight)
|
||||||
|
{
|
||||||
|
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 根据主题设置窗口背景
|
// 根据主题设置窗口背景
|
||||||
if (settings.RandSettings.SelectedBackgroundIndex <= 0)
|
if (settings.RandSettings.SelectedBackgroundIndex <= 0)
|
||||||
{
|
{
|
||||||
@@ -99,6 +120,23 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsSystemThemeLight()
|
||||||
|
{
|
||||||
|
var light = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var registryKey = Microsoft.Win32.Registry.CurrentUser;
|
||||||
|
var themeKey =
|
||||||
|
registryKey.OpenSubKey("software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
|
||||||
|
var keyValue = 0;
|
||||||
|
if (themeKey != null) keyValue = (int)themeKey.GetValue("SystemUsesLightTheme");
|
||||||
|
if (keyValue == 1) light = true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
|
||||||
|
return light;
|
||||||
|
}
|
||||||
|
|
||||||
public RandWindow(Settings settings, bool IsAutoClose)
|
public RandWindow(Settings settings, bool IsAutoClose)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
Reference in New Issue
Block a user