a7m3dalbalawi

Steam Theme v.1 - KingDomSc

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