public ColorScheme(string displayName, IKeyedResourceContainer baseTheme, IKeyedResourceContainer theme, IKeyedResourceContainer accent) { ThrowHelper.IfNullThenThrow(() => baseTheme); ThrowHelper.IfNullThenThrow(() => theme); ThrowHelper.IfNullThenThrow(() => accent); ThrowHelper.IfNullThenThrow(() => baseTheme.Resources.Source); ThrowHelper.IfNullThenThrow(() => theme.Resources.Source); ThrowHelper.IfNullThenThrow(() => accent.Resources.Source); Base = baseTheme; Theme = theme; Accent = accent; Guid = GuidHelper.Create(GuidHelper.UrlNamespace, Base.Resources.Source.AbsoluteUri + Theme.Resources.Source.AbsoluteUri + Accent.Resources.Source.AbsoluteUri); DisplayName = displayName; }
private static void ReplaceResources(ResourceDictionary resources, IKeyedResourceContainer oldResources, IKeyedResourceContainer newResources) { if (oldResources == null || oldResources.Guid == newResources.Guid) return; var oldThemeResources = resources.MergedDictionaries .FirstOrDefault(d => d.Source == oldResources.Resources.Source); SwapResources(resources, oldThemeResources, newResources.Resources); }
private static void ReplaceResources(ResourceDictionary resources, IKeyedResourceContainer newResources) { var oldThemeResources = resources.MergedDictionaries .FirstOrDefault(d => d.Source == resources.Source); SwapResources(resources, oldThemeResources, newResources.Resources); }
/// <summary> /// Sets the current (managed) theme, which will be pushed to all registered <see cref="ISchemedElement" />s. /// </summary> /// <param name="newValue">The theme to register.</param> public static void SetManagedTheme(IKeyedResourceContainer newValue) { ThrowHelper.IfNullThenThrow(() => newValue); if (_currentScheme.Theme.Guid == newValue.Guid) return; CurrentScheme.Theme = newValue; }
public static void SetManagedColorScheme(IKeyedResourceContainer theme, IKeyedResourceContainer accent) { ThrowHelper.IfNullThenThrow(() => theme); ThrowHelper.IfNullThenThrow(() => accent); SetManagedAccent(accent); SetManagedTheme(theme); }
/// <summary> /// Takes an <see cref="IColorSchemeExtensionContainer " /> and populates the <see cref="ColorSchemeManager" /> /// with the Accents, Themes, and default scheme. /// </summary> public static void PopulateSchemes(IColorSchemeExtensionContainer container) { _container = container; CurrentScheme = container.DefaultScheme; _baseTheme = container.BaseTheme; }
public ColorSchemeExtension(string displayName, IKeyedResourceContainer baseColors, IKeyedResourceContainer theme, IKeyedResourceContainer accent) : base(displayName, baseColors, theme, accent) { }
internal void ChangeFlyoutTheme(IKeyedResourceContainer windowAccent, IKeyedResourceContainer windowTheme) { // Beware: Über-dumb code ahead! switch (Theme) { case FlyoutTheme.Accent: ColorScheme.Accent = windowAccent; ColorScheme.Theme = windowTheme; //ColorSchemeManager.UpdateColorScheme(windowAccent, windowTheme); SetResourceReference(BackgroundProperty, "HighlightBrush"); SetResourceReference(ForegroundProperty, "IdealForegroundColorBrush"); break; case FlyoutTheme.Adapt: ColorScheme.Accent = windowAccent; ColorScheme.Theme = windowTheme; break; //case FlyoutTheme.Dark: // ColorSchemeManager.UpdateColorScheme(windowAccent, ColorSchemeManager.GetTheme("BaseDark")); // break; //case FlyoutTheme.Light: // ColorSchemeManager.UpdateColorScheme(this.Resources, windowAccent, ColorSchemeManager.GetTheme("BaseLight")); // break; } }
private void SetAndRaise(ref IKeyedResourceContainer field, IKeyedResourceContainer value, EventHandler<ChangedEventArgs<IKeyedResourceContainer>> handler) { var args = new ChangedEventArgs<IKeyedResourceContainer>(field, value); field = value; SafeRaise.Raise(handler, this, args); }