' Draw a border inside this rectangle.
Private Sub DrawBorder(ByVal gr As Graphics, ByVal rect As _
Rectangle, ByVal border_style As BorderStyle, Optional _
ByVal sunken As Boolean = True)
Select Case border_style
Case BorderStyle.FixedSingle
rect.Width -= 1
rect.Height -= 1
gr.DrawRectangle(Pens.Black, rect)
Case BorderStyle.Fixed3D
Dim colors() As Color
If sunken Then
colors = New Color() { _
SystemColors.ControlDark, _
SystemColors.ControlDarkDark, _
SystemColors.ControlLightLight, _
SystemColors.ControlLight _
}
Else
colors = New Color() { _
SystemColors.ControlLightLight, _
SystemColors.ControlLight, _
SystemColors.ControlDark, _
SystemColors.ControlDarkDark _
}
End If
Dim p As Pen
p = New Pen(colors(0))
gr.DrawLine(p, rect.X, rect.Y + rect.Height - _
1, rect.X, rect.Y)
gr.DrawLine(p, rect.X, rect.Y, rect.X + _
rect.Width - 1, rect.Y)
p = New Pen(colors(1))
gr.DrawLine(p, rect.X + 1, rect.Y + rect.Height _
- 2, rect.X + 1, rect.Y + 1)
gr.DrawLine(p, rect.X + 1, rect.Y + 1, rect.X + _
rect.Width - 2, rect.Y + 1)
p = New Pen(colors(2))
gr.DrawLine(p, rect.X, rect.Y + rect.Height - _
1, rect.X + rect.Width - 1, rect.Y + _
rect.Height - 1)
gr.DrawLine(p, rect.X + rect.Width - 1, rect.Y _
+ rect.Height - 1, rect.X + rect.Width - 1, _
rect.Y)
p = New Pen(colors(3))
gr.DrawLine(p, rect.X + 1, rect.Y + rect.Height _
- 2, rect.X + rect.Width - 2, rect.Y + _
rect.Height - 2)
gr.DrawLine(p, rect.X + rect.Width - 2, rect.Y _
+ rect.Height - 2, rect.X + rect.Width - 2, _
rect.Y + 1)
End Select
End Sub
|