using WPFluent.Appearance;
using System.Windows.Markup;
namespace WPFluent.Markup;
///
/// Provides a dictionary implementation that contains WPF UI theme resources used by components and other
/// elements of a WPF application.
///
///
/// /// <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> ///
///
[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);
}
///
/// Sets the default application theme.
///
public ApplicationTheme Theme { set => SetSourceBasedOnSelectedTheme(value); }
}