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


C# CGContext.SetLineWidth方法代码示例

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


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

示例1: Draw

        public override void Draw(CGRect bounds, CGContext context, UIView view)
        {
            var width = 0.5f / UIScreen.MainScreen.Scale;
            context.BeginPath();
            context.SetLineWidth(width);
            context.SetStrokeColor(UIColor.FromRGB(150, 150, 154).CGColor);
            var x = bounds.Width / 2f - width;
			context.MoveTo(x, 0f);
			context.AddLineToPoint(x, bounds.Height);
            context.StrokePath();

            var row = Value;
            var half = bounds.Height / 2;
            var halfText = _font.LineHeight / 2 + 1;

            row.Image1.Draw(new CGRect(15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text1))
            {
                UIColor.Gray.SetColor();
                new NSString(row.Text1).DrawString(new CGRect(36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }

            row.Image2.Draw(new CGRect(bounds.Width / 2 + 15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text2))
            {
                UIColor.Gray.SetColor();
                new NSString(row.Text2).DrawString(new CGRect(bounds.Width / 2 + 36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }
        }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:31,代码来源:SplitElement.cs

示例2: DrawEllipsis

 public static void DrawEllipsis(CGContext context, RectangleF rect, CGColor color, float lineWidth)
 {
     context.SaveState();
     context.SetStrokeColor(color);
     context.SetLineWidth(lineWidth);
     context.AddEllipseInRect(rect);
     context.StrokePath();
     context.RestoreState();
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:9,代码来源:CoreGraphicsHelper.cs

示例3: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		context.SetRGBStrokeColor (1, 1, 1, 1f);
		
		// Draw lines with a stroke width from 1-10
		for (int i = 1; i <= 10; ++i) {
			context.SetLineWidth (i);
			context.MoveTo (10, (float) i * 20.5f);
			context.AddLineToPoint (310, (float)i * 20.5f);
			context.StrokePath ();
		}
		
		// Demonstration that stroke is even on both sides of the line
		context.SetLineWidth(15);
		context.MoveTo (10, 245.5f);
		context.AddLineToPoint (310, 245.5f);
		context.StrokePath ();
	
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.SetLineWidth (3);
		context.MoveTo (10, 245.5f);
		context.AddLineToPoint (310, 245.5f);
		context.StrokePath ();
	}	
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:24,代码来源:LineDrawing.cs

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

示例5: DrawInContext

        public override void DrawInContext(CGContext ctx)
        {
            base.DrawInContext (ctx);

            // clip
            var cornerRadius = Bounds.Height / 2.0f;
            UIBezierPath switchOutline =  UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
            ctx.AddPath (switchOutline.CGPath);
            ctx.Clip ();

            // 1) fill the track
            ctx.SetFillColor (UIColor.Green.CGColor);
            ctx.AddPath(switchOutline.CGPath);
            ctx.FillPath ();

            // 2) fill the highlighed range //Skipped for demo

            // 3) add a highlight over the track
            CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
                Bounds.Width - cornerRadius, Bounds.Height/2);
            UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height / 2.0f);
            ctx.AddPath(highlightPath.CGPath);
            ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
            ctx.FillPath ();

            // 4) inner shadow
            ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
            ctx.AddPath (switchOutline.CGPath);
            ctx.SetStrokeColor(UIColor.Gray.CGColor);
            ctx.StrokePath ();

            // 5) outline the track
            ctx.AddPath( switchOutline.CGPath);
            ctx.SetStrokeColor(UIColor.Black.CGColor);
            ctx.SetLineWidth ((nfloat)0.5f);
            ctx.StrokePath ();

            //
            //			ctx.SetFillColor (UIColor.Blue.CGColor);
            //			ctx.FillRect (Bounds);
        }
开发者ID:jasallen,项目名称:RangeSliderDemoVideoFiles,代码行数:41,代码来源:RangeSliderTrackLayer.cs

示例6: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetRGBStrokeColor (1, 1, 1, 1);
		// And drawing with a blue fill color
		context.SetRGBFillColor (0, 0, 1, 1);
		// Draw them with a 2 stroke width so they are a bit more visible.
		context.SetLineWidth (2);
		
		// Add Rect to the current path, then stroke it
		context.AddRect (new RectangleF (30, 30, 60, 60));
		context.StrokePath ();
		
		// Stroke Rect convenience that is equivalent to above
		context.StrokeRect (new RectangleF (30, 120, 60, 60));
		
		// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 10);
		// Demonstate the stroke is on both sides of the path.
		context.SaveState ();
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRectWithWidth (new RectangleF (30, 210, 60, 60), 2);
		context.RestoreState ();
		
		var rects = new RectangleF []
		{
			new RectangleF (120, 30, 60, 60),
			new RectangleF (120, 120, 60, 60),
			new RectangleF (120, 210, 60, 60),
		};
		// Bulk call to add rects to the current path.
		context.AddRects (rects);
		context.StrokePath ();
		
		// Create filled rectangles via two different paths.
		// Add/Fill path
		context.AddRect (new RectangleF (210, 30, 60, 60));
		context.FillPath ();
		// Fill convienience.
		context.FillRect (new RectangleF (210, 120, 60, 60));
	}	
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:41,代码来源:PolyDrawing.cs

示例7: DrawInContext

        public override void DrawInContext(CGContext ctx)
        {
            base.DrawInContext (ctx);

            // clip
            var cornerRadius = Bounds.Height * Slider.Curvaceousness / 2.0f;
            UIBezierPath switchOutline =  UIBezierPath.FromRoundedRect( (CGRect)Bounds, (nfloat)cornerRadius);
            ctx.AddPath (switchOutline.CGPath);
            ctx.Clip ();

            // 1) fill the track
            ctx.SetFillColor (Slider.TrackColor.CGColor);
            ctx.AddPath(switchOutline.CGPath);
            ctx.FillPath ();

            // 2) fill the highlighed range
            ctx.SetFillColor(Slider.TrackHighlightColor.CGColor);
            var lower = Slider.positionForValue (Slider.LowValue);
            var higher = Slider.positionForValue(Slider.HighValue);
            ctx.FillRect((CGRect)new CGRect(lower, 0, higher - lower, Bounds.Height));

            // 3) add a highlight over the track
            CGRect highlight = new CGRect(cornerRadius/2, Bounds.Height/2,
                Bounds.Width - cornerRadius, Bounds.Height/2);
            UIBezierPath highlightPath = UIBezierPath.FromRoundedRect ((CGRect)highlight, (nfloat)highlight.Height * Slider.Curvaceousness / 2.0f);
            ctx.AddPath(highlightPath.CGPath);
            ctx.SetFillColor( UIColor.FromWhiteAlpha((nfloat)1.0f, (nfloat)0.4f).CGColor);
            ctx.FillPath ();

            // 4) inner shadow
            ctx.SetShadow( new CGSize(0f, 2.0f), 3.0f, UIColor.Gray.CGColor);
            ctx.AddPath (switchOutline.CGPath);
            ctx.SetStrokeColor(UIColor.Gray.CGColor);
            ctx.StrokePath ();

            // 5) outline the track
            ctx.AddPath( switchOutline.CGPath);
            ctx.SetStrokeColor(UIColor.Black.CGColor);
            ctx.SetLineWidth ((nfloat)0.5f);
            ctx.StrokePath ();
        }
开发者ID:jasallen,项目名称:FuRangeSlider,代码行数:41,代码来源:FuRangeSliderTrackLayer.cs

示例8: Draw

        public override void Draw(RectangleF bounds, CGContext context, UIView view)
        {
            context.BeginPath();
			context.SetLineWidth(1.0f);
			context.SetStrokeColor(UIColor.FromRGB(199, 199, 205).CGColor);
			var x = (int)System.Math.Ceiling(bounds.Width / 2 - 0.5f);
			context.MoveTo(x, 0f);
			context.AddLineToPoint(x, bounds.Height);
            context.StrokePath();

            /*
            context.BeginPath();
            context.SetStrokeColor(UIColor.FromRGBA(250, 250, 250, 128).CGColor);
            context.MoveTo(bounds.Width / 2 + 0.5f, 0);
            context.AddLineToPoint(bounds.Width / 2 + 0.5f, bounds.Height);
            context.StrokePath();
            */

            var row = Value;
            var half = bounds.Height / 2;
            var halfText = _font.LineHeight / 2 + 1;

            row.Image1.Draw(new RectangleF(15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text1))
            {
                UIColor.Gray.SetColor();
                view.DrawString(row.Text1, new RectangleF(36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }

            row.Image2.Draw(new RectangleF(bounds.Width / 2 + 15, half - 8f, 16f, 16f));

            if (!string.IsNullOrEmpty(row.Text2))
            {
                UIColor.Gray.SetColor();
                view.DrawString(row.Text2, new RectangleF(bounds.Width / 2 + 36,  half - halfText, bounds.Width / 2 - 40, _font.LineHeight), _font, UILineBreakMode.TailTruncation);
            }
        }
开发者ID:rcaratchuk,项目名称:MonoTouch.Dialog,代码行数:38,代码来源:SplitElement.cs

示例9: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		var imageRect = new RectangleF (8, 8, 64, 64);
		
		// Note: The images are actually drawn upside down because Quartz image drawing expects
		// the coordinate system to have the origin in the lower-left corner, but a UIView
		// puts the origin in the upper-left corner. For the sake of brevity (and because
		// it likely would go unnoticed for the image used) this is not addressed here.
		// For the demonstration of PDF drawing however, it is addressed, as it would definately
		// be noticed, and one method of addressing it is shown there.
	
		// Draw the image in the upper left corner (0,0) with size 64x64
		context.DrawImage (imageRect, image);
		
		// Tile the same image across the bottom of the view
		// CGContextDrawTiledImage() will fill the entire clipping area with the image, so to avoid
		// filling the entire view, we'll clip the view to the rect below. This rect extends
		// past the region of the view, but since the view's rectangle has already been applied as a clip
		// to our drawing area, it will be intersected with this rect to form the final clipping area
		context.ClipToRect(new RectangleF (0, 80, Bounds.Width, Bounds.Height));
		
		// The origin of the image rect works similarly to the phase parameter for SetLineDash and
		// SetPatternPhase and specifies where in the coordinate system the "first" image is drawn.
		// The size (previously set to 64x64) specifies the size the image is scaled to before being tiled.
		imageRect.X = 32;
		imageRect.Y = 112;
		context.DrawTiledImage (imageRect, image);
		
		// Highlight the "first" image from the DrawTiledImage call.
		context.SetRGBFillColor (1, 0, 0, 0.5f);
		context.FillRect (imageRect);
		
		// And stroke the clipped area
		context.SetLineWidth (3);
		context.SetRGBStrokeColor (1, 0, 0, 1);
		context.StrokeRect (context.GetClipBoundingBox ());
	}
开发者ID:BoogieMAN2K,项目名称:monotouch-samples,代码行数:37,代码来源:ImageDrawing.cs

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

示例11: HatchSolidDiamond

        void HatchSolidDiamond(CGContext context)
        {
            var hatchWidth = getHatchWidth (hatchStyle);
            var hatchHeight = getHatchHeight (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchHeight, false);

            /* draw background */
            drawBackground (context, backColor, hatchWidth, hatchHeight);

            /* draw lines in the foreground color */
            context.SetFillColor(foreColor.ToCGColor());
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchWidth / 2.0f;

            // We will paint two triangles from corners meeting in the middle
            // make sure to offset by half pixels so that the point is actually a point.
            context.MoveTo(-HALF_PIXEL_X,HALF_PIXEL_Y);
            context.AddLineToPoint(2+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(-HALF_PIXEL_X, hatchHeight- (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();

            // now we do the right one
            context.MoveTo(hatchWidth,HALF_PIXEL_Y);
            context.AddLineToPoint(halfMe+HALF_PIXEL_X, halfMe - HALF_PIXEL_Y);
            context.AddLineToPoint(hatchWidth, hatchHeight - (1.0f + HALF_PIXEL_Y));
            context.ClosePath();
            context.FillPath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:34,代码来源:HatchBrush.cs

示例12: HatchSphere

        /**
         * This is fill of hackish stuff.
         * Thought this was going to be easier but that just did not work out.
         **/
        protected void HatchSphere(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            initializeContext(context, hatchSize, false);

            /* draw background in fore ground color*/
            drawBackground (context, backColor, hatchSize, hatchSize);

            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetFillColor(foreColor.ToCGColor());

            context.SetLineWidth(1);
            context.SetLineCap(CGLineCap.Square);

            // Initialize work rectangle
            CGRect rect = new CGRect (0,0,1,1);

            float quad = hatchSize / 2.0f;

            // Left lower quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = 0;
            rect.Y = 0;

            context.StrokeRect(rect);

            // right upper quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = quad;
            rect.Y = quad;

            context.StrokeRect(rect);

            // left upper quad
            rect.Width = quad;
            rect.Height = quad;
            rect.X = 0;
            rect.Y = quad + 1;

            context.FillRect(rect);

            // right lower quod
            rect.Width = quad;
            rect.Height = quad;
            rect.X = quad + 1;
            rect.Y = 0;

            context.FillRect(rect);

            // Now we fill in some corner bits with background
            // This is a bad hack but now sure what else to do
            context.SetFillColor(backColor.ToCGColor());

            rect.Height = 1;
            rect.Width = 1;

            rect.X = 0;
            rect.Y = 0;
            setPixels (context, rect);

            rect.X = 0;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = 0;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = 0;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = quad;
            rect.Y = hatchSize;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = 0;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = quad;
            setPixels(context, rect);

            rect.X = hatchSize;
            rect.Y = hatchSize;
            setPixels(context, rect);

//.........这里部分代码省略.........
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:101,代码来源:HatchBrush.cs

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

示例14: HatchUpwardDiagonal

        protected void HatchUpwardDiagonal(CGContext context)
        {
            var hatchSize = getHatchWidth (hatchStyle);
            var lineWidth = getLineWidth (hatchStyle);

            if (hatchStyle != HatchStyle.ForwardDiagonal &&
                hatchStyle != HatchStyle.BackwardDiagonal)
            {
                initializeContext(context, hatchSize, false);
            }
            else {
                initializeContext(context, hatchSize, true);
            }

            /* draw background */
            drawBackground (context, backColor, hatchSize, hatchSize);

            /* draw lines in the foreground color */
            context.SetStrokeColor(foreColor.ToCGColor());
            context.SetFillColor(foreColor.ToCGColor());

            context.SetLineWidth(1);
            context.SetLineCap(CGLineCap.Square);

            context.MoveTo(0,0);
            context.AddLineToPoint(hatchSize,hatchSize);
            /* draw a diagonal line for as many times as linewidth*/
            for (int l = 0; l < lineWidth; l++)
            {
                /* draw a diagonal line */
                context.MoveTo(l,0);
                context.AddLineToPoint(hatchSize, hatchSize-l);

                context.StrokePath();
            }

            /**
             * because we are within a rectangular pattern we have to complete the tip of the preceeding line
             * pattern
             */
            for (int k = 1; k < lineWidth; k++)
            {
                /* draw a diagonal line */
                context.MoveTo(0,hatchSize-k);
                context.AddLineToPoint(k-1, hatchSize-1);

                context.StrokePath();
            }
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:49,代码来源:HatchBrush.cs

示例15: DrawInContext

		public void DrawInContext (CGContext context, bool isDebuggingEnabled, bool usePreciseLocation)
		{
			LinePoint maybePriorPoint = null;

			foreach (var point in points) {
				if (maybePriorPoint == null) {
					maybePriorPoint = point;
					continue;
				}

				var priorPoint = maybePriorPoint;

				var color = UIColor.Black;

				if (isDebuggingEnabled) {
					if (point.Properties.Contains (PointType.Cancelled))
						color = UIColor.Red;
					else if (point.Properties.Contains (PointType.NeedsUpdate))
						color = UIColor.Orange;
					else if (point.Properties.Contains (PointType.Finger))
						color = UIColor.Purple;
					else if (point.Properties.Contains (PointType.Coalesced))
						color = UIColor.Green;
					else if (point.Properties.Contains (PointType.Predicted))
						color = UIColor.Blue;
				} else {
					if (point.Properties.Contains (PointType.Cancelled))
						color = UIColor.Clear;
					else if (point.Properties.Contains (PointType.Finger))
						color = UIColor.Purple;
					if (point.Properties.Contains (PointType.Predicted) && !point.Properties.Contains (PointType.Cancelled))
						color = color.ColorWithAlpha (0.5f);
				}

				var location = usePreciseLocation ? point.PreciseLocation : point.Location;
				var priorLocation = usePreciseLocation ? priorPoint.PreciseLocation : priorPoint.Location;

				context.SetStrokeColor (color.CGColor);
				context.BeginPath ();
				context.MoveTo (priorLocation.X, priorLocation.Y);
				context.AddLineToPoint (location.X, location.Y);
				context.SetLineWidth (point.Magnitude);
				context.StrokePath ();

				maybePriorPoint = point;
			}
		}
开发者ID:russellharvey,项目名称:monotouch-samples,代码行数:47,代码来源:Line.cs


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