Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 private static void ReplaceResources(ResourceDictionary resources, IKeyedResourceContainer newResources)
 {
     var oldThemeResources = resources.MergedDictionaries
         .FirstOrDefault(d => d.Source == resources.Source);
     SwapResources(resources, oldThemeResources, newResources.Resources);
 }
Exemplo n.º 4
0
        /// <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;
        }
Exemplo n.º 5
0
        public static void SetManagedColorScheme(IKeyedResourceContainer theme, IKeyedResourceContainer accent)
        {
            ThrowHelper.IfNullThenThrow(() => theme);
            ThrowHelper.IfNullThenThrow(() => accent);

            SetManagedAccent(accent);
            SetManagedTheme(theme);
        }
Exemplo n.º 6
0
 /// <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;
 }
Exemplo n.º 7
0
 public ColorSchemeExtension(string displayName, IKeyedResourceContainer baseColors, IKeyedResourceContainer theme, IKeyedResourceContainer accent)
     : base(displayName, baseColors, theme, accent)
 {
 }
Exemplo n.º 8
0
        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;
            }
        }
Exemplo n.º 9
0
 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);
 }