|
|
|
Select your preferred language |
To create the window region.
private void
CreateWindowRegion()
{
GraphicsPath
gp=new GraphicsPath(FillMode.Winding);
gp.AddArc(0,0,90,90,180,90);
gp.AddLine(45,0,this.Size.Width-45,0);
gp.AddArc(this.Size.Width-90,0,90,90,270,90);
gp.AddLine(this.Size.Width,45,this.Size.Width,this.Size.Height-45);
gp.AddArc(this.Size.Width-90,this.Size.Height-90,90,90,0,90);
gp.AddLine(this.Size.Width-45,this.Size.Height,45,this.Size.Height);
gp.AddArc(0,this.Size.Height-90,90,90,90,90);
gp.AddLine(0,this.Size.Height-45,0,45);
gp.CloseFigure();
OuterPath=gp;
GraphicsPath
border=(GraphicsPath)gp.Clone();
border.Widen(new
Pen(Color.Black,4));
borderRegion=new
Region(border);
System.Drawing.Region
r = new Region(gp);
r.Union(new
Rectangle(this.Width-(45),45-closerPos,closerPos,closerPos));
this.Region=r;
}
Private Sub
CreateWindowRegion()
Dim
gp As New
GraphicsPath(FillMode.Winding)
gp.AddArc(0, 0, 90, 90, 180, 90)
gp.AddLine(45, 0, Me.Size.Width - 45, 0)
gp.AddArc(Me.Size.Width
- 90, 0, 90, 90, 270, 90)
gp.AddLine(Me.Size.Width,
45, Me.Size.Width, Me.Size.Height
- 45)
gp.AddArc(Me.Size.Width
- 90, Me.Size.Height - 90, 90, 90, 0, 90)
gp.AddLine(Me.Size.Width
- 45, Me.Size.Height, 45,
Me.Size.Height)
gp.AddArc(0, Me.Size.Height - 90, 90, 90,
90, 90)
gp.AddLine(0, Me.Size.Height - 45, 0, 45)
gp.CloseFigure()
OuterPath
= gp
Dim
border As GraphicsPath =
CType(gp.Clone(), GraphicsPath)
border.Widen(New
Pen(Color.Black, 4))
borderRegion
= New [Region](border)
Dim
r = New [Region](gp)
r.Union(New
Rectangle(Me.Width - 45, 45 - closerPos,
closerPos, closerPos))
Me.Region
= r
End
Sub 'CreateWindowRegion
The area used to contain the close
button is a simple rectangular region that can be moved into position
step-by-step to reveal the area where the bitmap representing the close button
is painted. The dynamic shape of the window is controlled by the union of
the main region and the rectangle.
Return to the article.