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


C# CGPath.AddRect方法代码示例

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


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

示例1: Draw

        public override void Draw(CGRect rect)
        {
            //get graphics context
            using (CGContext g = UIGraphics.GetCurrentContext())
            {
                //set up drawing attributes
                UIColor.Black.SetFill();

                //create geometry
                _overlay = new CGPath();
                
                _overlay.AddRect(new RectangleF(0f, 0f, _width, _height));
                
                if(_isRound)
                    _overlay.AddEllipseInRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));
                else
                    _overlay.AddRect(new RectangleF((float)_rect.X, (float)_rect.Y, (float)_rect.Width, (float)_rect.Height));

                g.SetStrokeColor(UIColor.Clear.CGColor);
                g.SetAlpha(0.6f);

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

示例2: Draw

        public override void Draw(CGRect rect)
        {
            //get graphics context
            using (CGContext g = UIGraphics.GetCurrentContext())
            {                
                g.SetLineWidth(_lineWidth);
                //set up drawing attributes
                UIColor.Clear.SetFill();

                if (_isRound)
                {
                    var circle = new CGPath();
                    var circleSize = rect.Size.Width / 2;
                    circle.AddArc(circleSize, circleSize, circleSize, 0, endangle, true);
                    Console.WriteLine("circleSize: {0}", circleSize);
                    g.AddPath(circle);
                }
                else
                {
                    //create geometry
                    var rectangle = new CGPath();
                    rectangle.AddRect(new RectangleF(0f, 0f, (float)rect.Size.Width, (float)rect.Size.Height));
                    rectangle.CloseSubpath();
                    //add geometry to graphics context and draw it
                    g.AddPath(rectangle);
                }

                g.SetStrokeColor(_color.CGColor);
                g.SetAlpha(_transparancy);
                
                g.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:33,代码来源:CropperView.cs

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

示例4: Draw

		// rect changes depending on if the whole view is being redrawn, or just a section
		public override void Draw (CGRect rect)
		{
			Console.WriteLine ("Draw() Called");
			base.Draw (rect);

			using (CGContext context = UIGraphics.GetCurrentContext ()) {
				// draw a rectangle using a path
				myRectangleButtonPath = new CGPath ();
				myRectangleButtonPath.AddRect (new CGRect (new CGPoint (100, 10), new CGSize (200, 400)));
				context.AddPath (myRectangleButtonPath);
				context.DrawPath (CGPathDrawingMode.Stroke);
			}
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:14,代码来源:View.cs

示例5: Draw

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

            using (CGContext gctx = UIGraphics.GetCurrentContext()) {
                gctx.SetLineWidth(3);
                UIColor.Clear.SetFill();
                StrokeColor.SetStroke();

                path = new CGPath ();
                path.AddRect(rect);
                path.CloseSubpath();

                gctx.AddPath(path);
                gctx.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }
开发者ID:fdibartolo,项目名称:boletamovil,代码行数:17,代码来源:FrameView.cs

示例6: Draw

        public override void Draw(RectangleF rect)
        {
            using (var g = UIGraphics.GetCurrentContext())
            {
                g.SetLineWidth(10);
                UIColor.FromRGB(64,30,168).SetStroke ();
                UIColor.Clear.SetFill ();

                //create geometry
                var path = new CGPath ();
                path.AddRect (rect);
                path.CloseSubpath();

                //add geometry to graphics context and draw it
                g.AddPath(path);
                g.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:rmarinho,项目名称:AnirolaC-Toolkit,代码行数:18,代码来源:GridViewItemCell.cs

示例7: Draw

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

             using (var g = UIGraphics.GetCurrentContext ()) {

            g.SetFillColor (UIColor.Gray.CGColor);
            g.FillRect (rect);

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

            var path = new CGPath ();
            path.AddRect (new CGRect (origin, cropSize));

            g.AddPath (path);
            g.DrawPath (CGPathDrawingMode.Fill);
             }
        }
开发者ID:bkmza,项目名称:XamCropBkmzaSampleIOS,代码行数:19,代码来源:CropperView.cs

示例8: Draw

        public override void Draw(System.Drawing.RectangleF rect)
        {
            base.Draw (rect);

            CGContext context = UIGraphics.GetCurrentContext ();
            // Apply a transform that flips the Y axis, since CT uses a different coords system
            //			context.TextMatrix = CGAffineTransform.MakeIdentity ();
            //			context.TranslateCTM (0, this.Bounds.Size.Height);
            //			context.ScaleCTM (1.0f, -1.0f);

            CGPath path = new CGPath ();
            path.AddRect (this.Bounds);

            try {
                CTFrame frame = Framesetter.GetFrame (new NSRange (0, this._text.Length), path, null);

                frame.Draw (context);
            } catch (Exception ex) {
                Console.WriteLine (ex.Message);
            }
        }
开发者ID:cwenham,项目名称:SpendingConsequences,代码行数:21,代码来源:CoreTextView.cs

示例9: StringSize

		NativeSize StringSize (string str, int startIndex, int length)
		{
			if (str == null || length <= 0) return NativeSize.Empty;

			using (var astr = new NSMutableAttributedString (str)) {
				astr.AddAttributes (attrs, new NSRange (startIndex, length));
				using (var fs = new CTFramesetter (astr)) {
					using (var path = new CGPath ()) {
						path.AddRect (new NativeRect (0, 0, 30000, attrs.Font.XHeightMetric * 10));
						using (var f = fs.GetFrame (new NSRange (startIndex, length), path, null)) {
							var line = f.GetLines () [0];
							NativeValue a, d, l;
							var tw = line.GetTypographicBounds (out a, out d, out l);
							return new NativeSize ((float)tw, (a + d) * 1.2f);
						}
					}
				}
			}
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:19,代码来源:CoreGraphicsGraphics.cs

示例10: DrawString

		public void DrawString (string s, float x, float y)
		{
			if (string.IsNullOrEmpty (s))
				return;
			using (var astr = new NSMutableAttributedString (s)) {
				astr.AddAttributes (_attrs, new NSRange (0, s.Length));
				using (var fs = new CTFramesetter (astr)) {
					using (var path = new CGPath ()) {
						var h = _lastFont.Size * 2;
						path.AddRect (new NativeRect (0, 0, s.Length * h, h));
						using (var f = fs.GetFrame (new NSRange (0, 0), path, null)) {
							var line = f.GetLines () [0];
							NativeValue a, d, l;
							line.GetTypographicBounds (out a, out d, out l);

							_c.SaveState ();
							_c.TranslateCTM (x, h + y - d);
							_c.ScaleCTM (1, -1);

							f.Draw (_c);

							_c.RestoreState ();
						}
					}
				}
			}

//			var c = _color;
//			SetColor (Colors.Black);
//			DrawRect (x, y, 100, _lastFont.Size, 1);
//			SetColor (c);
		}
开发者ID:praeclarum,项目名称:Praeclarum,代码行数:32,代码来源:CoreGraphicsGraphics.cs

示例11: newPathInRect

 CGPath newPathInRect(RectangleF rect)
 {
     CGPath path = new CGPath ();
     path.AddRect (rect);
     return path;
 }
开发者ID:WinterGroveProductions,项目名称:monotouch-bindings,代码行数:6,代码来源:OverlayController.cs

示例12: Draw

		public override void Draw(RectangleF rect)
		{
			//temp until I figure out why dthis doesn't work properly on iPad.
			return;

			if (_Cell != null)
			{
				CGContext context = UIGraphics.GetCurrentContext();
				
				CGPath path;
				var borderRect = rect;

				if (_Cell.TableView.Style == UITableViewStyle.Grouped)
				{
					borderRect = _Cell.CalculateInnerRect();
					path = _Cell.GetCellBorderPath(borderRect);
				} 
				else
				{
					path = new CGPath();
					path.AddRect(borderRect);
				}
				
				context.AddPath(path);
				context.SetFillColor(_Cell.Element.Theme.DisabledColor.CGColor);
				context.SetBlendMode(CGBlendMode.Overlay);
				context.DrawPath(CGPathDrawingMode.Fill);
			}
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:29,代码来源:UITableViewElementCell.cs

示例13: DrawContentView

		public void DrawContentView()
		{
			if (!Highlighted)
			{
				var borderRect = Bounds;

				var innerRect = CalculateInnerRect(); 

				CGPath path = null;
				
				var backgroundColor = TableView.BackgroundColor;

				CGContext context = UIGraphics.GetCurrentContext();
				context.SaveState();
				

				context.SetFillColor(backgroundColor.CGColor);
	
				if (TableView.Style == UITableViewStyle.Grouped)
				{
					borderRect = CalculateInnerRect();
					path = GetCellBorderPath(borderRect);
				}
				else
				{
					path = new CGPath();
					path.AddRect(borderRect);
				}
				
				context.AddPath(path);
				context.Clip();
	
				ShouldDrawBorder = false;
				
				if (Element.Theme.DrawElementViewAction != null)
				{
					DrawElementView(innerRect, context);
				}

				context.RestoreState();

				if (ShouldDrawBorder)
				{
					DrawBorder(context, path);
				}
			}
		}
开发者ID:vknair74,项目名称:MonoMobile.Views,代码行数:47,代码来源:UITableViewElementCell.cs

示例14: DrawRectangle

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.SetAlias(true);
            var convertedRect = rect.ConvertAliased();

            if (fill.IsVisible())
            {
                this.SetFill(fill);
                using (var path = new CGPath())
                {
                    path.AddRect(convertedRect);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Fill);
            }

            if (stroke.IsVisible() && thickness > 0)
            {
                this.SetStroke(stroke, thickness);

                using (var path = new CGPath())
                {
                    path.AddRect(convertedRect);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:37,代码来源:CoreGraphicsRenderContext.cs

示例15: Draw

			public override void Draw (RectangleF rect)
			{
				Console.WriteLine ("# Draw: rect={{X={0}, Y={1}, Width={2}, Height={3}}}", rect.X, rect.Y, rect.Width, rect.Height);
				// Initialize a graphics context and set the text matrix to a known value
				var context = UIGraphics.GetCurrentContext ();
				// context.TextMatrix = CGAffineTransform.MakeIdentity ();
				context.TextMatrix = CGAffineTransform.MakeScale (1f, -1f);

	            // initialize a rectangular path
				var path = new CGPath ();
				// path.AddRect (new RectangleF (10.0f, 10.0f, 200.0f, 30.0f));
				path.AddRect (rect);
				RectangleF r;
				Console.WriteLine ("path.IsRect={0}; Width={1}, Height={2}", path.IsRect (out r), r.Width, r.Height);

				// initialize an attributed string
				var attrString = new NSMutableAttributedString ("We hold this truth to be self evident, that everyone is created equal.");
	            // use a red font for the first 50 chars
				attrString.AddAttributes(new CTStringAttributes () {
						ForegroundColor = new CGColor (
							CGColorSpace.CreateDeviceRGB(),
							new[]{1.0f, 0.0f, 0.0f, 0.8f}
						),
					}, new NSRange (0, 50));

				// Create the framesetter with the attributed string
				using (var framesetter = new CTFramesetter (attrString)) {
					NSRange fitRange;
					var size = framesetter.SuggestFrameSize (new NSRange (), null, new SizeF (200f, 200f), out fitRange);
					Console.WriteLine ("fitRange.Location={0}; fitRange.Length={1}", fitRange.Location, fitRange.Length);
					Console.WriteLine ("Size: Width={0}; Height={1}", size.Width, size.Height);

					// Create the frame and draw it into the graphics context
					using (var frame = framesetter.GetFrame (new NSRange (0, 70), path, null))
						frame.Draw (context);
					context.ShowText ("hello, world!");
				}
			}
开发者ID:jonpryor,项目名称:monotouch-samples,代码行数:38,代码来源:CoreTextDemo.cs


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