a7m3dalbalawi

Mac Theme For Vb.NET

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