public void RefreshStyles(Color? color = null) { DebugWrite($"Color: {color}"); if (color == null) color = AccentColor; if (color == default(Color)) return; // since every brush will be based on one color, // we will do so with theme in mind. switch (RequestedTheme) { case ElementTheme.Light: case ElementTheme.Default: case ElementTheme.Dark: { this.SetIfNotSet(NavAreaBackgroundProperty, Colors.Gainsboro.Darken(ColorUtils.Add._80p).ToSolidColorBrush()); this.SetIfNotSet(SecondarySeparatorProperty, Colors.DimGray.ToSolidColorBrush()); this.SetIfNotSet(PaneBorderBrushProperty, Colors.Transparent.ToSolidColorBrush()); this.SetIfNotSet(PaneBorderThicknessProperty, new Thickness(0)); this.SetIfNotSet(HamburgerForegroundProperty, Colors.White.ToSolidColorBrush()); this.SetIfNotSet(HamburgerBackgroundProperty, color?.ToSolidColorBrush()); this.SetIfNotSet(NavButtonForegroundProperty, Colors.White.Darken(ColorUtils.Add._20p).ToSolidColorBrush()); this.SetIfNotSet(NavButtonBackgroundProperty, Colors.Transparent.ToSolidColorBrush()); this.SetIfNotSet(NavButtonCheckedForegroundProperty, Colors.White.ToSolidColorBrush()); this.SetIfNotSet(NavButtonCheckedBackgroundProperty, Colors.Transparent.ToSolidColorBrush()); this.SetIfNotSet(NavButtonCheckedIndicatorBrushProperty, Colors.White.ToSolidColorBrush()); this.SetIfNotSet(NavButtonPressedForegroundProperty, Colors.White.Darken(ColorUtils.Add._30p).ToSolidColorBrush()); this.SetIfNotSet(NavButtonPressedBackgroundProperty, Colors.Transparent.ToSolidColorBrush()); this.SetIfNotSet(NavButtonHoverForegroundProperty, Colors.White.Darken(ColorUtils.Add._10p).ToSolidColorBrush()); this.SetIfNotSet(NavButtonHoverBackgroundProperty, Colors.Transparent.ToSolidColorBrush()); break; } } }
public void RefreshStyles(Color? color = null) { DebugWrite($"Color: {color}"); if (color == null) color = AccentColor; // since every brush will be based on one color, // we will do so with theme in mind. switch (RequestedTheme) { case ElementTheme.Light: case ElementTheme.Default: case ElementTheme.Dark: { NavAreaBackground = Colors.Gainsboro.Darken(ColorUtils.Add._80p).ToSolidColorBrush(); SecondarySeparator = Colors.DimGray.ToSolidColorBrush(); PaneBorderBrush = Colors.Transparent.ToSolidColorBrush(); HamburgerForeground = Colors.White.ToSolidColorBrush(); HamburgerBackground = color?.ToSolidColorBrush(); NavButtonForeground = Colors.White.Darken(ColorUtils.Add._20p).ToSolidColorBrush(); NavButtonBackground = Colors.Transparent.ToSolidColorBrush(); NavButtonCheckedForeground = Colors.White.ToSolidColorBrush(); NavButtonCheckedBackground = Colors.Transparent.ToSolidColorBrush(); NavButtonCheckedIndicatorBrush = Colors.White.ToSolidColorBrush(); NavButtonPressedForeground = Colors.White.Darken(ColorUtils.Add._30p).ToSolidColorBrush(); NavButtonPressedBackground = Colors.Transparent.ToSolidColorBrush(); NavButtonHoverForeground = Colors.White.Darken(ColorUtils.Add._10p).ToSolidColorBrush(); NavButtonHoverBackground = Colors.Transparent.ToSolidColorBrush(); break; } } }
public void RefreshStyles(Color? color = null) { if (color == null) { // manually setting the brushes is a way of ignoring the themes // in this block we will unset, then re-set the values var hamburgerBackground = HamburgerBackground; var hamburgerForeground = HamburgerForeground; var navAreaBackground = NavAreaBackground; var navButtonBackground = NavButtonBackground; var navButtonForeground = NavButtonForeground; var navButtonCheckedBackground = NavButtonCheckedBackground; var navButtonPressedBackground = NavButtonPressedBackground; var navButtonHoverBackground = NavButtonHoverBackground; var navButtonCheckedForeground = NavButtonCheckedForeground; var secondarySeparator = SecondarySeparator; HamburgerBackground = null; HamburgerForeground = null; NavAreaBackground = null; NavButtonBackground = null; NavButtonForeground = null; NavButtonCheckedBackground = null; NavButtonPressedBackground = null; NavButtonHoverBackground = null; NavButtonCheckedForeground = null; SecondarySeparator = null; HamburgerBackground = hamburgerBackground; HamburgerForeground = hamburgerForeground; NavAreaBackground = navAreaBackground; NavButtonBackground = navButtonBackground; NavButtonForeground = navButtonForeground; NavButtonCheckedBackground = navButtonCheckedBackground; NavButtonPressedBackground = navButtonPressedBackground; NavButtonHoverBackground = navButtonHoverBackground; NavButtonCheckedForeground = navButtonCheckedForeground; SecondarySeparator = secondarySeparator; } else { // since every brush will be based on one color, // we will do so with theme in mind. switch (RequestedTheme) { case ElementTheme.Light: HamburgerBackground = color?.ToSolidColorBrush(); HamburgerForeground = Colors.White.ToSolidColorBrush(); NavAreaBackground = Colors.DimGray.ToSolidColorBrush(); NavButtonBackground = Colors.Transparent.ToSolidColorBrush(); NavButtonForeground = Colors.White.ToSolidColorBrush(); NavButtonCheckedForeground = Colors.White.ToSolidColorBrush(); NavButtonCheckedBackground = color?.Lighten(ColorUtils.Accents.Plus20).ToSolidColorBrush(); NavButtonPressedBackground = Colors.Gainsboro.Darken(ColorUtils.Accents.Plus40).ToSolidColorBrush(); NavButtonHoverBackground = Colors.Gainsboro.Darken(ColorUtils.Accents.Plus60).ToSolidColorBrush(); NavButtonCheckedForeground = Colors.White.ToSolidColorBrush(); SecondarySeparator = Colors.Gainsboro.Darken(ColorUtils.Accents.Plus40).ToSolidColorBrush(); break; case ElementTheme.Default: case ElementTheme.Dark: HamburgerBackground = color?.ToSolidColorBrush(); HamburgerForeground = Colors.White.ToSolidColorBrush(); NavAreaBackground = Colors.Gainsboro.Darken(ColorUtils.Accents.Plus80).ToSolidColorBrush(); NavButtonBackground = Colors.Transparent.ToSolidColorBrush(); NavButtonForeground = Colors.White.ToSolidColorBrush(); NavButtonCheckedForeground = Colors.White.ToSolidColorBrush(); NavButtonCheckedBackground = color?.Darken(ColorUtils.Accents.Plus40).ToSolidColorBrush(); NavButtonPressedBackground = Colors.Gainsboro.Lighten(ColorUtils.Accents.Plus40).ToSolidColorBrush(); NavButtonHoverBackground = Colors.Gainsboro.Lighten(ColorUtils.Accents.Plus60).ToSolidColorBrush(); NavButtonCheckedForeground = Colors.White.ToSolidColorBrush(); SecondarySeparator = Colors.Gainsboro.ToSolidColorBrush(); break; } } }