当前位置: 首页>>代码示例>>C#>>正文


C# LinearGradientBrush.Freeze方法代码示例

本文整理汇总了C#中System.Windows.Media.LinearGradientBrush.Freeze方法的典型用法代码示例。如果您正苦于以下问题:C# LinearGradientBrush.Freeze方法的具体用法?C# LinearGradientBrush.Freeze怎么用?C# LinearGradientBrush.Freeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.LinearGradientBrush的用法示例。


在下文中一共展示了LinearGradientBrush.Freeze方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Convert

        public static GradientBrush Convert(System.Windows.Media.Color color)
        {
            var scrgb = color.ToScRGBColor();

            var xyz = KnownColorSpaces.scRGB.ToXYZColor(scrgb);

            var lab = KnownColorSpaces.Lab.FromXYZColor(xyz) as LabColor;

            var l_base = lab.L;

            var gradientStops = new GradientStopCollection();

            var _lab = new LabColor(0xff, l_base * 1.07, lab.a, lab.b);
            var _c = _lab.ToWindowsMediaColor();

            gradientStops.Add(new GradientStop(_c, 0.5));


            _lab = new LabColor(0xff, l_base * .93, lab.a, lab.b);
            _c = _lab.ToWindowsMediaColor();

            gradientStops.Add(new GradientStop(_c, 1));


            var result = new LinearGradientBrush(gradientStops, 90);

            result.Freeze();

            return result;
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:30,代码来源:ColorToGradientBrushConverter.cs

示例2: ResizeChrome

		static ResizeChrome()
		{
			TransparentBrush = Brushes.Transparent;
			TransparentBrush.Freeze();
			var borderBrush = new LinearGradientBrush()
			{
				Opacity = 0.7,
				StartPoint = new Point(0, 0),
				EndPoint = new Point(1, 0.3),

			};
			borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 0));
			borderBrush.GradientStops.Add(new GradientStop(Colors.LightBlue, 0.5));
			borderBrush.GradientStops.Add(new GradientStop(Colors.SlateBlue, 1));
			borderBrush.Freeze();
			BorderBrush = borderBrush;
			var thumbBrush = new RadialGradientBrush()
			{
				Center = new Point(0.3, 0.3),
				GradientOrigin = new Point(0.3, 0.3),
				RadiusX = 0.7,
				RadiusY = 0.7,
			};
			thumbBrush.GradientStops.Add(new GradientStop(Colors.White, 0));
			thumbBrush.GradientStops.Add(new GradientStop(Colors.DarkSlateBlue, 0.9));
			thumbBrush.Freeze();
			ThumbBrush = thumbBrush;
			TransparentPen = new Pen(TransparentBrush, 3.5);
			BorderPen = new Pen(BorderBrush, 2);
			BorderPen.DashStyle = DashStyles.Dash;
			ThumbGeometry = new EllipseGeometry();
			UpdateZoom(1);
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:33,代码来源:ResizeChrome.cs

示例3: CreateFrozenBrush

        protected static LinearGradientBrush CreateFrozenBrush(GradientStopCollection stops, Point start, Point end)
        {
            var brush = new LinearGradientBrush(stops, start, end);

            brush.Freeze();

            return brush;
        }
开发者ID:HEskandari,项目名称:FarsiLibrary,代码行数:8,代码来源:ButtonChrome.cs

示例4: ColorManager

 static ColorManager()
 {
     var brush = new LinearGradientBrush();
     brush.GradientStops.Add(new GradientStop(Colors.Red, 0));
     brush.GradientStops.Add(new GradientStop(Colors.Green, .5));
     brush.GradientStops.Add(new GradientStop(Colors.Blue, 1));
     brush.Freeze();
     RgbBrush = brush;
 }
开发者ID:kjburns31,项目名称:vixen-modules,代码行数:9,代码来源:ColorManager.cs

示例5: AssocColor

        public void AssocColor(string seriesId, Color b)
        {
            Color bTransparent = b;
            bTransparent.A = 0;

            GradientStopCollection gs = new GradientStopCollection();
            gs.Add(new GradientStop(bTransparent, 0));
            gs.Add(new GradientStop(b, 0.1));
            LinearGradientBrush g = new LinearGradientBrush(gs, new Point(0,0), new Point(ActualWidth, 0));
            g.MappingMode = BrushMappingMode.Absolute;
            g.Freeze();
            brushes[seriesId] = g;
        }
开发者ID:23119841,项目名称:FERA-2015,代码行数:13,代码来源:AVPlot.xaml.cs

示例6: Tooltip

        static Tooltip()
        {
            timer = new DispatcherTimer(TimeSpan.FromMilliseconds(1500), DispatcherPriority.Normal,
                delegate { timer.Stop(); ttip.IsOpen = false; },
                Application.Current.Dispatcher);

            var fillBrush = new LinearGradientBrush(Color.FromRgb(223, 20, 20), Color.FromRgb(255, 116, 116), 90);
            fillBrush.Freeze();

            ttip.BorderBrush = Brushes.Black;
            ttip.BorderThickness = new Thickness(1);
            ttip.Background = fillBrush;
            ttip.Placement = PlacementMode.MousePoint;
            ttip.Padding = new Thickness(20, 8, 20, 8);
        }
开发者ID:kellyelton,项目名称:octgnwlobby,代码行数:15,代码来源:Tooltip.cs

示例7: End

		public override void End()
		{
			Color newColor = Colors.Transparent;
			if (this.TurnNumber % 2 == 0)
				newColor = Colors.DarkGray;
				//expTurns.BorderBrush = Brushes.DarkGray;
			else
				newColor = Colors.DimGray;
				//expTurns.BorderBrush = Brushes.DimGray;

			lEdge.Stroke = new SolidColorBrush(newColor);
			LinearGradientBrush lgb = new LinearGradientBrush(new GradientStopCollection() { 
				new GradientStop(newColor, 0.0), 
				new GradientStop(newColor, 0.25), 
				new GradientStop(Colors.Transparent, 1.25) });
			lgb.Freeze();
			lTop.Stroke = lBottom.Stroke = lgb;
		}
开发者ID:micahpaul,项目名称:dominion_net_multi,代码行数:18,代码来源:ucGameTurn.xaml.cs

示例8: CreateBrushes

        // *** Private static methods ***
        private static void CreateBrushes()
        {
            // Get the colors for the shadow
            Color shadowColor = Color.FromArgb(128, 0, 0, 0);
            Color transparentColor = Color.FromArgb(16, 0, 0, 0);
            // Create a GradientStopCollection from these
            GradientStopCollection gradient = new GradientStopCollection(2);
            gradient.Add(new GradientStop(shadowColor, 0.5));
            gradient.Add(new GradientStop(transparentColor, 1.0));
            gradient.Freeze();
            // Create the background brush
            backgroundBrush = new SolidColorBrush(shadowColor);
            backgroundBrush.Freeze();
            // Create the LinearGradientBrushes
            rightBrush = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(1.0, 0.0)); rightBrush.Freeze();
            bottomBrush = new LinearGradientBrush(gradient, new Point(0.0, 0.0), new Point(0.0, 1.0)); bottomBrush.Freeze();
            // Create the RadialGradientBrushes
            bottomRightBrush = new RadialGradientBrush(gradient);
            bottomRightBrush.GradientOrigin = new Point(0.0, 0.0);
            bottomRightBrush.Center = new Point(0.0, 0.0);
            bottomRightBrush.RadiusX = 1.0;
            bottomRightBrush.RadiusY = 1.0;
            bottomRightBrush.Freeze();

            topRightBrush = new RadialGradientBrush(gradient);
            topRightBrush.GradientOrigin = new Point(0.0, 1.0);
            topRightBrush.Center = new Point(0.0, 1.0);
            topRightBrush.RadiusX = 1.0;
            topRightBrush.RadiusY = 1.0;
            topRightBrush.Freeze();

            bottomLeftBrush = new RadialGradientBrush(gradient);
            bottomLeftBrush.GradientOrigin = new Point(1.0, 0.0);
            bottomLeftBrush.Center = new Point(1.0, 0.0);
            bottomLeftBrush.RadiusX = 1.0;
            bottomLeftBrush.RadiusY = 1.0;
            bottomLeftBrush.Freeze();
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:39,代码来源:ShadowChrome.cs

示例9: Timer_Tick

        private void Timer_Tick(object sender, EventArgs e)
        {
            var minHeight = barContainer.ActualHeight * 0.1;
            bar.Height = (bar.Height-minHeight) * 0.9 + ((barContainer.ActualHeight-minHeight) * targetValue) * 0.1 + minHeight;

            if (confidence != targetConfidence)
            {
                confidence = confidence * 0.9 + targetConfidence * 0.1;

                if (Math.Abs(confidence - targetConfidence) < 0.0001)
                    confidence = targetConfidence;

                Color bTransparent = Colors.CadetBlue;
                bTransparent.A = 0;

                GradientStopCollection gs = new GradientStopCollection();
                gs.Add(new GradientStop(bTransparent, 0));
                gs.Add(new GradientStop(Colors.CadetBlue, 1));
                LinearGradientBrush g = new LinearGradientBrush(gs, new Point(0, 0), new Point(0, bar.Height*(1-confidence)));
                g.MappingMode = BrushMappingMode.Absolute;
                g.Freeze();
                bar.Fill = g;
            }
        }
开发者ID:haolinwei,项目名称:FERA-2015,代码行数:24,代码来源:BarGraph.xaml.cs

示例10: DonationControl

        public DonationControl()
        {
            SetCols(2);
            SetRows(5);

            Width = 250;
            VerticalAlignment = VerticalAlignment.Top;
            HorizontalAlignment = HorizontalAlignment.Left;
            Margin = new Thickness(5);
            DataContext = this;
            ColumnDefinitions[0].Width = GridLength.Auto;

            LinearGradientBrush backgroundStroke = new LinearGradientBrush
            {
                EndPoint = new Point(0.5, 1),
                StartPoint = new Point(0.5, 0),
                RelativeTransform = new RotateTransform(115, 0.5, 0.5),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0),
                    new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504),
                    new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1)
                }
            };
            backgroundStroke.Freeze();

            LinearGradientBrush backgroundFill = new LinearGradientBrush
            {
                MappingMode = BrushMappingMode.RelativeToBoundingBox,
                StartPoint = new Point(0.5, 1.0),
                EndPoint = new Point(0.5, -0.4),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0),
                    new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1)
                }
            };
            backgroundFill.Freeze();

            Rectangle backround = AddUiElement(new Rectangle {Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5}, 0, 0, 9, 2);

            UiTextBlock title = AddUiElement(UiTextBlockFactory.Create("Пожертвования"), 0, 0, 0, 2);
            title.FontSize = 18;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            title.Margin = new Thickness(0, 4, 0, 0);

            AddUiElement(UiTextBoxFactory.Create("Яндекс: "), 1, 0);
            AddUiElement(UiTextBoxFactory.Create("410013254932482"), 1, 1);
            AddUiElement(UiTextBoxFactory.Create("WMR: "), 2, 0);
            AddUiElement(UiTextBoxFactory.Create("R255847965836"), 2, 1);
            AddUiElement(UiTextBoxFactory.Create("WMZ: "), 3, 0);
            AddUiElement(UiTextBoxFactory.Create("Z321220468886 "), 3, 1);
            AddUiElement(UiTextBoxFactory.Create("WME: "), 4, 0);
            AddUiElement(UiTextBoxFactory.Create("E223137827385"), 4, 1).Margin = new Thickness(0,0,0,5);

            foreach (FrameworkElement child in Children)
            {
                if (!ReferenceEquals(child, backround))
                {
                    child.Margin = GetColumn(child) == 0
                        ? new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right, child.Margin.Bottom)
                        : new Thickness(child.Margin.Left, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom);
                }

                TextBlock textBlock = child as TextBlock;
                if (textBlock != null)
                {
                    textBlock.Foreground = Brushes.WhiteSmoke;
                    textBlock.FontWeight = FontWeight.FromOpenTypeWeight(500);
                    continue;
                }

                TextBox textBox = child as TextBox;
                if (textBox != null)
                {
                    textBox.Foreground = Brushes.WhiteSmoke;
                    textBox.FontWeight = FontWeight.FromOpenTypeWeight(500);
                    textBox.Background = Brushes.Transparent;
                    textBox.BorderThickness = new Thickness(0);
                    textBox.IsReadOnly = true;
                }
            }
        }
开发者ID:akimoto-akira,项目名称:Pulse,代码行数:83,代码来源:DonationControl.cs

示例11: RenderTheme

        private void RenderTheme(DrawingContext dc)
        {
            Size size = RenderSize;
            bool horizontal = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered = isClickable && IsHovered;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool isSelected = IsSelected;

            EnsureCache((int)RoyaleFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width = size.Height;
                size.Height = temp;
            }

            // Draw the background
            RoyaleFreezables backgroundType = isPressed ? RoyaleFreezables.PressedBackground : isHovered ? RoyaleFreezables.HoveredBackground : RoyaleFreezables.NormalBackground;
            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
            if (background == null)
            {
                background = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint = new Point(0.0, 1.0);

                if (isPressed)
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB9, 0xB9, 0xC8), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 0.1));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 1.0));
                }
                else if (isHovered || isSelected)
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.85));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                }
                else
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.85));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                }

                background.Freeze();
                CacheFreezable(background, (int)backgroundType);
            }

            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if (isHovered && !isPressed && (size.Width >= 6.0) && (size.Height >= 4.0))
            {
                // When hovered, there is a colored tab at the bottom
                TranslateTransform positionTransform = new TranslateTransform(0.0, size.Height - 3.0);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                PathGeometry tabGeometry = new PathGeometry();
                PathFigure tabFigure = new PathFigure();

                tabFigure.StartPoint = new Point(0.5, 0.5);

                LineSegment line = new LineSegment(new Point(size.Width - 0.5, 0.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                ArcSegment arc = new ArcSegment(new Point(size.Width - 2.5, 2.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                line = new LineSegment(new Point(2.5, 2.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                arc = new ArcSegment(new Point(0.5, 0.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                tabFigure.IsClosed = true;
                tabFigure.Freeze();

                tabGeometry.Figures.Add(tabFigure);
                tabGeometry.Freeze();

                Pen tabStroke = (Pen)GetCachedFreezable((int)RoyaleFreezables.TabStroke);
                if (tabStroke == null)
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:DataGridHeaderBorder.cs

示例12: RenderAeroNormalColor

        private void RenderAeroNormalColor(DrawingContext dc)
        {
            Size size = RenderSize;
            bool horizontal = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered = isClickable && IsHovered;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool isSelected = IsSelected;
            bool hasBevel = (!isHovered && !isPressed && !isSorted && !isSelected);

            EnsureCache((int)AeroFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width = size.Height;
                size.Height = temp;
            }

            if (hasBevel)
            {
                // This is a highlight that can be drawn by just filling the background with the color.
                // It will be seen through the gab between the border and the background.
                LinearGradientBrush bevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.NormalBevel);
                if (bevel == null)
                {
                    bevel = new LinearGradientBrush();
                    bevel.StartPoint = new Point();
                    bevel.EndPoint = new Point(0.0, 1.0);
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFD), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFB, 0xFC, 0xFC), 1.0));
                    bevel.Freeze();

                    CacheFreezable(bevel, (int)AeroFreezables.NormalBevel);
                }

                dc.DrawRectangle(bevel, null, new Rect(0.0, 0.0, size.Width, size.Height));
            }

            // Fill the background
            AeroFreezables backgroundType = AeroFreezables.NormalBackground;
            if (isPressed)
            {
                backgroundType = AeroFreezables.PressedBackground;
            }
            else if (isHovered)
            {
                backgroundType = AeroFreezables.HoveredBackground;
            }
            else if (isSorted || isSelected)
            {
                backgroundType = AeroFreezables.SortedBackground;
            }

            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
            if (background == null)
            {
                background = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint = new Point(0.0, 1.0);

                switch (backgroundType)
                {
                    case AeroFreezables.NormalBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF7, 0xF8, 0xFA), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0xF2, 0xF4), 1.0));
                        break;

                    case AeroFreezables.PressedBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8D, 0xD6, 0xF7), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8A, 0xD1, 0xF5), 1.0));
                        break;

                    case AeroFreezables.HoveredBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xED, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xE7, 0xFB), 1.0));
                        break;

                    case AeroFreezables.SortedBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.0));
//.........这里部分代码省略.........
开发者ID:pusp,项目名称:o2platform,代码行数:101,代码来源:DataGridHeaderBorder.cs

示例13: GetRandomBrush

 Brush GetRandomBrush()
 {
     byte[] b = new byte[4];
     randy.NextBytes(b);
     Color c1 = Color.FromRgb(b[0], b[1], b[2]);
     randy.NextBytes(b);
     Color c2 = Color.FromRgb(b[0], b[1], b[2]);
     Brush brush = new LinearGradientBrush(c1, c2, 90);
     brush.Freeze();
     return brush;
 }
开发者ID:wolfoerster,项目名称:WFTools3D,代码行数:11,代码来源:MainWindow.xaml.cs

示例14: GameSettingsControl

        public GameSettingsControl()
        {
            SetCols(2);
            SetRows(9);

            Width = 250;
            VerticalAlignment = VerticalAlignment.Top;
            HorizontalAlignment = HorizontalAlignment.Left;
            Margin = new Thickness(5);
            DataContext = this;

            _info = InteractionService.LocalizatorEnvironment.Provide();
            InteractionService.LocalizatorEnvironment.InfoProvided += OnLocalizatorEnvironmentProvided;

            LinearGradientBrush backgroundStroke = new LinearGradientBrush
            {
                EndPoint = new Point(0.5, 1),
                StartPoint = new Point(0.5, 0),
                RelativeTransform = new RotateTransform(115, 0.5, 0.5),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0),
                    new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504),
                    new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1)
                }
            };
            backgroundStroke.Freeze();

            LinearGradientBrush backgroundFill = new LinearGradientBrush
            {
                MappingMode = BrushMappingMode.RelativeToBoundingBox,
                StartPoint = new Point(0.5, 1.0),
                EndPoint = new Point(0.5, -0.4),
                GradientStops = new GradientStopCollection
                {
                    new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0),
                    new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1)
                }
            };
            backgroundFill.Freeze();

            Rectangle backround = AddUiElement(new Rectangle {Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5}, 0, 0, 9, 2);

            InverseBoolConverter inverseBoolConverter = new InverseBoolConverter();
            Thickness rowMargin = new Thickness(0, 8, 0, 3);

            const string screenGroup = "Отображение:";
            AddUiElement(UiTextBlockFactory.Create(screenGroup), 0, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Экран", true), 1, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen") {Mode = BindingMode.TwoWay});
            AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Окно", false), 1, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen") {Mode = BindingMode.TwoWay, Converter = inverseBoolConverter});

            const string resolutionGroup = "Разрешение:";
            AddUiElement(UiTextBlockFactory.Create(resolutionGroup), 2, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1920x1080", true), 3, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd") {Mode = BindingMode.TwoWay});
            AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1280x720", false), 3, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd") {Mode = BindingMode.TwoWay, Converter = inverseBoolConverter});

            const string voiceGroup = "Озвучка:";
            AddUiElement(UiTextBlockFactory.Create(voiceGroup), 4, 0, 0, 2).Margin = rowMargin;
            AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Японская", true), 5, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice") {Mode = BindingMode.TwoWay});
            AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Английская", false), 5, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice") {Mode = BindingMode.TwoWay, Converter = inverseBoolConverter});

            UiCheckBox switchButtons = AddUiElement(UiCheckBoxFactory.Create("Поменять кнопки X/O", null), 6, 0, 0, 2);
            switchButtons.Margin = rowMargin;
            switchButtons.IsThreeState = true;
            switchButtons.SetBinding(ToggleButton.IsCheckedProperty, new Binding("SwitchButtons") {Mode = BindingMode.TwoWay});

            AddUiElement(UiTextBlockFactory.Create("MSAA:"), 7, 0).Margin = rowMargin;
            UiComboBox antiAliasing = AddUiElement(UiComboBoxFactory.Create(), 8, 0);
            antiAliasing.ItemStringFormat = "x{0}";
            antiAliasing.ItemsSource = new[] {2, 4, 8, 16};
            antiAliasing.SelectedIndex = 3;
            antiAliasing.SetBinding(Selector.SelectedItemProperty, new Binding("AntiAliasing") {Mode = BindingMode.TwoWay});
            antiAliasing.Margin = new Thickness(0, 0, 0, 8);

            AddUiElement(UiTextBlockFactory.Create("Тени:"), 7, 1).Margin = rowMargin;
            UiComboBox shadows = AddUiElement(UiComboBoxFactory.Create(), 8, 1);
            shadows.ItemStringFormat = "{0}x{0}";
            shadows.ItemsSource = new[] {512, 1024, 2048, 4096, 8192};
            shadows.SelectedIndex = 1;
            shadows.SetBinding(Selector.SelectedItemProperty, new Binding("ShadowResolution") {Mode = BindingMode.TwoWay});
            shadows.Margin = new Thickness(0, 0, 0, 8);

            foreach (FrameworkElement child in Children)
            {
                if (!ReferenceEquals(child, backround))
                    child.Margin = new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom);

                TextBlock textblock = child as TextBlock;
                if (textblock != null)
                {
                    textblock.Foreground = Brushes.WhiteSmoke;
                    textblock.FontWeight = FontWeight.FromOpenTypeWeight(500);
                    continue;
                }

                Control control = child as Control;
                if (control != null && !(control is ComboBox))
                    control.Foreground = Brushes.WhiteSmoke;
            }
        }
开发者ID:akimoto-akira,项目名称:Pulse,代码行数:100,代码来源:GameSettingsControl.cs

示例15: CreateBrushes

        // Creates an array of brushes needed to render this 
        private static Brush[] CreateBrushes(Color c, CornerRadius cornerRadius)
        {
            Brush[] brushes = new Brush[9];

            // Create center brush
            brushes[Center] = new SolidColorBrush(c);
            brushes[Center].Freeze();



            // Sides
            GradientStopCollection sideStops = CreateStops(c, 0);
            LinearGradientBrush top = new LinearGradientBrush(sideStops, new Point(0, 1), new Point(0, 0));
            top.Freeze();
            brushes[Top] = top;

            LinearGradientBrush left = new LinearGradientBrush(sideStops, new Point(1, 0), new Point(0, 0));
            left.Freeze();
            brushes[Left] = left;

            LinearGradientBrush right = new LinearGradientBrush(sideStops, new Point(0, 0), new Point(1, 0));
            right.Freeze();
            brushes[Right] = right;

            LinearGradientBrush bottom = new LinearGradientBrush(sideStops, new Point(0, 0), new Point(0, 1));
            bottom.Freeze();
            brushes[Bottom] = bottom;

            // Corners

            // Use side stops if the corner radius is 0
            GradientStopCollection topLeftStops;
            if (cornerRadius.TopLeft == 0)
                topLeftStops = sideStops;
            else
                topLeftStops = CreateStops(c, cornerRadius.TopLeft);

            RadialGradientBrush topLeft = new RadialGradientBrush(topLeftStops);
            topLeft.RadiusX = 1;
            topLeft.RadiusY = 1;
            topLeft.Center = new Point(1, 1);
            topLeft.GradientOrigin = new Point(1, 1);
            topLeft.Freeze();
            brushes[TopLeft] = topLeft;

            // Reuse previous stops if corner radius is the same as side or top left
            GradientStopCollection topRightStops;
            if (cornerRadius.TopRight == 0)
                topRightStops = sideStops;
            else if (cornerRadius.TopRight == cornerRadius.TopLeft)
                topRightStops = topLeftStops;
            else
                topRightStops = CreateStops(c, cornerRadius.TopRight);

            RadialGradientBrush topRight = new RadialGradientBrush(topRightStops);
            topRight.RadiusX = 1;
            topRight.RadiusY = 1;
            topRight.Center = new Point(0, 1);
            topRight.GradientOrigin = new Point(0, 1);
            topRight.Freeze();
            brushes[TopRight] = topRight;

            // Reuse previous stops if corner radius is the same as any of the previous radii
            GradientStopCollection bottomLeftStops;
            if (cornerRadius.BottomLeft == 0)
                bottomLeftStops = sideStops;
            else if (cornerRadius.BottomLeft == cornerRadius.TopLeft)
                bottomLeftStops = topLeftStops;
            else if (cornerRadius.BottomLeft == cornerRadius.TopRight)
                bottomLeftStops = topRightStops;
            else
                bottomLeftStops = CreateStops(c, cornerRadius.BottomLeft);

            RadialGradientBrush bottomLeft = new RadialGradientBrush(bottomLeftStops);
            bottomLeft.RadiusX = 1;
            bottomLeft.RadiusY = 1;
            bottomLeft.Center = new Point(1, 0);
            bottomLeft.GradientOrigin = new Point(1, 0);
            bottomLeft.Freeze();
            brushes[BottomLeft] = bottomLeft;

            // Reuse previous stops if corner radius is the same as any of the previous radii
            GradientStopCollection bottomRightStops;
            if (cornerRadius.BottomRight == 0)
                bottomRightStops = sideStops;
            else if (cornerRadius.BottomRight == cornerRadius.TopLeft)
                bottomRightStops = topLeftStops;
            else if (cornerRadius.BottomRight == cornerRadius.TopRight)
                bottomRightStops = topRightStops;
            else if (cornerRadius.BottomRight == cornerRadius.BottomLeft)
                bottomRightStops = bottomLeftStops;
            else
                bottomRightStops = CreateStops(c, cornerRadius.BottomRight);

            RadialGradientBrush bottomRight = new RadialGradientBrush(bottomRightStops);
            bottomRight.RadiusX = 1;
            bottomRight.RadiusY = 1;
            bottomRight.Center = new Point(0, 0);
            bottomRight.GradientOrigin = new Point(0, 0);
//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:SystemDropShadowChrome.cs


注:本文中的System.Windows.Media.LinearGradientBrush.Freeze方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。