在这里你去:
GraphicsPath path = new GraphicsPath();
path.FillMode = FillMode.Winding;
int cut = 80;
Rectangle cr = panel1.ClientRectangle;
Point[] points =
{
new Point(0, cr.Height - cut),
new Point(0, 0),
new Point(cr.Width, 0),
new Point(cr.Width, cr.Height - cut),
new Point(cr.Width - cut, cr.Height),
new Point(cut, cr.Height),
new Point(0, cr.Height - cut),
};
path.AddPolygon(points);
Rectangle arcRect = new Rectangle(0, cr.Height - 2 * cut, 2 * cut, 2 * cut);
path.AddArc(arcRect, 90f, 90f);
的电弧由边界矩形,这在我们的情况下,具有切口的大小的两倍限定。它从x轴开始顺时针旋转90°,并且(至少)90°以上。
您可以add it to a GraphicsPath或draw it with a Graphics对象。
下面是从MSDN报价:
如果有图中的前一个直线或曲线,直线加 到前一段的端点连接到的 弧开始。
沿着由指定矩形包围的椭圆的周长来追踪圆弧。圆弧的起点由 决定,从椭圆的x轴(在0度 角度)处顺时针测量开始角度的度数。端点 类似地通过从起点开始顺时针测量 扫描角度中的度数来定位。如果扫描角度是大于360度或小于-360度的 ,则电弧分别被精确地360度或-360度扫过 。
我已经添加了弧的边界矩形,仅供演示使用。该代码不包括它。
对于其他角落的圆角切割,您需要更改&展开点数组并添加更多/其他弧。
其它角弧采取这些矩形:
Rectangle arcRectTL = new Rectangle(0, 0, 2 * cut, 2 * cut);
Rectangle arcRectTR = new Rectangle(cr.Width - 2 * cut, 0, 2 * cut, 2 * cut);
Rectangle arcRectBR = new Rectangle(cr.Width - 2*cut, cr.Height - 2*cut, 2*cut, 2*cut);
起始角度分别为:180°, 270° and 0°
。
尺寸和清扫角度保持不变。
您将需要添加一个弧。 – TaW
@TaW,我该如何使用它? – DeaDViruS
查看我的答案的例子。我已经清理了一下你的代码。 – TaW