本文整理汇总了C#中Color.?.ToSolidColorBrush方法的典型用法代码示例。如果您正苦于以下问题:C# Color.?.ToSolidColorBrush方法的具体用法?C# Color.?.ToSolidColorBrush怎么用?C# Color.?.ToSolidColorBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color.?.ToSolidColorBrush方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshStyles
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;
}
}
}
示例2: RefreshStyles
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;
}
}
}
示例3: RefreshStyles
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;
}
}
}