//utility for drawing triangle shape public void DrawTriangleInContext(CGContext ctx, CGRect rect, float BorderWidth, bool isLeft) { UIColor color = UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f); ctx.SetLineWidth(BorderWidth); ctx.SetStrokeColor(color.CGColor); ctx.SetFillColor(color.CGColor); ctx.SaveState(); if (isLeft) { ctx.MoveTo(rect.GetMinX(), rect.GetMinY()); } else { ctx.MoveTo(rect.GetMaxX(), rect.GetMinY()); } ctx.AddLineToPoint(rect.GetMinX(), rect.GetMaxY()); ctx.AddLineToPoint(rect.GetMaxX(), rect.GetMaxY()); ctx.ClosePath(); ctx.DrawPath(CGPathDrawingMode.FillStroke); ctx.RestoreState(); }
//utility for drawing rectangle shape public void DrawRectShapeInContext(CGContext ctx, CGRect rect) { ctx.SetFillColor(UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f).CGColor); ctx.SetStrokeColor(UIColor.FromRGBA(95.0f / 255.0f, 104.0f / 255.0f, 114.0f / 255.0f, 1.0f).CGColor); ctx.StrokeRect(rect); ctx.FillRect(rect); // Add rounded rect over plain rect with 4 pixel below the origin y, so that it will visible only the bottom rounded corners CGRect cornerRect = new CGRect(rect.X, rect.Y + 4, rect.Width, rect.Height); nfloat radius = 4; nfloat minx = cornerRect.GetMinX(), midx = cornerRect.GetMidX(), maxx = cornerRect.GetMaxX(); nfloat miny = cornerRect.GetMinY(), midy = cornerRect.GetMidY(), maxy = cornerRect.GetMaxY(); ctx.SaveState(); ctx.MoveTo(minx, miny); ctx.AddArcToPoint(minx, miny, midx, miny, radius); ctx.AddArcToPoint(maxx, miny, maxx, midy, radius); ctx.AddArcToPoint(maxx, maxy, midx, maxy, radius); ctx.AddArcToPoint(minx, maxy, minx, midy, radius); ctx.ClosePath(); ctx.DrawPath(CGPathDrawingMode.FillStroke); ctx.RestoreState(); }