Advertisement
Finessed

Evolve Theme

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