a7m3dalbalawi

Whatstheme v.1.0 KingDom

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