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


C# NGraphics.Pen类代码示例

本文整理汇总了C#中NGraphics.Pen的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: DrawLine

 public static void DrawLine(this ICanvas canvas, Point start, Point end, Pen pen)
 {
     var p = new Path { Pen = pen };
     p.MoveTo (start);
     p.LineTo (end);
     p.Draw (canvas);
 }
开发者ID:rbrian,项目名称:NGraphics,代码行数:7,代码来源:ICanvas.cs

示例2: Element

		protected Element (Pen pen, Brush brush)
		{
			Id = "";
			Pen = pen;
			Brush = brush;
			Transform = NGraphics.Transform.Identity;
		}
开发者ID:superlloyd,项目名称:NGraphics,代码行数:7,代码来源:Element.cs

示例3: Element

 public Element(Pen pen, Brush brush)
 {
     Id = Guid.NewGuid ().ToString ();
     Pen = pen;
     Brush = brush;
     Transform = NGraphics.Transform.Identity;
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:7,代码来源:Element.cs

示例4: DrawEllipse

		public void DrawEllipse (Rect frame, Pen pen = null, Brush brush = null)
		{
			var ch = GetChild (ChildType.Ellipse);
			var s = (Shapes.Rectangle)ch.Shape;
			s.Width = frame.Width;
			s.Height = frame.Height;
			FormatShape (s, pen, brush);
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:8,代码来源:CanvasCanvas.cs

示例5: Text

		public Text (Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
			: base (pen, brush)
		{
			Frame = frame;
			Font = font;
			Alignment = alignment;
			Spans = new List<TextSpan> ();
		}
开发者ID:michaelstonis,项目名称:NGraphics,代码行数:8,代码来源:Text.cs

示例6: Text

 public Text(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
     : base(pen, brush)
 {
     String = text;
     Frame = frame;
     Font = font;
     Alignment = alignment;
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:8,代码来源:Text.cs

示例7: Draw

		public override void Draw(ICanvas canvas, Rect rect)
		{
			if(DrawingFunction != null)
			{
				base.Draw(canvas, rect);
				return;
			}

			var borderColro = NGraphics.Color.FromHSL(
				                  BorderColor.Hue,
				                  BorderColor.Saturation,
				                  BorderColor.Luminosity,
				                  BorderColor.A);
			var pen = new Pen(borderColro, BorderWidth);
			var fillColor = NGraphics.Color.FromHSL(
				                BackColor.Hue,
				                BackColor.Saturation,
				                BackColor.Luminosity,
				                BackColor.A);
			var brush = new SolidBrush(fillColor);

			var padding = BorderWidth <= 0 ? 0.0 : BorderWidth;
			var newRect = rect.GetInflated(-padding);
			var curveSize = newRect.Height / 2;

			canvas.DrawPath(new PathOp []{ 
				new MoveTo(newRect.Left+curveSize, newRect.Top),
				new LineTo(newRect.Right-curveSize, newRect.Top),
				new CurveTo(
					new NGraphics.Point(newRect.Right-curveSize, newRect.Top),
					newRect.TopRight,
					new NGraphics.Point(newRect.Right, newRect.Top+curveSize)
				),
				new CurveTo(
					new NGraphics.Point(newRect.Right, newRect.Bottom-curveSize),
					newRect.BottomRight,
					new NGraphics.Point(newRect.Right-curveSize, newRect.Bottom)
				),
				new LineTo(newRect.Left+curveSize, newRect.Bottom),
				new CurveTo(
					new NGraphics.Point(newRect.Left+curveSize, newRect.Bottom),
					newRect.BottomLeft,
					new NGraphics.Point(newRect.Left, newRect.Bottom-curveSize)
				),
				new CurveTo(
					new NGraphics.Point(newRect.Left, newRect.Top+curveSize),
					newRect.TopLeft,
					new NGraphics.Point(newRect.Left+curveSize, newRect.Top)
				),
				new ClosePath()
			}, pen, brush);
		}
开发者ID:P3PPP,项目名称:XFAedSearch,代码行数:52,代码来源:RoundedButton.cs

示例8: DrawRectangle

 public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
 {
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:3,代码来源:NullPlatform.cs

示例9: DrawText

        public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
        {
            if (brush == null)
                return;

            var paint = GetFontPaint (font, alignment);
            var w = paint.MeasureText (text);
            var fm = paint.GetFontMetrics ();
            var h = fm.Ascent + fm.Descent;
            var point = frame.Position;
            var fr = new Rect (point, new Size (w, h));
            AddBrushPaint (paint, brush, fr);
            graphics.DrawText (text, (float)point.X, (float)point.Y, paint);
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:14,代码来源:AndroidPlatform.cs

示例10: GetPenPaint

 Paint GetPenPaint(Pen pen)
 {
     var paint = new Paint (PaintFlags.AntiAlias);
     paint.SetStyle (Paint.Style.Stroke);
     paint.SetARGB (pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B);
     paint.StrokeWidth = (float)pen.Width;
     return paint;
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:8,代码来源:AndroidPlatform.cs

示例11: DrawPath

        public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
        {
            if (pen == null && brush == null)
                return;

            using (var path = new global::Android.Graphics.Path ()) {

                var bb = new BoundingBoxBuilder ();

                foreach (var op in ops) {
                    var mt = op as MoveTo;
                    if (mt != null) {
                        var p = mt.Point;
                        path.MoveTo ((float)p.X, (float)p.Y);
                        bb.Add (p);
                        continue;
                    }
                    var lt = op as LineTo;
                    if (lt != null) {
                        var p = lt.Point;
                        path.LineTo ((float)p.X, (float)p.Y);
                        bb.Add (p);
                        continue;
                    }
                    var at = op as ArcTo;
                    if (at != null) {
                        var p = at.Point;
                        path.LineTo ((float)p.X, (float)p.Y);
                        bb.Add (p);
                        continue;
                    }
                    var ct = op as CurveTo;
                    if (ct != null) {
                        var p = ct.Point;
                        var c1 = ct.Control1;
                        var c2 = ct.Control2;
                        path.CubicTo ((float)c1.X, (float)c1.Y, (float)c2.X, (float)c2.Y, (float)p.X, (float)p.Y);
                        bb.Add (p);
                        bb.Add (c1);
                        bb.Add (c2);
                        continue;
                    }
                    var cp = op as ClosePath;
                    if (cp != null) {
                        path.Close ();
                        continue;
                    }

                    throw new NotSupportedException ("Path Op " + op);
                }

                var frame = bb.BoundingBox;

                if (brush != null) {
                    var paint = GetBrushPaint (brush, frame);
                    graphics.DrawPath (path, paint);
                }
                if (pen != null) {
                    var paint = GetPenPaint (pen);
                    graphics.DrawPath (path, paint);
                }
            }
        }
开发者ID:sami1971,项目名称:NGraphics,代码行数:63,代码来源:AndroidPlatform.cs

示例12: DrawRectangle

 public void DrawRectangle(Rect frame, Pen pen = null, Brush brush = null)
 {
     if (brush != null) {
         var paint = GetBrushPaint (brush, frame);
         graphics.DrawRect ((float)(frame.X), (float)(frame.Y), (float)(frame.X + frame.Width), (float)(frame.Y + frame.Height), paint);
     }
     if (pen != null) {
         var paint = GetPenPaint (pen);
         graphics.DrawRect ((float)(frame.X), (float)(frame.Y), (float)(frame.X + frame.Width), (float)(frame.Y + frame.Height), paint);
     }
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:11,代码来源:AndroidPlatform.cs

示例13: DrawPath

        public void DrawPath(IEnumerable<PathOp> ops, Pen pen = null, Brush brush = null)
        {
            var bb = new BoundingBoxBuilder ();
            var s = new D2D1.PathGeometry (factories.D2DFactory);
            var figureDepth = 0;
            using (var sink = s.Open ()) {
                foreach (var op in ops) {
                    if (op is MoveTo) {
                        while (figureDepth > 0) {
                            sink.EndFigure (D2D1.FigureEnd.Open);
                            figureDepth--;
                        }
                        var mt = ((MoveTo)op);
                        sink.BeginFigure (Conversions.ToVector2 (mt.Point), D2D1.FigureBegin.Filled);
                        figureDepth++;
                        bb.Add (mt.Point);
                    }
                    else if (op is LineTo) {
                        var lt = ((LineTo)op);
                        sink.AddLine (Conversions.ToVector2 (lt.Point));
                        bb.Add (lt.Point);
                    }
                    else if (op is ArcTo) {
                        var ar = ((ArcTo)op);
                        // TODO: Direct2D Arcs
                        //sink.AddArc (new D2D1.ArcSegment {
                        //	Size = Conversions.ToSize2F (ar.Radius),
                        //	Point = Conversions.ToVector2 (ar.Point),
                        //	SweepDirection = ar.SweepClockwise ? D2D1.SweepDirection.Clockwise : D2D1.SweepDirection.CounterClockwise,
                        //});
                        sink.AddLine (Conversions.ToVector2 (ar.Point));
                        bb.Add (ar.Point);
                    }
                    else if (op is CurveTo) {
                        var ct = ((CurveTo)op);
                        sink.AddBezier (new D2D1.BezierSegment {
                            Point1 = Conversions.ToVector2 (ct.Control1),
                            Point2 = Conversions.ToVector2 (ct.Control2),
                            Point3 = Conversions.ToVector2 (ct.Point),
                        });
                        bb.Add (ct.Point);
                        bb.Add (ct.Control1);
                        bb.Add (ct.Control2);
                    }
                    else if (op is ClosePath) {
                        sink.EndFigure (D2D1.FigureEnd.Closed);
                        figureDepth--;
                    }
                    else {
                        // TODO: More path operations
                    }
                }
                while (figureDepth > 0) {
                    sink.EndFigure (D2D1.FigureEnd.Open);
                    figureDepth--;
                }
                sink.Close ();
            }

            var p = GetBrush (pen);
            var b = GetBrush (bb.BoundingBox, brush);

            if (b != null) {
                renderTarget.FillGeometry (s, b);
            }
            if (p != null) {
                renderTarget.DrawGeometry (s, p, (float)pen.Width, GetStrokeStyle (pen));
            }
        }
开发者ID:rbrian,项目名称:NGraphics,代码行数:69,代码来源:Direct2DCanvas.cs

示例14: DrawEllipse

 public void DrawEllipse(Rect frame, Pen pen = null, Brush brush = null)
 {
     if (brush != null) {
         var paint = GetBrushPaint (brush, frame);
         graphics.DrawOval (Conversions.GetRectF (frame), paint);
     }
     if (pen != null) {
         var paint = GetPenPaint (pen);
         graphics.DrawOval (Conversions.GetRectF (frame), paint);
     }
 }
开发者ID:sami1971,项目名称:NGraphics,代码行数:11,代码来源:AndroidPlatform.cs

示例15: DrawText

 public void DrawText(string text, Rect frame, Font font, TextAlignment alignment = TextAlignment.Left, Pen pen = null, Brush brush = null)
 {
 }
开发者ID:xamarin-libraries,项目名称:xamarin-libraries,代码行数:3,代码来源:NullPlatform.cs


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