public override void Draw(Canvas canvas) { cxBoxView boxv = (cxBoxView)this.Element; Rect rc = new Rect(); GetDrawingRect(rc); Rect interior = rc; interior.Inset((int)boxv.StrokeThickness, (int)boxv.StrokeThickness); Paint p = new Paint() { Color = boxv.Color.ToAndroid(), AntiAlias = true, }; canvas.DrawRoundRect(new RectF(interior), (float)boxv.CornerRadius, (float)boxv.CornerRadius, p); p.Color = boxv.Stroke.ToAndroid(); p.StrokeWidth = (float)boxv.StrokeThickness; p.SetStyle(Paint.Style.Stroke); canvas.DrawRoundRect(new RectF(rc), (float)boxv.CornerRadius, (float)boxv.CornerRadius, p); }
public override void Draw(System.Drawing.RectangleF rect) { cxBoxView boxv = (cxBoxView)this.Element; using (var context = UIGraphics.GetCurrentContext()) { context.SetFillColor(boxv.Color.ToCGColor()); context.SetStrokeColor(boxv.Stroke.ToCGColor()); context.SetLineWidth((float)boxv.StrokeThickness); var rc = this.Bounds.Inset((int)boxv.StrokeThickness, (int)boxv.StrokeThickness); float radius = (float)boxv.CornerRadius; radius = (float)Math.Max(0, Math.Min(radius, Math.Max(rc.Height / 2, rc.Width / 2))); var path = CGPath.FromRoundedRect(rc, radius, radius); context.AddPath(path); context.DrawPath(CGPathDrawingMode.FillStroke); } }