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


C# TranslateTransform.Freeze方法代码示例

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


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

示例1: ArrangeCore

		protected override void ArrangeCore(Rect finalRect) {
			double x = lineStart.X, y = lineStart.Y;
			foreach (var line in hexLines) {
				var visual = line.GetOrCreateDrawingVisual();
				var t = new TranslateTransform((int)x, (int)y);
				t.Freeze();
				visual.Transform = t;
				y += line.Height;
			}
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:10,代码来源:HexLineLayer.cs

示例2: InitializeTransform

        /// <summary>  </summary>
        public override void InitializeTransform()
        {
            double mercatorSize = 360;
            TranslateTransform translateTransform = new TranslateTransform(MapView.ReferenceSize / 2 - 180, MapView.ReferenceSize / 2 - 180);
            ScaleTransform zoomTransform = new ScaleTransform(MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ZoomAdjust * MapView.ReferenceSize / mercatorSize, MapView.ReferenceSize / 2, MapView.ReferenceSize / 2);
            TransformGroup transformGroup = new TransformGroup();
            transformGroup.Children.Add(translateTransform);
            transformGroup.Children.Add(zoomTransform);

            zoomTransform.Freeze();
            translateTransform.Freeze();
            transformGroup.Freeze();

            this.RenderTransform = transformGroup;
        }
开发者ID:MuffPotter,项目名称:xservernet-bin,代码行数:16,代码来源:VectorLayer.cs

示例3: RenderTheme

        private void RenderTheme(DrawingContext dc)
        {
            Size size = RenderSize;
            bool isClickable = IsClickable && IsEnabled;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool horizontal = Orientation == Orientation.Horizontal;
            Brush background = EnsureControlBrush();
            Brush light = SystemColors.ControlLightBrush;
            Brush dark = SystemColors.ControlDarkBrush;
            bool shouldDrawRight = true;
            bool shouldDrawBottom = true;
            bool usingSeparatorBrush = false;

            Brush darkDarkRight = null;
            if (!horizontal)
            {
                if (SeparatorVisibility == Visibility.Visible && SeparatorBrush != null)
                {
                    darkDarkRight = SeparatorBrush;
                    usingSeparatorBrush = true;
                }
                else
                {
                    shouldDrawRight = false;
                }
            }
            else
            {
                darkDarkRight = SystemColors.ControlDarkDarkBrush;
            }

            Brush darkDarkBottom = null;
            if (horizontal)
            {
                if (SeparatorVisibility == Visibility.Visible && SeparatorBrush != null)
                {
                    darkDarkBottom = SeparatorBrush;
                    usingSeparatorBrush = true;
                }
                else
                {
                    shouldDrawBottom = false;
                }
            }
            else
            {
                darkDarkBottom = SystemColors.ControlDarkDarkBrush;
            }

            EnsureCache((int)ClassicFreezables.NumFreezables);

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

            if ((size.Width > 3.0) && (size.Height > 3.0))
            {
                // Draw the border
                if (isPressed)
                {
                    dc.DrawRectangle(dark, null, new Rect(0.0, 0.0, size.Width, 1.0));
                    dc.DrawRectangle(dark, null, new Rect(0.0, 0.0, 1.0, size.Height));
                    dc.DrawRectangle(dark, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
                    dc.DrawRectangle(dark, null, new Rect(Max0(size.Width - 1.0), 0.0, 1.0, size.Height));
                }
                else
                {
                    dc.DrawRectangle(light, null, new Rect(0.0, 0.0, 1.0, Max0(size.Height - 1.0)));
                    dc.DrawRectangle(light, null, new Rect(0.0, 0.0, Max0(size.Width - 1.0), 1.0));

                    if (shouldDrawRight)
                    {
                        if (!usingSeparatorBrush)
                        {
                            dc.DrawRectangle(dark, null, new Rect(Max0(size.Width - 2.0), 1.0, 1.0, Max0(size.Height - 2.0)));
                        }

                        dc.DrawRectangle(darkDarkRight, null, new Rect(Max0(size.Width - 1.0), 0.0, 1.0, size.Height));
                    }

                    if (shouldDrawBottom)
                    {
                        if (!usingSeparatorBrush)
                        {
                            dc.DrawRectangle(dark, null, new Rect(1.0, Max0(size.Height - 2.0), Max0(size.Width - 2.0), 1.0));
                        }

                        dc.DrawRectangle(darkDarkBottom, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
                    }
                }
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // If sorted, draw an arrow on the right
                TranslateTransform positionTransform = new TranslateTransform(size.Width - 15.0, (size.Height - 5.0) * 0.5);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

//.........这里部分代码省略.........
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:DataGridHeaderBorder.cs

示例4: SetLayoutOffset

        /// <summary>
        /// This is the method layout parent uses to set a location of the child 
        /// relative to parent's visual as a result of layout. Typically, this is called
        /// by the parent inside of its ArrangeOverride implementation after calling Arrange on a child. 
        /// Note that this method resets layout tarnsform set by <see cref="InternalSetLayoutTransform"/> method, 
        /// so only one of these two should be used by the parent.
        /// </summary> 
        private void SetLayoutOffset(Vector offset, Size oldRenderSize)
        {
            //
            // Attempt to avoid changing the transform more often than needed, 
            // such as when a parent is arrange dirty but its children aren't.
            // 
            // The dependencies for VisualTransform are as follows: 
            //     Mirror
            //         RenderSize.Width 
            //         FlowDirection
            //         parent.FlowDirection
            //     RenderTransform
            //         RenderTransformOrigin 
            //     LayoutTransform
            //         RenderSize 
            //         Width, MinWidth, MaxWidth 
            //         Height, MinHeight, MaxHeight
            // 
            // The AreTransformsClean flag will be false (dirty) when FlowDirection,
            // RenderTransform, LayoutTransform, Min/Max/Width/Height, or
            // RenderTransformOrigin changes.
            // 
            // RenderSize is compared here with the previous size to see if it changed.
            // 
            if (!AreTransformsClean || !DoubleUtil.AreClose(RenderSize, oldRenderSize)) 
            {
                Transform additionalTransform = GetFlowDirectionTransform(); //rtl 

                Transform renderTransform = this.RenderTransform;
                if(renderTransform == Transform.Identity) renderTransform = null;
 
                LayoutTransformData ltd = LayoutTransformDataField.GetValue(this);
 
                TransformGroup t = null; 

                //arbitrary transform, create a collection 
                if (additionalTransform != null
                    || renderTransform != null
                    || ltd != null)
                { 
                    // Create a TransformGroup and make sure it does not participate
                    // in the InheritanceContext treeness because it is internal operation only. 
                    t = new TransformGroup(); 
                    t.CanBeInheritanceContext = false;
                    t.Children.CanBeInheritanceContext = false; 

                    if (additionalTransform != null)
                        t.Children.Add(additionalTransform);
 
                    if(ltd != null)
                    { 
                        t.Children.Add(ltd.Transform); 

                        // see if  MaxWidth/MaxHeight limit the element 
                        MinMax mm = new MinMax(this);

                        //this is in element's local rendering coord system
                        Size inkSize = this.RenderSize; 

                        double maxWidthClip = (Double.IsPositiveInfinity(mm.maxWidth) ? inkSize.Width : mm.maxWidth); 
                        double maxHeightClip = (Double.IsPositiveInfinity(mm.maxHeight) ? inkSize.Height : mm.maxHeight); 

                        //get the size clipped by the MaxWidth/MaxHeight/Width/Height 
                        inkSize.Width = Math.Min(inkSize.Width, mm.maxWidth);
                        inkSize.Height = Math.Min(inkSize.Height, mm.maxHeight);

                        Rect inkRectTransformed = Rect.Transform(new Rect(inkSize), ltd.Transform.Value); 

                        t.Children.Add(new TranslateTransform(-inkRectTransformed.X, -inkRectTransformed.Y)); 
                    } 

                    if (renderTransform != null) 
                    {
                        Point origin = GetRenderTransformOrigin();
                        bool hasOrigin = (origin.X != 0d || origin.Y != 0d);
                        if (hasOrigin) 
                        {
                            TranslateTransform backOrigin = new TranslateTransform(-origin.X, -origin.Y); 
                            backOrigin.Freeze(); 
                            t.Children.Add(backOrigin);
                        } 

                        //can not freeze render transform - it can be animated
                        t.Children.Add(renderTransform);
 
                        if (hasOrigin)
                        { 
                            TranslateTransform forwardOrigin = new TranslateTransform(origin.X, origin.Y); 
                            forwardOrigin.Freeze();
                            t.Children.Add(forwardOrigin); 
                        }

                    }
//.........这里部分代码省略.........
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:101,代码来源:FrameworkElement.cs

示例5: OnRender

			protected override void OnRender(DrawingContext drawingContext)
			{
				var renderSize = this.RenderSize;
				var document = editor.Document;
				var textView = editor.TextArea.TextView;
				double documentHeight = textView.DocumentHeight;
				foreach (var marker in textMarkerService.TextMarkers) {
					if (!IsVisibleInAdorner(marker))
						continue;
					var location = document.GetLocation(marker.StartOffset);
					double visualTop = textView.GetVisualTopByDocumentLine(location.Line);
					double renderPos = visualTop / documentHeight * renderSize.Height;
					var brush = GetBrush(marker.MarkerColor);
					bool isLineOrCircle = false;
					if ((marker.MarkerTypes & (TextMarkerTypes.LineInScrollBar)) != 0) {
						drawingContext.DrawRectangle(brush, null, new Rect(3, renderPos - 1, renderSize.Width - 6, 2));
						isLineOrCircle = true;
					}
					if ((marker.MarkerTypes & (TextMarkerTypes.CircleInScrollBar)) != 0) {
						const double radius = 3;
						drawingContext.DrawEllipse(brush, null, new Point(renderSize.Width / 2, renderPos), radius, radius);
						isLineOrCircle = true;
					}
					if (!isLineOrCircle) {
						var translateTransform = new TranslateTransform(6, renderPos);
						translateTransform.Freeze();
						drawingContext.PushTransform(translateTransform);
					
						if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarLeftTriangle)) != 0) {
							var scaleTransform = new ScaleTransform(-1, 1);
							scaleTransform.Freeze();
							drawingContext.PushTransform(scaleTransform);
							drawingContext.DrawGeometry(brush, null, triangleGeometry);
							drawingContext.Pop();
						}
						if ((marker.MarkerTypes & (TextMarkerTypes.ScrollBarRightTriangle)) != 0) {
							drawingContext.DrawGeometry(brush, null, triangleGeometry);
						}
						drawingContext.Pop();
					}
				}
			}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:42,代码来源:EnhancedScrollBar.cs

示例6: SetLayoutOffset

 private void SetLayoutOffset(Vector offset, Size oldRenderSize)
 {
     if (!this.AreTransformsClean || !DoubleUtil.AreClose(this.RenderSize, oldRenderSize))
       {
     Transform directionTransform = this.GetFlowDirectionTransform();
     Transform transform = this.RenderTransform;
     if (transform == Transform.Identity)
       transform = (Transform) null;
     FrameworkElement.LayoutTransformData layoutTransformData = FrameworkElement.LayoutTransformDataField.GetValue((DependencyObject) this);
     TransformGroup transformGroup = (TransformGroup) null;
     if (directionTransform != null || transform != null || layoutTransformData != null)
     {
       transformGroup = new TransformGroup();
       transformGroup.CanBeInheritanceContext = false;
       transformGroup.Children.CanBeInheritanceContext = false;
       if (directionTransform != null)
     transformGroup.Children.Add(directionTransform);
       if (layoutTransformData != null)
       {
     transformGroup.Children.Add(layoutTransformData.Transform);
     FrameworkElement.MinMax minMax = new FrameworkElement.MinMax(this);
     Size renderSize = this.RenderSize;
     if (double.IsPositiveInfinity(minMax.maxWidth))
     {
       double width = renderSize.Width;
     }
     if (double.IsPositiveInfinity(minMax.maxHeight))
     {
       double height = renderSize.Height;
     }
     renderSize.Width = Math.Min(renderSize.Width, minMax.maxWidth);
     renderSize.Height = Math.Min(renderSize.Height, minMax.maxHeight);
     Rect rect = Rect.Transform(new Rect(renderSize), layoutTransformData.Transform.Value);
     transformGroup.Children.Add((Transform) new TranslateTransform(-rect.X, -rect.Y));
       }
       if (transform != null)
       {
     Point renderTransformOrigin = this.GetRenderTransformOrigin();
     bool flag = renderTransformOrigin.X != 0.0 || renderTransformOrigin.Y != 0.0;
     if (flag)
     {
       TranslateTransform translateTransform = new TranslateTransform(-renderTransformOrigin.X, -renderTransformOrigin.Y);
       translateTransform.Freeze();
       transformGroup.Children.Add((Transform) translateTransform);
     }
     transformGroup.Children.Add(transform);
     if (flag)
     {
       TranslateTransform translateTransform = new TranslateTransform(renderTransformOrigin.X, renderTransformOrigin.Y);
       translateTransform.Freeze();
       transformGroup.Children.Add((Transform) translateTransform);
     }
       }
     }
     this.VisualTransform = (Transform) transformGroup;
     this.AreTransformsClean = true;
       }
       Vector visualOffset = this.VisualOffset;
       if (DoubleUtil.AreClose(visualOffset.X, offset.X) && DoubleUtil.AreClose(visualOffset.Y, offset.Y))
     return;
       this.VisualOffset = offset;
 }
开发者ID:jchristian,项目名称:ui_events,代码行数:62,代码来源:FrameworkElement.cs

示例7: RenderToBitmap

        /// <summary>
        /// Creates a bit map representation of a given visual
        /// </summary>
        /// <param name="visual">visual to render</param>
        /// <param name="bitmapSize">the size of bitmap (this may be larger then visual itself, but normally size of the visual)</param>
        /// <param name="visualPositionOnBitmap">position of visual on bitmap (normally 0,0)</param>
        /// <param name="visualSize">size of the visual</param>
        /// <param name="pixelFormat"></param>
        /// <param name="flowDirection"></param>
        /// <param name="dpiX"></param>
        /// <param name="dpiY"></param>
        /// <returns></returns>
        public static BitmapSource RenderToBitmap(
            this Visual visual,
            Size bitmapSize,
            Point visualPositionOnBitmap,
            Size visualSize,
            PixelFormat pixelFormat,
            FlowDirection flowDirection = FlowDirection.LeftToRight,
            double dpiX = 96.0,
            double dpiY = 96.0)
        {
            var rtb = new RenderTargetBitmap((int)(bitmapSize.Width * dpiX / 96.0),
                                             (int)(bitmapSize.Height * dpiY / 96.0),
                                             dpiX,
                                             dpiY,
                                             pixelFormat);
            
            var dv = visual as DrawingVisual;

            if (dv != null)
            {
                var transform = new TranslateTransform(-dv.ContentBounds.Left,-dv.ContentBounds.Top);
                transform.Freeze();

                dv.Transform = transform;
                
                rtb.Render(dv);

                dv.Transform = null;
            }
            else
            {
                dv = new DrawingVisual();

                using (var ctx = dv.RenderOpen())
                {
                    ctx.Render(visual, visualPositionOnBitmap, visualSize, flowDirection);
                }

                rtb.Render(dv);
            }


            return rtb;
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:56,代码来源:Visual.extensions.cs

示例8: 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

示例9: 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

示例10: RandomSquares__DrawVisual2

        IPixelCanvas RandomSquares__DrawVisual2(int count, int square_size, int canvas_size)
        {
            var rd = new Random();

            var pc = new PixelArrayCanvas(canvas_size, canvas_size);

            var dv = new DrawingVisual();

            var geom = new RectangleGeometry(new System.Windows.Rect(0, 0, square_size, square_size));
            geom.Freeze();

            using (var cx = dv.RenderOpen())
            {
                var canvas = new RectangleGeometry(new Rect(0, 0, canvas_size, canvas_size));
                canvas.Freeze();

                cx.DrawGeometry(Brushes.Transparent, null, canvas);

                var lols = new ConcurrentBag<DrawingWithExtras>();                

                Parallel.For(0, count, i =>
                 {
                     var drawing = new GeometryDrawing(Brushes.Red, new Pen(Brushes.Red, 1), geom);
                     drawing.Freeze();

                     var trans = new TranslateTransform(rd.Next(0, canvas_size - square_size), rd.Next(0, canvas_size - square_size));
                     trans.Freeze();

                     lols.Add(new DrawingWithExtras { drawing = drawing, transform = trans });
                 });

                foreach(var lol in lols)
                {
                    cx.PushTransform(lol.transform);
                    cx.DrawDrawing(lol.drawing);
                    cx.Pop();
                }
            }

            pc.DrawVisual(0, 0, dv, BlendMode.Copy);

            return pc;
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:43,代码来源:PerformanceOptimizations.cs


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