整理控件库
This commit is contained in:
@@ -9,36 +9,46 @@ using WPFluent.Appearance;
|
||||
namespace WPFluent.Markup;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a dictionary implementation that contains <c>WPF UI</c> theme resources used by components and other
|
||||
/// 提供一个字典实现,其中包含组件和其他设备使用的 <c>WPF UI</c> 主题资源。
|
||||
/// elements of a WPF application.
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// <code lang="xml"> /// <Application /// xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"> ///
|
||||
/// <Application.Resources> /// <ResourceDictionary> ///
|
||||
/// <ResourceDictionary.MergedDictionaries> /// <ui:ThemesDictionary Theme = "Dark" /> ///
|
||||
/// </ResourceDictionary.MergedDictionaries> /// </ResourceDictionary> ///
|
||||
/// </Application.Resources> /// </Application> ///</code>
|
||||
/// <code lang="xml">
|
||||
/// <Application
|
||||
/// xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
|
||||
/// <Application.Resources>
|
||||
/// <ResourceDictionary>
|
||||
/// <ResourceDictionary.MergedDictionaries>
|
||||
/// <ui:ThemesDictionary Theme = "Dark" />
|
||||
/// </ResourceDictionary.MergedDictionaries>
|
||||
/// </ResourceDictionary>
|
||||
/// </Application.Resources>
|
||||
/// </Application>
|
||||
/// </code>
|
||||
/// </example>
|
||||
[Localizability(LocalizationCategory.Ignore)]
|
||||
[Ambient]
|
||||
[UsableDuringInitialization(true)]
|
||||
public class ThemesDictionary : ResourceDictionary
|
||||
{
|
||||
public ThemesDictionary() { SetSourceBasedOnSelectedTheme(ApplicationTheme.Light); }
|
||||
public ThemesDictionary() { SetSourceBasedOnSelectedTheme(ThemeType.Light); }
|
||||
|
||||
private void SetSourceBasedOnSelectedTheme(ApplicationTheme? selectedApplicationTheme)
|
||||
private void SetSourceBasedOnSelectedTheme(ThemeType? selectedApplicationTheme)
|
||||
{
|
||||
var themeName = selectedApplicationTheme switch
|
||||
{
|
||||
ApplicationTheme.Dark => "Dark",
|
||||
ThemeType.Light => "Light",
|
||||
ThemeType.Dark => "Dark",
|
||||
ThemeType.HcWhite => "HCWhite",
|
||||
ThemeType.HcBlack => "HCBlack",
|
||||
_ => "Light",
|
||||
};
|
||||
|
||||
Source = new Uri($"{ApplicationThemeManager.ThemesDictionaryPath}{themeName}.xaml", UriKind.Absolute);
|
||||
Source = new Uri($"{ThemeManager.ThemesDictionaryPath}{themeName}.xaml", UriKind.Absolute);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the default application theme.
|
||||
/// </summary>
|
||||
public ApplicationTheme Theme { set => SetSourceBasedOnSelectedTheme(value); }
|
||||
public ThemeType Theme { set => SetSourceBasedOnSelectedTheme(value); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user