本文整理汇总了C#中CGContext.AddLineToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CGContext.AddLineToPoint方法的具体用法?C# CGContext.AddLineToPoint怎么用?C# CGContext.AddLineToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGContext
的用法示例。
在下文中一共展示了CGContext.AddLineToPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addPath
static void addPath(CGContext context, CGRect rect, float radius, RoundedCorner cornerMask)
{
context.MoveTo(rect.X, rect.Y + radius);
context.AddLineToPoint(rect.X, rect.Y + rect.Height - radius);
if (((int)cornerMask & (int)RoundedCorner.BottomLeft) != 0) {
context.AddArc(rect.X + radius, rect.Y + rect.Height - radius,
radius, (nfloat)Math.PI, (nfloat)Math.PI / 2, true);
}
else {
context.AddLineToPoint(rect.X, rect.Y + rect.Height);
context.AddLineToPoint(rect.X + radius, rect.Y + rect.Height);
}
context.AddLineToPoint(rect.X + rect.Width - radius,
rect.Y + rect.Height);
if (((int)cornerMask & (int)RoundedCorner.BottomRight) != 0) {
context.AddArc(rect.X + rect.Width - radius,
rect.Y + rect.Height - radius, radius, (nfloat)Math.PI / 2, 0.0f, true);
}
else {
context.AddLineToPoint(rect.X + rect.Width, rect.Y + rect.Height);
context.AddLineToPoint(rect.X + rect.Width, rect.Y + rect.Height - radius);
}
context.AddLineToPoint(rect.X + rect.Width, rect.Y + radius);
if (((int)cornerMask & (int)RoundedCorner.TopRight) != 0) {
context.AddArc(rect.X + rect.Width - radius, rect.Y + radius,
radius, 0, -(nfloat)Math.PI / 2, true);
}
else {
context.AddLineToPoint(rect.X + rect.Width, rect.Y);
context.AddLineToPoint(rect.X + rect.Width - radius, rect.Y);
}
context.AddLineToPoint(rect.X + radius, rect.Y);
if (((int)cornerMask & (int)RoundedCorner.TopLeft) != 0) {
context.AddArc(rect.X + radius, rect.Y + radius, radius,
-(nfloat)Math.PI / 2, (nfloat)Math.PI, true);
}
else {
context.AddLineToPoint(rect.X, rect.Y);
context.AddLineToPoint(rect.X, rect.Y + radius);
}
context.ClosePath();
}
示例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: 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();
}
示例4: 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();
}
示例5: 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 ();
}
示例6: DrawInContext
public override void DrawInContext (CGContext ctx)
{
base.DrawInContext (ctx);
var bounds = Bounds;
var c = new PointF (bounds.GetMidX (), bounds.GetMidY ());
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)Angle, false);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (otherColor);
ctx.FillPath ();
ctx.BeginPath ();
ctx.MoveTo (c.X, c.Y);
ctx.AddLineToPoint (bounds.Right, c.Y);
ctx.AddArc (c.X, c.Y, bounds.Width/2, (float)0, (float)(1e-7 + Angle), true);
ctx.AddLineToPoint (c.X, c.Y);
ctx.SetFillColor (color);
ctx.FillPath ();
}
示例7: DrawStar
/// <summary>
/// Draws a star at the bottom left of the context of the specified diameter
/// </summary>
protected void DrawStar (CGContext context, float starDiameter)
{
// declare vars
// 144º
float theta = 2 * (float)Math.PI * (2f / 5f);
float radius = starDiameter / 2;
// move up and over
context.TranslateCTM (starDiameter / 2, starDiameter / 2);
context.MoveTo (0, radius);
for (int i = 1; i < 5; i++) {
context.AddLineToPoint (radius * (float)Math.Sin (i * theta), radius * (float)Math.Cos (i * theta));
}
//context.SetRGBFillColor (1, 1, 1, 1);
context.ClosePath ();
context.FillPath ();
}
示例8: DrawStarPattern
/// <summary>
/// This is a slightly more complicated draw pattern, but using it is just
/// as easy as the previous one. To use this one, simply change "DrawPolkaDotPattern"
/// in line 54 above to "DrawStarPattern"
/// </summary>
protected void DrawStarPattern (CGContext context)
{
// declare vars
float starDiameter = 16;
// 144º
float theta = 2 * (float)Math.PI * (2f / 5f);
float radius = starDiameter / 2;
// move up and over
context.TranslateCTM (starDiameter / 2, starDiameter / 2);
context.MoveTo (0, radius);
for (int i = 1; i < 5; i++) {
context.AddLineToPoint (radius * (float)Math.Sin (i * theta), radius * (float)Math.Cos (i * theta));
}
// fill our star as dark gray
context.ClosePath ();
context.FillPath ();
}
示例9: 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);
}
}
示例10: draw
public void draw(CGContext context)
{
context.SetLineWidth(lineWidth);
context.MoveTo(this.begin.X, this.begin.Y);
context.AddLineToPoint(this.end.X, this.end.Y);
UIColor clr = new UIColor(red, green, blue, alpha);
clr.SetStroke();
context.StrokePath();
}
示例11: drawWithColor
public void drawWithColor(CGContext context, UIColor clr)
{
context.SetLineWidth(lineWidth);
context.MoveTo(this.begin.X, this.begin.Y);
context.AddLineToPoint(this.end.X, this.end.Y);
clr.SetStroke();
context.StrokePath();
}
示例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: HatchDiagonalCross
void HatchDiagonalCross(CGContext context)
{
var hatchWidth = getHatchWidth (hatchStyle);
var hatchHeight = getHatchHeight (hatchStyle);
var lineWidth = getLineWidth (hatchStyle);
initializeContext(context, hatchHeight, true);
/* 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;
context.MoveTo(0, 0);
context.AddLineToPoint(hatchWidth, hatchHeight);
context.StrokePath();
context.MoveTo(hatchWidth, 0);
context.AddLineToPoint(0, hatchHeight);
context.StrokePath();
}
示例14: 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();
}
示例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;
}
}