我使用以下代码更改为winform的形状。 它改变了形状,但不像我想要的那样。 我需要表格有弯角。
我应该用它来获得它?
public void MakeNonRectangularForm()
{
System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath();
int width = this.ClientSize.Width;
int height = this.ClientSize.Height;
p.AddClosedCurve(new Point[]{new Point(width/2, height/2),
new Point(width,0), new Point(width, height/3),
new Point(width-width/3, height),
new Point(width/7, height-height/8)});
this.Region = new Region(p);
}
答案 0 :(得分:2)
以下是我之前用于创建圆边的一些代码,使用AddArc
和线条拼接边框:
(您可以使用xRadius
和yRadius
来达到理想的“舍入”数量。
int xRadius = {insert value here};
int yRadius = {insert value here};
GraphicsPath edge = new GraphicsPath();
int rightHandLeft = this.Width - xRadius - 1;
int bottomSideTop = this.Height - yRadius - 1;
edge.AddArc(0, 0, xRadius, yRadius, 180, 90);
edge.AddLine(xRadius, 0, rightHandLeft, 0);
edge.AddArc(rightHandLeft, 0, xRadius, yRadius, 270, 90);
edge.AddLine(this.Width, yRadius, this.Width, bottomSideTop);
edge.AddArc(rightHandLeft, bottomSideTop, xRadius, yRadius, 0, 90);
edge.AddLine(rightHandLeft, this.Height, xRadius, this.Height);
edge.AddArc(0, bottomSideTop, xRadius, yRadius, 90, 90);
edge.AddLine(0, bottomSideTop, 0, yRadius);
this.Region = new Region(edge);