public static void SetBaseTheme(this IExtendedTheme theme, IExtendedBaseTheme baseTheme)
        {
            // call implementation of MaterialDesignThemes
            theme.SetBaseTheme((IBaseTheme)baseTheme);

            // set extended properties of the theme
            theme.NavigationItemIcon      = baseTheme.MaterialDesignNavigationItemIcon;
            theme.NavigationItemText      = baseTheme.MaterialDesignNavigationItemText;
            theme.NavigationItemSubheader = baseTheme.MaterialDesignNavigationItemSubheader;
            theme.StepperInactiveStep     = baseTheme.MaterialDesignStepperInactiveStep;
            theme.StepperActiveStep       = baseTheme.MaterialDesignStepperActiveStep;
            theme.StepperSeparator        = baseTheme.MaterialDesignStepperSeparator;
        }
        /// <summary>
        /// Writes the specified theme into the resource dictionary.
        /// The implementation is based on MaterialDesignThemes.Wpf.ResourceDictionaryExtensions.SetTheme(this ResourceDictionary resourceDictionary, ITheme theme).
        /// </summary>
        /// <param name="resourceDictionary"></param>
        /// <param name="theme"></param>
        public static void SetExtendedTheme(this ResourceDictionary resourceDictionary, IExtendedTheme theme)
        {
            if (resourceDictionary == null)
            {
                throw new ArgumentNullException(nameof(resourceDictionary));
            }

            SetSolidColorBrush(resourceDictionary, "PrimaryHueLightBrush", theme.PrimaryLight.Color);
            SetSolidColorBrush(resourceDictionary, "PrimaryHueLightForegroundBrush", theme.PrimaryLight.ForegroundColor ?? theme.PrimaryLight.Color.ContrastingForegroundColor());
            SetSolidColorBrush(resourceDictionary, "PrimaryHueMidBrush", theme.PrimaryMid.Color);
            SetSolidColorBrush(resourceDictionary, "PrimaryHueMidForegroundBrush", theme.PrimaryMid.ForegroundColor ?? theme.PrimaryMid.Color.ContrastingForegroundColor());
            SetSolidColorBrush(resourceDictionary, "PrimaryHueDarkBrush", theme.PrimaryDark.Color);
            SetSolidColorBrush(resourceDictionary, "PrimaryHueDarkForegroundBrush", theme.PrimaryDark.ForegroundColor ?? theme.PrimaryDark.Color.ContrastingForegroundColor());

            SetSolidColorBrush(resourceDictionary, "SecondaryHueLightBrush", theme.SecondaryLight.Color);
            SetSolidColorBrush(resourceDictionary, "SecondaryHueLightForegroundBrush", theme.SecondaryLight.ForegroundColor ?? theme.SecondaryLight.Color.ContrastingForegroundColor());
            SetSolidColorBrush(resourceDictionary, "SecondaryHueMidBrush", theme.SecondaryMid.Color);
            SetSolidColorBrush(resourceDictionary, "SecondaryHueMidForegroundBrush", theme.SecondaryMid.ForegroundColor ?? theme.SecondaryMid.Color.ContrastingForegroundColor());
            SetSolidColorBrush(resourceDictionary, "SecondaryHueDarkBrush", theme.SecondaryDark.Color);
            SetSolidColorBrush(resourceDictionary, "SecondaryHueDarkForegroundBrush", theme.SecondaryDark.ForegroundColor ?? theme.SecondaryDark.Color.ContrastingForegroundColor());

            // these are here for backwards compatibility, and will be removed in a future version.
            SetSolidColorBrush(resourceDictionary, "SecondaryHueMidBrush", theme.SecondaryMid.Color);
            SetSolidColorBrush(resourceDictionary, "SecondaryHueMidForegroundBrush", theme.SecondaryMid.ForegroundColor ?? theme.SecondaryMid.Color.ContrastingForegroundColor());

            SetSolidColorBrush(resourceDictionary, "ValidationErrorBrush", theme.ValidationError);
            resourceDictionary["MaterialDesignValidationErrorColor"] = theme.ValidationError;

            GetColorProperties(theme.GetType(), true, false)
            .ForEach(property => SetSolidColorBrush(resourceDictionary, GetKey(property), (Color)property.GetValue(theme)));

            if (!(resourceDictionary.GetThemeManager() is ThemeManager themeManager))
            {
                resourceDictionary[ThemeManagerKey] = themeManager = new ThemeManager(resourceDictionary);
            }

            ITheme oldTheme = resourceDictionary.GetTheme();

            resourceDictionary[CurrentThemeKey] = theme;

            themeManager.OnThemeChange(oldTheme, theme);
        }
Пример #3
0
 public void SetExtendedTheme(IExtendedTheme theme)
 {
     SetTheme(theme);
 }