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


C# CGContext.SetStrokeColor方法代码示例

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


在下文中一共展示了CGContext.SetStrokeColor方法的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 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

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

示例5: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		// Drawing with a white stroke color
		context.SetStrokeColor (1, 1, 1, 1);
		// And 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);

		// Add Rect to the current path, then stroke it
		context.AddRect (new CGRect (30, 30, 60, 60));
		context.StrokePath ();

		// Stroke Rect convenience that is equivalent to above
		context.StrokeRect (new CGRect (30, 120, 60, 60));

		// Stroke rect convenience equivalent to the above, plus a call to context.SetLineWidth ().
		context.StrokeRectWithWidth (new CGRect (30, 210, 60, 60), 10);
		// Demonstate the stroke is on both sides of the path.
		context.SaveState ();
		context.SetStrokeColor (1, 0, 0, 1);
		context.StrokeRectWithWidth (new CGRect (30, 210, 60, 60), 2);
		context.RestoreState ();

		var rects = new CGRect [] {
			new CGRect (120, 30, 60, 60),
			new CGRect (120, 120, 60, 60),
			new CGRect (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 CGRect (210, 30, 60, 60));
		context.FillPath ();
		// Fill convienience.
		context.FillRect (new CGRect (210, 120, 60, 60));
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:40,代码来源:PolyDrawing.cs

示例6: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		context.SetStrokeColor (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.SetStrokeColor (1, 0, 0, 1);
		context.SetLineWidth (3);
		context.MoveTo (10, 245.5f);
		context.AddLineToPoint (310, 245.5f);
		context.StrokePath ();
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:24,代码来源:LineDrawing.cs

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

示例8: DrawInContext

	public override void DrawInContext (CGContext context)
	{
		var imageRect = new CGRect (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 CGRect (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.SetFillColor (1, 0, 0, 0.5f);
		context.FillRect (imageRect);

		// And stroke the clipped area
		context.SetLineWidth (3);
		context.SetStrokeColor (1, 0, 0, 1);
		context.StrokeRect (context.GetClipBoundingBox ());
	}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:37,代码来源:ImageDrawing.cs

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

示例10: HatchWeave

        void HatchWeave(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());

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

            float halfWidth = hatchWidth / 2.0f;
            float halfHeight = hatchHeight / 2.0f;

            CGRect rect = new CGRect (0,0,1,1);

            // Add upward diagonals
            context.MoveTo(0,0);
            context.AddLineToPoint(halfWidth, halfHeight);
            context.StrokePath();

            context.MoveTo(0, halfHeight);
            context.AddLineToPoint(halfWidth -1, hatchHeight - 1);
            context.StrokePath();

            context.MoveTo(halfWidth, 0);
            context.AddLineToPoint(6, 2);
            context.StrokePath();

            //			context.MoveTo(0, 4);
            //			context.AddLineToPoint(2, 2);
            //			context.StrokePath();

            context.MoveTo(2,6);
            context.AddLineToPoint(7, 1);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:45,代码来源:HatchBrush.cs

示例11: DrawRectangle

        private void DrawRectangle(CGContext g, PinboardData.RectangleInfo rectInfo)
        {
            g.SetFillColor(rectInfo.Color);
            g.FillRect(rectInfo.Rectangle);

            float pw = 0.5f;
            CGColor rectBorderColor = new CGColor(0f, rectInfo.Color.Alpha);

            g.SetLineWidth(pw);
            g.SetStrokeColor(rectBorderColor);
            g.SetFillColor(rectInfo.Color);
            g.SetLineJoin(CGLineJoin.Miter);
            g.BeginPath();
            g.StrokeRect(rectInfo.Rectangle);

            int margin = 5;
            // TODO: Make the font configurable
            NSFont font = NSFont.FromFontName("Helvetica", 12f);
            NSObject[] objects = new NSObject[] { font, (NSNumber)0 };
            NSObject[] keys = new NSObject[] { NSAttributedString.FontAttributeName, NSAttributedString.LigatureAttributeName };
            NSDictionary attributes = NSDictionary.FromObjectsAndKeys(objects, keys);
            NSAttributedString attrString = new NSAttributedString(rectInfo.Name, attributes);

            attrString.DrawString(new RectangleF(rectInfo.X + margin, rectInfo.Y + margin, rectInfo.Width - 2 * margin, rectInfo.Height - 2 * margin));
        }
开发者ID:jlyonsmith,项目名称:Pinboard,代码行数:25,代码来源:PinboardView.cs

示例12: DrawSelected

        private void DrawSelected(CGContext g)
        {
            if (selectionRect.IsEmpty)
                return;

            CGImage grabberImage;
            var targetRect = new CGRect(CGPoint.Empty, grabberSize);

            grabberImage = NSImage.ImageNamed("Grabber").AsCGImage(ref targetRect, NSGraphicsContext.CurrentContext, new NSDictionary());

            g.SetStrokeColor(new CGColor(0.5f, 0.5f));
            g.StrokeRectWithWidth(selectionRect, 0.5f);

            for (int i = 0; i < grabberRects.Length; i++)
            {
                g.DrawImage(grabberRects[i], grabberImage);
            }
        }
开发者ID:jlyonsmith,项目名称:Pinboard,代码行数:18,代码来源:PinboardView.cs

示例13: HatchShingle

        void HatchShingle(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 are basically going to draw a lamda sign

            // Draw base
            context.MoveTo(0,0);
            context.AddLineToPoint(halfMe,halfMe-HALF_PIXEL_Y);
            context.AddLineToPoint(hatchWidth, HALF_PIXEL_Y);
            context.StrokePath();

            // draw the first part of tail
            context.MoveTo(halfMe + HALF_PIXEL_X, halfMe);
            context.AddLineToPoint(halfMe + HALF_PIXEL_X, halfMe + 1);
            context.StrokePath();

            // now the last curl on the tail
            CGRect rect = new CGRect (1,hatchHeight-1,1,1);
            setPixels(context, rect);

            rect.X += 1;
            setPixels(context, rect);

            rect.X += 1;
            rect.Y -= 1;
            setPixels(context, rect);
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:43,代码来源:HatchBrush.cs

示例14: HatchDashedHorizontal

        void HatchDashedHorizontal(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.SetStrokeColor(foreColor.ToCGColor());
            context.SetLineWidth(lineWidth);
            context.SetLineCap(CGLineCap.Square);

            float halfMe = hatchHeight / 2.0f - 1;
            hatchWidth -=1;
            hatchHeight -= 1;

            context.MoveTo(halfMe+1, halfMe);
            context.AddLineToPoint(hatchWidth, halfMe);
            context.StrokePath();

            context.MoveTo(0,hatchHeight);
            context.AddLineToPoint(halfMe, hatchHeight);
            context.StrokePath();
        }
开发者ID:mono,项目名称:sysdrawing-coregraphics,代码行数:28,代码来源: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.SetStrokeColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。