ControlC ControlC.com

[VB.Net] YouTubeTabControl

Views: 140Total Chars: 2,474
Created: 6/12/12 11:01:39PM ET
Self Destructs: Never
Class YouTubeTabControl
Inherits TabControlDesigner

Private B1, B2, B3, B4, B5, B6, B7 As SolidBrush
Private P1, P2 As Pen
Private R1, R2, R3 As Rectangle

Sub New()
SetColor("Selected Tab #1", 28, 28, 28)
SetColor("Selected Tab #2", 196, 48, 43)
SetColor("Unselected Tab", 39, 39, 39)
SetColor("Hover Tab #1", 28, 28, 28)
SetColor("Hover Tab #2", 102, 102, 102)
SetColor("Panel Color", 39, 39, 39)
SetColor("Back Color", 236, 236, 236)
SetColor("Highlight #1", 50, 50, 50)
SetColor("Highlight #2", 27, 27, 27)

Alignment = TabAlignment.Left
SizeMode = TabSizeMode.Fixed
Font = New Font("Verdana", 8S)
ItemSize = New Size(37, 200)
Dock = DockStyle.Fill
End Sub

Protected Overrides Sub ColorHook()

B1 = GetBrush("Selected Tab #1")
B2 = GetBrush("Selected Tab #2")
B3 = GetBrush("Unselected Tab")
B4 = GetBrush("Hover Tab #1")
B5 = GetBrush("Hover Tab #2")
B6 = GetBrush("Panel Color")
B7 = GetBrush("Back Color")

P1 = GetPen("Highlight #1")
P2 = GetPen("Highlight #2")

End Sub

Protected Overrides Sub PaintHook()
R1 = New Rectangle(0, 0, ItemSize.Height + 1, Height)
R2 = New Rectangle(ItemSize.Height - 1, 0, Width - ItemSize.Height, Height)

G.FillRectangle(B6, R1)
G.FillRectangle(B7, R2)
End Sub

Protected Overrides Sub TabPaint(ByVal Index As Integer)
Try : TabPages(Index).BackColor = B7.Color : Catch : End Try

Dim T As String = TabPages(Index).Text

R1 = GetTabRect(Index)
R2 = New Rectangle(R1.X - 1, R1.Y - 1, R1.Width - 4, R1.Height)
R3 = New Rectangle(R2.Right - 2, R2.Top, 4, R2.Height)

If SelectedIndex = Index Then
G.FillRectangle(B1, R2)
G.FillRectangle(B2, R3)

G.DrawString(T, Font, Brushes.White, Center(T, R2))
ElseIf State = MouseState.Over AndAlso R2.Contains(Coordinates) Then
G.FillRectangle(B4, R2)
G.FillRectangle(B5, R3)

G.DrawString(T, Font, Brushes.DimGray, Center(T, R2))
Else
G.FillRectangle(B3, R2)

G.DrawString(T, Font, Brushes.DimGray, Center(T, R2))
End If

G.DrawLine(P1, R2.X, R2.Y, R2.Right + 1, R2.Y)
G.DrawLine(P2, R2.X, R2.Bottom, R2.Right, R2.Bottom)

End Sub

End Class
2,474 chars, 277 words, 79 lines·Create new version