[VB.Net] BlueTabControl
Class BlueTabControl
Inherits TabControlDesigner
Private C1, C2, C3, C4, C5, C6 As Color
Private L1, L2 As LinearGradientBrush
Sub New()
C1 = RGB(207, 219, 236) 'Panel Color
C2 = RGB(109, 106, 98) 'Line Color
C3 = ARGB(120, Color.White) 'Highlight
C4 = RGB(171, 180, 194) 'Unselected Tab #1
C5 = RGB(197, 208, 223) 'Unselected Tab #2
C6 = RGB(110, 116, 124) 'Tab Line
Alignment = TabAlignment.Top
Font = New Font("Verdana", 8S)
ItemSize = New Size(130, 30)
PanelColor = Color.Transparent
For I As Integer = 0 To TabPages.Count - 1
TabPages(I).BackColor = C1
Next
End Sub
Protected Overrides Sub TabPaint(ByVal e As Integer)
Dim Text = TabPages(e).Text
Dim Tab = GetTabRect(e)
Dim Temp = New Rectangle(Tab.X + 1, Tab.Y + 1, Tab.Width - 6, Tab.Height + If(SelectedIndex = e, 1, 0))
Dim Highlight = New Rectangle(Temp.X, Temp.Y, Temp.Width, 10)
Dim Outline = New Point() {New Point(Temp.X, Temp.Bottom), New Point(Temp.X, Temp.Top), New Point(Temp.Right, Temp.Top), New Point(Temp.Right, Temp.Bottom)}
L1 = New LinearGradientBrush(Highlight, C3, Color.Transparent, 90S)
L2 = New LinearGradientBrush(Temp, C4, C5, 90S)
If SelectedIndex = e Then
Try : TabPages(e).BackColor = C1 : Catch : End Try
G.FillRectangle(ToBrush(C1), Temp)
G.FillRectangle(L1, Highlight)
ElseIf State = MouseState.Over AndAlso Temp.Contains(Coordinates) Then
G.FillRectangle(L2, Temp)
G.FillRectangle(L1, Highlight)
Else
G.FillRectangle(L2, Temp)
End If
G.DrawLines(ToPen(C2), Outline)
G.DrawString(Text, Font, Brushes.Black, Center(Text, Font, Temp, 0, 0))
End Sub
Protected Overrides Sub PaintHook()
Dim Outline = New Point() {New Point(ClientRectangle.X + 3, ClientRectangle.Y + 34), _
New Point(ClientRectangle.X + 3, ClientRectangle.Bottom - 4), _
New Point(ClientRectangle.Right - 4, ClientRectangle.Bottom - 4), _
New Point(ClientRectangle.Right - 4, ClientRectangle.Top + 34)}
G.DrawLines(ToPen(C6), Outline)
G.DrawLine(ToPen(C6), 4, 33, Width - 4, 33)
End Sub
End Class
Inherits TabControlDesigner
Private C1, C2, C3, C4, C5, C6 As Color
Private L1, L2 As LinearGradientBrush
Sub New()
C1 = RGB(207, 219, 236) 'Panel Color
C2 = RGB(109, 106, 98) 'Line Color
C3 = ARGB(120, Color.White) 'Highlight
C4 = RGB(171, 180, 194) 'Unselected Tab #1
C5 = RGB(197, 208, 223) 'Unselected Tab #2
C6 = RGB(110, 116, 124) 'Tab Line
Alignment = TabAlignment.Top
Font = New Font("Verdana", 8S)
ItemSize = New Size(130, 30)
PanelColor = Color.Transparent
For I As Integer = 0 To TabPages.Count - 1
TabPages(I).BackColor = C1
Next
End Sub
Protected Overrides Sub TabPaint(ByVal e As Integer)
Dim Text = TabPages(e).Text
Dim Tab = GetTabRect(e)
Dim Temp = New Rectangle(Tab.X + 1, Tab.Y + 1, Tab.Width - 6, Tab.Height + If(SelectedIndex = e, 1, 0))
Dim Highlight = New Rectangle(Temp.X, Temp.Y, Temp.Width, 10)
Dim Outline = New Point() {New Point(Temp.X, Temp.Bottom), New Point(Temp.X, Temp.Top), New Point(Temp.Right, Temp.Top), New Point(Temp.Right, Temp.Bottom)}
L1 = New LinearGradientBrush(Highlight, C3, Color.Transparent, 90S)
L2 = New LinearGradientBrush(Temp, C4, C5, 90S)
If SelectedIndex = e Then
Try : TabPages(e).BackColor = C1 : Catch : End Try
G.FillRectangle(ToBrush(C1), Temp)
G.FillRectangle(L1, Highlight)
ElseIf State = MouseState.Over AndAlso Temp.Contains(Coordinates) Then
G.FillRectangle(L2, Temp)
G.FillRectangle(L1, Highlight)
Else
G.FillRectangle(L2, Temp)
End If
G.DrawLines(ToPen(C2), Outline)
G.DrawString(Text, Font, Brushes.Black, Center(Text, Font, Temp, 0, 0))
End Sub
Protected Overrides Sub PaintHook()
Dim Outline = New Point() {New Point(ClientRectangle.X + 3, ClientRectangle.Y + 34), _
New Point(ClientRectangle.X + 3, ClientRectangle.Bottom - 4), _
New Point(ClientRectangle.Right - 4, ClientRectangle.Bottom - 4), _
New Point(ClientRectangle.Right - 4, ClientRectangle.Top + 34)}
G.DrawLines(ToPen(C6), Outline)
G.DrawLine(ToPen(C6), 4, 33, Width - 4, 33)
End Sub
End Class