Hi everyone... I am very new to GDI+, studying up on it and all... yesterday, I made a tab with the system.drawing and system.drawing.drawing2D namespaces... My code is at the bottom... What's weird is that during build time I can take the control and add it to a form, it'll resize and all like it should, but during runtime, the mousehover and mouseleave events don't create the inteded draw actions... what am I doing wrong?
VB.NET:
Public Class qlTab
Inherits UserControl
Dim index As Integer
Dim title As String
Dim fntList As FontFamily
Dim tFont As Font = New Font(fntList.GenericSansSerif, 8)
Dim cA As Integer = 5 ' curveAmount
Dim tL(2) As Point ' top left
Dim tR(2) As Point ' top right
Dim bL(2) As Point 'bottom left
Dim bR(2) As Point ' bottom right
Dim area As Rectangle
Dim transparent As Color = Color.FromArgb(0, 0, 0, 0)
Dim barheight As Integer = 6
Dim glowBarRGB(1) As Color
Dim tabRGB(1) As Color
Private Sub qlTab_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.MinimumSize = New Size(14, 24)
With area
.X = 0
.Y = 0
.Width = Me.Width
.Height = Me.Height
End With
tL(0) = New Point(1, 1 + cA)
tL(1) = New Point(3, 3)
tL(2) = New Point(1 + cA, 1)
tR(0) = New Point((Me.Width - 1) - cA, 1)
tR(1) = New Point((Me.Width - 3), 3)
tR(2) = New Point((Me.Width - 1), 1 + cA)
bL(0) = New Point(1 + cA, (Me.Height - 1))
bL(1) = New Point(2, (Me.Height - 3))
bL(2) = New Point(0, Me.Height - barheight)
bR(0) = New Point((Me.Width - 1), Me.Height - barheight)
bR(1) = New Point((Me.Width - 3), (Me.Height - 3))
bR(2) = New Point((Me.Width - 1) - cA, (Me.Height - 1))
glowBarRGB(0) = Color.FromArgb(255, 142, 140, 125)
glowBarRGB(1) = Color.FromArgb(255, 219, 217, 202)
tabRGB(0) = Color.FromArgb(255, 250, 249, 245)
tabRGB(1) = Color.FromArgb(255, 192, 192, 168)
End Sub
Private Sub qlTab_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseHover
glowBarRGB(0) = Color.FromArgb(255, 255, 205, 0)
glowBarRGB(1) = Color.FromArgb(255, 255, 243, 104)
End Sub
Private Sub qlTab_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
glowBarRGB(0) = Color.FromArgb(255, 142, 140, 125)
glowBarRGB(1) = Color.FromArgb(255, 219, 217, 202)
End Sub
Private Sub qlTab_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
tL(0) = New Point(1, 1 + cA)
tL(1) = New Point(3, 3)
tL(2) = New Point(1 + cA, 1)
tR(0) = New Point((Me.Width - 1) - cA, 1)
tR(1) = New Point((Me.Width - 3), 3)
tR(2) = New Point((Me.Width - 1), 1 + cA)
bL(0) = New Point(1 + cA, (Me.Height - 1))
bL(1) = New Point(2, (Me.Height - 3))
bL(2) = New Point(0, Me.Height - barheight)
bR(0) = New Point((Me.Width - 1), Me.Height - barheight)
bR(1) = New Point((Me.Width - 3), (Me.Height - 3))
bR(2) = New Point((Me.Width - 1) - cA, (Me.Height - 1))
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
Dim G As Graphics = e.Graphics
Dim pen As Pen = New Pen(Color.Transparent)
Dim glowBar As GraphicsPath = New GraphicsPath
glowBar.AddLine(New PointF(0, (Me.Height - barheight)), New PointF(Me.Width, (Me.Height - barheight)))
glowBar.AddCurve(bR)
glowBar.AddLine(bR(2), bL(0))
glowBar.AddCurve(bL)
G.DrawPath(pen, glowBar)
G.FillPath(New LinearGradientBrush(New Point(0, (Me.Height - barheight)), New Point(0, Me.Height), glowBarRGB(0), glowBarRGB(1)), glowBar)
Dim tab As GraphicsPath = New GraphicsPath
tab.AddLine(New Point(0, 0), New Point(Me.Width, 0))
tab.AddLine(New Point(Me.Width, 0), New Point(Me.Width, (Me.Height - barheight)))
tab.AddLine(New Point(Me.Width, (Me.Height - barheight)), New Point(0, (Me.Height - barheight)))
tab.AddLine(New Point(0, (Me.Height - barheight)), New Point(0, 0))
G.FillPath(New LinearGradientBrush(New Point(0, 0), New Point(0, (Me.Height - barheight)), tabRGB(0), tabRGB(1)), tab)
G.DrawLine(New Pen(Color.FromArgb(100, 0, 0, 0)), New Point(1, 3), New Point(1, (Me.Height - (barheight + 3))))
G.DrawLine(New Pen(Color.FromArgb(100, 0, 0, 0)), New Point((Me.Width - 1), 3), New Point((Me.Width - 1), (Me.Height - (barheight + 3))))
End Sub
End Class