Public Class UserControl1
Inherits System.Windows.Forms.Control
'windows generated code
[COLOR=Red]SetStyle[/COLOR](controlstyles.AllPaintingInWmPaint,True)[COLOR=Blue] 'Declaration Expected[/COLOR]
[COLOR=Red]SetStyle[/COLOR](ControlStyles.DoubleBuffer,true)[COLOR=Blue] 'Declaration Expected[/COLOR]
[COLOR=Red]SetStyle[/COLOR](ControlStyles.UserPaint,True)[COLOR=Blue] 'Declaration Expected[/COLOR]
Private _GradientStartColor As Color = Color.Blue
Private _GradientEndColor As Color = Color.Red
Private Mode As [COLOR=Red]LinearGradientMode [/COLOR]= LinearGradientMode.Horizontal [COLOR=Blue]'Type LinearGradientMode is not defined[/COLOR]
Private DrawFocusRectangle As Boolean = False
Public Property GradientStartColor() As Color
Get
Return Me._GradientStartColor
End Get
Set(ByVal Value As Color)
Me._GradientStartColor = Value
Me.Invalidate()
End Set
End Property
Public Property GradientEndColor() As Color
Get
Return Me._GradientEndColor
End Get
Set(ByVal Value As Color)
Me._GradientEndColor = value
Me.Invalidate()
End Set
End Property
Public Property GradientMode() As [COLOR=Red]LinearGradientMode [/COLOR][COLOR=Blue]'Type LinearGradientMode is not defined[/COLOR]
Get
Return Me.Mode
End Get
Set(ByVal Value As [COLOR=Red]linearGradientMode[/COLOR]) [COLOR=Blue]'Type LinearGradientMode is not defined[/COLOR]
Me.Mode = Value
Me.Invalidate()
End Set
End Property
Protected Overrides Sub [COLOR=Red]Paint[/COLOR](ByVal e As System.windows.forms.PaintEventArgs) [COLOR=Blue]'sub Paint conflicts with event paint in the base class Control and so should be declared as Shadows[/COLOR]
MyBase.OnPaint(e)
Dim Rc As Rectangle = Me.ClientRectangle
Rc.inflate(-1, -1)
Dim ButtonBrush As New [COLOR=Red]LinearGradientBrush[/COLOR](rc, Me._GradientStartColor, Me.GradientEndColor, Me.Mode) [COLOR=Blue]'Type LinearGradientMode is not defined[/COLOR]
e.Graphics.FillRectangle(ButtonBrush, rc)
ButtonBrush.dispose()
e.Graphics.DrawRectangle(Pens.Black, rc)
If Me.DrawFocusRectangle Then
rc.inflate(-3, -3)
Dim focuspen As New Pen(Color.Black, -1)
[COLOR=Red]focuspen.penstyle [/COLOR]= [COLOR=Red]penstyle[/COLOR].dot [COLOR=Blue]'penstyle is not a member of System.Drawing.Pen[/COLOR]
e.Graphics.DrawRectangle(focuspen, rc)
focuspen.Dispose()
End If
End Sub
Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
MyBase.OnMouseEnter(e)
Me.DrawFocusRectangle = True
Me.Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
MyBase.OnMouseLeave(e)
Me.DrawFocusRectangle = False
Me.Invalidate()
End Sub
End Class