本文整理汇总了C#中CGContext.StrokePath方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.StrokePath方法的具体用法?C# CGContext.StrokePath怎么用?C# CGContext.StrokePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.StrokePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
}
}
示例2: 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);
}
}
示例3: 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();
}
示例4: DrawGridlines
protected override void DrawGridlines(RectangleF rect, CGContext context)
{
float maxY = rect.Size.Height;
for (float y = CellSize.Height; y < maxY; y += (CellSize.Height + Gridlines.Thickness))
{
context.MoveTo(rect.Left, y + 0.5f);
context.AddLineToPoint(rect.Right, y + 0.5f);
}
context.StrokePath();
}
示例5: DrawGridlines
protected override void DrawGridlines(RectangleF rect, CGContext context)
{
float maxX = rect.Size.Width;
float cellWidth = CellSize.Width;
for (float x = cellWidth; x < maxX; x += (cellWidth + Gridlines.Thickness))
{
context.MoveTo(x + 0.5f, rect.Location.Y);
context.AddLineToPoint(x + 0.5f, rect.Size.Height);
}
context.StrokePath();
}
示例6: 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);
}
示例7: 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));
}
示例8: 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 ();
}
示例9: DrawInContext
public override void DrawInContext (CGContext context)
{
// Draw lines with a white stroke color
context.SetRGBStrokeColor (1f, 1f, 1f, 1f);
// Draw them with a 2.0 stroke width so they are more visible
context.SetLineWidth (2);
context.MoveTo (10, 30);
context.AddLineToPoint (310, 30);
context.StrokePath ();
// Draw connected sequence of lines
var points = new PointF [] {
new PointF (10, 90),
new PointF (70, 60),
new PointF (130, 90),
new PointF (190, 60),
new PointF (250, 90),
new PointF (310, 60)
};
context.AddLines (points);
context.StrokePath ();
var segments = new PointF [] {
new PointF (10, 150),
new PointF (70, 120),
new PointF (130, 150),
new PointF (190, 120),
new PointF (250, 150),
new PointF (310, 120),
};
// Bulk call to stroke a sequence of line segments
context.StrokeLineSegments (segments);
}
示例10: 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 ();
}
}
示例11: 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);
}
}
示例12: 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;
var pointType = point.PointType;
if (isDebuggingEnabled) {
if (pointType.Has (PointType.Cancelled))
color = UIColor.Red;
else if (pointType.Has (PointType.NeedsUpdate))
color = UIColor.Orange;
else if (pointType.Has (PointType.Finger))
color = UIColor.Purple;
else if (pointType.Has (PointType.Coalesced))
color = UIColor.Green;
else if (pointType.Has (PointType.Predicted))
color = UIColor.Blue;
} else {
if (pointType.Has (PointType.Cancelled))
color = UIColor.Red;
else if (pointType.Has (PointType.Finger))
color = UIColor.Purple;
if (pointType.Has (PointType.Predicted) && !pointType.Has (PointType.Cancelled))
color = color.ColorWithAlpha (.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 ();
// Draw azimuith and elevation on all non-coalesced points when debugging.
if (isDebuggingEnabled &&
!point.PointType.Has (PointType.Coalesced) &&
!point.PointType.Has (PointType.Predicted) &&
!point.PointType.Has (PointType.Finger)) {
context.BeginPath ();
context.SetStrokeColor (UIColor.Red.CGColor);
context.SetLineWidth (.5f);
context.MoveTo (location.X, location.Y);
var targetPoint = new CGPoint (.5f + 10f * NMath.Cos (point.AltitudeAngle), 0f);
targetPoint = CGAffineTransform.MakeRotation (point.AzimuthAngle).TransformPoint (targetPoint);
targetPoint.X += location.X;
targetPoint.Y += location.Y;
context.AddLineToPoint (targetPoint.X, targetPoint.Y);
context.StrokePath ();
}
maybePriorPoint = point;
}
}
示例13: HatchHorizontalBrick
void HatchHorizontalBrick(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);
CGRect rect = new CGRect (0,0,1,1);
rect.Y = 3;
rect.Width = hatchWidth;
rect.Height = hatchHeight - 4;
context.StrokeRect(rect);
context.MoveTo(hatchWidth / 2.0f, 0);
context.AddLineToPoint(hatchWidth / 2.0f,3);
context.StrokePath();
}
示例14: 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;
}
}
示例15: 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();
}
}