Advertisement
Finessed

V Theme

Dec 2nd, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 88.01 KB | None | 0 0
  1. Imports System, System.Collections
  2. Imports System.Drawing, System.Drawing.Drawing2D
  3. Imports System.ComponentModel, System.Windows.Forms
  4. Imports System.IO, System.Collections.Generic
  5. Imports System.Runtime.InteropServices
  6. Imports System.Drawing.Imaging
  7. ' Get more free themes at ThemesVB.NET
  8. '''''''''''''''''''''''''''''''''''''''''''''''''''
  9. ''''Credits: Aeonhack, Mavamaarten,  Support™.'''''
  10. ''''''''''''Themebase version: 1.5.4'''''''''''''''
  11. '''''''''''''''''''''''''''''''''''''''''''''''''''
  12. ' Get more free themes at ThemesVB.NET
  13. #Region "VTheme"
  14.  
  15.  
  16. Class VTheme
  17.     Inherits ThemeContainer154
  18.  
  19.     Sub New()
  20.         TransparencyKey = Color.Fuchsia
  21.     End Sub
  22.  
  23.     Protected Overrides Sub ColorHook()
  24.  
  25.     End Sub
  26.  
  27.     Protected Overrides Sub PaintHook()
  28.         G.Clear(Color.FromArgb(12, 12, 12))
  29.         Dim P As New Pen(Color.FromArgb(32, 32, 32))
  30.         G.DrawLine(P, 11, 31, Width - 12, 31)
  31.         G.DrawLine(P, 11, 8, Width - 12, 8)
  32.         G.FillRectangle(New LinearGradientBrush(New Rectangle(8, 38, Width - 16, Height - 46), Color.FromArgb(12, 12, 12), Color.FromArgb(18, 18, 18), LinearGradientMode.BackwardDiagonal), 8, 38, Width - 16, Height - 46)
  33.         DrawText(Brushes.White, HorizontalAlignment.Left, 25, 6)
  34.         DrawBorders(New Pen(Color.FromArgb(60, 60, 60)), 1)
  35.         DrawBorders(Pens.Black)
  36.  
  37.         P = New Pen(Color.FromArgb(25, 25, 25))
  38.         G.DrawLine(Pens.Black, 6, 0, 6, Height - 6)
  39.         G.DrawLine(Pens.Black, Width - 6, 0, Width - 6, Height - 6)
  40.         G.DrawLine(P, 6, 0, 6, Height - 6)
  41.         G.DrawLine(P, Width - 8, 0, Width - 8, Height - 6)
  42.  
  43.         G.DrawRectangle(Pens.Black, 11, 4, Width - 23, 22)
  44.         G.DrawLine(P, 6, Height - 6, Width - 8, Height - 6)
  45.         G.DrawLine(Pens.Black, 6, Height - 8, Width - 8, Height - 8)
  46.         DrawCorners(Color.Fuchsia)
  47.     End Sub
  48.  
  49. End Class
  50.  
  51. Class VTabControl
  52.     Inherits TabControl
  53.     Dim OldIndex As Integer
  54.     Private _Speed As Integer = 10
  55.     Public Property Speed() As Integer
  56.         Get
  57.             Return _Speed
  58.         End Get
  59.         Set(ByVal value As Integer)
  60.             If value > 20 Or value < -20 Then
  61.                 MsgBox("Speed needs to be in between -20 and 20.")
  62.             Else
  63.                 _Speed = value
  64.             End If
  65.         End Set
  66.     End Property
  67.     Private LightBlack As Color = Color.FromArgb(18, 18, 18)
  68.     Private LighterBlack As Color = Color.FromArgb(21, 21, 21)
  69.     Private DrawGradientBrush, DrawGradientBrush2, DrawGradientBrushPen, DrawGradientBrushTab As LinearGradientBrush
  70.     Private _ControlBColor As Color
  71.     Public Property TabTextColor() As Color
  72.         Get
  73.             Return _ControlBColor
  74.         End Get
  75.         Set(ByVal v As Color)
  76.             _ControlBColor = v
  77.             Invalidate()
  78.         End Set
  79.     End Property
  80. ' Get more free themes at ThemesVB.NET
  81.     Sub New()
  82.         MyBase.New()
  83.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  84.         TabTextColor = Color.White
  85.     End Sub
  86.     Sub DoAnimationScrollDown(ByVal Control1 As Control, ByVal Control2 As Control)
  87.         Dim G As Graphics = Control1.CreateGraphics()
  88.         Dim P1 As New Bitmap(Control1.Width, Control1.Height)
  89.         Dim P2 As New Bitmap(Control2.Width, Control2.Height)
  90.         Control1.DrawToBitmap(P1, New Rectangle(0, 0, Control1.Width, Control1.Height))
  91.         Control2.DrawToBitmap(P2, New Rectangle(0, 0, Control2.Width, Control2.Height))
  92.         For Each c As Control In Control1.Controls
  93.             c.Hide()
  94.         Next
  95.         Dim Slide As Integer = Control1.Height - (Control1.Height Mod _Speed)
  96.         Dim a As Integer
  97.         For a = 0 To Slide Step _Speed
  98.             G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  99.             G.DrawImage(P2, New Rectangle(0, a - Control2.Height, Control2.Width, Control2.Height))
  100.         Next
  101.         a = Control1.Width
  102.         G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  103.         G.DrawImage(P2, New Rectangle(0, a - Control2.Height, Control2.Width, Control2.Height))
  104.         SelectedTab = Control2
  105.         For Each c As Control In Control2.Controls
  106.             c.Show()
  107.         Next
  108.         For Each c As Control In Control1.Controls
  109.             c.Show()
  110.         Next
  111.     End Sub
  112.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  113.         MyBase.OnPaint(e)
  114.         Dim r2 As New Rectangle(2, 0, Width, 25)
  115.         Dim r3 As New Rectangle(2, 0, Width, 25)
  116.         e.Graphics.Clear(Color.FromArgb(18, 18, 18))
  117.         Dim ItemBounds As Rectangle
  118.         Dim TextBrush As New SolidBrush(Color.Empty)
  119.         Dim TabBrush As New SolidBrush(Color.FromArgb(15, 15, 15))
  120.         DrawGradientBrush2 = New LinearGradientBrush(r3, Color.FromArgb(25, 25, 25), Color.FromArgb(42, 42, 42), LinearGradientMode.ForwardDiagonal)
  121.         e.Graphics.FillRectangle(DrawGradientBrush2, r2)
  122.         For TabItemIndex As Integer = 0 To Me.TabCount - 1
  123.             ItemBounds = Me.GetTabRect(TabItemIndex)
  124.  
  125.             If CBool(TabItemIndex And 1) Then
  126.                 TabBrush.Color = Color.Transparent
  127.             Else
  128.                 TabBrush.Color = Color.Transparent
  129.             End If
  130.             e.Graphics.FillRectangle(TabBrush, ItemBounds)
  131.             Dim BorderPen As Pen
  132.             If TabItemIndex = SelectedIndex Then
  133.                 BorderPen = New Pen(Color.Black, 1)
  134.             Else
  135.                 BorderPen = New Pen(Color.Black, 1)
  136.             End If
  137.             Dim rPen As New Rectangle(ItemBounds.Location.X + 3, ItemBounds.Location.Y + 0, ItemBounds.Width - 4, ItemBounds.Height - 2)
  138.             e.Graphics.DrawRectangle(BorderPen, rPen)
  139.             DrawGradientBrushPen = New LinearGradientBrush(rPen, Color.FromArgb(5, 5, 5), Color.FromArgb(24, 24, 24), LinearGradientMode.Vertical)
  140.             e.Graphics.FillRectangle(DrawGradientBrushPen, rPen)
  141.             BorderPen.Dispose()
  142.             Dim sf As New StringFormat
  143.             sf.LineAlignment = StringAlignment.Center
  144.             sf.Alignment = StringAlignment.Center
  145.  
  146.             If Me.SelectedIndex = TabItemIndex Then
  147.                 TextBrush.Color = TabTextColor
  148.             Else
  149.                 TextBrush.Color = Color.Gray
  150.             End If
  151.             e.Graphics.DrawString( _
  152.             Me.TabPages(TabItemIndex).Text, _
  153.             Me.Font, TextBrush, _
  154.             RectangleF.op_Implicit(Me.GetTabRect(TabItemIndex)), sf)
  155.             Try
  156.                 Me.TabPages(TabItemIndex).BackColor = Color.FromArgb(15, 15, 15)
  157.  
  158.             Catch
  159.             End Try
  160.         Next
  161.         Try
  162.             For Each Page As TabPage In Me.TabPages
  163.                 Page.BorderStyle = BorderStyle.None
  164.             Next
  165.         Catch
  166.         End Try
  167.         e.Graphics.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(255, Color.Black))), 2, 0, Width - 3, Height - 3)
  168.         e.Graphics.DrawRectangle(New Pen(New SolidBrush(LighterBlack)), New Rectangle(3, 24, Width - 5, Height - 28))
  169.         e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(255, Color.Black))), 2, 23, Width - 2, 23)
  170.         e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(35, 35, 35))), 0, 0, 1, 1)
  171.         e.Graphics.DrawLine(New Pen(New SolidBrush(Color.FromArgb(70, 70, 70))), 2, Height - 2, Width + 1, Height - 2)
  172.  
  173.     End Sub
  174.     Protected Overrides Sub OnSelecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
  175.         If OldIndex < e.TabPageIndex Then
  176.             DoAnimationScrollUp(TabPages(OldIndex), TabPages(e.TabPageIndex))
  177.         Else
  178.             DoAnimationScrollDown(TabPages(OldIndex), TabPages(e.TabPageIndex))
  179.         End If
  180.     End Sub
  181. ' Get more free themes at ThemesVB.NET
  182.     Protected Overrides Sub OnDeselecting(ByVal e As System.Windows.Forms.TabControlCancelEventArgs)
  183.         OldIndex = e.TabPageIndex
  184.     End Sub
  185.     Sub DoAnimationScrollUp(ByVal Control1 As Control, ByVal Control2 As Control)
  186.         Dim G As Graphics = Control1.CreateGraphics()
  187.         Dim P1 As New Bitmap(Control1.Width, Control1.Height)
  188.         Dim P2 As New Bitmap(Control2.Width, Control2.Height)
  189.         Control1.DrawToBitmap(P1, New Rectangle(0, 0, Control1.Width, Control1.Height))
  190.         Control2.DrawToBitmap(P2, New Rectangle(0, 0, Control2.Width, Control2.Height))
  191.  
  192.         For Each c As Control In Control1.Controls
  193.             c.Hide()
  194.         Next
  195.         Dim Slide As Integer = Control1.Height - (Control1.Height Mod _Speed)
  196.         Dim a As Integer
  197.         For a = 0 To -Slide Step -_Speed
  198.             G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  199.             G.DrawImage(P2, New Rectangle(0, a + Control2.Height, Control2.Width, Control2.Height))
  200.         Next
  201.         a = Control1.Width
  202.         G.DrawImage(P1, New Rectangle(0, a, Control1.Width, Control1.Height))
  203.         G.DrawImage(P2, New Rectangle(0, a + Control2.Height, Control2.Width, Control2.Height))
  204.  
  205.         SelectedTab = Control2
  206.  
  207.         For Each c As Control In Control2.Controls
  208.             c.Show()
  209.         Next
  210.  
  211.         For Each c As Control In Control1.Controls
  212.             c.Show()
  213.         Next
  214.     End Sub
  215. End Class
  216.  
  217. Class VGroupBox
  218.     Inherits ThemeContainer154
  219.  
  220.     Sub New()
  221.         ControlMode = True
  222.     End Sub
  223.  
  224.     Protected Overrides Sub ColorHook()
  225.  
  226.     End Sub
  227.  
  228.     Protected Overrides Sub PaintHook()
  229.         G.Clear(Color.Transparent)
  230.         DrawBorders(New Pen(Color.FromArgb(36, 36, 36)), 1)
  231.         DrawBorders(Pens.Black)
  232.         G.DrawLine(New Pen(Color.FromArgb(48, 48, 48)), 1, 1, Width - 2, 1)
  233.         G.FillRectangle(New LinearGradientBrush(New Rectangle(8, 8, Width - 16, Height - 16), Color.FromArgb(12, 12, 12), Color.FromArgb(18, 18, 18), LinearGradientMode.BackwardDiagonal), 8, 8, Width - 16, Height - 16)
  234.         DrawBorders(New Pen(Color.FromArgb(36, 36, 36)), 7)
  235.     End Sub
  236. End Class
  237.  
  238. Class VSeperator
  239.     Inherits ThemeControl154
  240.  
  241.     Private _Orientation As Orientation
  242.     Property Orientation() As Orientation
  243.         Get
  244.             Return _Orientation
  245.         End Get
  246.         Set(ByVal value As Orientation)
  247.             _Orientation = value
  248.  
  249.             If value = Windows.Forms.Orientation.Vertical Then
  250.                 LockHeight = 0
  251.                 LockWidth = 14
  252.             Else
  253.                 LockHeight = 14
  254.                 LockWidth = 0
  255.             End If
  256.  
  257.             Invalidate()
  258.         End Set
  259.     End Property
  260.  
  261.     Sub New()
  262.         Transparent = True
  263.         BackColor = Color.Transparent
  264.  
  265.         LockHeight = 14
  266.     End Sub
  267.  
  268.     Protected Overrides Sub ColorHook()
  269.  
  270.     End Sub
  271.  
  272.     Protected Overrides Sub PaintHook()
  273.         G.Clear(BackColor)
  274.  
  275.         Dim BL1, BL2 As New ColorBlend
  276.         BL1.Positions = New Single() {0.0F, 0.15F, 0.85F, 1.0F}
  277.         BL2.Positions = New Single() {0.0F, 0.15F, 0.5F, 0.85F, 1.0F}
  278.  
  279.         BL1.Colors = New Color() {Color.Transparent, Color.Black, Color.Black, Color.Transparent}
  280.         BL2.Colors = New Color() {Color.Transparent, Color.FromArgb(24, 24, 24), Color.FromArgb(40, 40, 40), Color.FromArgb(36, 36, 36), Color.Transparent}
  281.  
  282.         If _Orientation = Windows.Forms.Orientation.Vertical Then
  283.             DrawGradient(BL1, 6, 0, 1, Height)
  284.             DrawGradient(BL2, 7, 0, 1, Height)
  285.         Else
  286.             DrawGradient(BL1, 0, 6, Width, 1, 0.0F)
  287.             DrawGradient(BL2, 0, 7, Width, 1, 0.0F)
  288.         End If
  289.  
  290.     End Sub
  291.  
  292. End Class
  293.  
  294. Class VCheckBox
  295.     Inherits ThemeControl154
  296.     Private P1 As Pen
  297.     Private B1 As Brush
  298.     Private B2 As Brush
  299.     Private B3 As Brush
  300.     Private _Checked As Boolean = False
  301.     Public Property Checked() As Boolean
  302.         Get
  303.             Return _Checked
  304.         End Get
  305.         Set(ByVal checked As Boolean)
  306.             _Checked = checked
  307.             Invalidate()
  308.         End Set
  309.     End Property
  310.     Sub New()
  311.         BackColor = Color.Transparent
  312.         Transparent = True
  313.         Size = New Size(150, 16)
  314.     End Sub
  315.     Sub changeChecked() Handles Me.Click
  316.         Select Case _Checked
  317.             Case False
  318.                 _Checked = True
  319.             Case True
  320.                 _Checked = False
  321.         End Select
  322.     End Sub
  323.     Protected Overrides Sub ColorHook()
  324.         P1 = New Pen(Color.FromArgb(0, 0, 0))
  325.         B1 = New SolidBrush(Color.FromArgb(15, Color.FromArgb(26, 26, 26)))
  326.         B2 = New SolidBrush(Color.White)
  327.         B3 = New SolidBrush(Color.FromArgb(0, 0, 0))
  328.     End Sub
  329.  
  330.     Protected Overrides Sub PaintHook()
  331.         G.Clear(BackColor)
  332.         G.FillRectangle(B3, 0, 0, 45, 15)
  333.         G.DrawRectangle(P1, 0, 0, 45, 15)
  334.         If (_Checked = False) Then
  335.             G.DrawString("OFF", Font, Brushes.Gray, 3, 1)
  336.             G.FillRectangle(New LinearGradientBrush(New Rectangle(29, -1, 13, 16), Color.FromArgb(35, 35, 35), Color.FromArgb(25, 25, 25), 90S), 29, -1, 13, 16)
  337.         Else
  338.             DrawGradient(Color.FromArgb(10, 10, 10), Color.FromArgb(20, 20, 20), 15, 2, 28, 11, 90S)
  339.             G.DrawString("ON", Font, Brushes.White, 18, 0)
  340.             G.FillRectangle(New LinearGradientBrush(New Rectangle(2, -1, 13, 16), Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 90S), 2, -1, 13, 16)
  341.         End If
  342.         G.FillRectangle(B1, 2, 2, 41, 11)
  343.         DrawText(B2, HorizontalAlignment.Left, 50, 0)
  344.     End Sub
  345. End Class
  346.  
  347. Class VRadiobutton
  348.     Inherits ThemeControl154
  349.     Sub New()
  350.         BackColor = Color.Transparent
  351.         Transparent = True
  352.         Size = New Point(50, 17)
  353.     End Sub
  354.     Private _Checked As Boolean
  355.     Public Property Checked() As Boolean
  356.         Get
  357.             Return _Checked
  358.         End Get
  359.         Set(ByVal V As Boolean)
  360.             _Checked = V
  361.             Invalidate()
  362.         End Set
  363.     End Property
  364.  
  365.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  366.         MyBase.OnClick(e)
  367.         For Each C As Control In Parent.Controls
  368.             If C.GetType.ToString = Replace(My.Application.Info.ProductName, " ", "_") & ".VRadiobutton" Then
  369.                 Dim CC As VRadiobutton
  370.                 CC = C
  371.                 CC.Checked = False
  372.             End If
  373.         Next
  374.         _Checked = True
  375.     End Sub
  376.  
  377.     Protected Overrides Sub ColorHook()
  378.  
  379.     End Sub
  380.  
  381.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  382.         MyBase.OnTextChanged(e)
  383.         Dim textSize As Integer
  384.         textSize = Me.CreateGraphics.MeasureString(Text, Font).Width
  385.         Me.Width = 25 + textSize
  386.     End Sub
  387.  
  388.     Protected Overrides Sub PaintHook()
  389.         G.Clear(BackColor)
  390.         G.SmoothingMode = SmoothingMode.AntiAlias
  391.  
  392.         If _Checked = False Then
  393.             G.FillEllipse(New SolidBrush(Color.Black), 0, 0, 16, 16)
  394.             Dim Gbrush As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(24, 30, 36), Color.FromArgb(25, 25, 25), 90.0F)
  395.             G.FillEllipse(Gbrush, New Rectangle(1, 1, 14, 14))
  396.             Gbrush = New LinearGradientBrush(New Rectangle(2, 2, 12, 12), Color.FromArgb(12, 12, 12), Color.FromArgb(25, 25, 25), 90.0F)
  397.             G.FillEllipse(Gbrush, New Rectangle(2, 2, 12, 12))
  398.         Else
  399.             G.FillEllipse(New SolidBrush(Color.Black), 0, 0, 16, 16)
  400.             Dim Gbrush As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(45, 45, 45), Color.FromArgb(10, 10, 10), 90.0F)
  401.             G.FillEllipse(Gbrush, New Rectangle(1, 1, 14, 14))
  402.             Gbrush = New LinearGradientBrush(New Rectangle(2, 2, 12, 12), Color.FromArgb(25, 25, 25), Color.FromArgb(20, 20, 20), 90.0F)
  403.             G.FillEllipse(Gbrush, New Rectangle(2, 2, 12, 12))
  404.             G.FillEllipse(Brushes.Black, New Rectangle(5, 6, 5, 5))
  405.             Dim Gbrush2 As New LinearGradientBrush(New Rectangle(1, 1, 14, 14), Color.FromArgb(130, 130, 130), Color.FromArgb(20, 20, 20), LinearGradientMode.ForwardDiagonal)
  406.             G.FillEllipse(Gbrush2, New Rectangle(3, 3, 10, 10))
  407.         End If
  408.         G.DrawString(Text, Font, Brushes.White, 22, 2)
  409.     End Sub
  410.  
  411.  
  412. End Class
  413.  
  414. Class VButton
  415.     Inherits ThemeControl154
  416.  
  417.     Protected Overrides Sub ColorHook()
  418.  
  419.     End Sub
  420.  
  421.     Protected Overrides Sub PaintHook()
  422.         DrawBorders(New Pen(Color.FromArgb(16, 16, 16)), 1)
  423.         G.FillRectangle(New SolidBrush(Color.FromArgb(5, 5, 5)), 0, 0, Width, 8)
  424.         DrawBorders(Pens.Black, 3)
  425.         DrawBorders(New Pen(Color.FromArgb(24, 24, 24)))
  426.  
  427.         If State = MouseState.Over Then
  428.             G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), 3, 3, Width - 6, Height - 6)
  429.             DrawBorders(New Pen(Color.FromArgb(0, 0, 0)), 2)
  430.         ElseIf State = MouseState.Down Then
  431.             G.FillRectangle(New LinearGradientBrush(New Rectangle(3, 3, Width - 6, Height - 6), Color.FromArgb(12, 12, 12), Color.FromArgb(30, 30, 30), LinearGradientMode.BackwardDiagonal), 3, 3, Width - 6, Height - 6)
  432.             DrawBorders(New Pen(Color.FromArgb(0, 0, 0)), 2)
  433.         Else
  434.             G.FillRectangle(New LinearGradientBrush(New Rectangle(3, 3, Width - 6, Height - 6), Color.FromArgb(9, 9, 9), Color.FromArgb(18, 18, 18), LinearGradientMode.Vertical), 3, 3, Width - 6, Height - 6)
  435.             DrawBorders(New Pen(Color.FromArgb(32, 32, 32)), 2)
  436.         End If
  437.         If State = MouseState.Down Then
  438.             DrawText(Brushes.White, HorizontalAlignment.Center, 2, 2)
  439.         Else
  440.             DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
  441.         End If
  442.     End Sub
  443.  
  444. End Class
  445.  
  446. Class VTextBox
  447.     Inherits ThemeControl154
  448.     Dim WithEvents Txt As New TextBox
  449.  
  450.     Private _Mulitline As Boolean
  451.     Public Property Multiline() As Boolean
  452.         Get
  453.             Return _Mulitline
  454.         End Get
  455.         Set(ByVal value As Boolean)
  456.             _Mulitline = value
  457.         End Set
  458.     End Property
  459.     Private _PassMask As Boolean
  460.     Public Property UsePasswordMask() As Boolean
  461.         Get
  462.             Return _PassMask
  463.         End Get
  464.         Set(ByVal v As Boolean)
  465.             _PassMask = v
  466.             Txt.UseSystemPasswordChar = v
  467.         End Set
  468.     End Property
  469.     Private _maxchars As Integer
  470.     Public Property MaxCharacters() As Integer
  471.         Get
  472.             Return _maxchars
  473.         End Get
  474.         Set(ByVal v As Integer)
  475.             _maxchars = v
  476.             Txt.MaxLength = v
  477.         End Set
  478.     End Property
  479.  
  480.     Sub New()
  481.  
  482.         Txt.TextAlign = HorizontalAlignment.Left
  483.         Txt.BorderStyle = BorderStyle.None
  484.         Txt.Location = New Point(10, 6)
  485.         Txt.Font = New Font("Verdana", 8)
  486.         Controls.Add(Txt)
  487.         Text = ""
  488.         Txt.Text = ""
  489.         Size = New Size(150, 25)
  490.     End Sub
  491.  
  492.     Protected Overrides Sub ColorHook()
  493.         Txt.ForeColor = Color.White
  494.         Txt.BackColor = Color.FromArgb(15, 15, 15)
  495.     End Sub
  496.  
  497.     Protected Overrides Sub PaintHook()
  498.         G.Clear(Color.FromArgb(15, 15, 15))
  499.         Txt.Size = New Size(Width - 20, Height - 10)
  500.         Select Case Multiline
  501.             Case True
  502.                 Size = New Size(Width, Height)
  503.             Case False
  504.                 Size = New Size(Width, 25)
  505.         End Select
  506.  
  507.         G.FillRectangle(New SolidBrush(Color.FromArgb(15, 15, 15)), New Rectangle(1, 1, Width - 2, Height - 2))
  508.         DrawBorders(New Pen(New SolidBrush(Color.FromArgb(32, 32, 32))), 1)
  509.         DrawBorders(New Pen(New SolidBrush(Color.Black)))
  510.         DrawCorners(Color.FromArgb(15, 15, 15))
  511.         DrawCorners(Color.FromArgb(15, 15, 15), New Rectangle(1, 1, Width - 2, Height - 2))
  512.     End Sub
  513.     Sub TextChngTxtBox() Handles Txt.TextChanged
  514.         Text = Txt.Text
  515.     End Sub
  516.     Sub TextChng() Handles MyBase.TextChanged
  517.         Txt.Text = Text
  518.     End Sub
  519. End Class
  520.  
  521. #End Region
  522. #Region "Themebase154"
  523.  
  524. '------------------
  525. 'Creator: aeonhack
  526. 'Site: elitevs.net
  527. 'Created: 08/02/2011
  528. 'Changed: 12/06/2011
  529. 'Version: 1.5.4
  530. '------------------
  531. MustInherit Class ThemeContainer154
  532.     Inherits ContainerControl
  533.  
  534. #Region " Initialization "
  535.  
  536.     Protected G As Graphics, B As Bitmap
  537.  
  538.     Sub New()
  539.         SetStyle(DirectCast(139270, ControlStyles), True)
  540.  
  541.         _ImageSize = Size.Empty
  542.         Font = New Font("Verdana", 8S)
  543.  
  544.         MeasureBitmap = New Bitmap(1, 1)
  545.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  546.  
  547.         DrawRadialPath = New GraphicsPath
  548.  
  549.         InvalidateCustimization()
  550.     End Sub
  551.  
  552.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  553.         If DoneCreation Then InitializeMessages()
  554.  
  555.         InvalidateCustimization()
  556.         ColorHook()
  557.  
  558.         If Not _LockWidth = 0 Then Width = _LockWidth
  559.         If Not _LockHeight = 0 Then Height = _LockHeight
  560.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  561.  
  562.         Transparent = _Transparent
  563.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  564.  
  565.         MyBase.OnHandleCreated(e)
  566.     End Sub
  567.  
  568.     Private DoneCreation As Boolean
  569.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  570.         MyBase.OnParentChanged(e)
  571.  
  572.         If Parent Is Nothing Then Return
  573.         _IsParentForm = TypeOf Parent Is Form
  574.  
  575.         If Not _ControlMode Then
  576.             InitializeMessages()
  577.  
  578.             If _IsParentForm Then
  579.                 ParentForm.FormBorderStyle = _BorderStyle
  580.                 ParentForm.TransparencyKey = _TransparencyKey
  581.  
  582.                 If Not DesignMode Then
  583.                     AddHandler ParentForm.Shown, AddressOf FormShown
  584.                 End If
  585.             End If
  586.  
  587.             Parent.BackColor = BackColor
  588.         End If
  589.  
  590.         OnCreation()
  591.         DoneCreation = True
  592.         InvalidateTimer()
  593.     End Sub
  594.  
  595. #End Region
  596. ' Get more free themes at ThemesVB.NET
  597.     Private Sub DoAnimation(ByVal i As Boolean)
  598.         OnAnimation()
  599.         If i Then Invalidate()
  600.     End Sub
  601.  
  602.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  603.         If Width = 0 OrElse Height = 0 Then Return
  604.  
  605.         If _Transparent AndAlso _ControlMode Then
  606.             PaintHook()
  607.             e.Graphics.DrawImage(B, 0, 0)
  608.         Else
  609.             G = e.Graphics
  610.             PaintHook()
  611.         End If
  612.     End Sub
  613.  
  614.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  615.         RemoveAnimationCallback(AddressOf DoAnimation)
  616.         MyBase.OnHandleDestroyed(e)
  617.     End Sub
  618.  
  619.     Private HasShown As Boolean
  620.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  621.         If _ControlMode OrElse HasShown Then Return
  622.  
  623.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  624.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  625.             Dim CB As Rectangle = ParentForm.Bounds
  626.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  627.         End If
  628.  
  629.         HasShown = True
  630.     End Sub
  631.  
  632.  
  633. #Region " Size Handling "
  634.  
  635.     Private Frame As Rectangle
  636.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  637.         If _Movable AndAlso Not _ControlMode Then
  638.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  639.         End If
  640.  
  641.         InvalidateBitmap()
  642.         Invalidate()
  643.  
  644.         MyBase.OnSizeChanged(e)
  645.     End Sub
  646.  
  647.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  648.         If Not _LockWidth = 0 Then width = _LockWidth
  649.         If Not _LockHeight = 0 Then height = _LockHeight
  650.         MyBase.SetBoundsCore(x, y, width, height, specified)
  651.     End Sub
  652.  
  653. #End Region
  654.  
  655. #Region " State Handling "
  656.  
  657.     Protected State As MouseState
  658.     Private Sub SetState(ByVal current As MouseState)
  659.         State = current
  660.         Invalidate()
  661.     End Sub
  662.  
  663.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  664.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  665.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  666.         End If
  667.  
  668.         MyBase.OnMouseMove(e)
  669.     End Sub
  670.  
  671.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  672.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  673.         MyBase.OnEnabledChanged(e)
  674.     End Sub
  675.  
  676.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  677.         SetState(MouseState.Over)
  678.         MyBase.OnMouseEnter(e)
  679.     End Sub
  680.  
  681.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  682.         SetState(MouseState.Over)
  683.         MyBase.OnMouseUp(e)
  684.     End Sub
  685.  
  686.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  687.         SetState(MouseState.None)
  688.  
  689.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  690.             If _Sizable AndAlso Not _ControlMode Then
  691.                 Cursor = Cursors.Default
  692.                 Previous = 0
  693.             End If
  694.         End If
  695.  
  696.         MyBase.OnMouseLeave(e)
  697.     End Sub
  698.  
  699.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  700.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  701.  
  702.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  703.             If _Movable AndAlso Frame.Contains(e.Location) Then
  704.                 Capture = False
  705.                 WM_LMBUTTONDOWN = True
  706.                 DefWndProc(Messages(0))
  707.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  708.                 Capture = False
  709.                 WM_LMBUTTONDOWN = True
  710.                 DefWndProc(Messages(Previous))
  711.             End If
  712.         End If
  713.  
  714.         MyBase.OnMouseDown(e)
  715.     End Sub
  716.  
  717.     Private WM_LMBUTTONDOWN As Boolean
  718.     Protected Overrides Sub WndProc(ByRef m As Message)
  719.         MyBase.WndProc(m)
  720.  
  721.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  722.             WM_LMBUTTONDOWN = False
  723.  
  724.             SetState(MouseState.Over)
  725.             If Not _SmartBounds Then Return
  726.  
  727.             If IsParentMdi Then
  728.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  729.             Else
  730.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  731.             End If
  732.         End If
  733.     End Sub
  734.  
  735.     Private GetIndexPoint As Point
  736.     Private B1, B2, B3, B4 As Boolean
  737.     Private Function GetIndex() As Integer
  738.         GetIndexPoint = PointToClient(MousePosition)
  739.         B1 = GetIndexPoint.X < 7
  740.         B2 = GetIndexPoint.X > Width - 7
  741.         B3 = GetIndexPoint.Y < 7
  742.         B4 = GetIndexPoint.Y > Height - 7
  743.  
  744.         If B1 AndAlso B3 Then Return 4
  745.         If B1 AndAlso B4 Then Return 7
  746.         If B2 AndAlso B3 Then Return 5
  747.         If B2 AndAlso B4 Then Return 8
  748.         If B1 Then Return 1
  749.         If B2 Then Return 2
  750.         If B3 Then Return 3
  751.         If B4 Then Return 6
  752.         Return 0
  753.     End Function
  754.  
  755.     Private Current, Previous As Integer
  756.     Private Sub InvalidateMouse()
  757.         Current = GetIndex()
  758.         If Current = Previous Then Return
  759.  
  760.         Previous = Current
  761.         Select Case Previous
  762.             Case 0
  763.                 Cursor = Cursors.Default
  764.             Case 1, 2
  765.                 Cursor = Cursors.SizeWE
  766.             Case 3, 6
  767.                 Cursor = Cursors.SizeNS
  768.             Case 4, 8
  769.                 Cursor = Cursors.SizeNWSE
  770.             Case 5, 7
  771.                 Cursor = Cursors.SizeNESW
  772.         End Select
  773.     End Sub
  774.  
  775.     Private Messages(8) As Message
  776.     Private Sub InitializeMessages()
  777.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  778.         For I As Integer = 1 To 8
  779.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  780.         Next
  781.     End Sub
  782.  
  783.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  784.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  785.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  786.  
  787.         Dim X As Integer = Parent.Location.X
  788.         Dim Y As Integer = Parent.Location.Y
  789.  
  790.         If X < bounds.X Then X = bounds.X
  791.         If Y < bounds.Y Then Y = bounds.Y
  792.  
  793.         Dim Width As Integer = bounds.X + bounds.Width
  794.         Dim Height As Integer = bounds.Y + bounds.Height
  795.  
  796.         If X + Parent.Width > Width Then X = Width - Parent.Width
  797.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  798.  
  799.         Parent.Location = New Point(X, Y)
  800.     End Sub
  801.  
  802. #End Region
  803.  
  804.  
  805. #Region " Base Properties "
  806.  
  807.     Overrides Property Dock() As DockStyle
  808.         Get
  809.             Return MyBase.Dock
  810.         End Get
  811.         Set(ByVal value As DockStyle)
  812.             If Not _ControlMode Then Return
  813.             MyBase.Dock = value
  814.         End Set
  815.     End Property
  816.  
  817.     Private _BackColor As Boolean
  818.     <Category("Misc")> _
  819.     Overrides Property BackColor() As Color
  820.         Get
  821.             Return MyBase.BackColor
  822.         End Get
  823.         Set(ByVal value As Color)
  824.             If value = MyBase.BackColor Then Return
  825.  
  826.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  827.                 _BackColor = True
  828.                 Return
  829.             End If
  830.  
  831.             MyBase.BackColor = value
  832.             If Parent IsNot Nothing Then
  833.                 If Not _ControlMode Then Parent.BackColor = value
  834.                 ColorHook()
  835.             End If
  836.         End Set
  837.     End Property
  838. ' Get more free themes at ThemesVB.NET
  839.     Overrides Property MinimumSize() As Size
  840.         Get
  841.             Return MyBase.MinimumSize
  842.         End Get
  843.         Set(ByVal value As Size)
  844.             MyBase.MinimumSize = value
  845.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  846.         End Set
  847.     End Property
  848.  
  849.     Overrides Property MaximumSize() As Size
  850.         Get
  851.             Return MyBase.MaximumSize
  852.         End Get
  853.         Set(ByVal value As Size)
  854.             MyBase.MaximumSize = value
  855.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  856.         End Set
  857.     End Property
  858.  
  859.     Overrides Property Text() As String
  860.         Get
  861.             Return MyBase.Text
  862.         End Get
  863.         Set(ByVal value As String)
  864.             MyBase.Text = value
  865.             Invalidate()
  866.         End Set
  867.     End Property
  868.  
  869.     Overrides Property Font() As Font
  870.         Get
  871.             Return MyBase.Font
  872.         End Get
  873.         Set(ByVal value As Font)
  874.             MyBase.Font = value
  875.             Invalidate()
  876.         End Set
  877.     End Property
  878.  
  879.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  880.     Overrides Property ForeColor() As Color
  881.         Get
  882.             Return Color.Empty
  883.         End Get
  884.         Set(ByVal value As Color)
  885.         End Set
  886.     End Property
  887.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  888.     Overrides Property BackgroundImage() As Image
  889.         Get
  890.             Return Nothing
  891.         End Get
  892.         Set(ByVal value As Image)
  893.         End Set
  894.     End Property
  895.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  896.     Overrides Property BackgroundImageLayout() As ImageLayout
  897.         Get
  898.             Return ImageLayout.None
  899.         End Get
  900.         Set(ByVal value As ImageLayout)
  901.         End Set
  902.     End Property
  903.  
  904. #End Region
  905.  
  906. #Region " Public Properties "
  907.  
  908.     Private _SmartBounds As Boolean = True
  909.     Property SmartBounds() As Boolean
  910.         Get
  911.             Return _SmartBounds
  912.         End Get
  913.         Set(ByVal value As Boolean)
  914.             _SmartBounds = value
  915.         End Set
  916.     End Property
  917.  
  918.     Private _Movable As Boolean = True
  919.     Property Movable() As Boolean
  920.         Get
  921.             Return _Movable
  922.         End Get
  923.         Set(ByVal value As Boolean)
  924.             _Movable = value
  925.         End Set
  926.     End Property
  927.  
  928.     Private _Sizable As Boolean = True
  929.     Property Sizable() As Boolean
  930.         Get
  931.             Return _Sizable
  932.         End Get
  933.         Set(ByVal value As Boolean)
  934.             _Sizable = value
  935.         End Set
  936.     End Property
  937.  
  938.     Private _TransparencyKey As Color
  939.     Property TransparencyKey() As Color
  940.         Get
  941.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  942.         End Get
  943.         Set(ByVal value As Color)
  944.             If value = _TransparencyKey Then Return
  945.             _TransparencyKey = value
  946.  
  947.             If _IsParentForm AndAlso Not _ControlMode Then
  948.                 ParentForm.TransparencyKey = value
  949.                 ColorHook()
  950.             End If
  951.         End Set
  952.     End Property
  953.  
  954.     Private _BorderStyle As FormBorderStyle
  955.     Property BorderStyle() As FormBorderStyle
  956.         Get
  957.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  958.         End Get
  959.         Set(ByVal value As FormBorderStyle)
  960.             _BorderStyle = value
  961.  
  962.             If _IsParentForm AndAlso Not _ControlMode Then
  963.                 ParentForm.FormBorderStyle = value
  964.  
  965.                 If Not value = FormBorderStyle.None Then
  966.                     Movable = False
  967.                     Sizable = False
  968.                 End If
  969.             End If
  970.         End Set
  971.     End Property
  972.  
  973.     Private _StartPosition As FormStartPosition
  974.     Property StartPosition() As FormStartPosition
  975.         Get
  976.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  977.         End Get
  978.         Set(ByVal value As FormStartPosition)
  979.             _StartPosition = value
  980.  
  981.             If _IsParentForm AndAlso Not _ControlMode Then
  982.                 ParentForm.StartPosition = value
  983.             End If
  984.         End Set
  985.     End Property
  986.  
  987.     Private _NoRounding As Boolean
  988.     Property NoRounding() As Boolean
  989.         Get
  990.             Return _NoRounding
  991.         End Get
  992.         Set(ByVal v As Boolean)
  993.             _NoRounding = v
  994.             Invalidate()
  995.         End Set
  996.     End Property
  997.  
  998.     Private _Image As Image
  999.     Property Image() As Image
  1000.         Get
  1001.             Return _Image
  1002.         End Get
  1003.         Set(ByVal value As Image)
  1004.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  1005.  
  1006.             _Image = value
  1007.             Invalidate()
  1008.         End Set
  1009.     End Property
  1010.  
  1011.     Private Items As New Dictionary(Of String, Color)
  1012.     Property Colors() As Bloom()
  1013.         Get
  1014.             Dim T As New List(Of Bloom)
  1015.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1016.  
  1017.             While E.MoveNext
  1018.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1019.             End While
  1020.  
  1021.             Return T.ToArray
  1022.         End Get
  1023.         Set(ByVal value As Bloom())
  1024.             For Each B As Bloom In value
  1025.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1026.             Next
  1027.  
  1028.             InvalidateCustimization()
  1029.             ColorHook()
  1030.             Invalidate()
  1031.         End Set
  1032.     End Property
  1033.  
  1034.     Private _Customization As String
  1035.     Property Customization() As String
  1036.         Get
  1037.             Return _Customization
  1038.         End Get
  1039.         Set(ByVal value As String)
  1040.             If value = _Customization Then Return
  1041.  
  1042.             Dim Data As Byte()
  1043.             Dim Items As Bloom() = Colors
  1044.  
  1045.             Try
  1046.                 Data = Convert.FromBase64String(value)
  1047.                 For I As Integer = 0 To Items.Length - 1
  1048.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1049.                 Next
  1050.             Catch
  1051.                 Return
  1052.             End Try
  1053.  
  1054.             _Customization = value
  1055.  
  1056.             Colors = Items
  1057.             ColorHook()
  1058.             Invalidate()
  1059.         End Set
  1060.     End Property
  1061.  
  1062.     Private _Transparent As Boolean
  1063.     Property Transparent() As Boolean
  1064.         Get
  1065.             Return _Transparent
  1066.         End Get
  1067.         Set(ByVal value As Boolean)
  1068.             _Transparent = value
  1069.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  1070.  
  1071.             If Not value AndAlso Not BackColor.A = 255 Then
  1072.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1073.             End If
  1074.  
  1075.             SetStyle(ControlStyles.Opaque, Not value)
  1076.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1077.  
  1078.             InvalidateBitmap()
  1079.             Invalidate()
  1080.         End Set
  1081.     End Property
  1082.  
  1083. #End Region
  1084.  
  1085. #Region " Private Properties "
  1086.  
  1087.     Private _ImageSize As Size
  1088.     Protected ReadOnly Property ImageSize() As Size
  1089.         Get
  1090.             Return _ImageSize
  1091.         End Get
  1092.     End Property
  1093.  
  1094.     Private _IsParentForm As Boolean
  1095.     Protected ReadOnly Property IsParentForm() As Boolean
  1096.         Get
  1097.             Return _IsParentForm
  1098.         End Get
  1099.     End Property
  1100. ' Get more free themes at ThemesVB.NET
  1101.     Protected ReadOnly Property IsParentMdi() As Boolean
  1102.         Get
  1103.             If Parent Is Nothing Then Return False
  1104.             Return Parent.Parent IsNot Nothing
  1105.         End Get
  1106.     End Property
  1107.  
  1108.     Private _LockWidth As Integer
  1109.     Protected Property LockWidth() As Integer
  1110.         Get
  1111.             Return _LockWidth
  1112.         End Get
  1113.         Set(ByVal value As Integer)
  1114.             _LockWidth = value
  1115.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1116.         End Set
  1117.     End Property
  1118.  
  1119.     Private _LockHeight As Integer
  1120.     Protected Property LockHeight() As Integer
  1121.         Get
  1122.             Return _LockHeight
  1123.         End Get
  1124.         Set(ByVal value As Integer)
  1125.             _LockHeight = value
  1126.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1127.         End Set
  1128.     End Property
  1129.  
  1130.     Private _Header As Integer = 24
  1131.     Protected Property Header() As Integer
  1132.         Get
  1133.             Return _Header
  1134.         End Get
  1135.         Set(ByVal v As Integer)
  1136.             _Header = v
  1137.  
  1138.             If Not _ControlMode Then
  1139.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  1140.                 Invalidate()
  1141.             End If
  1142.         End Set
  1143.     End Property
  1144.  
  1145.     Private _ControlMode As Boolean
  1146.     Protected Property ControlMode() As Boolean
  1147.         Get
  1148.             Return _ControlMode
  1149.         End Get
  1150.         Set(ByVal v As Boolean)
  1151.             _ControlMode = v
  1152.  
  1153.             Transparent = _Transparent
  1154.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1155.  
  1156.             InvalidateBitmap()
  1157.             Invalidate()
  1158.         End Set
  1159.     End Property
  1160.  
  1161.     Private _IsAnimated As Boolean
  1162.     Protected Property IsAnimated() As Boolean
  1163.         Get
  1164.             Return _IsAnimated
  1165.         End Get
  1166.         Set(ByVal value As Boolean)
  1167.             _IsAnimated = value
  1168.             InvalidateTimer()
  1169.         End Set
  1170.     End Property
  1171.  
  1172. #End Region
  1173.  
  1174.  
  1175. #Region " Property Helpers "
  1176.  
  1177.     Protected Function GetPen(ByVal name As String) As Pen
  1178.         Return New Pen(Items(name))
  1179.     End Function
  1180.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1181.         Return New Pen(Items(name), width)
  1182.     End Function
  1183.  
  1184.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1185.         Return New SolidBrush(Items(name))
  1186.     End Function
  1187.  
  1188.     Protected Function GetColor(ByVal name As String) As Color
  1189.         Return Items(name)
  1190.     End Function
  1191.  
  1192.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1193.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1194.     End Sub
  1195.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1196.         SetColor(name, Color.FromArgb(r, g, b))
  1197.     End Sub
  1198.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1199.         SetColor(name, Color.FromArgb(a, r, g, b))
  1200.     End Sub
  1201.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1202.         SetColor(name, Color.FromArgb(a, value))
  1203.     End Sub
  1204.  
  1205.     Private Sub InvalidateBitmap()
  1206.         If _Transparent AndAlso _ControlMode Then
  1207.             If Width = 0 OrElse Height = 0 Then Return
  1208.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1209.             G = Graphics.FromImage(B)
  1210.         Else
  1211.             G = Nothing
  1212.             B = Nothing
  1213.         End If
  1214.     End Sub
  1215.  
  1216.     Private Sub InvalidateCustimization()
  1217.         Dim M As New MemoryStream(Items.Count * 4)
  1218.  
  1219.         For Each B As Bloom In Colors
  1220.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1221.         Next
  1222.  
  1223.         M.Close()
  1224.         _Customization = Convert.ToBase64String(M.ToArray)
  1225.     End Sub
  1226.  
  1227.     Private Sub InvalidateTimer()
  1228.         If DesignMode OrElse Not DoneCreation Then Return
  1229.  
  1230.         If _IsAnimated Then
  1231.             AddAnimationCallback(AddressOf DoAnimation)
  1232.         Else
  1233.             RemoveAnimationCallback(AddressOf DoAnimation)
  1234.         End If
  1235.     End Sub
  1236.  
  1237. #End Region
  1238.  
  1239.  
  1240. #Region " User Hooks "
  1241.  
  1242.     Protected MustOverride Sub ColorHook()
  1243.     Protected MustOverride Sub PaintHook()
  1244.  
  1245.     Protected Overridable Sub OnCreation()
  1246.     End Sub
  1247.  
  1248.     Protected Overridable Sub OnAnimation()
  1249.     End Sub
  1250.  
  1251. #End Region
  1252.  
  1253.  
  1254. #Region " Offset "
  1255. ' Get more free themes at ThemesVB.NET
  1256.     Private OffsetReturnRectangle As Rectangle
  1257.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1258.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1259.         Return OffsetReturnRectangle
  1260.     End Function
  1261.  
  1262.     Private OffsetReturnSize As Size
  1263.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1264.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1265.         Return OffsetReturnSize
  1266.     End Function
  1267.  
  1268.     Private OffsetReturnPoint As Point
  1269.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1270.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1271.         Return OffsetReturnPoint
  1272.     End Function
  1273.  
  1274. #End Region
  1275.  
  1276. #Region " Center "
  1277.  
  1278.     Private CenterReturn As Point
  1279.  
  1280.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1281.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1282.         Return CenterReturn
  1283.     End Function
  1284.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1285.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1286.         Return CenterReturn
  1287.     End Function
  1288.  
  1289.     Protected Function Center(ByVal child As Rectangle) As Point
  1290.         Return Center(Width, Height, child.Width, child.Height)
  1291.     End Function
  1292.     Protected Function Center(ByVal child As Size) As Point
  1293.         Return Center(Width, Height, child.Width, child.Height)
  1294.     End Function
  1295.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1296.         Return Center(Width, Height, childWidth, childHeight)
  1297.     End Function
  1298.  
  1299.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1300.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1301.     End Function
  1302.  
  1303.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1304.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1305.         Return CenterReturn
  1306.     End Function
  1307.  
  1308. #End Region
  1309.  
  1310. #Region " Measure "
  1311.  
  1312.     Private MeasureBitmap As Bitmap
  1313.     Private MeasureGraphics As Graphics
  1314.  
  1315.     Protected Function Measure() As Size
  1316.         SyncLock MeasureGraphics
  1317.             Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1318.         End SyncLock
  1319.     End Function
  1320.     Protected Function Measure(ByVal text As String) As Size
  1321.         SyncLock MeasureGraphics
  1322.             Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1323.         End SyncLock
  1324.     End Function
  1325.  
  1326. #End Region
  1327.  
  1328.  
  1329. #Region " DrawPixel "
  1330.  
  1331.     Private DrawPixelBrush As SolidBrush
  1332.  
  1333.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1334.         If _Transparent Then
  1335.             B.SetPixel(x, y, c1)
  1336.         Else
  1337.             DrawPixelBrush = New SolidBrush(c1)
  1338.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1339.         End If
  1340.     End Sub
  1341.  
  1342. #End Region
  1343.  
  1344. #Region " DrawCorners "
  1345.  
  1346.     Private DrawCornersBrush As SolidBrush
  1347.  
  1348.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1349.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1350.     End Sub
  1351.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1352.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1353.     End Sub
  1354.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1355.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1356.     End Sub
  1357.  
  1358.     Protected Sub DrawCorners(ByVal c1 As Color)
  1359.         DrawCorners(c1, 0, 0, Width, Height)
  1360.     End Sub
  1361.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1362.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1363.     End Sub
  1364.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1365.         If _NoRounding Then Return
  1366.  
  1367.         If _Transparent Then
  1368.             B.SetPixel(x, y, c1)
  1369.             B.SetPixel(x + (width - 1), y, c1)
  1370.             B.SetPixel(x, y + (height - 1), c1)
  1371.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1372.         Else
  1373.             DrawCornersBrush = New SolidBrush(c1)
  1374.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1375.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1376.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1377.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1378.         End If
  1379.     End Sub
  1380.  
  1381. #End Region
  1382.  
  1383. #Region " DrawBorders "
  1384.  
  1385.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1386.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1387.     End Sub
  1388.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1389.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1390.     End Sub
  1391.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1392.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1393.     End Sub
  1394.  
  1395.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1396.         DrawBorders(p1, 0, 0, Width, Height)
  1397.     End Sub
  1398.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1399.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1400.     End Sub
  1401.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1402.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1403.     End Sub
  1404.  
  1405. #End Region
  1406.  
  1407. #Region " DrawText "
  1408.  
  1409.     Private DrawTextPoint As Point
  1410.     Private DrawTextSize As Size
  1411.  
  1412.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1413.         DrawText(b1, Text, a, x, y)
  1414.     End Sub
  1415.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1416.         If text.Length = 0 Then Return
  1417.  
  1418.         DrawTextSize = Measure(text)
  1419.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  1420.  
  1421.         Select Case a
  1422.             Case HorizontalAlignment.Left
  1423.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1424.             Case HorizontalAlignment.Center
  1425.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1426.             Case HorizontalAlignment.Right
  1427.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1428.         End Select
  1429.     End Sub
  1430.  
  1431.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1432.         If Text.Length = 0 Then Return
  1433.         G.DrawString(Text, Font, b1, p1)
  1434.     End Sub
  1435.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1436.         If Text.Length = 0 Then Return
  1437.         G.DrawString(Text, Font, b1, x, y)
  1438.     End Sub
  1439.  
  1440. #End Region
  1441.  
  1442. #Region " DrawImage "
  1443.  
  1444.     Private DrawImagePoint As Point
  1445.  
  1446.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1447.         DrawImage(_Image, a, x, y)
  1448.     End Sub
  1449.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1450.         If image Is Nothing Then Return
  1451.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  1452.  
  1453.         Select Case a
  1454.             Case HorizontalAlignment.Left
  1455.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1456.             Case HorizontalAlignment.Center
  1457.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1458.             Case HorizontalAlignment.Right
  1459.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1460.         End Select
  1461.     End Sub
  1462.  
  1463.     Protected Sub DrawImage(ByVal p1 As Point)
  1464.         DrawImage(_Image, p1.X, p1.Y)
  1465.     End Sub
  1466.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1467.         DrawImage(_Image, x, y)
  1468.     End Sub
  1469.  
  1470.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1471.         DrawImage(image, p1.X, p1.Y)
  1472.     End Sub
  1473.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1474.         If image Is Nothing Then Return
  1475.         G.DrawImage(image, x, y, image.Width, image.Height)
  1476.     End Sub
  1477.  
  1478. #End Region
  1479.  
  1480. #Region " DrawGradient "
  1481.  
  1482.     Private DrawGradientBrush As LinearGradientBrush
  1483.     Private DrawGradientRectangle As Rectangle
  1484.  
  1485.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1486.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1487.         DrawGradient(blend, DrawGradientRectangle)
  1488.     End Sub
  1489.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1490.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1491.         DrawGradient(blend, DrawGradientRectangle, angle)
  1492.     End Sub
  1493.  
  1494.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1495.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1496.         DrawGradientBrush.InterpolationColors = blend
  1497.         G.FillRectangle(DrawGradientBrush, r)
  1498.     End Sub
  1499.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1500.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1501.         DrawGradientBrush.InterpolationColors = blend
  1502.         G.FillRectangle(DrawGradientBrush, r)
  1503.     End Sub
  1504.  
  1505.  
  1506.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1507.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1508.         DrawGradient(c1, c2, DrawGradientRectangle)
  1509.     End Sub
  1510.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1511.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1512.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1513.     End Sub
  1514.  
  1515.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1516.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1517.         G.FillRectangle(DrawGradientBrush, r)
  1518.     End Sub
  1519.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1520.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1521.         G.FillRectangle(DrawGradientBrush, r)
  1522.     End Sub
  1523.  
  1524. #End Region
  1525.  
  1526. #Region " DrawRadial "
  1527.  
  1528.     Private DrawRadialPath As GraphicsPath
  1529.     Private DrawRadialBrush1 As PathGradientBrush
  1530.     Private DrawRadialBrush2 As LinearGradientBrush
  1531.     Private DrawRadialRectangle As Rectangle
  1532.  
  1533.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1534.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1535.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1536.     End Sub
  1537.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  1538.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1539.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1540.     End Sub
  1541.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  1542.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1543.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1544.     End Sub
  1545.  
  1546.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1547.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1548.     End Sub
  1549.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1550.         DrawRadial(blend, r, center.X, center.Y)
  1551.     End Sub
  1552.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1553.         DrawRadialPath.Reset()
  1554.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1555.  
  1556.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1557.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1558.         DrawRadialBrush1.InterpolationColors = blend
  1559.  
  1560.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1561.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1562.         Else
  1563.             G.FillEllipse(DrawRadialBrush1, r)
  1564.         End If
  1565.     End Sub
  1566.  
  1567.  
  1568.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1569.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1570.         DrawRadial(c1, c2, DrawGradientRectangle)
  1571.     End Sub
  1572.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  1573.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1574.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  1575.     End Sub
  1576.  
  1577.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1578.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1579.         G.FillRectangle(DrawGradientBrush, r)
  1580.     End Sub
  1581.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1582.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1583.         G.FillEllipse(DrawGradientBrush, r)
  1584.     End Sub
  1585.  
  1586. #End Region
  1587.  
  1588. #Region " CreateRound "
  1589.  
  1590.     Private CreateRoundPath As GraphicsPath
  1591.     Private CreateRoundRectangle As Rectangle
  1592.  
  1593.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1594.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1595.         Return CreateRound(CreateRoundRectangle, slope)
  1596.     End Function
  1597.  
  1598.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1599.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1600.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1601.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1602.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1603.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1604.         CreateRoundPath.CloseFigure()
  1605.         Return CreateRoundPath
  1606.     End Function
  1607.  
  1608. #End Region
  1609.  
  1610. End Class
  1611.  
  1612. MustInherit Class ThemeControl154
  1613.     Inherits Control
  1614.  
  1615.  
  1616. #Region " Initialization "
  1617.  
  1618.     Protected G As Graphics, B As Bitmap
  1619.  
  1620.     Sub New()
  1621.         SetStyle(DirectCast(139270, ControlStyles), True)
  1622.  
  1623.         _ImageSize = Size.Empty
  1624.         Font = New Font("Verdana", 8S)
  1625.  
  1626.         MeasureBitmap = New Bitmap(1, 1)
  1627.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1628.  
  1629.         DrawRadialPath = New GraphicsPath
  1630.  
  1631.         InvalidateCustimization() 'Remove?
  1632.     End Sub
  1633.  
  1634.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1635.         InvalidateCustimization()
  1636.         ColorHook()
  1637.  
  1638.         If Not _LockWidth = 0 Then Width = _LockWidth
  1639.         If Not _LockHeight = 0 Then Height = _LockHeight
  1640.  
  1641.         Transparent = _Transparent
  1642.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1643.  
  1644.         MyBase.OnHandleCreated(e)
  1645.     End Sub
  1646.  
  1647.     Private DoneCreation As Boolean
  1648.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1649.         If Parent IsNot Nothing Then
  1650.             OnCreation()
  1651.             DoneCreation = True
  1652.             InvalidateTimer()
  1653.         End If
  1654.  
  1655.         MyBase.OnParentChanged(e)
  1656.     End Sub
  1657.  
  1658. #End Region
  1659.  
  1660.     Private Sub DoAnimation(ByVal i As Boolean)
  1661.         OnAnimation()
  1662.         If i Then Invalidate()
  1663.     End Sub
  1664.  
  1665.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1666.         If Width = 0 OrElse Height = 0 Then Return
  1667.  
  1668.         If _Transparent Then
  1669.             PaintHook()
  1670.             e.Graphics.DrawImage(B, 0, 0)
  1671.         Else
  1672.             G = e.Graphics
  1673.             PaintHook()
  1674.         End If
  1675.     End Sub
  1676.  
  1677.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  1678.         RemoveAnimationCallback(AddressOf DoAnimation)
  1679.         MyBase.OnHandleDestroyed(e)
  1680.     End Sub
  1681.  
  1682. #Region " Size Handling "
  1683.  
  1684.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1685.         If _Transparent Then
  1686.             InvalidateBitmap()
  1687.         End If
  1688.  
  1689.         Invalidate()
  1690.         MyBase.OnSizeChanged(e)
  1691.     End Sub
  1692.  
  1693.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1694.         If Not _LockWidth = 0 Then width = _LockWidth
  1695.         If Not _LockHeight = 0 Then height = _LockHeight
  1696.         MyBase.SetBoundsCore(x, y, width, height, specified)
  1697.     End Sub
  1698.  
  1699. #End Region
  1700.  
  1701. #Region " State Handling "
  1702.  
  1703.     Private InPosition As Boolean
  1704.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1705.         InPosition = True
  1706.         SetState(MouseState.Over)
  1707.         MyBase.OnMouseEnter(e)
  1708.     End Sub
  1709.  
  1710.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1711.         If InPosition Then SetState(MouseState.Over)
  1712.         MyBase.OnMouseUp(e)
  1713.     End Sub
  1714.  
  1715.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1716.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1717.         MyBase.OnMouseDown(e)
  1718.     End Sub
  1719.  
  1720.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1721.         InPosition = False
  1722.         SetState(MouseState.None)
  1723.         MyBase.OnMouseLeave(e)
  1724.     End Sub
  1725.  
  1726.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1727.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1728.         MyBase.OnEnabledChanged(e)
  1729.     End Sub
  1730.  
  1731.     Protected State As MouseState
  1732.     Private Sub SetState(ByVal current As MouseState)
  1733.         State = current
  1734.         Invalidate()
  1735.     End Sub
  1736.  
  1737. #End Region
  1738.  
  1739.  
  1740. #Region " Base Properties "
  1741.  
  1742.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1743.     Overrides Property ForeColor() As Color
  1744.         Get
  1745.             Return Color.Empty
  1746.         End Get
  1747.         Set(ByVal value As Color)
  1748.         End Set
  1749.     End Property
  1750.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1751.     Overrides Property BackgroundImage() As Image
  1752.         Get
  1753.             Return Nothing
  1754.         End Get
  1755.         Set(ByVal value As Image)
  1756.         End Set
  1757.     End Property
  1758.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1759.     Overrides Property BackgroundImageLayout() As ImageLayout
  1760.         Get
  1761.             Return ImageLayout.None
  1762.         End Get
  1763.         Set(ByVal value As ImageLayout)
  1764.         End Set
  1765.     End Property
  1766.  
  1767.     Overrides Property Text() As String
  1768.         Get
  1769.             Return MyBase.Text
  1770.         End Get
  1771.         Set(ByVal value As String)
  1772.             MyBase.Text = value
  1773.             Invalidate()
  1774.         End Set
  1775.     End Property
  1776.     Overrides Property Font() As Font
  1777.         Get
  1778.             Return MyBase.Font
  1779.         End Get
  1780.         Set(ByVal value As Font)
  1781.             MyBase.Font = value
  1782.             Invalidate()
  1783.         End Set
  1784.     End Property
  1785.  
  1786.     Private _BackColor As Boolean
  1787.     <Category("Misc")> _
  1788.     Overrides Property BackColor() As Color
  1789.         Get
  1790.             Return MyBase.BackColor
  1791.         End Get
  1792.         Set(ByVal value As Color)
  1793.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1794.                 _BackColor = True
  1795.                 Return
  1796.             End If
  1797.  
  1798.             MyBase.BackColor = value
  1799.             If Parent IsNot Nothing Then ColorHook()
  1800.         End Set
  1801.     End Property
  1802.  
  1803. #End Region
  1804.  
  1805. #Region " Public Properties "
  1806.  
  1807.     Private _NoRounding As Boolean
  1808.     Property NoRounding() As Boolean
  1809.         Get
  1810.             Return _NoRounding
  1811.         End Get
  1812.         Set(ByVal v As Boolean)
  1813.             _NoRounding = v
  1814.             Invalidate()
  1815.         End Set
  1816.     End Property
  1817.  
  1818.     Private _Image As Image
  1819.     Property Image() As Image
  1820.         Get
  1821.             Return _Image
  1822.         End Get
  1823.         Set(ByVal value As Image)
  1824.             If value Is Nothing Then
  1825.                 _ImageSize = Size.Empty
  1826.             Else
  1827.                 _ImageSize = value.Size
  1828.             End If
  1829.  
  1830.             _Image = value
  1831.             Invalidate()
  1832.         End Set
  1833.     End Property
  1834. ' Get more free themes at ThemesVB.NET
  1835.     Private _Transparent As Boolean
  1836.     Property Transparent() As Boolean
  1837.         Get
  1838.             Return _Transparent
  1839.         End Get
  1840.         Set(ByVal value As Boolean)
  1841.             _Transparent = value
  1842.             If Not IsHandleCreated Then Return
  1843.  
  1844.             If Not value AndAlso Not BackColor.A = 255 Then
  1845.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1846.             End If
  1847.  
  1848.             SetStyle(ControlStyles.Opaque, Not value)
  1849.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1850.  
  1851.             If value Then InvalidateBitmap() Else B = Nothing
  1852.             Invalidate()
  1853.         End Set
  1854.     End Property
  1855.  
  1856.     Private Items As New Dictionary(Of String, Color)
  1857.     Property Colors() As Bloom()
  1858.         Get
  1859.             Dim T As New List(Of Bloom)
  1860.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1861.  
  1862.             While E.MoveNext
  1863.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1864.             End While
  1865.  
  1866.             Return T.ToArray
  1867.         End Get
  1868.         Set(ByVal value As Bloom())
  1869.             For Each B As Bloom In value
  1870.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1871.             Next
  1872.  
  1873.             InvalidateCustimization()
  1874.             ColorHook()
  1875.             Invalidate()
  1876.         End Set
  1877.     End Property
  1878.  
  1879.     Private _Customization As String
  1880.     Property Customization() As String
  1881.         Get
  1882.             Return _Customization
  1883.         End Get
  1884.         Set(ByVal value As String)
  1885.             If value = _Customization Then Return
  1886.  
  1887.             Dim Data As Byte()
  1888.             Dim Items As Bloom() = Colors
  1889.  
  1890.             Try
  1891.                 Data = Convert.FromBase64String(value)
  1892.                 For I As Integer = 0 To Items.Length - 1
  1893.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1894.                 Next
  1895.             Catch
  1896.                 Return
  1897.             End Try
  1898.  
  1899.             _Customization = value
  1900.  
  1901.             Colors = Items
  1902.             ColorHook()
  1903.             Invalidate()
  1904.         End Set
  1905.     End Property
  1906.  
  1907. #End Region
  1908.  
  1909. #Region " Private Properties "
  1910.  
  1911.     Private _ImageSize As Size
  1912.     Protected ReadOnly Property ImageSize() As Size
  1913.         Get
  1914.             Return _ImageSize
  1915.         End Get
  1916.     End Property
  1917.  
  1918.     Private _LockWidth As Integer
  1919.     Protected Property LockWidth() As Integer
  1920.         Get
  1921.             Return _LockWidth
  1922.         End Get
  1923.         Set(ByVal value As Integer)
  1924.             _LockWidth = value
  1925.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1926.         End Set
  1927.     End Property
  1928.  
  1929.     Private _LockHeight As Integer
  1930.     Protected Property LockHeight() As Integer
  1931.         Get
  1932.             Return _LockHeight
  1933.         End Get
  1934.         Set(ByVal value As Integer)
  1935.             _LockHeight = value
  1936.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1937.         End Set
  1938.     End Property
  1939.  
  1940.     Private _IsAnimated As Boolean
  1941.     Protected Property IsAnimated() As Boolean
  1942.         Get
  1943.             Return _IsAnimated
  1944.         End Get
  1945.         Set(ByVal value As Boolean)
  1946.             _IsAnimated = value
  1947.             InvalidateTimer()
  1948.         End Set
  1949.     End Property
  1950.  
  1951. #End Region
  1952.  
  1953.  
  1954. #Region " Property Helpers "
  1955.  
  1956.     Protected Function GetPen(ByVal name As String) As Pen
  1957.         Return New Pen(Items(name))
  1958.     End Function
  1959.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1960.         Return New Pen(Items(name), width)
  1961.     End Function
  1962.  
  1963.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1964.         Return New SolidBrush(Items(name))
  1965.     End Function
  1966.  
  1967.     Protected Function GetColor(ByVal name As String) As Color
  1968.         Return Items(name)
  1969.     End Function
  1970.  
  1971.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1972.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1973.     End Sub
  1974.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1975.         SetColor(name, Color.FromArgb(r, g, b))
  1976.     End Sub
  1977.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1978.         SetColor(name, Color.FromArgb(a, r, g, b))
  1979.     End Sub
  1980.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1981.         SetColor(name, Color.FromArgb(a, value))
  1982.     End Sub
  1983.  
  1984.     Private Sub InvalidateBitmap()
  1985.         If Width = 0 OrElse Height = 0 Then Return
  1986.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1987.         G = Graphics.FromImage(B)
  1988.     End Sub
  1989.  
  1990.     Private Sub InvalidateCustimization()
  1991.         Dim M As New MemoryStream(Items.Count * 4)
  1992.  
  1993.         For Each B As Bloom In Colors
  1994.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1995.         Next
  1996.  
  1997.         M.Close()
  1998.         _Customization = Convert.ToBase64String(M.ToArray)
  1999.     End Sub
  2000.  
  2001.     Private Sub InvalidateTimer()
  2002.         If DesignMode OrElse Not DoneCreation Then Return
  2003.  
  2004.         If _IsAnimated Then
  2005.             AddAnimationCallback(AddressOf DoAnimation)
  2006.         Else
  2007.             RemoveAnimationCallback(AddressOf DoAnimation)
  2008.         End If
  2009.     End Sub
  2010. #End Region
  2011.  
  2012.  
  2013. #Region " User Hooks "
  2014.  
  2015.     Protected MustOverride Sub ColorHook()
  2016.     Protected MustOverride Sub PaintHook()
  2017.  
  2018.     Protected Overridable Sub OnCreation()
  2019.     End Sub
  2020.  
  2021.     Protected Overridable Sub OnAnimation()
  2022.     End Sub
  2023.  
  2024. #End Region
  2025.  
  2026.  
  2027. #Region " Offset "
  2028.  
  2029.     Private OffsetReturnRectangle As Rectangle
  2030.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  2031.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  2032.         Return OffsetReturnRectangle
  2033.     End Function
  2034.  
  2035.     Private OffsetReturnSize As Size
  2036.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  2037.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  2038.         Return OffsetReturnSize
  2039.     End Function
  2040.  
  2041.     Private OffsetReturnPoint As Point
  2042.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  2043.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  2044.         Return OffsetReturnPoint
  2045.     End Function
  2046.  
  2047. #End Region
  2048.  
  2049. #Region " Center "
  2050.  
  2051.     Private CenterReturn As Point
  2052.  
  2053.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  2054.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  2055.         Return CenterReturn
  2056.     End Function
  2057.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  2058.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  2059.         Return CenterReturn
  2060.     End Function
  2061.  
  2062.     Protected Function Center(ByVal child As Rectangle) As Point
  2063.         Return Center(Width, Height, child.Width, child.Height)
  2064.     End Function
  2065.     Protected Function Center(ByVal child As Size) As Point
  2066.         Return Center(Width, Height, child.Width, child.Height)
  2067.     End Function
  2068.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  2069.         Return Center(Width, Height, childWidth, childHeight)
  2070.     End Function
  2071.  
  2072.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  2073.         Return Center(p.Width, p.Height, c.Width, c.Height)
  2074.     End Function
  2075.  
  2076.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  2077.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  2078.         Return CenterReturn
  2079.     End Function
  2080.  
  2081. #End Region
  2082.  
  2083. #Region " Measure "
  2084.  
  2085.     Private MeasureBitmap As Bitmap
  2086.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  2087.  
  2088.     Protected Function Measure() As Size
  2089.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  2090.     End Function
  2091.     Protected Function Measure(ByVal text As String) As Size
  2092.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  2093.     End Function
  2094.  
  2095. #End Region
  2096.  
  2097.  
  2098. #Region " DrawPixel "
  2099.  
  2100.     Private DrawPixelBrush As SolidBrush
  2101.  
  2102.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  2103.         If _Transparent Then
  2104.             B.SetPixel(x, y, c1)
  2105.         Else
  2106.             DrawPixelBrush = New SolidBrush(c1)
  2107.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  2108.         End If
  2109.     End Sub
  2110.  
  2111. #End Region
  2112.  
  2113. #Region " DrawCorners "
  2114.  
  2115.     Private DrawCornersBrush As SolidBrush
  2116.  
  2117.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  2118.         DrawCorners(c1, 0, 0, Width, Height, offset)
  2119.     End Sub
  2120.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  2121.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  2122.     End Sub
  2123.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  2124.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  2125.     End Sub
  2126.  
  2127.     Protected Sub DrawCorners(ByVal c1 As Color)
  2128.         DrawCorners(c1, 0, 0, Width, Height)
  2129.     End Sub
  2130.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  2131.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  2132.     End Sub
  2133.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2134.         If _NoRounding Then Return
  2135.  
  2136.         If _Transparent Then
  2137.             B.SetPixel(x, y, c1)
  2138.             B.SetPixel(x + (width - 1), y, c1)
  2139.             B.SetPixel(x, y + (height - 1), c1)
  2140.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  2141.         Else
  2142.             DrawCornersBrush = New SolidBrush(c1)
  2143.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  2144.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  2145.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  2146.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  2147.         End If
  2148.     End Sub
  2149.  
  2150. #End Region
  2151.  
  2152. #Region " DrawBorders "
  2153.  
  2154.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  2155.         DrawBorders(p1, 0, 0, Width, Height, offset)
  2156.     End Sub
  2157.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  2158.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  2159.     End Sub
  2160.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  2161.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  2162.     End Sub
  2163.  
  2164.     Protected Sub DrawBorders(ByVal p1 As Pen)
  2165.         DrawBorders(p1, 0, 0, Width, Height)
  2166.     End Sub
  2167.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  2168.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  2169.     End Sub
  2170.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2171.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  2172.     End Sub
  2173.  
  2174. #End Region
  2175.  
  2176. #Region " DrawText "
  2177.  
  2178.     Private DrawTextPoint As Point
  2179.     Private DrawTextSize As Size
  2180.  
  2181.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  2182.         DrawText(b1, Text, a, x, y)
  2183.     End Sub
  2184.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  2185.         If text.Length = 0 Then Return
  2186.  
  2187.         DrawTextSize = Measure(text)
  2188.         DrawTextPoint = Center(DrawTextSize)
  2189.  
  2190.         Select Case a
  2191.             Case HorizontalAlignment.Left
  2192.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  2193.             Case HorizontalAlignment.Center
  2194.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  2195.             Case HorizontalAlignment.Right
  2196.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  2197.         End Select
  2198.     End Sub
  2199.  
  2200.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  2201.         If Text.Length = 0 Then Return
  2202.         G.DrawString(Text, Font, b1, p1)
  2203.     End Sub
  2204.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  2205.         If Text.Length = 0 Then Return
  2206.         G.DrawString(Text, Font, b1, x, y)
  2207.     End Sub
  2208.  
  2209. #End Region
  2210.  
  2211. #Region " DrawImage "
  2212.  
  2213.     Private DrawImagePoint As Point
  2214.  
  2215.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  2216.         DrawImage(_Image, a, x, y)
  2217.     End Sub
  2218.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  2219.         If image Is Nothing Then Return
  2220.         DrawImagePoint = Center(image.Size)
  2221.  
  2222.         Select Case a
  2223.             Case HorizontalAlignment.Left
  2224.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  2225.             Case HorizontalAlignment.Center
  2226.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  2227.             Case HorizontalAlignment.Right
  2228.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  2229.         End Select
  2230.     End Sub
  2231.  
  2232.     Protected Sub DrawImage(ByVal p1 As Point)
  2233.         DrawImage(_Image, p1.X, p1.Y)
  2234.     End Sub
  2235.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  2236.         DrawImage(_Image, x, y)
  2237.     End Sub
  2238.  
  2239.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  2240.         DrawImage(image, p1.X, p1.Y)
  2241.     End Sub
  2242.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  2243.         If image Is Nothing Then Return
  2244.         G.DrawImage(image, x, y, image.Width, image.Height)
  2245.     End Sub
  2246.  
  2247. #End Region
  2248.  
  2249. #Region " DrawGradient "
  2250.  
  2251.     Private DrawGradientBrush As LinearGradientBrush
  2252.     Private DrawGradientRectangle As Rectangle
  2253.  
  2254.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2255.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  2256.         DrawGradient(blend, DrawGradientRectangle)
  2257.     End Sub
  2258.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  2259.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  2260.         DrawGradient(blend, DrawGradientRectangle, angle)
  2261.     End Sub
  2262.  
  2263.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  2264.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  2265.         DrawGradientBrush.InterpolationColors = blend
  2266.         G.FillRectangle(DrawGradientBrush, r)
  2267.     End Sub
  2268.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  2269.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  2270.         DrawGradientBrush.InterpolationColors = blend
  2271.         G.FillRectangle(DrawGradientBrush, r)
  2272.     End Sub
  2273.  
  2274.  
  2275.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2276.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  2277.         DrawGradient(c1, c2, DrawGradientRectangle)
  2278.     End Sub
  2279.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  2280.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  2281.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  2282.     End Sub
  2283.  
  2284.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  2285.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  2286.         G.FillRectangle(DrawGradientBrush, r)
  2287.     End Sub
  2288.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  2289.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  2290.         G.FillRectangle(DrawGradientBrush, r)
  2291.     End Sub
  2292.  
  2293. #End Region
  2294. ' Get more free themes at ThemesVB.NET
  2295. #Region " DrawRadial "
  2296.  
  2297.     Private DrawRadialPath As GraphicsPath
  2298.     Private DrawRadialBrush1 As PathGradientBrush
  2299.     Private DrawRadialBrush2 As LinearGradientBrush
  2300.     Private DrawRadialRectangle As Rectangle
  2301.  
  2302.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2303.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  2304.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  2305.     End Sub
  2306.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  2307.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  2308.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  2309.     End Sub
  2310.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  2311.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  2312.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  2313.     End Sub
  2314.  
  2315.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  2316.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  2317.     End Sub
  2318.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  2319.         DrawRadial(blend, r, center.X, center.Y)
  2320.     End Sub
  2321.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  2322.         DrawRadialPath.Reset()
  2323.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  2324.  
  2325.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  2326.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  2327.         DrawRadialBrush1.InterpolationColors = blend
  2328.  
  2329.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  2330.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  2331.         Else
  2332.             G.FillEllipse(DrawRadialBrush1, r)
  2333.         End If
  2334.     End Sub
  2335.  
  2336.  
  2337.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  2338.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  2339.         DrawRadial(c1, c2, DrawRadialRectangle)
  2340.     End Sub
  2341.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  2342.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  2343.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  2344.     End Sub
  2345.  
  2346.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  2347.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  2348.         G.FillEllipse(DrawRadialBrush2, r)
  2349.     End Sub
  2350.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  2351.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  2352.         G.FillEllipse(DrawRadialBrush2, r)
  2353.     End Sub
  2354.  
  2355. #End Region
  2356.  
  2357. #Region " CreateRound "
  2358.  
  2359.     Private CreateRoundPath As GraphicsPath
  2360.     Private CreateRoundRectangle As Rectangle
  2361.  
  2362.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  2363.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  2364.         Return CreateRound(CreateRoundRectangle, slope)
  2365.     End Function
  2366.  
  2367.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  2368.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  2369.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  2370.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  2371.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  2372.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  2373.         CreateRoundPath.CloseFigure()
  2374.         Return CreateRoundPath
  2375.     End Function
  2376.  
  2377. #End Region
  2378.  
  2379. End Class
  2380.  
  2381. Module ThemeShare
  2382.  
  2383. #Region " Animation "
  2384.  
  2385.     Private Frames As Integer
  2386.     Private Invalidate As Boolean
  2387.     Public ThemeTimer As New PrecisionTimer
  2388.  
  2389.     Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  2390.     Private Const Rate As Integer = 10
  2391.  
  2392.     Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  2393.  
  2394.     Private Callbacks As New List(Of AnimationDelegate)
  2395.  
  2396.     Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  2397.         Invalidate = (Frames >= FPS)
  2398.         If Invalidate Then Frames = 0
  2399.  
  2400.         SyncLock Callbacks
  2401.             For I As Integer = 0 To Callbacks.Count - 1
  2402.                 Callbacks(I).Invoke(Invalidate)
  2403.             Next
  2404.         End SyncLock
  2405.  
  2406.         Frames += Rate
  2407.     End Sub
  2408.  
  2409.     Private Sub InvalidateThemeTimer()
  2410.         If Callbacks.Count = 0 Then
  2411.             ThemeTimer.Delete()
  2412.         Else
  2413.             ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  2414.         End If
  2415.     End Sub
  2416.  
  2417.     Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  2418.         SyncLock Callbacks
  2419.             If Callbacks.Contains(callback) Then Return
  2420.  
  2421.             Callbacks.Add(callback)
  2422.             InvalidateThemeTimer()
  2423.         End SyncLock
  2424.     End Sub
  2425. ' Get more free themes at ThemesVB.NET
  2426.     Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  2427.         SyncLock Callbacks
  2428.             If Not Callbacks.Contains(callback) Then Return
  2429.  
  2430.             Callbacks.Remove(callback)
  2431.             InvalidateThemeTimer()
  2432.         End SyncLock
  2433.     End Sub
  2434.  
  2435. #End Region
  2436.  
  2437. End Module
  2438.  
  2439. Enum MouseState As Byte
  2440.     None = 0
  2441.     Over = 1
  2442.     Down = 2
  2443.     Block = 3
  2444. End Enum
  2445.  
  2446. Structure Bloom
  2447.  
  2448.     Public _Name As String
  2449.     ReadOnly Property Name() As String
  2450.         Get
  2451.             Return _Name
  2452.         End Get
  2453.     End Property
  2454.  
  2455.     Private _Value As Color
  2456.     Property Value() As Color
  2457.         Get
  2458.             Return _Value
  2459.         End Get
  2460.         Set(ByVal value As Color)
  2461.             _Value = value
  2462.         End Set
  2463.     End Property
  2464.  
  2465.     Property ValueHex() As String
  2466.         Get
  2467.             Return String.Concat("#", _
  2468.             _Value.R.ToString("X2", Nothing), _
  2469.             _Value.G.ToString("X2", Nothing), _
  2470.             _Value.B.ToString("X2", Nothing))
  2471.         End Get
  2472.         Set(ByVal value As String)
  2473.             Try
  2474.                 _Value = ColorTranslator.FromHtml(value)
  2475.             Catch
  2476.                 Return
  2477.             End Try
  2478.         End Set
  2479.     End Property
  2480.  
  2481.  
  2482.     Sub New(ByVal name As String, ByVal value As Color)
  2483.         _Name = name
  2484.         _Value = value
  2485.     End Sub
  2486. End Structure
  2487.  
  2488. '------------------
  2489. ' Get more free themes at ThemesVB.NET
  2490. 'Creator: aeonhack
  2491. 'Site: elitevs.net
  2492. 'Created: 11/30/2011
  2493. 'Changed: 11/30/2011
  2494. 'Version: 1.0.0
  2495. '------------------
  2496. Class PrecisionTimer
  2497.     Implements IDisposable
  2498.  
  2499.     Private _Enabled As Boolean
  2500.     ReadOnly Property Enabled() As Boolean
  2501.         Get
  2502.             Return _Enabled
  2503.         End Get
  2504.     End Property
  2505.  
  2506.     Private Handle As IntPtr
  2507.     Private TimerCallback As TimerDelegate
  2508.  
  2509.     <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")> _
  2510.     Private Shared Function CreateTimerQueueTimer( _
  2511.     ByRef handle As IntPtr, _
  2512.     ByVal queue As IntPtr, _
  2513.     ByVal callback As TimerDelegate, _
  2514.     ByVal state As IntPtr, _
  2515.     ByVal dueTime As UInteger, _
  2516.     ByVal period As UInteger, _
  2517.     ByVal flags As UInteger) As Boolean
  2518.     End Function
  2519.  
  2520.     <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")> _
  2521.     Private Shared Function DeleteTimerQueueTimer( _
  2522.     ByVal queue As IntPtr, _
  2523.     ByVal handle As IntPtr, _
  2524.     ByVal callback As IntPtr) As Boolean
  2525.     End Function
  2526.  
  2527.     Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  2528.  
  2529.     Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  2530.         If _Enabled Then Return
  2531.  
  2532.         TimerCallback = callback
  2533.         Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  2534.  
  2535.         If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  2536.         _Enabled = Success
  2537.     End Sub
  2538. ' Get more free themes at ThemesVB.NET
  2539.     Sub Delete()
  2540.         If Not _Enabled Then Return
  2541.         Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  2542.  
  2543.         If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  2544.             ThrowNewException("DeleteTimerQueueTimer")
  2545.         End If
  2546.  
  2547.         _Enabled = Not Success
  2548.     End Sub
  2549.  
  2550.     Private Sub ThrowNewException(ByVal name As String)
  2551.         Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  2552.     End Sub
  2553.  
  2554.     Public Sub Dispose() Implements IDisposable.Dispose
  2555.         Delete()
  2556.     End Sub
  2557. End Class
  2558.  
  2559. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement