VAG1

VB.NET Google Chrome Theme

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