mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 10:32:19 +08:00
feat: add ThemeHelper
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:main="clr-namespace:MaaWpfGui.Main"
|
||||
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
|
||||
xmlns:resources="clr-namespace:MaaWpfGui.Helper"
|
||||
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
<Application.Resources>
|
||||
@@ -28,6 +29,7 @@
|
||||
</s:ApplicationLoader.Bootstrapper>
|
||||
</s:ApplicationLoader>
|
||||
<hc:Theme Name="HandyTheme"/>
|
||||
<resources:ThemeHelper Name="MaaTheme"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- A Style that affects all TextBlocks -->
|
||||
<Style BasedOn="{StaticResource TextBlockDefault}" TargetType="controls:TextBlock" />
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace MaaWpfGui
|
||||
{
|
||||
SharedResourceDictionary.SharedDictionaries.Clear();
|
||||
Theme.GetTheme("HandyTheme", Resources).Skin = skin;
|
||||
Theme.GetTheme("MaaTheme", Resources).Skin = skin;
|
||||
Current.MainWindow?.OnApplyTemplate();
|
||||
}
|
||||
|
||||
@@ -49,6 +50,7 @@ namespace MaaWpfGui
|
||||
{
|
||||
SharedResourceDictionary.SharedDictionaries.Clear();
|
||||
Theme.GetTheme("HandyTheme", Resources).SyncWithSystem = syncWithSystem;
|
||||
Theme.GetTheme("MaaTheme", Resources).SyncWithSystem = syncWithSystem;
|
||||
Current.MainWindow?.OnApplyTemplate();
|
||||
}
|
||||
|
||||
|
||||
22
src/MaaWpfGui/Helper/ThemeHelper.cs
Normal file
22
src/MaaWpfGui/Helper/ThemeHelper.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Themes;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace MaaWpfGui.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// The theme class.
|
||||
/// </summary>
|
||||
public class ThemeHelper : Theme
|
||||
{
|
||||
public override ResourceDictionary GetSkin(SkinType skinType) =>
|
||||
ResourceHelper.GetSkin(typeof(App).Assembly, "Res/Themes", skinType);
|
||||
|
||||
public override ResourceDictionary GetTheme() => new ResourceDictionary()
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml"),
|
||||
};
|
||||
}
|
||||
}
|
||||
7
src/MaaWpfGui/Res/Themes/Colors.xaml
Normal file
7
src/MaaWpfGui/Res/Themes/Colors.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<Color x:Key="SecondaryRegionColor">#ffffff</Color>
|
||||
|
||||
</ResourceDictionary>
|
||||
8
src/MaaWpfGui/Res/Themes/ColorsDark.xaml
Normal file
8
src/MaaWpfGui/Res/Themes/ColorsDark.xaml
Normal file
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib">
|
||||
|
||||
<Color x:Key="PrimaryTextColor">#ddd</Color>
|
||||
<Color x:Key="TextIconColor">#ddd</Color>
|
||||
|
||||
</ResourceDictionary>
|
||||
7
src/MaaWpfGui/Res/Themes/SkinDark.xaml
Normal file
7
src/MaaWpfGui/Res/Themes/SkinDark.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ColorsDark.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
7
src/MaaWpfGui/Res/Themes/SkinDefault.xaml
Normal file
7
src/MaaWpfGui/Res/Themes/SkinDefault.xaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Colors.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user