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


C# CGPath.AddLines方法代码示例

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


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

示例1: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw (rect);

            var gctx = UIGraphics.GetCurrentContext ();

            // setting blend mode to clear and filling with
            // a clear color results in a transparent fill
            gctx.SetFillColor (UIColor.Purple.CGColor);
            gctx.FillRect (rect);

            gctx.SetBlendMode (CGBlendMode.Clear);
            UIColor.Clear.SetColor ();

            // create some cutout geometry
            var path = new CGPath ();
            path.AddLines(new CGPoint[]{
                new CGPoint(100,200),
                new CGPoint(160,100),
                new CGPoint(220,200)});
            path.CloseSubpath();

            gctx.AddPath(path);
            gctx.DrawPath(CGPathDrawingMode.Fill);
        }
开发者ID:yofanana,项目名称:recipes,代码行数:25,代码来源:TransparentRegionView.cs

示例2: ViewDidAppear

		public override void ViewDidAppear (bool animated)
		{
			base.ViewDidAppear (animated);

			// get the initial value to start the animation from
			PointF fromPt = layer.Position;

			// set the position to coincide with the final animation value
			// to prevent it from snapping back to the starting position
			// after the animation completes
			layer.Position = new PointF (200, 300);

			// create a path for the animation to follow
			CGPath path = new CGPath ();
			path.AddLines (new PointF[] { fromPt, new PointF (50, 300), new PointF (200, 50), new PointF (200, 300) });

			// create a keyframe animation for the position using the path
			CAKeyFrameAnimation animPosition = (CAKeyFrameAnimation)CAKeyFrameAnimation.FromKeyPath ("position");
			animPosition.Path = path;
			animPosition.Duration = 2;

			// add the animation to the layer
			// the "position" key is used to overwrite the implicit animation created
			// when the layer positino is set above
			layer.AddAnimation (animPosition, "position");
		}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:26,代码来源:ExplicitLayerAnimation.cs

示例3: Draw

 public override void Draw (RectangleF rect)
 {
     base.Draw (rect);
     
     //get graphics context
     CGContext gctx = UIGraphics.GetCurrentContext ();
     
     //set up drawing attributes
     gctx.SetLineWidth (2);
     UIColor.Gray.SetFill ();
     UIColor.Black.SetStroke ();
     
     //create geometry
     _path = new CGPath ();
     
     _path.AddLines (new PointF[] { new PointF (110, 100), new PointF (210, 100), new PointF (210, 200), new PointF (110, 200) });
     
     _path.CloseSubpath ();
     
     //add geometry to graphics context and draw it
     gctx.AddPath (_path);
     gctx.DrawPath (CGPathDrawingMode.FillStroke);
     
     _titleLabel.Frame = new RectangleF (5, 5, Bounds.Width - 10, 25);
     this.AddSubview (_titleLabel);
 }
开发者ID:enricos,项目名称:learning_monotouch_code,代码行数:26,代码来源:SecondView.cs

示例4: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
            this.BackgroundColor = UIColor.Clear;

            //get graphics context
            using (CGContext g = UIGraphics.GetCurrentContext())
            {

                //set up drawing attributes
                g.SetLineWidth(_lineWidth);
                _color.SetFill();
                //_color.SetStroke();
                UIColor.Clear.SetStroke();
                g.SetAlpha(_transparancy);

                //create geometry
                var path = new CGPath();

                path.AddLines(new CGPoint[]{
					new CGPoint (rect.X + rect.Width, rect.Y),
					new CGPoint (rect.X + rect.Width, rect.Y + rect.Height), 
					new CGPoint (rect.X, rect.Y + rect.Height)});

                path.CloseSubpath();

                //add geometry to graphics context and draw it
                g.AddPath(path);
                g.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:31,代码来源:CropperResizerView.cs

示例5: Draw

		public override void Draw (CGRect rect)
		{
			base.Draw (rect);

			var gctx = UIGraphics.GetCurrentContext ();

			// setting blend mode to clear and filling with
			// a clear color results in a transparent fill
			gctx.SetFillColor (UIColor.Clear.CGColor);
			gctx.FillRect (rect);

			//gctx.SetBlendMode (CGBlendMode.Clear);
			UIColor.Black.SetColor ();

			// create some cutout geometry
			var path = new CGPath ();   
			path.AddLines(new CGPoint[]{
				new CGPoint(0,rect.Height * (1.0/4.0)),
				new CGPoint(rect.Width * (3.0/5.0),rect.Height * (1.0/4.0)),
				new CGPoint(rect.Width * (3.0/5.0),0),
				new CGPoint(rect.Width,rect.Height / 2),
				new CGPoint(rect.Width * (3.0/5.0), rect.Height),
				new CGPoint(rect.Width * (3.0/5.0),rect.Height * (3.0/4.0)),
				new CGPoint(0, rect.Height * (3.0/4.0))
			}); 
			path.CloseSubpath();

			gctx.AddPath(path);
			gctx.DrawPath(CGPathDrawingMode.Fill);  
		}
开发者ID:ytechie,项目名称:BandPowerPointRemote.iOS,代码行数:30,代码来源:Arrow.cs

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

示例7: Draw

        public override void Draw (RectangleF rect)
        {
            base.Draw (rect);
            
            // get graphics context
            CGContext gctx = UIGraphics.GetCurrentContext ();
            
            // set up drawing attributes
            gctx.SetLineWidth (4);
            UIColor.Yellow.SetStroke ();
            
            // stroke with a dashed line
            gctx.SetLineDash (3, new float[] {6,2});     
            
            // create geometry
            var path = new CGPath ();
            
            PointF origin = new PointF (Bounds.GetMidX (), 
                                        Bounds.GetMinY () + 10);
            
            path.AddLines (new PointF[] { 
                origin, 
                new PointF (origin.X + 35, origin.Y + 80), 
                new PointF (origin.X - 50, origin.Y + 30), 
                new PointF (origin.X + 50, origin.Y + 30), 
                new PointF (origin.X - 35, origin.Y + 80) });
            
            path.CloseSubpath ();
            
            // add geometry to graphics context and draw it
            gctx.AddPath (path);
         
            gctx.DrawPath (CGPathDrawingMode.Stroke);

            // fill the star with a gradient          
            gctx.AddPath (path);          
            gctx.Clip ();
                 
            RectangleF starBoundingBox = path.BoundingBox;
            
            float[] locations = { 0.0f, 1.0f };
            float[] components = { 1.0f, 0.0f, 0.0f, 1.0f,
                                   0.0f, 0.0f, 1.0f, 1.0f };
            
            using (var rgb = CGColorSpace.CreateDeviceRGB()) {
                CGGradient gradient = new CGGradient (rgb, components, locations);  
 
                PointF gradientStart = new PointF (starBoundingBox.Left, starBoundingBox.Top);
                PointF gradientEnd = new PointF (starBoundingBox.Right, starBoundingBox.Bottom);
                gctx.DrawLinearGradient (gradient, gradientStart, gradientEnd, CGGradientDrawingOptions.DrawsBeforeStartLocation);
            }
        }
开发者ID:GSerjo,项目名称:Seminars,代码行数:52,代码来源:StarView.cs

示例8: Draw

		public override void Draw (CGRect rect)
		{
			base.Draw (rect);

			//get graphics context
			using (CGContext g = UIGraphics.GetCurrentContext ()) {

				//set up drawing attributes
				g.SetLineWidth (10);
				UIColor.Blue.SetFill ();
				UIColor.Red.SetStroke ();

				//create geometry
				var path = new CGPath ();

				path.AddLines (new CGPoint[]{
				new CGPoint (100, 200),
				new CGPoint (160, 100),
				new CGPoint (220, 200)});

				path.CloseSubpath ();

				//use a dashed line
				g.SetLineDash (0, new nfloat[]{10, 4});

				//add geometry to graphics context and draw it
				g.AddPath (path);
				g.DrawPath (CGPathDrawingMode.FillStroke);

				// add the path back to the graphics context so that it is the current path
				g.AddPath (path);
				// set the current path to be the clipping path
				g.Clip ();

				// the color space determines how Core Graphics interprets color information
				using (CGColorSpace rgb = CGColorSpace.CreateDeviceRGB()) {
					CGGradient gradient = new CGGradient (rgb, new CGColor[] {
					UIColor.Blue.CGColor,
					UIColor.Yellow.CGColor
				});

					// draw a linear gradient
					g.DrawLinearGradient (
					gradient,
					new CGPoint (path.BoundingBox.Left, path.BoundingBox.Top),
					new CGPoint (path.BoundingBox.Right, path.BoundingBox.Bottom),
					CGGradientDrawingOptions.DrawsBeforeStartLocation);
				}
			}
		}
开发者ID:g7steve,项目名称:monotouch-samples,代码行数:50,代码来源:TriangleView.cs

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

示例10: Draw

		public override void Draw (CGRect rect)
		{
			foreach (var line in Lines) {
				line.Color.SetStroke ();
				line.Path.Stroke ();


			}

			var context = UIGraphics.GetCurrentContext ();

			context.SetLineWidth(1);

			UIColor.Gray.SetStroke ();

			var path = new CGPath ();

			path.AddLines(new CGPoint[]{
				new CGPoint(rect.Size.Width/2,0),
				new CGPoint(rect.Size.Width/2,rect.Size.Height), 

			});
			path.AddLines(new CGPoint[]{
				new CGPoint(0,rect.Size.Height/2),
				new CGPoint(rect.Size.Width,rect.Size.Height/2), 

			});
			path.CloseSubpath();

			context.AddPath(path);      
			context.DrawPath(CGPathDrawingMode.FillStroke);
		}
开发者ID:kimuraeiji214,项目名称:Keys,代码行数:32,代码来源:WritingView.cs

示例11: Draw

		public override void Draw (CGRect rect)
		{
			DirectionArrow dv = (DirectionArrow)Element;

			var bounds = Bounds;

			float width;
			float height;

			width = height = (float)Math.Min(Bounds.Width, Bounds.Height);

			float centerX = width / 2.0f;
			float centerY = height / 2.0f;
			float size = (width * 0.8f) / 2.0f;
			float sizeSmall = size * 0.6f;

			// Draw background circle
			using (var context = UIGraphics.GetCurrentContext ()) {
				context.SetFillColor (dv.CircleColor.ToCGColor ());
				context.SetStrokeColor (dv.CircleColor.ToCGColor ());
				context.SetLineWidth (0.0f);
				// Draw circle
				using (CGPath path = new CGPath ()) {

					// Set colors and line widhts
					context.SetLineWidth (0.0f);
					context.SetStrokeColor (dv.CircleColor.ToCGColor ());
					context.SetFillColor (dv.CircleColor.ToCGColor ());
					// Draw circle
					path.AddArc (centerX, centerY, centerX, 0.0f, (float)Math.PI * 2.0f, true);
					path.CloseSubpath ();
					// Draw path
					context.AddPath (path);
					context.DrawPath (CGPathDrawingMode.FillStroke);

				}
			}

			// Check, if we inside of the zone
			if (double.IsPositiveInfinity(dv.Direction)) {
				// Draw circle, because we are here
				using (var context = UIGraphics.GetCurrentContext ()) {
					context.SetFillColor (dv.ArrowColor.ToCGColor ());
					context.SetStrokeColor (dv.ArrowColor.ToCGColor ());
					context.SetLineWidth (5.0f);
					// Draw circle
					using (CGPath path = new CGPath ()) {
						// Draw circle
						path.AddArc (centerX, centerY, centerX * 0.3f, 0.0f, (float)Math.PI * 2.0f, true);
						path.CloseSubpath ();
						// Draw path
						context.AddPath (path);
						context.DrawPath (CGPathDrawingMode.FillStroke);
					}
				}

				return;
			}

			// Check, if the direction is invalid
			if (double.IsNegativeInfinity(dv.Direction)) {
				// Draw cross, because direction is invalid
				using (var context = UIGraphics.GetCurrentContext()) {
					context.SetFillColor(dv.ArrowColor.ToCGColor());
					context.SetStrokeColor(dv.ArrowColor.ToCGColor());
					context.SetLineWidth(0.1875f * width);
					context.SetLineCap(CGLineCap.Round);
					// Draw circle
					using (CGPath path = new CGPath ()) {
						// Draw cross
						var points = new List<CGPoint>(2);

						points.Add(new CGPoint(centerX - centerX * 0.4f, centerY - centerY * 0.4f));
						points.Add(new CGPoint(centerX + centerX * 0.4f, centerY + centerY * 0.4f));

						path.AddLines(points.ToArray());

						path.CloseSubpath ();
						context.AddPath (path);

						points = new List<CGPoint>(2);

						points.Add(new CGPoint(centerX - centerX * 0.4f, centerY + centerY * 0.4f));
						points.Add(new CGPoint(centerX + centerX * 0.4f, centerY - centerY * 0.4f));

						path.AddLines(points.ToArray());

						path.CloseSubpath ();
						context.AddPath (path);

						context.SetLineCap(CGLineCap.Round);
						context.DrawPath(CGPathDrawingMode.Stroke);
					}
				}

				return;
			}

			// We have a direction, so draw an arrow
			var direction = 180.0 - dv.Direction;
//.........这里部分代码省略.........
开发者ID:Surfoo,项目名称:WF.Player,代码行数:101,代码来源:DirectionArrowRenderer.cs

示例12: Draw

		public override void Draw (CGRect rect)
		{
			base.Draw (rect);


			_highTemps = null;
			_lowTemps = null;

			_hourlyTemps = null;


			if (Forecasts.Count == 0 || Hourly.Count == 0) return;


			graphRect = new CGRect (rect.X + padding, rect.Y + padding, rect.Width - (padding * 2), rect.Height - (padding * 2));


			var days = Hourly.GroupBy (h => h.FCTTIME.mday).Select (g => g.First ().FCTTIME.weekday_name_abbrev).ToList ();

			var dayCount = hourly ? days.Count : Forecasts.Count;


			var xAxisScale = (graphRect.Width + padding / 2) / dayCount;

			inset = xAxisScale / 2;


			var highest = (nfloat)(hourly ? HourlyTemps.Max () : HighTemps.Max ());
			var lowest = (nfloat)(hourly ? HourlyTemps.Min () : LowTemps.Min ());


			scaleHigh = NMath.Round (highest, MidpointRounding.AwayFromZero);
			scaleLow = lowest < 0 ? NMath.Round (lowest, MidpointRounding.AwayFromZero) : NMath.Round (lowest);

			var rangePadding = Settings.UomTemperature.IsImperial () ? scalePadding : (scalePadding / 2);


			scaleHigh += rangePadding;
			scaleLow -= rangePadding;

			scaleRange = scaleHigh - scaleLow;


			var scaleIncrement = scaleRange / dividerCount;

			scaleX = (graphRect.Width - inset) / (hourly ? HourlyTemps.Count : Forecasts.Count);
			scaleY = graphRect.Height / dividerCount;


			nfloat x, y;


			using (CGContext ctx = UIGraphics.GetCurrentContext ()) {

				// Draw x and y axis
				using (UIColor color = UIColor.White) {

					color.SetStroke ();
					ctx.SetLineWidth (1);

					using (CGPath p = new CGPath ()) {

						p.MoveToPoint (graphRect.GetMinX (), graphRect.GetMaxY ());

						p.AddLines (new [] {
							new CGPoint (graphRect.GetMinX (), graphRect.GetMinY ()),
							new CGPoint (graphRect.GetMinX (), graphRect.GetMaxY ()),
							new CGPoint (graphRect.GetMaxX (), graphRect.GetMaxY ())
						});

						ctx.AddPath (p);
						ctx.DrawPath (CGPathDrawingMode.Stroke);
					}
				}


				// Draw horizontal gridlines
				using (UIColor color = UIColor.Black.ColorWithAlpha (0.08f)) {

					for (int i = 1; i < dividerCount; i += 2) {

						y = (i + 1) * scaleY;

						color.SetFill ();
						ctx.FillRect (new CGRect (graphRect.GetMinX (), graphRect.GetMaxY () - y, graphRect.Width, scaleY));
						ctx.StrokePath ();
					}
				}



				drawLines ();


				// Draw y-axis labels

				nfloat yStep = scaleLow;

				ctx.SaveState ();
				ctx.TranslateCTM (0, rect.Height);
//.........这里部分代码省略.........
开发者ID:colbylwilliams,项目名称:XWeather,代码行数:101,代码来源:DailyGraphView.cs

示例13: DrawLine

 private void DrawLine(int x, int y, int x2, int y2)
 {
     var path = new CGPath();
     path.AddLines(new CGPoint[] { new CGPoint(x, y), new CGPoint(x2, y2) });
     path.CloseSubpath();
     _context.AddPath(path);       
     _context.DrawPath(CGPathDrawingMode.Stroke);
 }
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:8,代码来源:AudioVisualizer.cs

示例14: Draw

        public override void Draw(CGRect rect)
        {
            base.Draw (rect);
             using (CGContext g = UIGraphics.GetCurrentContext ())
             {
            if (!isCroppedImageDisplayed)
            {
               g.ClearRect (Frame);

               g.SetLineWidth (10);
               UIColor.Blue.SetFill ();
               UIColor.Red.SetStroke ();

               var path = new CGPath ();
               path.AddLines (_markers.Select (x => x.Location).ToArray ());
               path.CloseSubpath ();

               g.AddPath (path);
               g.DrawPath (CGPathDrawingMode.FillStroke);
            }
            else
            {
               g.ClearRect (Frame);
               var markers = _markers;
               foreach (var marker in markers)
               {
                  marker.RemoveFromSuperview ();
               }
            }
             }
        }
开发者ID:bkmza,项目名称:XamCropBkmzaSampleIOS,代码行数:31,代码来源:BCroppableView.cs

示例15: Draw

            public override void Draw(RectangleF rect)
            {
                base.Draw (rect);
                // Red underline
                using (CGContext context = UIGraphics.GetCurrentContext ()) {
                    context.SetLineWidth(1);
                    UIColor.Red.SetStroke ();

                    //create geometry
                    CGPath path = new CGPath ();

                    path.AddLines(new PointF[]{
                        new PointF(5, rect.Height -5),
                        new PointF(rect.Width-5, rect.Height -5)});

                    path.CloseSubpath();

                    //add geometry to graphics context and draw it
                    context.AddPath(path);
                    context.DrawPath(CGPathDrawingMode.FillStroke);
                };
            }
开发者ID:jeanfrancoisdrapeau,项目名称:ProScanMobile-,代码行数:22,代码来源:TableCell.cs


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