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


C# CGContext.DrawPath方法代码示例

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


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

示例1: CreateShape

        public override void CreateShape(CGPath path, CGContext gctx)
        {
            path.AddRect (new RectangleF (_origin, new SizeF (100, 100)));
            gctx.AddPath (path);

            gctx.DrawPath (CGPathDrawingMode.FillStroke);
        }
开发者ID:martinbowling,项目名称:iBabySmash,代码行数:7,代码来源:SquareView.cs

示例2: DrawMapRect

 /// <summary>
 /// Draws the map rectangle.
 /// </summary>
 /// <param name="mapRect">Map rectangle.</param>
 /// <param name="zoomScale">Zoom scale.</param>
 /// <param name="context"> Graphics context.</param>
 public override void DrawMapRect(MKMapRect mapRect, nfloat zoomScale, CGContext context)
 {
     base.DrawMapRect(mapRect, zoomScale, context);
     var multiPolygons = (MultiPolygon)this.polygonOverlay;
     foreach (var item in multiPolygons.Polygons)
     {
         var path = new CGPath();
         this.InvokeOnMainThread(() =>
             {
                 path = PolyPath(item.Polygon);
             });
         if (path != null)
         {
             context.SetFillColor(item.FillColor);
             context.BeginPath();
             context.AddPath(path);
             context.DrawPath(CGPathDrawingMode.EOFill);
             if (item.DrawOutlines)
             {
                 context.BeginPath();
                 context.AddPath(path);
                 context.StrokePath();
             }
         }
     }
 }
开发者ID:MilenPavlov,项目名称:treewatch,代码行数:32,代码来源:MultiPolygonView.cs

示例3: DrawGraph

        public void DrawGraph(CGContext g,nfloat x0,nfloat y0)
        {
            g.SetLineWidth (_lineWidth);

            // Draw background circle
            CGPath path = new CGPath ();
            _backColor.SetStroke ();
            path.AddArc (x0, y0, _radius, 0, 2.0f * (float)Math.PI, true);
            g.AddPath (path);
            g.DrawPath (CGPathDrawingMode.Stroke);

            // Draw overlay circle
            var pathStatus = new CGPath ();
            _frontColor.SetStroke ();
            pathStatus.AddArc(x0, y0, _radius, 0, _degrees * (float)Math.PI, false);
            g.AddPath (pathStatus);
            g.DrawPath (CGPathDrawingMode.Stroke);
        }
开发者ID:sarathdev,项目名称:Circle-Di-Graph,代码行数:18,代码来源:DashboardGraphView.cs

示例4: CreateShape

        public override void CreateShape(CGPath path, CGContext gctx)
        {
            path.AddLines (new PointF[] { _origin, new PointF (_origin.X + 50, _origin.Y + 100), new PointF (_origin.X - 50, _origin.Y + 100) });

            path.CloseSubpath ();

            gctx.AddPath (path);

            gctx.DrawPath (CGPathDrawingMode.FillStroke);
        }
开发者ID:martinbowling,项目名称:iBabySmash,代码行数:10,代码来源:TriangleView.cs

示例5: DrawPolyline

 public void DrawPolyline(MKPolyline polygon,MKMapRect mapRect, float zoomScale, CGContext context)
 {
     CGPath path = this.polyPath (polygon,mapRect,zoomScale,context);
     if (path != null)
     {
         this.ApplyFillProperties (context, zoomScale);
         context.BeginPath ();
         context.AddPath (path);
         context.DrawPath (CGPathDrawingMode.Stroke);
         this.ApplyStrokeProperties (context, zoomScale);
         context.BeginPath ();
         context.AddPath (path);
         context.StrokePath ();
     }
 }
开发者ID:Clancey,项目名称:ClanceyLib,代码行数:15,代码来源:PolylineOverlay.cs

示例6: DrawMapRect

 public override void DrawMapRect (MKMapRect mapRect, float zoomScale, CGContext context)
 {
     UIGraphics.PushContext(context);
     
     context.SetLineWidth (4000);    
     
     UIColor.Blue.SetFill();  
     CGPath path = new CGPath ();
     
     RectangleF r = this.RectForMapRect(_overlay.BoundingMapRect());
     PointF _origin = r.Location;
                          
     path.AddLines (new PointF[] { 
         _origin, 
         new PointF (_origin.X + 35000, _origin.Y + 80000),
         new PointF (_origin.X - 50000, _origin.Y + 30000),
         new PointF (_origin.X + 50000, _origin.Y + 30000),
         new PointF (_origin.X - 35000, _origin.Y + 80000) });
              
     context.AddPath (path);
     context.DrawPath (CGPathDrawingMode.Fill);
     
     UIGraphics.PopContext();
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:24,代码来源:CustomOverlayView.cs

示例7: DrawBorder

		private void DrawBorder(CGContext context, CGPath path)
		{
			var separatorColor = Element.Theme.SeparatorColor ?? TableView.SeparatorColor;

		    context.SetLineWidth(1);

			context.SetStrokeColor(separatorColor.CGColor);
			context.SetShadowWithColor(new SizeF(0,0), 0f, UIColor.Clear.CGColor);
			context.AddPath(path);
			context.DrawPath(CGPathDrawingMode.Stroke);

			return;
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:13,代码来源:UITableViewElementCell.cs

示例8: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);
		// Drawing with a blue fill color
		context.SetFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);

		CGPoint center;

		// Draw a Star stroked
		center = new CGPoint (90, 90);
		context.MoveTo (center.X, center.Y + 60);
		for (int i = 1; i < 5; ++i) {
			float x = (float)(60 * Math.Sin (i * 4 * Math.PI / 5));
			float y = (float)(60 * Math.Cos (i * 4 * Math.PI / 5));

			context.AddLineToPoint (center.X + x, center.Y + y);
		}
		// Closing the path connects the current point to the start of the current path.
		context.ClosePath ();
		// And stroke the path
		context.StrokePath ();

		// Draw a Star filled
		center = new CGPoint (90, 210);
		context.MoveTo (center.X, center.Y + 60);
		for (int i = 1; i < 5; ++i) {
			float x = (float)(60 * Math.Sin (i * 4 * Math.PI / 5));
			float y = (float)(60 * Math.Cos (i * 4 * Math.PI / 5));
			context.AddLineToPoint (center.X + x, center.Y + y);
		}
		// Closing the path connects the current point to the start of the current path.
		context.ClosePath ();
		// Use the winding-rule fill mode.
		context.FillPath ();

		// Draw a Star filled
		center = new CGPoint (90, 330);
		context.MoveTo (center.X, center.Y + 60);
		for (int i = 1; i < 5; ++i) {
			float x = (float)(60 * Math.Sin (i * 4 * Math.PI / 5));
			float y = (float)(60 * Math.Cos (i * 4 * Math.PI / 5));
			context.AddLineToPoint (center.X + x, center.Y + y);
		}
		// Closing the path connects the current point to the start of the current path.
		context.ClosePath ();
		// Use the even-odd fill mode.
		context.EOFillPath ();

		// Draw a Hexagon stroked
		center = new CGPoint (210, 90);
		context.MoveTo (center.X, center.Y + 60);
		for (int i = 1; i < 6; ++i) {
			float x = (float)(60 * Math.Sin (i * 2 * Math.PI / 6));
			float y = (float)(60 * Math.Cos (i * 2 * Math.PI / 6));
			context.AddLineToPoint (center.X + x, center.Y + y);
		}
		// Closing the path connects the current point to the start of the current path.
		context.ClosePath ();
		// And stroke the path
		context.StrokePath ();

		// Draw a Hexagon stroked & filled
		center = new CGPoint (210, 240);
		context.MoveTo (center.X, center.Y + 60);
		for (int i = 1; i < 6; ++i) {
			float x = (float)(60 * Math.Sin (i * 2 * Math.PI / 6));
			float y = (float)(60 * Math.Cos (i * 2 * Math.PI / 6));
			context.AddLineToPoint (center.X + x, center.Y + y);
		}
		// Closing the path connects the current point to the start of the current path.
		context.ClosePath ();
		// Use the winding-rule fill mode, and stroke the path after.
		context.DrawPath (CGPathDrawingMode.FillStroke);
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:77,代码来源:PolyDrawing.cs

示例9: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);
		// And draw with a blue fill color
		context.SetFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);

		// Add an ellipse circumscribed in the given rect to the current path, then stroke it
		context.AddEllipseInRect (new CGRect (30, 30, 60, 60));
		context.StrokePath ();

		// Stroke ellipse convenience that is equivalent to AddEllipseInRect(); StrokePath();
		context.StrokeEllipseInRect (new CGRect (30, 120, 60, 60));

		// Fill rect convenience equivalent to AddEllipseInRect(); FillPath();
		context.FillEllipseInRect (new CGRect (30, 210, 60, 60));

		// Stroke 2 seperate arcs
		context.AddArc (150, 60, 30, 0, (float)Math.PI / 2, false);
		context.StrokePath ();
		context.AddArc (150, 60, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
		context.StrokePath ();

		// Stroke 2 arcs together going opposite directions.
		context.AddArc (150, 150, 30, 0, (float)Math.PI / 2, false);
		context.AddArc (150, 150, 30, (float)(3 * Math.PI / 2), (float)Math.PI, true);
		context.StrokePath ();

		// Stroke 2 arcs together going the same direction..
		context.AddArc (150, 240, 30, 0, (float)(Math.PI / 2), false);
		context.AddArc (150, 240, 30, (float)Math.PI, (float)(3 * Math.PI / 2), false);
		context.StrokePath ();

		// Stroke an arc using AddArcToPoint
		CGPoint[] p = {
			new CGPoint (210, 30),
			new CGPoint (210, 60),
			new CGPoint (240, 60),
		};
		context.MoveTo (p [0].X, p [0].Y);
		context.AddArcToPoint (p [1].X, p [1].Y, p [2].X, p [2].Y, 30);
		context.StrokePath ();

		// Show the two segments that are used to determine the tangent lines to draw the arc.
		context.SetStrokeColor (1, 0, 0, 1);
		context.AddLines (p);
		context.StrokePath ();

		// As a bonus, we'll combine arcs to create a round rectangle!

		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);

		// If you were making this as a routine, you would probably accept a rectangle
		// that defines its bounds, and a radius reflecting the "rounded-ness" of the rectangle.
		var rrect = new CGRect (210, 90, 60, 60);
		var radius = 10;
		// NOTE: At this point you may want to verify that your radius is no more than half
		// the width and height of your rectangle, as this technique degenerates for those cases.

		// In order to draw a rounded rectangle, we will take advantage of the fact that
		// context.AddArcToPoint will draw straight lines past the start and end of the arc
		// in order to create the path from the current position and the destination position.

		// In order to create the 4 arcs correctly, we need to know the min, mid and max positions
		// on the x and y lengths of the given rectangle.
		nfloat minx = rrect.X, midx = rrect.X + rrect.Width / 2, maxx = rrect.X + rrect.Width;
		nfloat miny = rrect.Y, midy = rrect.Y + rrect.Height / 2, maxy = rrect.Y + rrect.Height;

		// Next, we will go around the rectangle in the order given by the figure below.
		//       minx    midx    maxx
		// miny    2       3       4
		// midy   1 9              5
		// maxy    8       7       6
		// Which gives us a coincident start and end point, which is incidental to this technique, but still doesn't
		// form a closed path, so we still need to close the path to connect the ends correctly.
		// Thus we start by moving to point 1, then adding arcs through each pair of points that follows.
		// You could use a similar tecgnique to create any shape with rounded corners.

		// Start at 1
		context.MoveTo (minx, midy);
		// Add an arc through 2 to 3
		context.AddArcToPoint (minx, miny, midx, miny, radius);
		// Add an arc through 4 to 5
		context.AddArcToPoint (maxx, miny, maxx, midy, radius);
		// Add an arc through 6 to 7
		context.AddArcToPoint (maxx, maxy, midx, maxy, radius);
		// Add an arc through 8 to 9
		context.AddArcToPoint (minx, maxy, minx, midy, radius);
		// Close the path
		context.ClosePath ();
		// Fill & stroke the path
		context.DrawPath (CGPathDrawingMode.FillStroke);
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:96,代码来源:CurveDrawing.cs

示例10: DrawLayer

 public override void DrawLayer (CALayer layer, CGContext context)
 {   
     context.SetLineWidth (4);
     var path = new CGPath ();
     path.AddLines(new PointF[]{new PointF(0,0), new PointF(100,100), new PointF(100,0)});
     path.CloseSubpath ();
     context.AddPath (path);
     context.DrawPath (CGPathDrawingMode.Stroke);            
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:9,代码来源:AnimationViewController.xib.cs

示例11: DrawLines

        private void DrawLines(CGContext context)
        {
            context.SetDefaultLineSettings();

            for (float i = 0; i <= Frame.Height; i += cellHeight)
                context.AddLines(new[] { new PointF(Frame.X, Frame.Y + i), new PointF(Frame.X + Frame.Width, Frame.Y + i) });

            for (float i = 0; i <= Frame.Width; i += cellWidth)
                context.AddLines(new[] { new PointF(Frame.X + i, Frame.Y), new PointF(Frame.X + i, Frame.Y + Frame.Height) });

            context.DrawPath(CGPathDrawingMode.Stroke);
        }
开发者ID:ThunderMasta,项目名称:DyedSudoku,代码行数:12,代码来源:DialogViewModel.cs

示例12: DrawBackground

        private void DrawBackground(CGContext context)
        {
            context.SetFillDialogBorderColor();
            context.AddRect(
                new RectangleF(Frame.X - Border,
                               Frame.Y - Border,
                               Frame.Width + 2 * Border,
                               Frame.Height + 2 * Border));

            context.DrawPath(CGPathDrawingMode.Fill);

            context.SetFillDialogBackgroungColor();
            context.AddRect(Frame);
            context.DrawPath(CGPathDrawingMode.Fill);
        }
开发者ID:ThunderMasta,项目名称:DyedSudoku,代码行数:15,代码来源:DialogViewModel.cs

示例13: drawUnfilledArcInContext

        public static void drawUnfilledArcInContext(CGContext ctx, CGPoint center, nfloat radius, nfloat lineWidth, nfloat fromAngleFromNorth, nfloat toAngleFromNorth)
        {
            var cartesianFromAngle = (nfloat)CompassToCartesian(ConvertToRadians(fromAngleFromNorth));
            var cartesianToAngle = (nfloat)CompassToCartesian(ConvertToRadians(toAngleFromNorth));
            
            ctx.AddArc(center.X,   // arc start point x
                            center.Y,   // arc start point y
                            radius,     // arc radius from center
                            cartesianFromAngle, cartesianToAngle,
                            false); // iOS flips the y coordinate so anti-clockwise (specified here by 0) becomes clockwise (desired)!

            ctx.SetLineWidth(lineWidth);
            ctx.SetLineCap(CGLineCap.Butt);
            ctx.DrawPath(CGPathDrawingMode.Stroke);
        }
开发者ID:xabre,项目名称:Xamarin-CircularSlider-SeekArc,代码行数:15,代码来源:Utils.cs

示例14: DrawRect


//.........这里部分代码省略.........
                g.SetFillColor(strokeColor);
                List<Arc> innerArcs = new List<Arc>();
                if (cornerRadius.TopLeft != 0)
                {
                    innerArcs.Add(this.DrawArc(g, cornerRadius.TopLeft, center, borderThickness.LeftF(), borderThickness.TopF(), 180f, 270f));
                }
                else
                {
                    innerArcs.Add(new Arc() { Center = center });
                }
                g.BeginPath();
                g.SetLineWidth(borderThickness.TopF());
                g.MoveTo((nfloat)cornerRadius.TopLeft, borderThickness.TopF() / 2);
                g.AddLineToPoint(rect.Right - (nfloat)cornerRadius.TopRight - borderThickness.RightF() / 2, borderThickness.TopF() / 2);
                g.StrokePath();
                center = new CGPoint(rect.Right - cornerRadius.TopRight - borderThickness.Right / 2, rect.Top + cornerRadius.TopRight + borderThickness.Top / 2);
                if (cornerRadius.TopRight != 0)
                {
                    innerArcs.Add(this.DrawArc(g, cornerRadius.TopRight, center, borderThickness.TopF(), borderThickness.RightF(), -90f, 0f));
                }
                else
                {
                    innerArcs.Add(new Arc { Center = center });
                }
                g.BeginPath();
                g.SetLineWidth(borderThickness.RightF());
                g.MoveTo(rect.Right - borderThickness.RightF() / 2, (nfloat)cornerRadius.TopRight);
                g.AddLineToPoint(rect.Right - borderThickness.RightF() / 2, rect.Height - (nfloat)cornerRadius.BottomRight);
                g.StrokePath();
                center = new CGPoint(rect.Right - cornerRadius.BottomRight - borderThickness.Right / 2, rect.Bottom - cornerRadius.BottomRight - borderThickness.Bottom / 2);
                if (cornerRadius.BottomRight != 0)
                {
                    innerArcs.Add(this.DrawArc(g, cornerRadius.BottomRight, center, borderThickness.RightF(), borderThickness.BottomF(), 0f, 90f));
                }
                else
                {
                    innerArcs.Add(new Arc() { Center = center });
                }
                g.BeginPath();
                g.SetLineWidth(borderThickness.BottomF());
                g.MoveTo(rect.Right - (nfloat)cornerRadius.BottomRight, rect.Bottom - borderThickness.BottomF() / 2);
                g.AddLineToPoint(rect.Left + (nfloat)cornerRadius.BottomLeft, rect.Bottom - borderThickness.BottomF() / 2);
                g.StrokePath();
                center = new CGPoint((rect.Left + cornerRadius.BottomLeft + borderThickness.Left / 2), (rect.Bottom - cornerRadius.BottomLeft - borderThickness.Bottom / 2));
                if (cornerRadius.BottomLeft != 0)
                {
                    innerArcs.Add(this.DrawArc(g, cornerRadius.BottomLeft, center, borderThickness.BottomF(), borderThickness.LeftF(), 90f, 180f));
                }
                else
                {
                    innerArcs.Add(new Arc() { Center = center });
                }
                g.SetLineWidth((nfloat)borderThickness.Left);
                g.MoveTo(rect.Left + borderThickness.LeftF() / 2, rect.Bottom - (nfloat)cornerRadius.BottomLeft);
                g.AddLineToPoint(rect.Left + borderThickness.LeftF() / 2, rect.Top + (nfloat)cornerRadius.TopLeft);
                g.StrokePath();
                if (fill != null)
                {
                    var fillColor = fill.ToUIColor(rect.Size).CGColor;
                    g.SetFillColor(fillColor);
                    g.SetLineWidth(0);
                    using (CGPath path = new CGPath())
                    {
                        path.AddArc(
                            innerArcs[0].Center.X,
                            innerArcs[0].Center.Y,
                            innerArcs[0].Radius,
                            innerArcs[0].EndingAngle,
                            innerArcs[0].StartingAngle,
                            false);

                        path.AddArc(
                            innerArcs[1].Center.X,
                            innerArcs[1].Center.Y,
                            innerArcs[1].Radius,
                            innerArcs[1].EndingAngle,
                            innerArcs[1].StartingAngle,
                            false);

                        path.AddArc(
                            innerArcs[2].Center.X,
                            innerArcs[2].Center.Y,
                            innerArcs[2].Radius,
                            innerArcs[2].EndingAngle,
                            innerArcs[2].StartingAngle,
                            false);

                        path.AddArc(
                            innerArcs[3].Center.X,
                            innerArcs[3].Center.Y,
                            innerArcs[3].Radius,
                            innerArcs[3].EndingAngle,
                            innerArcs[3].StartingAngle,
                            false);

                        g.AddPath(path);
                        g.DrawPath(CGPathDrawingMode.Fill);
                    }
                }
            }
开发者ID:evnik,项目名称:UIFramework,代码行数:101,代码来源:Border.iOS.cs


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