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


C# Pen.Freeze方法代码示例

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


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

示例1: AreaVisual

 public AreaVisual(Pen pen1)
 {
     // pen = new Pen(Brushes.SpringGreen, 10);
     pen = pen1;
     pen.Freeze();
     Redraw();
 }
开发者ID:Svet-LAN-a,项目名称:mollusksRecognition,代码行数:7,代码来源:FossilVisual.cs

示例2: CreateErrorPen

 public static Pen CreateErrorPen(Color color)
 {
     var geometry = new StreamGeometry();
     using (var context = geometry.Open())
     {
         context.BeginFigure(new Point(-1, 0), false, false);
         context.PolyLineTo(new[] {
                 new Point(-0.5, 0.4),
                 new Point(0, 0),
                 new Point(0.5, -0.4),
                 new Point(1, 0),
             }, true, true);
     }
     var brushPattern = new GeometryDrawing
     {
         Pen = new Pen(new SolidColorBrush(color), 0.4),
         Geometry = geometry
     };
     var brush = new DrawingBrush(brushPattern)
     {
         TileMode = TileMode.Tile,
         Viewport = new Rect(-1, -1, 2, 2),
         ViewportUnits = BrushMappingMode.Absolute,
         Viewbox = new Rect(-1, -1, 2, 2),
         ViewboxUnits = BrushMappingMode.Absolute,
     };
     var pen = new Pen(brush, 3.0);
     pen.Freeze();
     return pen;
 }
开发者ID:osmedile,项目名称:TypeCobol,代码行数:30,代码来源:Pen.cs

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

示例4: OnRender

 protected override void OnRender(DrawingContext dc)
 {
     var pen = new Pen(this.Fill, this.PenWidth);
     pen.Freeze();
     var line = new Line(this.ActualWidth, this.ActualHeight, this.ReservedSpace, this.Placement, this.IsDirectionReversed);
     Vector offset = new Vector(0, 0);
     switch (this.Placement)
     {
         case TickBarPlacement.Left:
             offset = new Vector(this.ActualWidth, 0);
             break;
         case TickBarPlacement.Right:
             offset = new Vector(-1 * this.ActualWidth, 0);
             break;
         case TickBarPlacement.Top:
             offset = new Vector(0, this.ActualHeight);
             break;
         case TickBarPlacement.Bottom:
             offset = new Vector(0, -1 * this.ActualHeight);
             break;
     }
     foreach (var tick in this.AllTicks)
     {
         var p = TickHelper.ToPos(tick, this.Minimum, this.Maximum, line).Round(0);
         var l = new Line(p, p + offset);
         dc.DrawLine(pen, l);
     }
 }
开发者ID:JackWangCUMT,项目名称:Gu.Gauges,代码行数:28,代码来源:LinearTickBar.cs

示例5: TranslationAdornment

        /// <summary>
        /// Creates a square image and attaches an event handler to the layout changed event that
        /// adds the the square in the upper right-hand corner of the TextView via the adornment layer
        /// </summary>
        /// <param name="view">The <see cref="IWpfTextView"/> upon which the adornment will be drawn</param>
        public TranslationAdornment(IWpfTextView view)
        {
            _view = view;

            Brush brush = new SolidColorBrush(Colors.BlueViolet);
            brush.Freeze();
            Brush penBrush = new SolidColorBrush(Colors.Red);
            penBrush.Freeze();
            Pen pen = new Pen(penBrush, 0.5);
            pen.Freeze();

            //draw a square with the created brush and pen
            System.Windows.Rect r = new System.Windows.Rect(0, 0, 30, 30);
            Geometry g = new RectangleGeometry(r);
            GeometryDrawing drawing = new GeometryDrawing(brush, pen, g);
            drawing.Freeze();

            DrawingImage drawingImage = new DrawingImage(drawing);
            drawingImage.Freeze();

            _image = new Image();
            _image.Source = drawingImage;

            //Grab a reference to the adornment layer that this adornment should be added to
            _adornmentLayer = view.GetAdornmentLayer("TranslationAdornment");

            _view.ViewportHeightChanged += delegate { this.onSizeChange(); };
            _view.ViewportWidthChanged += delegate { this.onSizeChange(); };
        }
开发者ID:JeanAzzopardi,项目名称:TranslatorExtensionPackage,代码行数:34,代码来源:TranslationAdornment.cs

示例6: FloatExpElement

 public FloatExpElement()
 {
     pen3 = new Pen(ThemeManager.NoteFillBrushes[0], 3);
     pen2 = new Pen(ThemeManager.NoteFillBrushes[0], 2);
     pen3.Freeze();
     pen2.Freeze();
 }
开发者ID:KineticIsEpic,项目名称:OpenUtau,代码行数:7,代码来源:ExpElements.cs

示例7: AchievementAdornments

        public AchievementAdornments(IWpfTextView view)
        {
            this.view = view;
            this.layer = view.GetAdornmentLayer("AchievementAdornments");
            this.descriptionLayer = view.GetAdornmentLayer("AchievementAdornmentsDescription");

            view.LayoutChanged += OnLayoutChanged;

            Brush brush = new SolidColorBrush(Color.FromArgb(0x20, 0x00, 0x00, 0xff));
            brush.Freeze();

            Brush penBrush = new SolidColorBrush(Colors.Red);
            penBrush.Freeze();

            Pen pen = new Pen(penBrush, 0.5);
            pen.Freeze();

            this.brush = brush;
            this.pen = pen;

            AchievementUIContext.AchievementClicked += (sender, e) =>
            {
                Reset();

                var filePath = GetFilePath(view);
                if (e.AchievementDescriptor.CodeOrigin.FileName != filePath)
                    return;

                codeOrigin = e.AchievementDescriptor.CodeOrigin;
                achievementUiElement = (UIElement)e.UIElement;

                CreateAdornment();
            };
        }
开发者ID:clausjoergensen,项目名称:strokes,代码行数:34,代码来源:AchievementAdornments.cs

示例8: Draw

 public void Draw(TextView textView, DrawingContext drawingContext)
 {
     foreach (TextSegment current in this.SearchHitsSegments)
     {
         foreach (Rect current2 in BackgroundGeometryBuilder.GetRectsForSegment(textView, current))
         {
             Point bottomLeft = current2.BottomLeft;
             Point bottomRight = current2.BottomRight;
             Pen pen = new Pen(new SolidColorBrush(Colors.OrangeRed), 1);
             pen.Freeze();
             double num = 2.5;
             int count = System.Math.Max((int)((bottomRight.X - bottomLeft.X) / num) + 1, 4);
             StreamGeometry streamGeometry = new StreamGeometry();
             using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
             {
                 streamGeometryContext.BeginFigure(bottomLeft, true, true);
                 streamGeometryContext.LineTo(current2.TopLeft, true, false);
                 streamGeometryContext.LineTo(current2.TopRight, true, false);
                 streamGeometryContext.LineTo(current2.BottomRight, true, false);
             }
             streamGeometry.Freeze();
             drawingContext.DrawGeometry(Brushes.Transparent, pen, streamGeometry);
         }
     }
 }
开发者ID:BernardNotarianni,项目名称:DownmarkerWPF,代码行数:25,代码来源:SearchBackgroundRenderer.cs

示例9: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var dashPen = new Pen(Brushes.Red, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
            dashPen.Freeze();

            if( _grid  != null )
            {
                if (_grid.ColumnDefinitions != null)
                {
                    double xPos = 0;
                    foreach (var column in _grid.ColumnDefinitions)
                    {
                        xPos += column.ActualWidth;
                        drawingContext.DrawLine(dashPen, new Point(xPos, 0), new Point(xPos,ActualHeight));
                    }
                }
                if (_grid.RowDefinitions != null)
                {
                    double yPos = 0;
                    foreach (var column in _grid.RowDefinitions)
                    {
                        yPos += column.ActualHeight;
                        drawingContext.DrawLine(dashPen, new Point(0, yPos), new Point(ActualWidth, yPos));
                    }
                }
            }
            base.OnRender(drawingContext);
        }
开发者ID:bdurrani,项目名称:WPF-Inspector,代码行数:28,代码来源:GridAdorner.cs

示例10: VmsViewportAdornment

        public VmsViewportAdornment(IWpfTextView view, SVsServiceProvider serviceProvider)
        {
            var service = (DTE)serviceProvider.GetService(typeof(DTE));
            var properties = service.Properties["Visual Method Separators", "Global"];

            var colorProperty = properties.Item("Color");
            var color = UIntToColor(colorProperty.Value);

            var dashStyleProperty = properties.Item("PenDashStyle");
            var dashStyle = DashStyleFromInt(dashStyleProperty.Value);

            var thicknessProperty = properties.Item("Thickness");
            var thickness = (double) thicknessProperty.Value;

            _view = view;
            _view.LayoutChanged += OnLayoutChanged;

            _layer = view.GetAdornmentLayer("VmsViewportAdornment");

            _pen = new Pen(new SolidColorBrush(color), thickness)
                {
                    DashStyle = dashStyle,
                    DashCap = PenLineCap.Flat,
                };

            _pen.Freeze();
        }
开发者ID:rpeshkov,项目名称:VisualMethodSeparators,代码行数:27,代码来源:VmsViewportAdornment.cs

示例11: OnRender

        protected override void OnRender(DrawingContext drawingContext)
        {
            var fe = AdornedElement as FrameworkElement;
            if (fe == null)
            {
                return;
            }

            var rect = new Rect(1, 1, Math.Max(0, fe.ActualWidth - 2), Math.Max(0, fe.ActualHeight - 2));
            var color = Colors.Red;
            var brush = new SolidColorBrush(color);
            var pen = new Pen(brush, 1);
            pen.Freeze();

            var dashPen = new Pen(brush, 1) { DashStyle = new DashStyle(new double[] { 1, 6 }, 0) };
            dashPen.Freeze();

            var guidelineSet = new GuidelineSet();
            guidelineSet.GuidelinesX.Add(0.5);
            guidelineSet.GuidelinesY.Add(0.5);

            //var outlinePen = new Pen(new SolidColorBrush(Color.FromArgb(0x70, 0xFF, 0xFF, 0xFF)), 5);
            //outlinePen.Freeze();

            drawingContext.PushGuidelineSet(guidelineSet);

            //drawingContext.DrawRectangle(null, outlinePen, rect);
            drawingContext.DrawRectangle(null, pen, rect);

            //var parent = VisualTreeHelper.GetParent(fe) as FrameworkElement;
            //if (parent != null)
            //{
            //    var thisLeft = new Point(0, fe.ActualHeight / 2);
            //    var thisRight = new Point(fe.ActualWidth, fe.ActualHeight / 2);
            //    var thisTop = new Point(fe.ActualWidth / 2, 0);
            //    var thisBottom = new Point(fe.ActualWidth / 2, fe.ActualHeight);
            //    var ancestorLeft = new Point(parent.TranslatePoint(thisLeft, fe).X, thisLeft.Y);
            //    var ancestorRight = ancestorLeft + new Vector(parent.ActualWidth, 0);
            //    var ancestorTop = new Point(thisTop.X, parent.TranslatePoint(new Point(), fe).Y);
            //    var ancestorBottom = new Point(thisBottom.X, parent.TranslatePoint(new Point(), fe).Y + parent.ActualHeight);

            //    var leftPen = fe.HorizontalAlignment == HorizontalAlignment.Left || fe.HorizontalAlignment == HorizontalAlignment.Stretch ? pen : dashPen;
            //    var rightPen = fe.HorizontalAlignment == HorizontalAlignment.Right || fe.HorizontalAlignment == HorizontalAlignment.Stretch ? pen : dashPen;
            //    var topPen = fe.VerticalAlignment == VerticalAlignment.Top || fe.VerticalAlignment == VerticalAlignment.Stretch ? pen : dashPen;
            //    var bottomPen = fe.VerticalAlignment == VerticalAlignment.Bottom || fe.VerticalAlignment == VerticalAlignment.Stretch ? pen : dashPen;

            //    drawingContext.DrawLine(leftPen, thisLeft, ancestorLeft);
            //    drawingContext.DrawLine(rightPen, thisRight, ancestorRight);
            //    drawingContext.DrawLine(topPen, thisTop, ancestorTop);
            //    drawingContext.DrawLine(bottomPen, thisBottom, ancestorBottom);
            //}

            var formattedHeight = new FormattedText(string.Format("{0:0}", fe.ActualHeight), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            var formattedWidth = new FormattedText(string.Format("{0:0}", fe.ActualWidth), CultureInfo.InvariantCulture, FlowDirection.LeftToRight, TypeFace, 10, brush);
            drawingContext.DrawText(formattedHeight, new Point(rect.Width + 5, (rect.Height / 2) - (formattedHeight.Height / 2)));
            drawingContext.DrawText(formattedWidth, new Point(rect.Width / 2 - formattedWidth.Width / 2, rect.Height + 5));

            drawingContext.Pop();
        }
开发者ID:bdurrani,项目名称:WPF-Inspector,代码行数:59,代码来源:SelectionAdorner.cs

示例12: PostInfoDisplay

        public PostInfoDisplay(double textRightEdge,
            double viewRightEdge,
            Geometry newTextGeometry,
            string body)
        {
            if (brush == null)
            {
                brush = new SolidColorBrush(Color.FromArgb(0x20, 0x48, 0x3d, 0x8b));
                brush.Freeze();
                Brush penBrush = new SolidColorBrush(Colors.DarkSlateBlue);
                penBrush.Freeze();
                solidPen = new Pen(penBrush, 0.5);
                solidPen.Freeze();
                dashPen = new Pen(penBrush, 0.5);
                dashPen.DashStyle = DashStyles.Dash;
                dashPen.Freeze();
            }

            this.textGeometry = newTextGeometry;

            TextBlock tb = new TextBlock();
            tb.Text = "Blog Entry: " + body;

            const int MarginWidth = 8;
            this.postGrid = new Grid();
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            this.postGrid.RowDefinitions.Add(new RowDefinition());
            ColumnDefinition cEdge = new ColumnDefinition();
            cEdge.Width = new GridLength(MarginWidth);
            ColumnDefinition cEdge2 = new ColumnDefinition();
            cEdge2.Width = new GridLength(MarginWidth);
            this.postGrid.ColumnDefinitions.Add(cEdge);
            this.postGrid.ColumnDefinitions.Add(new ColumnDefinition());
            this.postGrid.ColumnDefinitions.Add(cEdge2);

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle();
            rect.RadiusX = 6;
            rect.RadiusY = 3;
            rect.Fill = brush;
            rect.Stroke = Brushes.DarkSlateBlue;

            Size inf = new Size(double.PositiveInfinity, double.PositiveInfinity);
            tb.Measure(inf);
            this.postGrid.Width = tb.DesiredSize.Width + 2 * MarginWidth;

            Grid.SetColumn(rect, 0);
            Grid.SetRow(rect, 0);
            Grid.SetRowSpan(rect, 1);
            Grid.SetColumnSpan(rect, 3);
            Grid.SetRow(tb, 0);
            Grid.SetColumn(tb, 1);
            this.postGrid.Children.Add(rect);
            this.postGrid.Children.Add(tb);

            Canvas.SetLeft(this.postGrid, Math.Max(viewRightEdge - this.postGrid.Width - 20.0, textRightEdge + 20.0));
            Canvas.SetTop(this.postGrid, textGeometry.GetRenderBounds(solidPen).Top);

            this.Children.Add(this.postGrid);
        }
开发者ID:detroitpro,项目名称:ProStudioSearch,代码行数:59,代码来源:PostInfoDisplay.cs

示例13: GetDashPen

 public static Pen GetDashPen(this FrameworkElement element, Brush brush, double thickness)
 {
     var pen = new Pen(brush, thickness) { DashStyle = new DashStyle() };
     pen.DashStyle.Dashes.Add(1);
     pen.DashStyle.Dashes.Add(3);
     pen.Freeze();
     return pen;
 }
开发者ID:Mrding,项目名称:Ribbon,代码行数:8,代码来源:DrawingContextExtension.cs

示例14: drawEraserPoint

        public void drawEraserPoint(Point p, int thickness, int time)
        {
            prepareDraw(time);

            Pen pen = new Pen(new SolidColorBrush(Colors.Red), thickness);
            pen.Freeze();
            staticTactics[time].map.drawEraser(p, pen);
        }
开发者ID:riskawarrior,项目名称:tacticplanner,代码行数:8,代码来源:StaticTactic.cs

示例15: PhonemesElement

 public PhonemesElement()
     : base()
 {
     penEnv = new Pen( ThemeManager.NoteFillBrushes[0] , 1);
     penEnv.Freeze();
     penEnvSel = new Pen(ThemeManager.NoteFillSelectedBrush, 1);
     penEnvSel.Freeze();
 }
开发者ID:KineticIsEpic,项目名称:OpenUtau,代码行数:8,代码来源:PhonemesElement.cs


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