當前位置: 首頁>>代碼示例>>C#>>正文


C# Color.?.ToSolidColorBrush方法代碼示例

本文整理匯總了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;
                    }
            }
        }
開發者ID:dpakpaul,項目名稱:Template10,代碼行數:40,代碼來源:HamburgerMenu.PublicMethods.xaml.cs

示例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;
                    }
            }
        }
開發者ID:gsantopaolo,項目名稱:Template10,代碼行數:39,代碼來源:HamburgerMenu.PublicMethods.xaml.cs

示例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;
                }
            }
        }
開發者ID:shyamalschandra,項目名稱:Template10,代碼行數:77,代碼來源:HamburgerMenu.xaml.cs


注:本文中的Color.?.ToSolidColorBrush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。