This commit is contained in:
NaBian committed 2020-04-19 14:58:48 +08:00
1 parent 61ee9a5337
commit 8f1bb42714
9 files changed
+80 -26

No files matched your search

+3 -12
View File
@@ -8,24 +8,15 @@
xmlns:data="clr-namespace:HandyControlDemo.Data"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:resources="clr-namespace:HandyControlDemo.Resources"
d1P1:Ignorable="d"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
<ResourceDictionary Source="Resources/Themes/SkinDefault.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
<ResourceDictionary Source="Resources/Themes/Theme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
<hc:Theme Name="HandyTheme"/>
<resources:DemoTheme Name="DemoTheme"/>
</ResourceDictionary.MergedDictionaries>
<langs:LangDecorator x:Key="DemoLangs"/>
+4 -14
View File
@@ -3,7 +3,9 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
#if !netle40
using System.Runtime;
#endif
using System.Security.Authentication;
using System.Threading;
using System.Windows;
@@ -86,21 +88,9 @@ namespace HandyControlDemo
internal void UpdateSkin(SkinType skin)
{
var skins0 = Resources.MergedDictionaries[0];
skins0.MergedDictionaries.Clear();
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin));
skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin));
ResourceHelper.GetTheme("HandyTheme", Resources).Skin = skin;
ResourceHelper.GetTheme("DemoTheme", Resources).Skin = skin;
var skins1 = Resources.MergedDictionaries[1];
skins1.MergedDictionaries.Clear();
skins1.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
});
skins1.MergedDictionaries.Add(new ResourceDictionary
{
Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
});
Current.MainWindow?.OnApplyTemplate();
}
@@ -29,6 +29,7 @@
<SubType>Code</SubType>
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Resources\DemoTheme.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Service\Data\DataService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\HatchBrushConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\String2BrushConverter.cs" />
@@ -0,0 +1,16 @@
using System;
using System.Windows;
using HandyControl.Data;
using HandyControl.Themes;
using HandyControl.Tools;
namespace HandyControlDemo.Resources
{
public class DemoTheme : Theme
{
public override Uri ThemeUri => new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml");
public override ResourceDictionary GetSkin(SkinType skinType) =>
ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
}
}