110,538
社区成员
发帖
与我相关
我的任务
分享
private void panel1_Paint(object sender, PaintEventArgs e)
{
GraphicsPath path = CreatePath(
new Rectangle(0, 0, panel1.Width, panel1.Height), 20);
panel1.Region = new System.Drawing.Region(path);
}
public static GraphicsPath CreatePath(Rectangle rect, int radius)
{
int w = rect.Width;
int h = rect.Height;
GraphicsPath path = new GraphicsPath();
int val = style.GetHashCode();
path.AddArc(1, 1, radius, radius, 180, 90);
path.AddArc(w - radius - 1, 1, radius, radius, 270, 90);
path.AddArc(w - radius - 1, h - radius - 1, radius, radius, 0, 90);
path.AddArc(1, h - radius - 1, radius, radius, 90, 90);
int offset = 0;
path.AddArc(offset, offset, radius, radius, 180, 90);
path.AddArc(w - radius - offset, offset, radius, radius, 270, 90);
path.AddArc(w - radius - offset, h - radius - offset, radius, radius, 0, 90);
path.AddArc(offset, h - radius - offset, radius, radius, 90, 90);
return path;
public static GraphicsPath CreatePath(Rectangle rect, int radius)
{
int w = rect.Width;
int h = rect.Height;
GraphicsPath path = new GraphicsPath();
int val = style.GetHashCode();
path.AddArc(1, 1, radius, radius, 180, 90);
path.AddArc(w - radius - 1, 1, radius, radius, 270, 90);
path.AddArc(w - radius - 1, h - radius - 1, radius, radius, 0, 90);
path.AddArc(1, h - radius - 1, radius, radius, 90, 90);
return path;
}