本文整理汇总了C#中CGPath.AddArcToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# CGPath.AddArcToPoint方法的具体用法?C# CGPath.AddArcToPoint怎么用?C# CGPath.AddArcToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGPath
的用法示例。
在下文中一共展示了CGPath.AddArcToPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw (CGRect rect)
{
WeatherForecastAnnotation annotation;
CGPath path;
base.Draw (rect);
annotation = Annotation as WeatherForecastAnnotation;
if (annotation == null)
return;
// Get the current graphics context
using (var context = UIGraphics.GetCurrentContext ()) {
context.SetLineWidth (1.0f);
// Draw the gray pointed shape:
path = new CGPath ();
path.MoveToPoint (14.0f, 0.0f);
path.AddLineToPoint (0.0f, 0.0f);
path.AddLineToPoint (55.0f, 50.0f);
context.AddPath (path);
context.SetFillColor (UIColor.LightGray.CGColor);
context.SetStrokeColor (UIColor.Gray.CGColor);
context.DrawPath (CGPathDrawingMode.FillStroke);
// Draw the cyan rounded box
path = new CGPath ();
path.MoveToPoint (15.0f, 0.5f);
path.AddArcToPoint (59.5f, 00.5f, 59.5f, 05.0f, 5.0f);
path.AddArcToPoint (59.5f, 69.5f, 55.5f, 69.5f, 5.0f);
path.AddArcToPoint (10.5f, 69.5f, 10.5f, 64.0f, 5.0f);
path.AddArcToPoint (10.5f, 00.5f, 15.5f, 00.5f, 5.0f);
context.AddPath (path);
context.SetFillColor (UIColor.Cyan.CGColor);
context.SetStrokeColor (UIColor.Blue.CGColor);
context.DrawPath (CGPathDrawingMode.FillStroke);
// Create the location & temperature string
WeatherForecast forecast = annotation.Forecast;
NSString temperature = new NSString (string.Format ("{0}\n{1} / {2}", forecast.Place, forecast.High, forecast.Low));
// Draw the text in black
UIColor.Black.SetColor ();
temperature.DrawString (new CGRect (15.0f, 5.0f, 50.0f, 40.0f), UIFont.SystemFontOfSize (11.0f));
temperature.Dispose ();
// Draw the icon for the weather condition
string imageName = string.Format ("WeatherMap.WeatherIcons.{0}.png", forecast.Condition);
UIImage image = UIImage.FromResource (typeof(WeatherAnnotationView).Assembly, imageName);
image.Draw (new CGRect (12.5f, 28.0f, 45.0f, 45.0f));
image.Dispose ();
}
}
示例2: MakeRoundedPath
public static CGPath MakeRoundedPath(float size, float radius)
{
float hsize = size / 2;
var path = new CGPath();
path.MoveToPoint(size, hsize);
path.AddArcToPoint(size, size, hsize, size, radius);
path.AddArcToPoint(0, size, 0, hsize, radius);
path.AddArcToPoint(0, 0, hsize, 0, radius);
path.AddArcToPoint(size, 0, size, hsize, radius);
path.CloseSubpath();
return path;
}
示例3: MakeRoundedPath
internal static CGPath MakeRoundedPath(float size)
{
float hsize = size/2;
var path = new CGPath ();
path.MoveToPoint (size, hsize);
path.AddArcToPoint (size, size, hsize, size, 4);
path.AddArcToPoint (0, size, 0, hsize, 4);
path.AddArcToPoint (0, 0, hsize, 0, 4);
path.AddArcToPoint (size, 0, size, hsize, 4);
path.CloseSubpath ();
return path;
}
示例4: MakeRoundedRectPath
/// <summary>
/// Creates a path for a rectangle with rounded corners
/// </summary>
/// <param name="rect">
/// The <see cref="CGRect"/> rectangle bounds
/// </param>
/// <param name="radius">
/// The <see cref="System.Single"/> size of the rounded corners
/// </param>
/// <returns>
/// A <see cref="CGPath"/> that can be used to stroke the rounded rectangle
/// </returns>
public static CGPath MakeRoundedRectPath(CGRect rect, float radius)
{
nfloat minx = rect.Left;
nfloat midx = rect.Left + (rect.Width) / 2;
nfloat maxx = rect.Right;
nfloat miny = rect.Top;
nfloat midy = rect.Y + rect.Size.Height / 2;
nfloat maxy = rect.Bottom;
var path = new CGPath();
path.MoveToPoint(minx, midy);
path.AddArcToPoint(minx, miny, midx, miny, radius);
path.AddArcToPoint(maxx, miny, maxx, midy, radius);
path.AddArcToPoint(maxx, maxy, midx, maxy, radius);
path.AddArcToPoint(minx, maxy, minx, midy, radius);
path.CloseSubpath();
return path;
}
示例5: GetCellBorderPath
public CGPath GetCellBorderPath(RectangleF rect)
{
var cornerRadius = 10;
float minx = rect.GetMinX(), midx = rect.GetMidX(), maxx = rect.GetMaxX();
float miny = rect.GetMinY(), midy = rect.GetMidY(), maxy = rect.GetMaxY();
CGPath path = new CGPath();
var cellPosition = CellPosition;
if (cellPosition == CellPosition.Top)
{
minx = minx + 1;
miny = miny + 1;
maxx = maxx - 1;
path.MoveToPoint(minx, maxy);
path.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
path.AddArcToPoint(maxx, miny, maxx, maxy, cornerRadius);
path.AddLineToPoint(maxx, maxy);
}
else if (cellPosition == CellPosition.Bottom)
{
minx = minx + 1;
maxx = maxx - 1;
maxy = maxy - 1;
path.MoveToPoint(minx, miny);
path.AddArcToPoint(minx, maxy, midx, maxy, cornerRadius);
path.AddArcToPoint(maxx, maxy, maxx, miny, cornerRadius);
path.AddLineToPoint(maxx, miny);
}
else if (cellPosition == CellPosition.Middle)
{
minx = minx + 1;
maxx = maxx - 1;
path.MoveToPoint(minx, miny);
path.AddLineToPoint(maxx, miny);
path.AddLineToPoint(maxx, maxy);
path.AddLineToPoint(minx, maxy);
}
else if (cellPosition == CellPosition.Single)
{
minx = minx + 1;
miny = miny + 1;
maxx = maxx - 1;
maxy = maxy - 1;
path.MoveToPoint(minx, midy);
path.AddArcToPoint(minx, miny, midx, miny, cornerRadius);
path.AddArcToPoint(maxx, miny, maxx, midy, cornerRadius);
path.AddArcToPoint(maxx, maxy, midx, maxy, cornerRadius);
path.AddArcToPoint(minx, maxy, minx, midy, cornerRadius);
}
path.CloseSubpath();
return path;
}
示例6: DrawSpeechBubbleAroundRect
//.........这里部分代码省略.........
// Items on the left shouldn't be right of the midline
if (arrowOffsetX > 0f)
arrowOffsetX = 0f;
}
if (arrowDirection == ArrowDirections.UpRight || arrowDirection == ArrowDirections.DownRight) {
arrowOffsetX = (nfloat)((rect.Width / 2f) - midArrowWidth - cornerRadius - 4f); // Move the up/down arrow to the right corner
// Items on the right shouldn't be left of the midline
if (arrowOffsetX < 0f)
arrowOffsetX = 0f;
}
if (arrowDirection == ArrowDirections.LeftTop || arrowDirection == ArrowDirections.RightTop) {
arrowOffsetY = (nfloat)(-1 * ((rect.Height / 2f) - midArrowWidth - cornerRadius - 4f)); // Move the left/tight arrow to the top corner
// Items on the top shouldn't be below the midline
if (arrowOffsetY > 0f)
arrowOffsetY = 0f;
}
if (arrowDirection == ArrowDirections.LeftBottom || arrowDirection == ArrowDirections.RightBottom) {
arrowOffsetY = (nfloat)((rect.Height / 2f) - midArrowWidth - cornerRadius - 4f); // Move the up/down arrow to the bottom corner
// Items on the bottom shouldn't be above the midline
if (arrowOffsetY < 0f)
arrowOffsetY = 0f;
}
if (hasUpArrow) {
// Adds a line to where the arrow starts
path.AddLineToPoint ((nfloat)Math.Round(midX - midArrowWidth) + 0.5f + arrowOffsetX, topY);
// Draws the arrow up, and then down again
path.AddLineToPoint (midX + arrowOffsetX, 0.5f);
path.AddLineToPoint (midX + midArrowWidth + 0.5f + arrowOffsetX, arrowHeight + 0.5f);
}
// Top right corner
path.AddArcToPoint (rightX, topY, rightX, bottomY, cornerRadius);
if (hasRightArrow) {
// Adds a line to where the arrow starts
path.AddLineToPoint (rightX, midY - midArrowWidth + arrowOffsetY );
// Draws the arrow right, and then left again
path.AddLineToPoint (rightX + arrowHeight, midY + arrowOffsetY);
path.AddLineToPoint (rightX, midY + midArrowWidth + arrowOffsetY);
}
// To Bottom right corner (curling towards bottom left corner)
path.AddArcToPoint(rightX, bottomY, leftX, bottomY, cornerRadius);
if (hasDownArrow) {
// Adds a line to where the arrow starts
path.AddLineToPoint (midX + midArrowWidth + arrowOffsetX, bottomY);
// Draws the arrow up, and then down again
path.AddLineToPoint (midX + arrowOffsetX, bottomY + arrowHeight);
path.AddLineToPoint (midX - midArrowWidth + arrowOffsetX, bottomY);
}
// To bottom left corner (curling up in direction of top left corner)
path.AddArcToPoint (leftX, bottomY, leftX, topY, cornerRadius);
if (hasLeftArrow) {
// Adds a line to where the arrow starts
path.AddLineToPoint (leftX, midY + midArrowWidth + arrowOffsetY );
// Draws the arrow right, and then left again
path.AddLineToPoint (leftX - arrowHeight, midY + arrowOffsetY);
path.AddLineToPoint (leftX, midY - midArrowWidth + arrowOffsetY);
}