WinForm------PanelControl控件中使用Pen类画角圆矩形方法

时间:2022-05-30 06:46:21
private void rightPanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Pen p = new Pen(Color.FromArgb(,,,));
p.Width = ;
DrawRoundRect(g, p, + nowPicture * , , , , );
} public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
{
  GraphicsPath gp = new GraphicsPath();   gp.AddLine(X + radius, Y, X + width - (radius * ), Y);
  
  gp.AddArc(X + width - (radius * ), Y, radius * , radius * , , );   gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * ));   gp.AddArc(X + width - (radius * ), Y + height - (radius * ), radius * , radius * , , );   gp.AddLine(X + width - (radius * ), Y + height, X + radius, Y + height);   gp.AddArc(X, Y + height - (radius * ), radius * , radius * , , );   gp.AddLine(X, Y + height - (radius * ), X, Y + radius);   gp.AddArc(X, Y, radius * , radius * , , );   gp.CloseFigure();   g.DrawPath(p, gp);
  gp.Dispose();
}