示例#1
0
        // 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
示例#3
0
        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();
        }
示例#4
0
        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 });
        }
        private static IThemeSetting GetThemeSetting(string themeName)
        {
            FontFamily    fontFamily   = new FontFamily("Microsoft YaHei");
            int           bodyfontSize = 14;
            IThemeSetting theme        = null;

            switch (themeName)
            {
            case "FluentLight":
                theme = new FluentLightThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "MaterialLight":
                theme = new MaterialLightThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "MaterialLightBlue":
                theme = new MaterialLightBlueThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "Office2019White":
                theme = new Office2019WhiteThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "FluentDark":
                theme = new FluentDarkThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "MaterialDark":
                theme = new MaterialDarkThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "MaterialDarkBlue":
                theme = new MaterialDarkBlueThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;

            case "Office2019Black":
                theme = new Office2019BlackThemeSettings()
                {
                    FontFamily = fontFamily, BodyFontSize = bodyfontSize,
                };
                break;
            }
            return(theme);
        }