优化更新代码,添加界面功能并整合

This commit is contained in:
GG Z
2025-02-10 20:53:40 +08:00
parent 83b846f15f
commit 978e03a67f
1389 changed files with 95739 additions and 22200 deletions

View File

@@ -0,0 +1,44 @@
using WPFluent.Appearance;
using System.Windows.Markup;
namespace WPFluent.Markup;
/// <summary>
/// Provides a dictionary implementation that contains <c>WPF UI</c> theme resources used by components and other
/// elements of a WPF application.
/// </summary>
/// <example>
/// <code lang="xml"> /// &lt;Application /// xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"&gt; ///
/// &lt;Application.Resources&gt; /// &lt;ResourceDictionary&gt; ///
/// &lt;ResourceDictionary.MergedDictionaries&gt; /// &lt;ui:ThemesDictionary Theme = "Dark" /&gt; ///
/// &lt;/ResourceDictionary.MergedDictionaries&gt; /// &lt;/ResourceDictionary&gt; ///
/// &lt;/Application.Resources&gt; /// &lt;/Application&gt; ///</code>
/// </example>
[Localizability(LocalizationCategory.Ignore)]
[Ambient]
[UsableDuringInitialization(true)]
public class ThemesDictionary : ResourceDictionary
{
public ThemesDictionary() { SetSourceBasedOnSelectedTheme(ApplicationTheme.Light); }
private void SetSourceBasedOnSelectedTheme(ApplicationTheme? selectedApplicationTheme)
{
var themeName = selectedApplicationTheme switch
{
ApplicationTheme.Dark => "Dark",
ApplicationTheme.HighContrast => "HighContrast",
_ => "Light",
};
Source = new Uri($"{ApplicationThemeManager.ThemesDictionaryPath}{themeName}.xaml", UriKind.Absolute);
}
/// <summary>
/// Sets the default application theme.
/// </summary>
public ApplicationTheme Theme { set => SetSourceBasedOnSelectedTheme(value); }
}