Exemplo n.º 1
0
        /// <summary>
        /// Sets the theme.
        /// </summary>
        /// <param name="style">The theme.</param>
        public void SetStyle(Style style)
        {
            Argument.IsNotNull(style);

            _style = style;

            if (Window.Current.Content is FrameworkElement frameworkElement && !new AccessibilitySettings().HighContrast)
            {
                var palette = FindColorPaletteResourcesForTheme(_style.Theme.ToString());

                if (palette is not null)
                {
                    palette.Accent = ColorHelper.HexStringToColor(style.Color);
                }
                else
                {
                    palette        = new ColorPaletteResources();
                    palette.Accent = ColorHelper.HexStringToColor(style.Color);
                    Application.Current.Resources.MergedDictionaries.Add(palette);
                }

                Application.Current.Resources["SystemAccentColor"] = style.Color;
                Application.Current.Resources["NavigationViewSelectionIndicatorForeground"] = style.Color;
            }

            SetupTitlebar();
            ReloadPageTheme(style.Theme);
        }
        public ColorMappingInstance(IColorPaletteEntry source, ColorTarget targetColor, ColorPaletteResources targetResources)
        {
            _source          = source;
            _targetColor     = targetColor;
            _targetResources = targetResources;

            Apply();

            _source.ActiveColorChanged += Source_ActiveColorChanged;
        }
Exemplo n.º 3
0
        public ThemeColorMappingInstance(IColorPaletteEntry source, ThemeColorTarget targetColor, ColorPaletteResources targetResources, ThemeExtraPalette extraPalette)
        {
            _source          = source;
            _targetColor     = targetColor;
            _targetResources = targetResources;
            _extraPalette    = extraPalette;

            Apply();

            _source.ActiveColorChanged += Source_ActiveColorChanged;
        }
Exemplo n.º 4
0
        public static void ChangeTheme(WtTheme theme)
        {
            if (theme != _currentTheme)
            {
                _currentTheme = theme;
                var rootFrame = Window.Current.Content as Frame;
                var mainPage  = rootFrame.GetChildren <LightMainPage>().First();

                var themeData = _themeDic.Single(t => t.Key == theme);
                ColorPaletteResources light = FindColorPaletteResourcesForTheme("Light");
                light.Accent = themeData.Value.Accent;
                ColorPaletteResources def = FindColorPaletteResourcesForTheme("Default");
                def.Accent = themeData.Value.Accent;

                Application.Current.Resources["SystemAccentColorDark1"]  = themeData.Value.SystemAccentColorDark1;
                Application.Current.Resources["SystemAccentColorDark2"]  = themeData.Value.SystemAccentColorDark2;
                Application.Current.Resources["SystemAccentColorDark3"]  = themeData.Value.SystemAccentColorDark3;
                Application.Current.Resources["SystemAccentColorLight1"] = themeData.Value.SystemAccentColorLight1;
                Application.Current.Resources["SystemAccentColorLight2"] = themeData.Value.SystemAccentColorLight2;
                Application.Current.Resources["SystemAccentColorLight3"] = themeData.Value.SystemAccentColorLight3;

                ReloadPageTheme(mainPage.RequestedTheme, mainPage);
            }
        }
Exemplo n.º 5
0
 public ThemeColorMappingInstance CreateInstance(ColorPaletteResources targetResources, ThemeExtraPalette extraPalette)
 {
     return(new ThemeColorMappingInstance(_source, _targetColor, targetResources, extraPalette));
 }
 public ColorMappingInstance CreateInstance(ColorPaletteResources targetResources)
 {
     return(new ColorMappingInstance(_source, _targetColor, targetResources));
 }