Advertisement
Guest User

Untitled

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