public override void DrawRectangle(PKPen pen, int x, int y, int w, int h, PKRectangleCorners corners) { if (h > 0 & w > 0) { var rect = PKRoundedRectangle.Create(x, y, w, h, 5, corners); using (Pen p = new Pen(Color.FromArgb(pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B), pen.Size)) { graphics.DrawPath(p, rect); } } }
public static GraphicsPath Create(Rectangle rect, int radius, PKRectangleCorners c) { return(Create(rect.X, rect.Y, rect.Width, rect.Height, radius, c)); }
public static GraphicsPath Create(int x, int y, int width, int height, int radius, PKRectangleCorners corners) { int xw = x + width; int yh = y + height; int xwr = xw - radius; int yhr = yh - radius; int xr = x + radius; int yr = y + radius; int r2 = radius * 2; int xwr2 = xw - r2; int yhr2 = yh - r2; GraphicsPath p = new GraphicsPath(); p.StartFigure(); //Top Left Corner if ((PKRectangleCorners.TopLeft & corners) == PKRectangleCorners.TopLeft) { p.AddArc(x, y, r2, r2, 180, 90); } else { p.AddLine(x, yr, x, y); p.AddLine(x, y, xr, y); } //Top Edge p.AddLine(xr, y, xwr, y); //Top Right Corner if ((PKRectangleCorners.TopRight & corners) == PKRectangleCorners.TopRight) { p.AddArc(xwr2, y, r2, r2, 270, 90); } else { p.AddLine(xwr, y, xw, y); p.AddLine(xw, y, xw, yr); } //Right Edge p.AddLine(xw, yr, xw, yhr); //Bottom Right Corner if ((PKRectangleCorners.BottomRight & corners) == PKRectangleCorners.BottomRight) { p.AddArc(xwr2, yhr2, r2, r2, 0, 90); } else { p.AddLine(xw, yhr, xw, yh); p.AddLine(xw, yh, xwr, yh); } //Bottom Edge p.AddLine(xwr, yh, xr, yh); //Bottom Left Corner if ((PKRectangleCorners.BottomLeft & corners) == PKRectangleCorners.BottomLeft) { p.AddArc(x, yhr2, r2, r2, 90, 90); } else { p.AddLine(xr, yh, x, yh); p.AddLine(x, yh, x, yhr); } //Left Edge p.AddLine(x, yhr, x, yr); p.CloseFigure(); return(p); }
public abstract void DrawRectangle(PKPen pen, int x, int y, int w, int h, PKRectangleCorners corners);
public abstract void FillRectangle(PKBrush brush, int x, int y, int w, int h, PKRectangleCorners corners);
public override void FillRectangle(PKBrush brush, int x, int y, int w, int h, PKRectangleCorners corners) { if (h > 0 & w > 0) { var rect = PKRoundedRectangle.Create(x, y, w, h, 5, corners); using (Brush b = FromBrush(brush, x, y, w, h)) { graphics.FillPath(b, rect); graphics.DrawPath(Pens.Black, rect); } } }