// Initialize everything related to Theming. public static void InitializeThemeHelper() { try { var settingsManager = ServiceLocator.Default.ResolveType <ISettingsManager>(); HandyControl.Themes.ThemeManager.Current.SetCurrentValue(HandyControl.Themes.ThemeManager.ApplicationThemeProperty, HandyControl.Themes.ApplicationTheme.Dark); var themeResources = new HandyControl.Themes.ThemeResources { AccentColor = HandyControl.Tools.ResourceHelper.GetResource <Brush>("MahApps.Brushes.Accent3") }; var themeSettings = new MaterialDarkThemeSettings { PrimaryBackground = new SolidColorBrush(settingsManager.GetThemeAccent()), BodyFontSize = 11, HeaderFontSize = 14, SubHeaderFontSize = 13, TitleFontSize = 13, SubTitleFontSize = 12, BodyAltFontSize = 11, FontFamily = new FontFamily("Segoe UI") }; SfSkinManager.RegisterThemeSettings("MaterialDark", themeSettings); SfSkinManager.ApplyStylesOnApplication = true; } catch (Exception e) { StaticReferences.Logger.Error(e); } }
} // end method GetProductVersion #endregion Public Methods #region Private Methods /// <summary> /// Apply corresponding theme settings. /// </summary> private static void ApplyTheme() { if (ShSzStockHelper.Properties.Settings.Default.AppTheme == (int) VisualStyles.MaterialDark) { var darkThemeSettings = new MaterialDarkThemeSettings { BodyAltFontSize = ShSzStockHelper.Properties.Settings.Default.ContentTextFontSize, BodyFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize, FontFamily = new FontFamily(ShSzStockHelper.Properties.Settings.Default.DisplayFontFamilyName), SubTitleFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize, TitleFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize }; SfSkinManager.RegisterThemeSettings("MaterialDark", darkThemeSettings); Current.Resources.MergedDictionaries.Add((ResourceDictionary)LoadComponent(new Uri("Resources/MaterialDark.xaml", UriKind.Relative))); } else { var lightThemeSettings = new MaterialLightThemeSettings { BodyAltFontSize = ShSzStockHelper.Properties.Settings.Default.ContentTextFontSize, BodyFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize, FontFamily = new FontFamily(ShSzStockHelper.Properties.Settings.Default.DisplayFontFamilyName), SubTitleFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize, TitleFontSize = ShSzStockHelper.Properties.Settings.Default.PrimaryTextFontSize }; SfSkinManager.RegisterThemeSettings("MaterialLight", lightThemeSettings); Current.Resources.MergedDictionaries.Add((ResourceDictionary)LoadComponent(new Uri("Resources/MaterialLight.xaml", UriKind.Relative))); } // end if...else } // end method ApplyTheme
/// <summary> /// Method helps to Change the Color palette for the SelectedTheme /// </summary> /// <param name="themeType">Type of the theme</param> /// <param name="theme">Name of the selected theme</param> private void changePalette(string themeType, string paletteType, string theme) { object themeSettings = Activator.CreateInstance(Type.GetType(themeType)); themeSettings.GetType().GetRuntimeProperty("Palette").SetValue(themeSettings, Enum.Parse(Type.GetType(paletteType), SelectedPalette.Name)); SfSkinManager.RegisterThemeSettings(theme, (IThemeSetting)themeSettings); }
public static void SetTheme( this DependencyObject dependencyObject, string themeName) { IThemeSetting theme = GetThemeSetting(themeName); var themeTypeName = theme.GetType().Name.Replace("ThemeSettings", ""); SfSkinManager.RegisterThemeSettings(themeTypeName, theme); SfSkinManager.SetTheme(dependencyObject, new Theme(themeTypeName)); }
public MainWindow() { MaterialDarkThemeSettings materialDarkThemeSettings = new MaterialDarkThemeSettings(); materialDarkThemeSettings.PrimaryBackground = new SolidColorBrush(Colors.Red); materialDarkThemeSettings.PrimaryForeground = new SolidColorBrush(Colors.AntiqueWhite); materialDarkThemeSettings.BodyFontSize = 15; materialDarkThemeSettings.HeaderFontSize = 18; materialDarkThemeSettings.SubHeaderFontSize = 17; materialDarkThemeSettings.TitleFontSize = 17; materialDarkThemeSettings.SubTitleFontSize = 16; materialDarkThemeSettings.FontFamily = new FontFamily("Callibri"); SfSkinManager.RegisterThemeSettings("MaterialDark", materialDarkThemeSettings); SfSkinManager.SetTheme(this, new Theme("MaterialDark")); InitializeComponent(); }
private static void ThemeInnerInit(ISettingsManager settings) { ControlzEx.Theming.ThemeManager.Current.ChangeTheme(System.Windows.Application.Current, ControlzEx.Theming.RuntimeThemeGenerator.Current.GenerateRuntimeTheme("Dark", settings.GetThemeAccent(), false)); var themeSettings = new MaterialDarkThemeSettings { PrimaryBackground = new SolidColorBrush(settings.GetThemeAccent()), BodyFontSize = 11, HeaderFontSize = 14, SubHeaderFontSize = 13, TitleFontSize = 13, SubTitleFontSize = 12, BodyAltFontSize = 11, FontFamily = new FontFamily("Segoe UI") }; SfSkinManager.RegisterThemeSettings("MaterialDark", themeSettings); // SfSkinManager.SetTheme(StaticReferences.GlobalShell, new FluentTheme() { ThemeName = "MaterialDark", ShowAcrylicBackground = true }); }