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


C# PathGeometry.Freeze方法代码示例

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


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

示例1: InsertionAdorner

        // Create the pen and triangle in a static constructor and freeze them to improve performance.
        static InsertionAdorner()
        {
            pen = new Pen
            {
                Brush = Brushes.Gray,
                Thickness = 2
            };
            pen.Freeze();

            LineSegment firstLine = new LineSegment(new Point(0, -5), false);
            firstLine.Freeze();
            LineSegment secondLine = new LineSegment(new Point(0, 5), false);
            secondLine.Freeze();

            PathFigure figure = new PathFigure
            {
                StartPoint = new Point(5, 0)
            };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            triangle = new PathGeometry();
            triangle.Figures.Add(figure);
            triangle.Freeze();
        }
开发者ID:Boddlnagg,项目名称:WordsLive,代码行数:27,代码来源:InsertionAdorner.cs

示例2: InsertionAdorner

 /// <summary>
 /// Create the pen and triangle in a static constructor and freeze them to improve performance.
 /// </summary>
 static InsertionAdorner()
 {
     Pen = new Pen { Brush = Brushes.SkyBlue, Thickness = LineThickness };
     Pen.Freeze();
     var firstLine = new LineSegment(new Point(0, -TriangleWidth), false);
     firstLine.Freeze();
     var secondLine = new LineSegment(new Point(0, TriangleWidth), false);
     secondLine.Freeze();
     var figure = new PathFigure {StartPoint = new Point(TriangleWidth, 0)};
     figure.Segments.Add(firstLine);
     figure.Segments.Add(secondLine);
     figure.Freeze();
     Triangle = new PathGeometry();
     Triangle.Figures.Add(figure);
     Triangle.Freeze();
 }
开发者ID:Orange637,项目名称:WpfStudy,代码行数:19,代码来源:InsertionAdorner.cs

示例3: InsertionAdorner

        /// <summary>
        /// Initializes static members of the <see cref="InsertionAdorner" /> class.
        /// </summary>
        static InsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            Pen = new Pen { Brush = Brushes.Gray, Thickness = 2 };
            Pen.Freeze();

            var firstLine = new LineSegment(new Point(0, -5), false);
            firstLine.Freeze();
            var secondLine = new LineSegment(new Point(0, 5), false);
            secondLine.Freeze();

            var figure = new PathFigure { StartPoint = new Point(5, 0) };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            Triangle = new PathGeometry();
            Triangle.Figures.Add(figure);
            Triangle.Freeze();
        }
开发者ID:hasol81,项目名称:PropertyTools,代码行数:23,代码来源:InsertionAdorner.cs

示例4: DropTargetInsertionAdorner

        static DropTargetInsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            const int triangleSize = 3;

            m_Pen = new Pen(Brushes.Gray, 2);
            m_Pen.Freeze();

            LineSegment firstLine = new LineSegment(new Point(0, -triangleSize), false);
            firstLine.Freeze();
            LineSegment secondLine = new LineSegment(new Point(0, triangleSize), false);
            secondLine.Freeze();

            PathFigure figure = new PathFigure { StartPoint = new Point(triangleSize, 0) };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            m_Triangle = new PathGeometry();
            m_Triangle.Figures.Add(figure);
            m_Triangle.Freeze();
        }
开发者ID:AugustinasNomicas,项目名称:MultitrackPlayer,代码行数:22,代码来源:DropTargetInsertionAdorner.cs

示例5: DropTargetMetroInsertionAdorner

        static DropTargetMetroInsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            const int triangleSize = 5;

            var color = (Color) ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
            m_Pen = new Pen(new SolidColorBrush(color), 2);
            m_Pen.Freeze();

            var firstLine = new LineSegment(new Point(0, -triangleSize), false);
            firstLine.Freeze();
            var secondLine = new LineSegment(new Point(0, triangleSize), false);
            secondLine.Freeze();

            var figure = new PathFigure {StartPoint = new Point(triangleSize, 0)};
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            m_Triangle = new PathGeometry();
            m_Triangle.Figures.Add(figure);
            m_Triangle.Freeze();
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:23,代码来源:DropTargetMetroInsertionAdorner.cs

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

示例7: OnRender

        /// <summary>
        /// 描画処理をおこないます。
        /// </summary>
        /// <param name="dc">描画するコンテキスト</param>
        protected override void OnRender(DrawingContext dc)
        {
            //base.OnRender(dc);

            if (XAxisData == null)
            {
                IsDataEnabled = false;
                return;
            }
            if (YAxisData == null)
            {
                IsDataEnabled = false;
                return;
            }

            var xArray = XAxisData.OfType<double>().ToArray();
            var yArray = YAxisData.OfType<double>().ToArray();
            var length = xArray.Length < yArray.Length ? xArray.Length : yArray.Length;
            Point? pt0 = null;
            var isLineFirst = true;
            var pathfigure = new PathFigure();
            var pen = new Pen(this.Color != null ? new SolidColorBrush(this.Color.Value) : this.Stroke, this.Thickness);
            pen.Freeze();
            Pen markerPen = null;
            if (this.MarkerPen != null)
            {
                markerPen = this.Color != null ? new Pen(new SolidColorBrush(this.Color.Value), this.MarkerPen.Thickness) : this.MarkerPen;
                markerPen.Freeze();
            }
            var markerFill = this.Color != null ? new SolidColorBrush(this.Color.Value) : this.Fill;
            if (markerFill != null)
                markerFill.Freeze();
            for (var i = 0; i < length; i++)
            {
                if (IsStrokeEnabled)
                {
                    #region 線の描画
                    if (pt0 != null)
                    {

                        if ((pt0.Value.Y >= this.YMax) && (yArray[i] >= this.YMax))
                        {
                            // 絶対に線の描画があり得ないパターン
                        }
                        else if ((pt0.Value.Y <= this.YMin) && (yArray[i] <= this.YMin))
                        {
                            // 絶対に線の描画があり得ないパターン
                        }
                        else
                        {
                            Point? ptLine0 = null;
                            Point? ptLine1 = null;

                            // 以前の点が右端より左側にあって
                            // 今回の点が左端より右側にある場合のみ
                            // 線を描画する可能性がある
                            if ((pt0.Value.X < this.XMax) && (xArray[i] > this.XMin))
                            {
                                // 以前の点が範囲内ならこれを左端の点とする
                                if ((this.XMin <= pt0.Value.X) && (pt0.Value.X <= this.XMax) && (this.YMin <= pt0.Value.Y) && (pt0.Value.Y <= this.YMax))
                                {
                                    ptLine0 = GetControlPointFromGraphPoint(pt0.Value);
                                }
                                // 今回の点が範囲内ならこれを右端の点とする
                                if ((this.XMin <= xArray[i]) && (xArray[i] <= this.XMax) && (this.YMin <= yArray[i]) && (yArray[i] <= this.YMax))
                                {
                                    ptLine1 = GetControlPointFromGraphPoint(xArray[i], yArray[i]);
                                }

                                // 左端または右端の点が確定していない場合はグラフ表示範囲の境界線との交点を調べる
                                if ((ptLine0 == null) || (ptLine1 == null))
                                {
                                    // y = ax + b
                                    // 傾き
                                    double? a = xArray[i] != pt0.Value.X ? (yArray[i] - pt0.Value.Y) / (xArray[i] - pt0.Value.X) : (double?)null;
                                    if (a != null)
                                    {
                                        // 切片
                                        double b = pt0.Value.Y - a.Value * pt0.Value.X;

                                        // 左端縦軸との交点
                                        var yLeft = a.Value * this.XMin + b;
                                        // 右端縦軸との交点
                                        var yRight = a.Value * this.XMax + b;
                                        // 上端横軸との交点
                                        var xTop = (this.YMax - b) / a.Value;
                                        // 下端横軸との交点
                                        var xBottom = (this.YMin - b) / a.Value;

                                        #region 左端の点を確定する
                                        if (ptLine0 == null)
                                        {
                                            // 左端縦軸交点の確認
                                            if ((this.YMin <= yLeft) && (yLeft <= this.YMax))
                                            {
                                                ptLine0 = GetControlPointFromGraphPoint(this.XMin, yLeft);
//.........这里部分代码省略.........
开发者ID:YKSoftware,项目名称:YKToolkit.Controls,代码行数:101,代码来源:LineGraphItem.cs

示例8: OnRender


//.........这里部分代码省略.........
                double bottomWidth = guidelineSetX[4] - guidelineSetX[3];
                if (bottomWidth > 0)
                {
                    Rect bottom = new Rect(guidelineSetX[3], guidelineSetY[5], bottomWidth, ShadowDepth);
                    drawingContext.DrawRectangle(brushes[Bottom], null, bottom);
                }

                Rect bottomRight = new Rect(guidelineSetX[4], guidelineSetY[4], cornerRadius.BottomRight, cornerRadius.BottomRight);
                drawingContext.DrawRectangle(brushes[BottomRight], null, bottomRight);


                // Fill Center

                // Because the heights of the top/bottom rects and widths of the left/right rects are fixed
                // and the corner rects are drawn with the size of the corner, the center 
                // may not be a square.  In this case, create a path to fill the area

                // When the target object's corner radius is 0, only need to draw one rect
                if (cornerRadius.TopLeft == ShadowDepth &&
                    cornerRadius.TopLeft == cornerRadius.TopRight &&
                    cornerRadius.TopLeft == cornerRadius.BottomLeft &&
                    cornerRadius.TopLeft == cornerRadius.BottomRight)
                {
                    // All corners of target are 0, render one large rectangle
                    Rect center = new Rect(guidelineSetX[0], guidelineSetY[0], centerWidth, centerHeight);
                    drawingContext.DrawRectangle(brushes[Center], null, center);
                }
                else
                {
                    // If the corner radius is TL=2, TR=1, BL=0, BR=2 the following shows the shape that needs to be created.
                    //             _________________
                    //            |                 |_
                    //         _ _|                   |
                    //        |                       |
                    //        |                    _ _|
                    //        |                   |   
                    //        |___________________| 
                    // The missing corners of the shape are filled with the radial gradients drawn above

                    // Define shape counter clockwise
                    PathFigure figure = new PathFigure();

                    if (cornerRadius.TopLeft > ShadowDepth)
                    {
                        figure.StartPoint = new Point(guidelineSetX[1], guidelineSetY[0]);
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[1], guidelineSetY[1]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[1]), true));
                    }
                    else
                    {
                        figure.StartPoint = new Point(guidelineSetX[0], guidelineSetY[0]);
                    }

                    if (cornerRadius.BottomLeft > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[3]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[3], guidelineSetY[3]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[3], guidelineSetY[5]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[5]), true));
                    }

                    if (cornerRadius.BottomRight > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[4], guidelineSetY[5]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[4], guidelineSetY[4]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[4]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[5]), true));
                    }


                    if (cornerRadius.TopRight > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[2]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[2], guidelineSetY[2]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[2], guidelineSetY[0]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[0]), true));
                    }
                    
                    figure.IsClosed = true;
                    figure.Freeze();

                    PathGeometry geometry = new PathGeometry();
                    geometry.Figures.Add(figure);
                    geometry.Freeze();

                    drawingContext.DrawGeometry(brushes[Center], null, geometry);
                }

                drawingContext.Pop();
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:101,代码来源:SystemDropShadowChrome.cs

示例9: ApplyTransform

        private static Geometry ApplyTransform(Geometry geometry, double bt, Size renderSize)
        {
            var pathGeometry = new PathGeometry();
            pathGeometry.AddGeometry(geometry);

            var hbt = bt * 0.5;
            //var scaleY = ((hbt * 100) / renderSize.Height) / 100;
            var scaleY = hbt / renderSize.Height;
            pathGeometry.Transform = new ScaleTransform(1, scaleY + 1, renderSize.Width * 0.5, 0);
            pathGeometry.Freeze();
            return pathGeometry;
        }
开发者ID:kekekeks,项目名称:PerspexVS,代码行数:12,代码来源:TabItemBorder.cs

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

示例11: CreateImage

        public static DrawingImage CreateImage(PointPattern[] pointPatterns, Size size, Color color)
        {
            if (pointPatterns == null)
                throw new Exception("You must provide a gesture before trying to generate a thumbnail");

            DrawingGroup drawingGroup = new DrawingGroup();
            for (int i = 0; i < pointPatterns.Length; i++)
            {
                PathGeometry pathGeometry = new PathGeometry();

                color.A = (byte)(0xFF - i * 0x55);
                SolidColorBrush brush = new SolidColorBrush(color);
                Pen drawingPen = new Pen(brush, 3 + i * 2) { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round };

                if (pointPatterns[i].Points == null) return null;
                for (int j = 0; j < pointPatterns[i].Points.Count; j++)
                {
                    if (pointPatterns[i].Points[j].Count == 1)
                    {
                        Geometry ellipse = new EllipseGeometry(new Point(size.Width * j + size.Width / 2, size.Height / 2),
                            drawingPen.Thickness / 2, drawingPen.Thickness / 2);
                        pathGeometry.AddGeometry(ellipse);
                        continue;
                    }
                    StreamGeometry sg = new StreamGeometry { FillRule = FillRule.EvenOdd };
                    using (StreamGeometryContext sgc = sg.Open())
                    {
                        // Create new size object accounting for pen width
                        Size szeAdjusted = new Size(size.Width - drawingPen.Thickness - 1,
                            (size.Height - drawingPen.Thickness - 1));

                        Size scaledSize;
                        Point[] scaledPoints = ScaleGesture(pointPatterns[i].Points[j], szeAdjusted.Width - 10, szeAdjusted.Height - 10,
                            out scaledSize);

                        // Define size that will mark the offset to center the gesture
                        double iLeftOffset = (size.Width / 2) - (scaledSize.Width / 2);
                        double iTopOffset = (size.Height / 2) - (scaledSize.Height / 2);
                        Vector sizOffset = new Vector(iLeftOffset + j * size.Width, iTopOffset);
                        sgc.BeginFigure(Point.Add(scaledPoints[0], sizOffset), false, false);
                        foreach (Point p in scaledPoints)
                        {
                            sgc.LineTo(Point.Add(p, sizOffset), true, true);
                        }
                        DrawArrow(sgc, scaledPoints, sizOffset, drawingPen.Thickness);
                    }
                    sg.Freeze();
                    pathGeometry.AddGeometry(sg);
                }
                pathGeometry.Freeze();
                GeometryDrawing drawing = new GeometryDrawing(null, drawingPen, pathGeometry);
                drawing.Freeze();
                drawingGroup.Children.Add(drawing);
            }
            //  myPath.Data = sg;
            drawingGroup.Freeze();
            DrawingImage drawingImage = new DrawingImage(drawingGroup);
            drawingImage.Freeze();

            return drawingImage;
        }
开发者ID:YashMaster,项目名称:GestureSign,代码行数:61,代码来源:GestureImage.cs

示例12: GenerateBorderGeometry

        // Creates a border geometry used to render complex border brushes
        private static Geometry GenerateBorderGeometry(Rect rect, Thickness borderThickness)
        {
            PathGeometry geometry = new PathGeometry();

            // Add outer rectangle figure
            geometry.Figures.Add(GenerateRectFigure(rect)); 

            // Subtract inner rectangle figure 
            geometry.Figures.Add(GenerateRectFigure(HelperDeflateRect(rect, borderThickness)));

            geometry.Freeze();

            return geometry;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:15,代码来源:ClassicBorderDecorator.cs

示例13: CreateGeometry

        private static PathGeometry CreateGeometry(Size contentDesiredSize)
        {
            //TODO Make better :)  do some funky beziers or summit
            const double cheapRadiusBig = 6.0;
            const double cheapRadiusSmall = cheapRadiusBig/2;
            
            const int angle = 20;
            const double radians = angle * (Math.PI / 180);

            var startPoint = new Point(0, contentDesiredSize.Height + cheapRadiusSmall + cheapRadiusSmall);

            //clockwise starting at bottom left
            var bottomLeftSegment = new ArcSegment(new Point(startPoint.X + cheapRadiusSmall, startPoint.Y - cheapRadiusSmall),
                new Size(cheapRadiusSmall, cheapRadiusSmall), 315, false, SweepDirection.Counterclockwise, true);
            var triangleX = Math.Tan(radians) * (contentDesiredSize.Height);
            var leftSegment = new LineSegment(new Point(bottomLeftSegment.Point.X + triangleX, bottomLeftSegment.Point.Y - contentDesiredSize.Height), true);
            var topLeftSegment = new ArcSegment(new Point(leftSegment.Point.X + cheapRadiusBig, leftSegment.Point.Y - cheapRadiusSmall), new Size(cheapRadiusBig, cheapRadiusBig), 120, false, SweepDirection.Clockwise, true);
            var topSegment = new LineSegment(new Point(contentDesiredSize.Width + cheapRadiusBig + cheapRadiusBig, 0), true);
            var topRightSegment = new ArcSegment(new Point(contentDesiredSize.Width + cheapRadiusBig + cheapRadiusBig + cheapRadiusBig, cheapRadiusSmall), new Size(cheapRadiusBig, cheapRadiusBig), 40, false, SweepDirection.Clockwise, true);

            triangleX = Math.Tan(radians) * (contentDesiredSize.Height);
            //triangleX = Math.Tan(radians)*(contentDesiredSize.Height - topRightSegment.Point.Y);
            var rightSegment =
                new LineSegment(new Point(topRightSegment.Point.X + triangleX,
                    topRightSegment.Point.Y + contentDesiredSize.Height), true);

            var bottomRightPoint = new Point(rightSegment.Point.X + cheapRadiusSmall,
                rightSegment.Point.Y + cheapRadiusSmall);
            var bottomRightSegment = new ArcSegment(bottomRightPoint,
                new Size(cheapRadiusSmall, cheapRadiusSmall), 25, false, SweepDirection.Counterclockwise, true);
            var bottomLeftPoint = new Point(0, bottomRightSegment.Point.Y);
            var bottomSegment = new LineSegment(bottomLeftPoint, true);            

            var pathSegmentCollection = new PathSegmentCollection
            {
                bottomLeftSegment, leftSegment, topLeftSegment, topSegment, topRightSegment, rightSegment, bottomRightSegment, bottomSegment
            };
            var pathFigure = new PathFigure(startPoint, pathSegmentCollection, true)
            {
                IsFilled = true
            };
            var pathFigureCollection = new PathFigureCollection
            {
                pathFigure
            };
            var geometryGroup = new PathGeometry(pathFigureCollection);            
            geometryGroup.Freeze();                        

            return geometryGroup;
        }
开发者ID:CensoredHF,项目名称:Snappie,代码行数:50,代码来源:Trapezoid.cs

示例14: GetMarkerGeometry

		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="span"/> is less than zero or greater than the buffer length for the associated <see cref="ISourceEditorView"/>.</para>
		/// </exception>
		public Geometry GetMarkerGeometry(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if ((span.Start < 0) || (span.End > _editorView.TextBuffer.Length))
			{
				throw new ArgumentOutOfRangeException("span");
			}
			if (span.IsEmpty)
			{
				return null;
			}
			PathGeometry geometry = new PathGeometry();
			geometry.FillRule = FillRule.Nonzero;
			IList<ITextLine> textLines = _editorView.TextLines;
			if (textLines.Count == 0)
			{
				return null;
			}
			if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
			{
				return null;
			}
			ITextLine item = null;
			ITextLine textLineClosestTo = null;
			if (span.Start < base.FirstRenderedCharacter)
			{
				item = textLines[0];
			}
			if (span.End > base.LastRenderedCharacter)
			{
				textLineClosestTo = textLines[textLines.Count - 1];
			}
			if (item == null)
			{
				item = base.GetTextLineClosestTo(span.Start);
			}
			if (textLineClosestTo == null)
			{
				textLineClosestTo = base.GetTextLineClosestTo(span.End);
			}
			if (item == textLineClosestTo)
			{
				foreach (TextBounds bounds in item.GetTextBounds(span))
				{
					RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
					geometry2.Freeze();
					geometry.AddGeometry(geometry2);
				}
			}
			else
			{
				foreach (TextBounds bounds2 in item.GetTextBounds(span))
				{
					RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
					geometry3.Freeze();
					geometry.AddGeometry(geometry3);
				}
				Int32 num = textLines.IndexOf(item) + 1;
				Int32 index = textLines.IndexOf(textLineClosestTo);
				for (Int32 i = num; i < index; i++)
				{
					ITextLine line3 = textLines[i];
					RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
					geometry4.Freeze();
					geometry.AddGeometry(geometry4);
				}
				foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
				{
					RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
					geometry5.Freeze();
					geometry.AddGeometry(geometry5);
				}
			}
			geometry.Freeze();
			return geometry.GetOutlinedPathGeometry();
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:87,代码来源:SourceEditorViewHelper.cs

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


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