BrrrBayBay.PwmGUIControl.LogicChannelControl.drawRoundRect C# (CSharp) Метод

drawRoundRect() публичный Метод

Draws a rounded rectangle on the graphics object
public drawRoundRect ( Graphics g, Pen p, Rectangle rect, float radius ) : void
g System.Drawing.Graphics The graphics object
p System.Drawing.Pen The pen
rect System.Drawing.Rectangle The rectangle
radius float The corner radius
Результат void
        public void drawRoundRect(Graphics g, Pen p, Rectangle rect, float radius)
        {
            GraphicsPath gp = new GraphicsPath();
            float x = rect.X;
            float y = rect.Y;
            float width = rect.Width;
            float height = rect.Height;
            g.SmoothingMode = SmoothingMode.HighQuality;

            gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line
            gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner
            gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line
            gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
            gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line
            gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner
            gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line
            gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
            gp.CloseFigure();

            g.DrawPath(p, gp);
            gp.Dispose();
        }