项目结构调整

This commit is contained in:
艾竹
2023-04-16 20:11:40 +08:00
parent cbfbf96033
commit 81f91f3f35
2124 changed files with 218 additions and 5516 deletions

View File

@@ -0,0 +1,47 @@
namespace FluentTest.Helpers
{
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Media;
using System.Xml;
using ControlzEx.Theming;
public static class ThemeHelper
{
public static Tuple<string, Theme> CreateTheme(string baseColorScheme, Color accentBaseColor, bool changeImmediately = false)
{
var theme = RuntimeThemeGenerator.Current.GenerateRuntimeTheme(baseColorScheme, accentBaseColor, false);
// Apply theme
if (changeImmediately)
{
var changedTheme = ThemeManager.Current.ChangeTheme(Application.Current, theme);
Debug.Assert(changedTheme == theme, "Theme must have been changed.");
}
return new Tuple<string, Theme>(string.Join(Environment.NewLine, theme.GetAllResources().Select(GetResourceDictionaryContent)), theme);
}
public static string GetResourceDictionaryContent(ResourceDictionary resourceDictionary)
{
using (var sw = new StringWriter())
{
using (var writer = XmlWriter.Create(sw, new XmlWriterSettings
{
Indent = true,
IndentChars = " "
}))
{
XamlWriter.Save(resourceDictionary, writer);
return sw.ToString();
}
}
}
}
}