Advertisement
Tidas

twitch Theme

Jun 22nd, 2013
7,381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 115.30 KB | None | 0 0
  1. '------------------
  2. 'Creator: Tidas
  3. 'Created: 06/22/2013
  4. 'Changed: 06/22/2013
  5. 'Version: 1.0.0
  6. 'Credits:
  7. ' • Aeonhack ~ Themebase
  8. ' • Mavamaarten ~ Textbox + Tutorials
  9. ' • xZ3ROxPROJ3CTx ~ General Help, Control Box, Progress Bar.
  10. '------------------
  11.  
  12. #Region "Themebase"
  13. Imports System, System.IO, System.Collections.Generic
  14. Imports System.Drawing, System.Drawing.Drawing2D
  15. Imports System.ComponentModel, System.Windows.Forms
  16. Imports System.Runtime.InteropServices
  17. Imports System.Drawing.Imaging
  18. Imports System.Drawing.Text
  19.  
  20. '------------------
  21. 'Creator: aeonhack
  22. 'Site: elitevs.net
  23. 'Created: 08/02/2011
  24. 'Changed: 12/06/2011
  25. 'Version: 1.5.4
  26. '------------------
  27.  
  28. MustInherit Class ThemeContainer154
  29.     Inherits ContainerControl
  30.  
  31. #Region " Initialization "
  32.  
  33.     Protected G As Graphics, B As Bitmap
  34.  
  35.     Sub New()
  36.         SetStyle(DirectCast(139270, ControlStyles), True)
  37.  
  38.         _ImageSize = Size.Empty
  39.         Font = New Font("Verdana", 8S)
  40.  
  41.         MeasureBitmap = New Bitmap(1, 1)
  42.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  43.  
  44.         DrawRadialPath = New GraphicsPath
  45.  
  46.         InvalidateCustimization()
  47.     End Sub
  48.  
  49.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  50.         If DoneCreation Then InitializeMessages()
  51.  
  52.         InvalidateCustimization()
  53.         ColorHook()
  54.  
  55.         If Not _LockWidth = 0 Then Width = _LockWidth
  56.         If Not _LockHeight = 0 Then Height = _LockHeight
  57.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  58.  
  59.         Transparent = _Transparent
  60.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  61.  
  62.         MyBase.OnHandleCreated(e)
  63.     End Sub
  64.  
  65.     Private DoneCreation As Boolean
  66.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  67.         MyBase.OnParentChanged(e)
  68.  
  69.         If Parent Is Nothing Then Return
  70.         _IsParentForm = TypeOf Parent Is Form
  71.  
  72.         If Not _ControlMode Then
  73.             InitializeMessages()
  74.  
  75.             If _IsParentForm Then
  76.                 ParentForm.FormBorderStyle = _BorderStyle
  77.                 ParentForm.TransparencyKey = _TransparencyKey
  78.  
  79.                 If Not DesignMode Then
  80.                     AddHandler ParentForm.Shown, AddressOf FormShown
  81.                 End If
  82.             End If
  83.  
  84.             Parent.BackColor = BackColor
  85.         End If
  86.  
  87.         OnCreation()
  88.         DoneCreation = True
  89.         InvalidateTimer()
  90.     End Sub
  91.  
  92. #End Region
  93.  
  94.     Private Sub DoAnimation(ByVal i As Boolean)
  95.         OnAnimation()
  96.         If i Then Invalidate()
  97.     End Sub
  98.  
  99.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  100.         If Width = 0 OrElse Height = 0 Then Return
  101.  
  102.         If _Transparent AndAlso _ControlMode Then
  103.             PaintHook()
  104.             e.Graphics.DrawImage(B, 0, 0)
  105.         Else
  106.             G = e.Graphics
  107.             PaintHook()
  108.         End If
  109.     End Sub
  110.  
  111.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  112.         RemoveAnimationCallback(AddressOf DoAnimation)
  113.         MyBase.OnHandleDestroyed(e)
  114.     End Sub
  115.  
  116.     Private HasShown As Boolean
  117.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  118.         If _ControlMode OrElse HasShown Then Return
  119.  
  120.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  121.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  122.             Dim CB As Rectangle = ParentForm.Bounds
  123.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  124.         End If
  125.  
  126.         HasShown = True
  127.     End Sub
  128.  
  129.  
  130. #Region " Size Handling "
  131.  
  132.     Private Frame As Rectangle
  133.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  134.         If _Movable AndAlso Not _ControlMode Then
  135.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  136.         End If
  137.  
  138.         InvalidateBitmap()
  139.         Invalidate()
  140.  
  141.         MyBase.OnSizeChanged(e)
  142.     End Sub
  143.  
  144.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  145.         If Not _LockWidth = 0 Then width = _LockWidth
  146.         If Not _LockHeight = 0 Then height = _LockHeight
  147.         MyBase.SetBoundsCore(x, y, width, height, specified)
  148.     End Sub
  149.  
  150. #End Region
  151.  
  152. #Region " State Handling "
  153.  
  154.     Protected State As MouseState
  155.     Private Sub SetState(ByVal current As MouseState)
  156.         State = current
  157.         Invalidate()
  158.     End Sub
  159.  
  160.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  161.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  162.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  163.         End If
  164.  
  165.         MyBase.OnMouseMove(e)
  166.     End Sub
  167.  
  168.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  169.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  170.         MyBase.OnEnabledChanged(e)
  171.     End Sub
  172.  
  173.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  174.         SetState(MouseState.Over)
  175.         MyBase.OnMouseEnter(e)
  176.     End Sub
  177.  
  178.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  179.         SetState(MouseState.Over)
  180.         MyBase.OnMouseUp(e)
  181.     End Sub
  182.  
  183.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  184.         SetState(MouseState.None)
  185.  
  186.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  187.             If _Sizable AndAlso Not _ControlMode Then
  188.                 Cursor = Cursors.Default
  189.                 Previous = 0
  190.             End If
  191.         End If
  192.  
  193.         MyBase.OnMouseLeave(e)
  194.     End Sub
  195.  
  196.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  197.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  198.  
  199.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  200.             If _Movable AndAlso Frame.Contains(e.Location) Then
  201.                 Capture = False
  202.                 WM_LMBUTTONDOWN = True
  203.                 DefWndProc(Messages(0))
  204.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  205.                 Capture = False
  206.                 WM_LMBUTTONDOWN = True
  207.                 DefWndProc(Messages(Previous))
  208.             End If
  209.         End If
  210.  
  211.         MyBase.OnMouseDown(e)
  212.     End Sub
  213.  
  214.     Private WM_LMBUTTONDOWN As Boolean
  215.     Protected Overrides Sub WndProc(ByRef m As Message)
  216.         MyBase.WndProc(m)
  217.  
  218.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  219.             WM_LMBUTTONDOWN = False
  220.  
  221.             SetState(MouseState.Over)
  222.             If Not _SmartBounds Then Return
  223.  
  224.             If IsParentMdi Then
  225.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  226.             Else
  227.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  228.             End If
  229.         End If
  230.     End Sub
  231.  
  232.     Private GetIndexPoint As Point
  233.     Private B1, B2, B3, B4 As Boolean
  234.     Private Function GetIndex() As Integer
  235.         GetIndexPoint = PointToClient(MousePosition)
  236.         B1 = GetIndexPoint.X < 7
  237.         B2 = GetIndexPoint.X > Width - 7
  238.         B3 = GetIndexPoint.Y < 7
  239.         B4 = GetIndexPoint.Y > Height - 7
  240.  
  241.         If B1 AndAlso B3 Then Return 4
  242.         If B1 AndAlso B4 Then Return 7
  243.         If B2 AndAlso B3 Then Return 5
  244.         If B2 AndAlso B4 Then Return 8
  245.         If B1 Then Return 1
  246.         If B2 Then Return 2
  247.         If B3 Then Return 3
  248.         If B4 Then Return 6
  249.         Return 0
  250.     End Function
  251.  
  252.     Private Current, Previous As Integer
  253.     Private Sub InvalidateMouse()
  254.         Current = GetIndex()
  255.         If Current = Previous Then Return
  256.  
  257.         Previous = Current
  258.         Select Case Previous
  259.             Case 0
  260.                 Cursor = Cursors.Default
  261.             Case 1, 2
  262.                 Cursor = Cursors.SizeWE
  263.             Case 3, 6
  264.                 Cursor = Cursors.SizeNS
  265.             Case 4, 8
  266.                 Cursor = Cursors.SizeNWSE
  267.             Case 5, 7
  268.                 Cursor = Cursors.SizeNESW
  269.         End Select
  270.     End Sub
  271.  
  272.     Private Messages(8) As Message
  273.     Private Sub InitializeMessages()
  274.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  275.         For I As Integer = 1 To 8
  276.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  277.         Next
  278.     End Sub
  279.  
  280.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  281.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  282.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  283.  
  284.         Dim X As Integer = Parent.Location.X
  285.         Dim Y As Integer = Parent.Location.Y
  286.  
  287.         If X < bounds.X Then X = bounds.X
  288.         If Y < bounds.Y Then Y = bounds.Y
  289.  
  290.         Dim Width As Integer = bounds.X + bounds.Width
  291.         Dim Height As Integer = bounds.Y + bounds.Height
  292.  
  293.         If X + Parent.Width > Width Then X = Width - Parent.Width
  294.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  295.  
  296.         Parent.Location = New Point(X, Y)
  297.     End Sub
  298.  
  299. #End Region
  300.  
  301.  
  302. #Region " Base Properties "
  303.  
  304.     Overrides Property Dock As DockStyle
  305.         Get
  306.             Return MyBase.Dock
  307.         End Get
  308.         Set(ByVal value As DockStyle)
  309.             If Not _ControlMode Then Return
  310.             MyBase.Dock = value
  311.         End Set
  312.     End Property
  313.  
  314.     Private _BackColor As Boolean
  315.     <Category("Misc")> _
  316.     Overrides Property BackColor() As Color
  317.         Get
  318.             Return MyBase.BackColor
  319.         End Get
  320.         Set(ByVal value As Color)
  321.             If value = MyBase.BackColor Then Return
  322.  
  323.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  324.                 _BackColor = True
  325.                 Return
  326.             End If
  327.  
  328.             MyBase.BackColor = value
  329.             If Parent IsNot Nothing Then
  330.                 If Not _ControlMode Then Parent.BackColor = value
  331.                 ColorHook()
  332.             End If
  333.         End Set
  334.     End Property
  335.  
  336.     Overrides Property MinimumSize As Size
  337.         Get
  338.             Return MyBase.MinimumSize
  339.         End Get
  340.         Set(ByVal value As Size)
  341.             MyBase.MinimumSize = value
  342.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  343.         End Set
  344.     End Property
  345.  
  346.     Overrides Property MaximumSize As Size
  347.         Get
  348.             Return MyBase.MaximumSize
  349.         End Get
  350.         Set(ByVal value As Size)
  351.             MyBase.MaximumSize = value
  352.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  353.         End Set
  354.     End Property
  355.  
  356.     Overrides Property Text() As String
  357.         Get
  358.             Return MyBase.Text
  359.         End Get
  360.         Set(ByVal value As String)
  361.             MyBase.Text = value
  362.             Invalidate()
  363.         End Set
  364.     End Property
  365.  
  366.     Overrides Property Font() As Font
  367.         Get
  368.             Return MyBase.Font
  369.         End Get
  370.         Set(ByVal value As Font)
  371.             MyBase.Font = value
  372.             Invalidate()
  373.         End Set
  374.     End Property
  375.  
  376.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  377.     Overrides Property ForeColor() As Color
  378.         Get
  379.             Return Color.Empty
  380.         End Get
  381.         Set(ByVal value As Color)
  382.         End Set
  383.     End Property
  384.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  385.     Overrides Property BackgroundImage() As Image
  386.         Get
  387.             Return Nothing
  388.         End Get
  389.         Set(ByVal value As Image)
  390.         End Set
  391.     End Property
  392.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  393.     Overrides Property BackgroundImageLayout() As ImageLayout
  394.         Get
  395.             Return ImageLayout.None
  396.         End Get
  397.         Set(ByVal value As ImageLayout)
  398.         End Set
  399.     End Property
  400.  
  401. #End Region
  402.  
  403. #Region " Public Properties "
  404.  
  405.     Private _SmartBounds As Boolean = True
  406.     Property SmartBounds() As Boolean
  407.         Get
  408.             Return _SmartBounds
  409.         End Get
  410.         Set(ByVal value As Boolean)
  411.             _SmartBounds = value
  412.         End Set
  413.     End Property
  414.  
  415.     Private _Movable As Boolean = True
  416.     Property Movable() As Boolean
  417.         Get
  418.             Return _Movable
  419.         End Get
  420.         Set(ByVal value As Boolean)
  421.             _Movable = value
  422.         End Set
  423.     End Property
  424.  
  425.     Private _Sizable As Boolean = True
  426.     Property Sizable() As Boolean
  427.         Get
  428.             Return _Sizable
  429.         End Get
  430.         Set(ByVal value As Boolean)
  431.             _Sizable = value
  432.         End Set
  433.     End Property
  434.  
  435.     Private _TransparencyKey As Color
  436.     Property TransparencyKey() As Color
  437.         Get
  438.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  439.         End Get
  440.         Set(ByVal value As Color)
  441.             If value = _TransparencyKey Then Return
  442.             _TransparencyKey = value
  443.  
  444.             If _IsParentForm AndAlso Not _ControlMode Then
  445.                 ParentForm.TransparencyKey = value
  446.                 ColorHook()
  447.             End If
  448.         End Set
  449.     End Property
  450.  
  451.     Private _BorderStyle As FormBorderStyle
  452.     Property BorderStyle() As FormBorderStyle
  453.         Get
  454.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  455.         End Get
  456.         Set(ByVal value As FormBorderStyle)
  457.             _BorderStyle = value
  458.  
  459.             If _IsParentForm AndAlso Not _ControlMode Then
  460.                 ParentForm.FormBorderStyle = value
  461.  
  462.                 If Not value = FormBorderStyle.None Then
  463.                     Movable = False
  464.                     Sizable = False
  465.                 End If
  466.             End If
  467.         End Set
  468.     End Property
  469.  
  470.     Private _StartPosition As FormStartPosition
  471.     Property StartPosition As FormStartPosition
  472.         Get
  473.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  474.         End Get
  475.         Set(ByVal value As FormStartPosition)
  476.             _StartPosition = value
  477.  
  478.             If _IsParentForm AndAlso Not _ControlMode Then
  479.                 ParentForm.StartPosition = value
  480.             End If
  481.         End Set
  482.     End Property
  483.  
  484.     Private _NoRounding As Boolean
  485.     Property NoRounding() As Boolean
  486.         Get
  487.             Return _NoRounding
  488.         End Get
  489.         Set(ByVal v As Boolean)
  490.             _NoRounding = v
  491.             Invalidate()
  492.         End Set
  493.     End Property
  494.  
  495.     Private _Image As Image
  496.     Property Image() As Image
  497.         Get
  498.             Return _Image
  499.         End Get
  500.         Set(ByVal value As Image)
  501.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  502.  
  503.             _Image = value
  504.             Invalidate()
  505.         End Set
  506.     End Property
  507.  
  508.     Private Items As New Dictionary(Of String, Color)
  509.     Property Colors() As Bloom()
  510.         Get
  511.             Dim T As New List(Of Bloom)
  512.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  513.  
  514.             While E.MoveNext
  515.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  516.             End While
  517.  
  518.             Return T.ToArray
  519.         End Get
  520.         Set(ByVal value As Bloom())
  521.             For Each B As Bloom In value
  522.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  523.             Next
  524.  
  525.             InvalidateCustimization()
  526.             ColorHook()
  527.             Invalidate()
  528.         End Set
  529.     End Property
  530.  
  531.     Private _Customization As String
  532.     Property Customization() As String
  533.         Get
  534.             Return _Customization
  535.         End Get
  536.         Set(ByVal value As String)
  537.             If value = _Customization Then Return
  538.  
  539.             Dim Data As Byte()
  540.             Dim Items As Bloom() = Colors
  541.  
  542.             Try
  543.                 Data = Convert.FromBase64String(value)
  544.                 For I As Integer = 0 To Items.Length - 1
  545.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  546.                 Next
  547.             Catch
  548.                 Return
  549.             End Try
  550.  
  551.             _Customization = value
  552.  
  553.             Colors = Items
  554.             ColorHook()
  555.             Invalidate()
  556.         End Set
  557.     End Property
  558.  
  559.     Private _Transparent As Boolean
  560.     Property Transparent() As Boolean
  561.         Get
  562.             Return _Transparent
  563.         End Get
  564.         Set(ByVal value As Boolean)
  565.             _Transparent = value
  566.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  567.  
  568.             If Not value AndAlso Not BackColor.A = 255 Then
  569.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  570.             End If
  571.  
  572.             SetStyle(ControlStyles.Opaque, Not value)
  573.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  574.  
  575.             InvalidateBitmap()
  576.             Invalidate()
  577.         End Set
  578.     End Property
  579.  
  580. #End Region
  581.  
  582. #Region " Private Properties "
  583.  
  584.     Private _ImageSize As Size
  585.     Protected ReadOnly Property ImageSize() As Size
  586.         Get
  587.             Return _ImageSize
  588.         End Get
  589.     End Property
  590.  
  591.     Private _IsParentForm As Boolean
  592.     Protected ReadOnly Property IsParentForm As Boolean
  593.         Get
  594.             Return _IsParentForm
  595.         End Get
  596.     End Property
  597.  
  598.     Protected ReadOnly Property IsParentMdi As Boolean
  599.         Get
  600.             If Parent Is Nothing Then Return False
  601.             Return Parent.Parent IsNot Nothing
  602.         End Get
  603.     End Property
  604.  
  605.     Private _LockWidth As Integer
  606.     Protected Property LockWidth() As Integer
  607.         Get
  608.             Return _LockWidth
  609.         End Get
  610.         Set(ByVal value As Integer)
  611.             _LockWidth = value
  612.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  613.         End Set
  614.     End Property
  615.  
  616.     Private _LockHeight As Integer
  617.     Protected Property LockHeight() As Integer
  618.         Get
  619.             Return _LockHeight
  620.         End Get
  621.         Set(ByVal value As Integer)
  622.             _LockHeight = value
  623.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  624.         End Set
  625.     End Property
  626.  
  627.     Private _Header As Integer = 24
  628.     Protected Property Header() As Integer
  629.         Get
  630.             Return _Header
  631.         End Get
  632.         Set(ByVal v As Integer)
  633.             _Header = v
  634.  
  635.             If Not _ControlMode Then
  636.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  637.                 Invalidate()
  638.             End If
  639.         End Set
  640.     End Property
  641.  
  642.     Private _ControlMode As Boolean
  643.     Protected Property ControlMode() As Boolean
  644.         Get
  645.             Return _ControlMode
  646.         End Get
  647.         Set(ByVal v As Boolean)
  648.             _ControlMode = v
  649.  
  650.             Transparent = _Transparent
  651.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  652.  
  653.             InvalidateBitmap()
  654.             Invalidate()
  655.         End Set
  656.     End Property
  657.  
  658.     Private _IsAnimated As Boolean
  659.     Protected Property IsAnimated() As Boolean
  660.         Get
  661.             Return _IsAnimated
  662.         End Get
  663.         Set(ByVal value As Boolean)
  664.             _IsAnimated = value
  665.             InvalidateTimer()
  666.         End Set
  667.     End Property
  668.  
  669. #End Region
  670.  
  671.  
  672. #Region " Property Helpers "
  673.  
  674.     Protected Function GetPen(ByVal name As String) As Pen
  675.         Return New Pen(Items(name))
  676.     End Function
  677.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  678.         Return New Pen(Items(name), width)
  679.     End Function
  680.  
  681.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  682.         Return New SolidBrush(Items(name))
  683.     End Function
  684.  
  685.     Protected Function GetColor(ByVal name As String) As Color
  686.         Return Items(name)
  687.     End Function
  688.  
  689.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  690.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  691.     End Sub
  692.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  693.         SetColor(name, Color.FromArgb(r, g, b))
  694.     End Sub
  695.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  696.         SetColor(name, Color.FromArgb(a, r, g, b))
  697.     End Sub
  698.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  699.         SetColor(name, Color.FromArgb(a, value))
  700.     End Sub
  701.  
  702.     Private Sub InvalidateBitmap()
  703.         If _Transparent AndAlso _ControlMode Then
  704.             If Width = 0 OrElse Height = 0 Then Return
  705.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  706.             G = Graphics.FromImage(B)
  707.         Else
  708.             G = Nothing
  709.             B = Nothing
  710.         End If
  711.     End Sub
  712.  
  713.     Private Sub InvalidateCustimization()
  714.         Dim M As New MemoryStream(Items.Count * 4)
  715.  
  716.         For Each B As Bloom In Colors
  717.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  718.         Next
  719.  
  720.         M.Close()
  721.         _Customization = Convert.ToBase64String(M.ToArray)
  722.     End Sub
  723.  
  724.     Private Sub InvalidateTimer()
  725.         If DesignMode OrElse Not DoneCreation Then Return
  726.  
  727.         If _IsAnimated Then
  728.             AddAnimationCallback(AddressOf DoAnimation)
  729.         Else
  730.             RemoveAnimationCallback(AddressOf DoAnimation)
  731.         End If
  732.     End Sub
  733.  
  734. #End Region
  735.  
  736.  
  737. #Region " User Hooks "
  738.  
  739.     Protected MustOverride Sub ColorHook()
  740.     Protected MustOverride Sub PaintHook()
  741.  
  742.     Protected Overridable Sub OnCreation()
  743.     End Sub
  744.  
  745.     Protected Overridable Sub OnAnimation()
  746.     End Sub
  747.  
  748. #End Region
  749.  
  750.  
  751. #Region " Offset "
  752.  
  753.     Private OffsetReturnRectangle As Rectangle
  754.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  755.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  756.         Return OffsetReturnRectangle
  757.     End Function
  758.  
  759.     Private OffsetReturnSize As Size
  760.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  761.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  762.         Return OffsetReturnSize
  763.     End Function
  764.  
  765.     Private OffsetReturnPoint As Point
  766.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  767.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  768.         Return OffsetReturnPoint
  769.     End Function
  770.  
  771. #End Region
  772.  
  773. #Region " Center "
  774.  
  775.     Private CenterReturn As Point
  776.  
  777.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  778.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  779.         Return CenterReturn
  780.     End Function
  781.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  782.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  783.         Return CenterReturn
  784.     End Function
  785.  
  786.     Protected Function Center(ByVal child As Rectangle) As Point
  787.         Return Center(Width, Height, child.Width, child.Height)
  788.     End Function
  789.     Protected Function Center(ByVal child As Size) As Point
  790.         Return Center(Width, Height, child.Width, child.Height)
  791.     End Function
  792.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  793.         Return Center(Width, Height, childWidth, childHeight)
  794.     End Function
  795.  
  796.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  797.         Return Center(p.Width, p.Height, c.Width, c.Height)
  798.     End Function
  799.  
  800.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  801.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  802.         Return CenterReturn
  803.     End Function
  804.  
  805. #End Region
  806.  
  807. #Region " Measure "
  808.  
  809.     Private MeasureBitmap As Bitmap
  810.     Private MeasureGraphics As Graphics
  811.  
  812.     Protected Function Measure() As Size
  813.         SyncLock MeasureGraphics
  814.             Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  815.         End SyncLock
  816.     End Function
  817.     Protected Function Measure(ByVal text As String) As Size
  818.         SyncLock MeasureGraphics
  819.             Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  820.         End SyncLock
  821.     End Function
  822.  
  823. #End Region
  824.  
  825.  
  826. #Region " DrawPixel "
  827.  
  828.     Private DrawPixelBrush As SolidBrush
  829.  
  830.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  831.         If _Transparent Then
  832.             B.SetPixel(x, y, c1)
  833.         Else
  834.             DrawPixelBrush = New SolidBrush(c1)
  835.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  836.         End If
  837.     End Sub
  838.  
  839. #End Region
  840.  
  841. #Region " DrawCorners "
  842.  
  843.     Private DrawCornersBrush As SolidBrush
  844.  
  845.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  846.         DrawCorners(c1, 0, 0, Width, Height, offset)
  847.     End Sub
  848.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  849.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  850.     End Sub
  851.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  852.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  853.     End Sub
  854.  
  855.     Protected Sub DrawCorners(ByVal c1 As Color)
  856.         DrawCorners(c1, 0, 0, Width, Height)
  857.     End Sub
  858.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  859.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  860.     End Sub
  861.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  862.         If _NoRounding Then Return
  863.  
  864.         If _Transparent Then
  865.             B.SetPixel(x, y, c1)
  866.             B.SetPixel(x + (width - 1), y, c1)
  867.             B.SetPixel(x, y + (height - 1), c1)
  868.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  869.         Else
  870.             DrawCornersBrush = New SolidBrush(c1)
  871.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  872.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  873.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  874.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  875.         End If
  876.     End Sub
  877.  
  878. #End Region
  879.  
  880. #Region " DrawBorders "
  881.  
  882.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  883.         DrawBorders(p1, 0, 0, Width, Height, offset)
  884.     End Sub
  885.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  886.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  887.     End Sub
  888.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  889.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  890.     End Sub
  891.  
  892.     Protected Sub DrawBorders(ByVal p1 As Pen)
  893.         DrawBorders(p1, 0, 0, Width, Height)
  894.     End Sub
  895.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  896.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  897.     End Sub
  898.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  899.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  900.     End Sub
  901.  
  902. #End Region
  903.  
  904. #Region " DrawText "
  905.  
  906.     Private DrawTextPoint As Point
  907.     Private DrawTextSize As Size
  908.  
  909.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  910.         DrawText(b1, Text, a, x, y)
  911.     End Sub
  912.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  913.         If text.Length = 0 Then Return
  914.  
  915.         DrawTextSize = Measure(text)
  916.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  917.  
  918.         Select Case a
  919.             Case HorizontalAlignment.Left
  920.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  921.             Case HorizontalAlignment.Center
  922.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  923.             Case HorizontalAlignment.Right
  924.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  925.         End Select
  926.     End Sub
  927.  
  928.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  929.         If Text.Length = 0 Then Return
  930.         G.DrawString(Text, Font, b1, p1)
  931.     End Sub
  932.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  933.         If Text.Length = 0 Then Return
  934.         G.DrawString(Text, Font, b1, x, y)
  935.     End Sub
  936.  
  937. #End Region
  938.  
  939. #Region " DrawImage "
  940.  
  941.     Private DrawImagePoint As Point
  942.  
  943.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  944.         DrawImage(_Image, a, x, y)
  945.     End Sub
  946.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  947.         If image Is Nothing Then Return
  948.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  949.  
  950.         Select Case a
  951.             Case HorizontalAlignment.Left
  952.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  953.             Case HorizontalAlignment.Center
  954.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  955.             Case HorizontalAlignment.Right
  956.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  957.         End Select
  958.     End Sub
  959.  
  960.     Protected Sub DrawImage(ByVal p1 As Point)
  961.         DrawImage(_Image, p1.X, p1.Y)
  962.     End Sub
  963.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  964.         DrawImage(_Image, x, y)
  965.     End Sub
  966.  
  967.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  968.         DrawImage(image, p1.X, p1.Y)
  969.     End Sub
  970.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  971.         If image Is Nothing Then Return
  972.         G.DrawImage(image, x, y, image.Width, image.Height)
  973.     End Sub
  974.  
  975. #End Region
  976.  
  977. #Region " DrawGradient "
  978.  
  979.     Private DrawGradientBrush As LinearGradientBrush
  980.     Private DrawGradientRectangle As Rectangle
  981.  
  982.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  983.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  984.         DrawGradient(blend, DrawGradientRectangle)
  985.     End Sub
  986.     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)
  987.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  988.         DrawGradient(blend, DrawGradientRectangle, angle)
  989.     End Sub
  990.  
  991.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  992.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  993.         DrawGradientBrush.InterpolationColors = blend
  994.         G.FillRectangle(DrawGradientBrush, r)
  995.     End Sub
  996.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  997.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  998.         DrawGradientBrush.InterpolationColors = blend
  999.         G.FillRectangle(DrawGradientBrush, r)
  1000.     End Sub
  1001.  
  1002.  
  1003.     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)
  1004.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1005.         DrawGradient(c1, c2, DrawGradientRectangle)
  1006.     End Sub
  1007.     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)
  1008.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1009.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1010.     End Sub
  1011.  
  1012.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1013.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1014.         G.FillRectangle(DrawGradientBrush, r)
  1015.     End Sub
  1016.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1017.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1018.         G.FillRectangle(DrawGradientBrush, r)
  1019.     End Sub
  1020.  
  1021. #End Region
  1022.  
  1023. #Region " DrawRadial "
  1024.  
  1025.     Private DrawRadialPath As GraphicsPath
  1026.     Private DrawRadialBrush1 As PathGradientBrush
  1027.     Private DrawRadialBrush2 As LinearGradientBrush
  1028.     Private DrawRadialRectangle As Rectangle
  1029.  
  1030.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1031.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1032.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1033.     End Sub
  1034.     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)
  1035.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1036.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1037.     End Sub
  1038.     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)
  1039.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1040.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1041.     End Sub
  1042.  
  1043.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1044.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1045.     End Sub
  1046.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1047.         DrawRadial(blend, r, center.X, center.Y)
  1048.     End Sub
  1049.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1050.         DrawRadialPath.Reset()
  1051.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1052.  
  1053.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1054.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1055.         DrawRadialBrush1.InterpolationColors = blend
  1056.  
  1057.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1058.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1059.         Else
  1060.             G.FillEllipse(DrawRadialBrush1, r)
  1061.         End If
  1062.     End Sub
  1063.  
  1064.  
  1065.     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)
  1066.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1067.         DrawRadial(c1, c2, DrawGradientRectangle)
  1068.     End Sub
  1069.     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)
  1070.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1071.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  1072.     End Sub
  1073.  
  1074.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1075.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1076.         G.FillRectangle(DrawGradientBrush, r)
  1077.     End Sub
  1078.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1079.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1080.         G.FillEllipse(DrawGradientBrush, r)
  1081.     End Sub
  1082.  
  1083. #End Region
  1084.  
  1085. #Region " CreateRound "
  1086.  
  1087.     Private CreateRoundPath As GraphicsPath
  1088.     Private CreateRoundRectangle As Rectangle
  1089.  
  1090.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1091.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1092.         Return CreateRound(CreateRoundRectangle, slope)
  1093.     End Function
  1094.  
  1095.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1096.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1097.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1098.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1099.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1100.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1101.         CreateRoundPath.CloseFigure()
  1102.         Return CreateRoundPath
  1103.     End Function
  1104.  
  1105. #End Region
  1106.  
  1107. End Class
  1108.  
  1109. MustInherit Class ThemeControl154
  1110.     Inherits Control
  1111.  
  1112.  
  1113. #Region " Initialization "
  1114.  
  1115.     Protected G As Graphics, B As Bitmap
  1116.  
  1117.     Sub New()
  1118.         SetStyle(DirectCast(139270, ControlStyles), True)
  1119.  
  1120.         _ImageSize = Size.Empty
  1121.         Font = New Font("Verdana", 8S)
  1122.  
  1123.         MeasureBitmap = New Bitmap(1, 1)
  1124.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1125.  
  1126.         DrawRadialPath = New GraphicsPath
  1127.  
  1128.         InvalidateCustimization() 'Remove?
  1129.     End Sub
  1130.  
  1131.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1132.         InvalidateCustimization()
  1133.         ColorHook()
  1134.  
  1135.         If Not _LockWidth = 0 Then Width = _LockWidth
  1136.         If Not _LockHeight = 0 Then Height = _LockHeight
  1137.  
  1138.         Transparent = _Transparent
  1139.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1140.  
  1141.         MyBase.OnHandleCreated(e)
  1142.     End Sub
  1143.  
  1144.     Private DoneCreation As Boolean
  1145.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1146.         If Parent IsNot Nothing Then
  1147.             OnCreation()
  1148.             DoneCreation = True
  1149.             InvalidateTimer()
  1150.         End If
  1151.  
  1152.         MyBase.OnParentChanged(e)
  1153.     End Sub
  1154.  
  1155. #End Region
  1156.  
  1157.     Private Sub DoAnimation(ByVal i As Boolean)
  1158.         OnAnimation()
  1159.         If i Then Invalidate()
  1160.     End Sub
  1161.  
  1162.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1163.         If Width = 0 OrElse Height = 0 Then Return
  1164.  
  1165.         If _Transparent Then
  1166.             PaintHook()
  1167.             e.Graphics.DrawImage(B, 0, 0)
  1168.         Else
  1169.             G = e.Graphics
  1170.             PaintHook()
  1171.         End If
  1172.     End Sub
  1173.  
  1174.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  1175.         RemoveAnimationCallback(AddressOf DoAnimation)
  1176.         MyBase.OnHandleDestroyed(e)
  1177.     End Sub
  1178.  
  1179. #Region " Size Handling "
  1180.  
  1181.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1182.         If _Transparent Then
  1183.             InvalidateBitmap()
  1184.         End If
  1185.  
  1186.         Invalidate()
  1187.         MyBase.OnSizeChanged(e)
  1188.     End Sub
  1189.  
  1190.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1191.         If Not _LockWidth = 0 Then width = _LockWidth
  1192.         If Not _LockHeight = 0 Then height = _LockHeight
  1193.         MyBase.SetBoundsCore(x, y, width, height, specified)
  1194.     End Sub
  1195.  
  1196. #End Region
  1197.  
  1198. #Region " State Handling "
  1199.  
  1200.     Private InPosition As Boolean
  1201.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1202.         InPosition = True
  1203.         SetState(MouseState.Over)
  1204.         MyBase.OnMouseEnter(e)
  1205.     End Sub
  1206.  
  1207.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1208.         If InPosition Then SetState(MouseState.Over)
  1209.         MyBase.OnMouseUp(e)
  1210.     End Sub
  1211.  
  1212.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1213.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1214.         MyBase.OnMouseDown(e)
  1215.     End Sub
  1216.  
  1217.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1218.         InPosition = False
  1219.         SetState(MouseState.None)
  1220.         MyBase.OnMouseLeave(e)
  1221.     End Sub
  1222.  
  1223.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1224.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1225.         MyBase.OnEnabledChanged(e)
  1226.     End Sub
  1227.  
  1228.     Protected State As MouseState
  1229.     Private Sub SetState(ByVal current As MouseState)
  1230.         State = current
  1231.         Invalidate()
  1232.     End Sub
  1233.  
  1234. #End Region
  1235.  
  1236.  
  1237. #Region " Base Properties "
  1238.  
  1239.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1240.     Overrides Property ForeColor() As Color
  1241.         Get
  1242.             Return Color.Empty
  1243.         End Get
  1244.         Set(ByVal value As Color)
  1245.         End Set
  1246.     End Property
  1247.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1248.     Overrides Property BackgroundImage() As Image
  1249.         Get
  1250.             Return Nothing
  1251.         End Get
  1252.         Set(ByVal value As Image)
  1253.         End Set
  1254.     End Property
  1255.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  1256.     Overrides Property BackgroundImageLayout() As ImageLayout
  1257.         Get
  1258.             Return ImageLayout.None
  1259.         End Get
  1260.         Set(ByVal value As ImageLayout)
  1261.         End Set
  1262.     End Property
  1263.  
  1264.     Overrides Property Text() As String
  1265.         Get
  1266.             Return MyBase.Text
  1267.         End Get
  1268.         Set(ByVal value As String)
  1269.             MyBase.Text = value
  1270.             Invalidate()
  1271.         End Set
  1272.     End Property
  1273.     Overrides Property Font() As Font
  1274.         Get
  1275.             Return MyBase.Font
  1276.         End Get
  1277.         Set(ByVal value As Font)
  1278.             MyBase.Font = value
  1279.             Invalidate()
  1280.         End Set
  1281.     End Property
  1282.  
  1283.     Private _BackColor As Boolean
  1284.     <Category("Misc")> _
  1285.     Overrides Property BackColor() As Color
  1286.         Get
  1287.             Return MyBase.BackColor
  1288.         End Get
  1289.         Set(ByVal value As Color)
  1290.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1291.                 _BackColor = True
  1292.                 Return
  1293.             End If
  1294.  
  1295.             MyBase.BackColor = value
  1296.             If Parent IsNot Nothing Then ColorHook()
  1297.         End Set
  1298.     End Property
  1299.  
  1300. #End Region
  1301.  
  1302. #Region " Public Properties "
  1303.  
  1304.     Private _NoRounding As Boolean
  1305.     Property NoRounding() As Boolean
  1306.         Get
  1307.             Return _NoRounding
  1308.         End Get
  1309.         Set(ByVal v As Boolean)
  1310.             _NoRounding = v
  1311.             Invalidate()
  1312.         End Set
  1313.     End Property
  1314.  
  1315.     Private _Image As Image
  1316.     Property Image() As Image
  1317.         Get
  1318.             Return _Image
  1319.         End Get
  1320.         Set(ByVal value As Image)
  1321.             If value Is Nothing Then
  1322.                 _ImageSize = Size.Empty
  1323.             Else
  1324.                 _ImageSize = value.Size
  1325.             End If
  1326.  
  1327.             _Image = value
  1328.             Invalidate()
  1329.         End Set
  1330.     End Property
  1331.  
  1332.     Private _Transparent As Boolean
  1333.     Property Transparent() As Boolean
  1334.         Get
  1335.             Return _Transparent
  1336.         End Get
  1337.         Set(ByVal value As Boolean)
  1338.             _Transparent = value
  1339.             If Not IsHandleCreated Then Return
  1340.  
  1341.             If Not value AndAlso Not BackColor.A = 255 Then
  1342.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1343.             End If
  1344.  
  1345.             SetStyle(ControlStyles.Opaque, Not value)
  1346.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1347.  
  1348.             If value Then InvalidateBitmap() Else B = Nothing
  1349.             Invalidate()
  1350.         End Set
  1351.     End Property
  1352.  
  1353.     Private Items As New Dictionary(Of String, Color)
  1354.     Property Colors() As Bloom()
  1355.         Get
  1356.             Dim T As New List(Of Bloom)
  1357.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1358.  
  1359.             While E.MoveNext
  1360.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1361.             End While
  1362.  
  1363.             Return T.ToArray
  1364.         End Get
  1365.         Set(ByVal value As Bloom())
  1366.             For Each B As Bloom In value
  1367.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1368.             Next
  1369.  
  1370.             InvalidateCustimization()
  1371.             ColorHook()
  1372.             Invalidate()
  1373.         End Set
  1374.     End Property
  1375.  
  1376.     Private _Customization As String
  1377.     Property Customization() As String
  1378.         Get
  1379.             Return _Customization
  1380.         End Get
  1381.         Set(ByVal value As String)
  1382.             If value = _Customization Then Return
  1383.  
  1384.             Dim Data As Byte()
  1385.             Dim Items As Bloom() = Colors
  1386.  
  1387.             Try
  1388.                 Data = Convert.FromBase64String(value)
  1389.                 For I As Integer = 0 To Items.Length - 1
  1390.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1391.                 Next
  1392.             Catch
  1393.                 Return
  1394.             End Try
  1395.  
  1396.             _Customization = value
  1397.  
  1398.             Colors = Items
  1399.             ColorHook()
  1400.             Invalidate()
  1401.         End Set
  1402.     End Property
  1403.  
  1404. #End Region
  1405.  
  1406. #Region " Private Properties "
  1407.  
  1408.     Private _ImageSize As Size
  1409.     Protected ReadOnly Property ImageSize() As Size
  1410.         Get
  1411.             Return _ImageSize
  1412.         End Get
  1413.     End Property
  1414.  
  1415.     Private _LockWidth As Integer
  1416.     Protected Property LockWidth() As Integer
  1417.         Get
  1418.             Return _LockWidth
  1419.         End Get
  1420.         Set(ByVal value As Integer)
  1421.             _LockWidth = value
  1422.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1423.         End Set
  1424.     End Property
  1425.  
  1426.     Private _LockHeight As Integer
  1427.     Protected Property LockHeight() As Integer
  1428.         Get
  1429.             Return _LockHeight
  1430.         End Get
  1431.         Set(ByVal value As Integer)
  1432.             _LockHeight = value
  1433.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1434.         End Set
  1435.     End Property
  1436.  
  1437.     Private _IsAnimated As Boolean
  1438.     Protected Property IsAnimated() As Boolean
  1439.         Get
  1440.             Return _IsAnimated
  1441.         End Get
  1442.         Set(ByVal value As Boolean)
  1443.             _IsAnimated = value
  1444.             InvalidateTimer()
  1445.         End Set
  1446.     End Property
  1447.  
  1448. #End Region
  1449.  
  1450.  
  1451. #Region " Property Helpers "
  1452.  
  1453.     Protected Function GetPen(ByVal name As String) As Pen
  1454.         Return New Pen(Items(name))
  1455.     End Function
  1456.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1457.         Return New Pen(Items(name), width)
  1458.     End Function
  1459.  
  1460.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1461.         Return New SolidBrush(Items(name))
  1462.     End Function
  1463.  
  1464.     Protected Function GetColor(ByVal name As String) As Color
  1465.         Return Items(name)
  1466.     End Function
  1467.  
  1468.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1469.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1470.     End Sub
  1471.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1472.         SetColor(name, Color.FromArgb(r, g, b))
  1473.     End Sub
  1474.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1475.         SetColor(name, Color.FromArgb(a, r, g, b))
  1476.     End Sub
  1477.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1478.         SetColor(name, Color.FromArgb(a, value))
  1479.     End Sub
  1480.  
  1481.     Private Sub InvalidateBitmap()
  1482.         If Width = 0 OrElse Height = 0 Then Return
  1483.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1484.         G = Graphics.FromImage(B)
  1485.     End Sub
  1486.  
  1487.     Private Sub InvalidateCustimization()
  1488.         Dim M As New MemoryStream(Items.Count * 4)
  1489.  
  1490.         For Each B As Bloom In Colors
  1491.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1492.         Next
  1493.  
  1494.         M.Close()
  1495.         _Customization = Convert.ToBase64String(M.ToArray)
  1496.     End Sub
  1497.  
  1498.     Private Sub InvalidateTimer()
  1499.         If DesignMode OrElse Not DoneCreation Then Return
  1500.  
  1501.         If _IsAnimated Then
  1502.             AddAnimationCallback(AddressOf DoAnimation)
  1503.         Else
  1504.             RemoveAnimationCallback(AddressOf DoAnimation)
  1505.         End If
  1506.     End Sub
  1507. #End Region
  1508.  
  1509.  
  1510. #Region " User Hooks "
  1511.  
  1512.     Protected MustOverride Sub ColorHook()
  1513.     Protected MustOverride Sub PaintHook()
  1514.  
  1515.     Protected Overridable Sub OnCreation()
  1516.     End Sub
  1517.  
  1518.     Protected Overridable Sub OnAnimation()
  1519.     End Sub
  1520.  
  1521. #End Region
  1522.  
  1523.  
  1524. #Region " Offset "
  1525.  
  1526.     Private OffsetReturnRectangle As Rectangle
  1527.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1528.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1529.         Return OffsetReturnRectangle
  1530.     End Function
  1531.  
  1532.     Private OffsetReturnSize As Size
  1533.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1534.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1535.         Return OffsetReturnSize
  1536.     End Function
  1537.  
  1538.     Private OffsetReturnPoint As Point
  1539.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1540.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1541.         Return OffsetReturnPoint
  1542.     End Function
  1543.  
  1544. #End Region
  1545.  
  1546. #Region " Center "
  1547.  
  1548.     Private CenterReturn As Point
  1549.  
  1550.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1551.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1552.         Return CenterReturn
  1553.     End Function
  1554.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1555.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1556.         Return CenterReturn
  1557.     End Function
  1558.  
  1559.     Protected Function Center(ByVal child As Rectangle) As Point
  1560.         Return Center(Width, Height, child.Width, child.Height)
  1561.     End Function
  1562.     Protected Function Center(ByVal child As Size) As Point
  1563.         Return Center(Width, Height, child.Width, child.Height)
  1564.     End Function
  1565.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1566.         Return Center(Width, Height, childWidth, childHeight)
  1567.     End Function
  1568.  
  1569.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1570.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1571.     End Function
  1572.  
  1573.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1574.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1575.         Return CenterReturn
  1576.     End Function
  1577.  
  1578. #End Region
  1579.  
  1580. #Region " Measure "
  1581.  
  1582.     Private MeasureBitmap As Bitmap
  1583.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1584.  
  1585.     Protected Function Measure() As Size
  1586.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1587.     End Function
  1588.     Protected Function Measure(ByVal text As String) As Size
  1589.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1590.     End Function
  1591.  
  1592. #End Region
  1593.  
  1594.  
  1595. #Region " DrawPixel "
  1596.  
  1597.     Private DrawPixelBrush As SolidBrush
  1598.  
  1599.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1600.         If _Transparent Then
  1601.             B.SetPixel(x, y, c1)
  1602.         Else
  1603.             DrawPixelBrush = New SolidBrush(c1)
  1604.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1605.         End If
  1606.     End Sub
  1607.  
  1608. #End Region
  1609.  
  1610. #Region " DrawCorners "
  1611.  
  1612.     Private DrawCornersBrush As SolidBrush
  1613.  
  1614.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1615.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1616.     End Sub
  1617.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1618.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1619.     End Sub
  1620.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1621.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1622.     End Sub
  1623.  
  1624.     Protected Sub DrawCorners(ByVal c1 As Color)
  1625.         DrawCorners(c1, 0, 0, Width, Height)
  1626.     End Sub
  1627.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1628.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1629.     End Sub
  1630.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1631.         If _NoRounding Then Return
  1632.  
  1633.         If _Transparent Then
  1634.             B.SetPixel(x, y, c1)
  1635.             B.SetPixel(x + (width - 1), y, c1)
  1636.             B.SetPixel(x, y + (height - 1), c1)
  1637.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1638.         Else
  1639.             DrawCornersBrush = New SolidBrush(c1)
  1640.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1641.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1642.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1643.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1644.         End If
  1645.     End Sub
  1646.  
  1647. #End Region
  1648.  
  1649. #Region " DrawBorders "
  1650.  
  1651.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1652.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1653.     End Sub
  1654.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1655.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1656.     End Sub
  1657.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  1658.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1659.     End Sub
  1660.  
  1661.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1662.         DrawBorders(p1, 0, 0, Width, Height)
  1663.     End Sub
  1664.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1665.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1666.     End Sub
  1667.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1668.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1669.     End Sub
  1670.  
  1671. #End Region
  1672.  
  1673. #Region " DrawText "
  1674.  
  1675.     Private DrawTextPoint As Point
  1676.     Private DrawTextSize As Size
  1677.  
  1678.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1679.         DrawText(b1, Text, a, x, y)
  1680.     End Sub
  1681.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1682.         If text.Length = 0 Then Return
  1683.  
  1684.         DrawTextSize = Measure(text)
  1685.         DrawTextPoint = Center(DrawTextSize)
  1686.  
  1687.         Select Case a
  1688.             Case HorizontalAlignment.Left
  1689.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1690.             Case HorizontalAlignment.Center
  1691.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1692.             Case HorizontalAlignment.Right
  1693.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1694.         End Select
  1695.     End Sub
  1696.  
  1697.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1698.         If Text.Length = 0 Then Return
  1699.         G.DrawString(Text, Font, b1, p1)
  1700.     End Sub
  1701.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1702.         If Text.Length = 0 Then Return
  1703.         G.DrawString(Text, Font, b1, x, y)
  1704.     End Sub
  1705.  
  1706. #End Region
  1707.  
  1708. #Region " DrawImage "
  1709.  
  1710.     Private DrawImagePoint As Point
  1711.  
  1712.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1713.         DrawImage(_Image, a, x, y)
  1714.     End Sub
  1715.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1716.         If image Is Nothing Then Return
  1717.         DrawImagePoint = Center(image.Size)
  1718.  
  1719.         Select Case a
  1720.             Case HorizontalAlignment.Left
  1721.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1722.             Case HorizontalAlignment.Center
  1723.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1724.             Case HorizontalAlignment.Right
  1725.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1726.         End Select
  1727.     End Sub
  1728.  
  1729.     Protected Sub DrawImage(ByVal p1 As Point)
  1730.         DrawImage(_Image, p1.X, p1.Y)
  1731.     End Sub
  1732.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1733.         DrawImage(_Image, x, y)
  1734.     End Sub
  1735.  
  1736.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1737.         DrawImage(image, p1.X, p1.Y)
  1738.     End Sub
  1739.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1740.         If image Is Nothing Then Return
  1741.         G.DrawImage(image, x, y, image.Width, image.Height)
  1742.     End Sub
  1743.  
  1744. #End Region
  1745.  
  1746. #Region " DrawGradient "
  1747.  
  1748.     Private DrawGradientBrush As LinearGradientBrush
  1749.     Private DrawGradientRectangle As Rectangle
  1750.  
  1751.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1752.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1753.         DrawGradient(blend, DrawGradientRectangle)
  1754.     End Sub
  1755.     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)
  1756.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1757.         DrawGradient(blend, DrawGradientRectangle, angle)
  1758.     End Sub
  1759.  
  1760.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1761.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1762.         DrawGradientBrush.InterpolationColors = blend
  1763.         G.FillRectangle(DrawGradientBrush, r)
  1764.     End Sub
  1765.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1766.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1767.         DrawGradientBrush.InterpolationColors = blend
  1768.         G.FillRectangle(DrawGradientBrush, r)
  1769.     End Sub
  1770.  
  1771.  
  1772.     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)
  1773.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1774.         DrawGradient(c1, c2, DrawGradientRectangle)
  1775.     End Sub
  1776.     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)
  1777.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1778.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1779.     End Sub
  1780.  
  1781.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1782.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1783.         G.FillRectangle(DrawGradientBrush, r)
  1784.     End Sub
  1785.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1786.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1787.         G.FillRectangle(DrawGradientBrush, r)
  1788.     End Sub
  1789.  
  1790. #End Region
  1791.  
  1792. #Region " DrawRadial "
  1793.  
  1794.     Private DrawRadialPath As GraphicsPath
  1795.     Private DrawRadialBrush1 As PathGradientBrush
  1796.     Private DrawRadialBrush2 As LinearGradientBrush
  1797.     Private DrawRadialRectangle As Rectangle
  1798.  
  1799.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1800.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1801.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1802.     End Sub
  1803.     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)
  1804.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1805.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1806.     End Sub
  1807.     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)
  1808.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1809.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1810.     End Sub
  1811.  
  1812.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1813.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1814.     End Sub
  1815.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1816.         DrawRadial(blend, r, center.X, center.Y)
  1817.     End Sub
  1818.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1819.         DrawRadialPath.Reset()
  1820.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1821.  
  1822.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1823.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1824.         DrawRadialBrush1.InterpolationColors = blend
  1825.  
  1826.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1827.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1828.         Else
  1829.             G.FillEllipse(DrawRadialBrush1, r)
  1830.         End If
  1831.     End Sub
  1832.  
  1833.  
  1834.     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)
  1835.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1836.         DrawRadial(c1, c2, DrawRadialRectangle)
  1837.     End Sub
  1838.     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)
  1839.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1840.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1841.     End Sub
  1842.  
  1843.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1844.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1845.         G.FillEllipse(DrawRadialBrush2, r)
  1846.     End Sub
  1847.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1848.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1849.         G.FillEllipse(DrawRadialBrush2, r)
  1850.     End Sub
  1851.  
  1852. #End Region
  1853.  
  1854. #Region " CreateRound "
  1855.  
  1856.     Private CreateRoundPath As GraphicsPath
  1857.     Private CreateRoundRectangle As Rectangle
  1858.  
  1859.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1860.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1861.         Return CreateRound(CreateRoundRectangle, slope)
  1862.     End Function
  1863.  
  1864.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1865.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1866.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1867.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1868.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1869.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1870.         CreateRoundPath.CloseFigure()
  1871.         Return CreateRoundPath
  1872.     End Function
  1873.  
  1874. #End Region
  1875.  
  1876. End Class
  1877.  
  1878. Module ThemeShare
  1879.  
  1880. #Region " Animation "
  1881.  
  1882.     Private Frames As Integer
  1883.     Private Invalidate As Boolean
  1884.     Public ThemeTimer As New PrecisionTimer
  1885.  
  1886.     Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  1887.     Private Const Rate As Integer = 10
  1888.  
  1889.     Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  1890.  
  1891.     Private Callbacks As New List(Of AnimationDelegate)
  1892.  
  1893.     Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  1894.         Invalidate = (Frames >= FPS)
  1895.         If Invalidate Then Frames = 0
  1896.  
  1897.         SyncLock Callbacks
  1898.             For I As Integer = 0 To Callbacks.Count - 1
  1899.                 Callbacks(I).Invoke(Invalidate)
  1900.             Next
  1901.         End SyncLock
  1902.  
  1903.         Frames += Rate
  1904.     End Sub
  1905.  
  1906.     Private Sub InvalidateThemeTimer()
  1907.         If Callbacks.Count = 0 Then
  1908.             ThemeTimer.Delete()
  1909.         Else
  1910.             ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  1911.         End If
  1912.     End Sub
  1913.  
  1914.     Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  1915.         SyncLock Callbacks
  1916.             If Callbacks.Contains(callback) Then Return
  1917.  
  1918.             Callbacks.Add(callback)
  1919.             InvalidateThemeTimer()
  1920.         End SyncLock
  1921.     End Sub
  1922.  
  1923.     Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  1924.         SyncLock Callbacks
  1925.             If Not Callbacks.Contains(callback) Then Return
  1926.  
  1927.             Callbacks.Remove(callback)
  1928.             InvalidateThemeTimer()
  1929.         End SyncLock
  1930.     End Sub
  1931.  
  1932. #End Region
  1933.  
  1934. End Module
  1935.  
  1936. Enum MouseState As Byte
  1937.     None = 0
  1938.     Over = 1
  1939.     Down = 2
  1940.     Block = 3
  1941. End Enum
  1942.  
  1943. Structure Bloom
  1944.  
  1945.     Public _Name As String
  1946.     ReadOnly Property Name() As String
  1947.         Get
  1948.             Return _Name
  1949.         End Get
  1950.     End Property
  1951.  
  1952.     Private _Value As Color
  1953.     Property Value() As Color
  1954.         Get
  1955.             Return _Value
  1956.         End Get
  1957.         Set(ByVal value As Color)
  1958.             _Value = value
  1959.         End Set
  1960.     End Property
  1961.  
  1962.     Property ValueHex() As String
  1963.         Get
  1964.             Return String.Concat("#", _
  1965.             _Value.R.ToString("X2", Nothing), _
  1966.             _Value.G.ToString("X2", Nothing), _
  1967.             _Value.B.ToString("X2", Nothing))
  1968.         End Get
  1969.         Set(ByVal value As String)
  1970.             Try
  1971.                 _Value = ColorTranslator.FromHtml(value)
  1972.             Catch
  1973.                 Return
  1974.             End Try
  1975.         End Set
  1976.     End Property
  1977.  
  1978.  
  1979.     Sub New(ByVal name As String, ByVal value As Color)
  1980.         _Name = name
  1981.         _Value = value
  1982.     End Sub
  1983. End Structure
  1984.  
  1985. '------------------
  1986. 'Creator: aeonhack
  1987. 'Site: elitevs.net
  1988. 'Created: 11/30/2011
  1989. 'Changed: 11/30/2011
  1990. 'Version: 1.0.0
  1991. '------------------
  1992. Class PrecisionTimer
  1993.     Implements IDisposable
  1994.  
  1995.     Private _Enabled As Boolean
  1996.     ReadOnly Property Enabled() As Boolean
  1997.         Get
  1998.             Return _Enabled
  1999.         End Get
  2000.     End Property
  2001.  
  2002.     Private Handle As IntPtr
  2003.     Private TimerCallback As TimerDelegate
  2004.  
  2005.     <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")> _
  2006.     Private Shared Function CreateTimerQueueTimer( _
  2007.     ByRef handle As IntPtr, _
  2008.     ByVal queue As IntPtr, _
  2009.     ByVal callback As TimerDelegate, _
  2010.     ByVal state As IntPtr, _
  2011.     ByVal dueTime As UInteger, _
  2012.     ByVal period As UInteger, _
  2013.     ByVal flags As UInteger) As Boolean
  2014.     End Function
  2015.  
  2016.     <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")> _
  2017.     Private Shared Function DeleteTimerQueueTimer( _
  2018.     ByVal queue As IntPtr, _
  2019.     ByVal handle As IntPtr, _
  2020.     ByVal callback As IntPtr) As Boolean
  2021.     End Function
  2022.  
  2023.     Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  2024.  
  2025.     Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  2026.         If _Enabled Then Return
  2027.  
  2028.         TimerCallback = callback
  2029.         Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  2030.  
  2031.         If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  2032.         _Enabled = Success
  2033.     End Sub
  2034.  
  2035.     Sub Delete()
  2036.         If Not _Enabled Then Return
  2037.         Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  2038.  
  2039.         If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  2040.             ThrowNewException("DeleteTimerQueueTimer")
  2041.         End If
  2042.  
  2043.         _Enabled = Not Success
  2044.     End Sub
  2045.  
  2046.     Private Sub ThrowNewException(ByVal name As String)
  2047.         Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  2048.     End Sub
  2049.  
  2050.     Public Sub Dispose() Implements IDisposable.Dispose
  2051.         Delete()
  2052.     End Sub
  2053. End Class
  2054. #End Region
  2055.  
  2056. #Region " Draw Methods - xZ3ROxPROJ3CTx"
  2057. Module Draw
  2058.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  2059.         Dim P As GraphicsPath = New GraphicsPath()
  2060.         Dim ArcRectangleWidth As Integer = Curve * 2
  2061.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  2062.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  2063.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  2064.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  2065.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  2066.         Return P
  2067.     End Function
  2068.     Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
  2069.         Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
  2070.         Dim P As GraphicsPath = New GraphicsPath()
  2071.         Dim ArcRectangleWidth As Integer = Curve * 2
  2072.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  2073.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  2074.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  2075.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  2076.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  2077.         Return P
  2078.     End Function
  2079.     Private Function ImageFromCode(ByRef str$) As Image
  2080.         Dim imageBytes As Byte() = Convert.FromBase64String(str)
  2081.         Dim ms As New IO.MemoryStream(imageBytes, 0, imageBytes.Length) : ms.Write(imageBytes, 0, imageBytes.Length)
  2082.         Dim i As Image = Image.FromStream(ms, True) : Return i
  2083.     End Function
  2084.     Public Function TiledTextureFromCode(ByVal str As String) As TextureBrush
  2085.         Return New TextureBrush(Draw.ImageFromCode(str), WrapMode.Tile)
  2086.     End Function
  2087. End Module
  2088. #End Region
  2089.  
  2090. Class TwitchTheme
  2091.     Inherits ThemeContainer154
  2092.     Public Property Fill As Boolean
  2093.  
  2094.     Sub New()
  2095.         TransparencyKey = Color.Fuchsia
  2096.         BackColor = Color.Red
  2097.         Font = New Font("Segoe UI", 9)
  2098.         SetColor("Border", BackColor)
  2099.         Fill = True
  2100.     End Sub
  2101.  
  2102.     Dim Border As Color
  2103.     Protected Overrides Sub ColorHook()
  2104.         Border = GetColor("Border")
  2105.         BackColor = Color.White
  2106.     End Sub
  2107.  
  2108.     Protected Overrides Sub PaintHook()
  2109.         G.Clear(Border)
  2110.         G.FillRectangle(Brushes.White, New Rectangle(0, 0, Width, Height))
  2111.         G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, 0, Width, 30))
  2112.         'G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, 30, 10, Height - 30))
  2113.         'G.DrawLine(Pens.Black, Width - 11, 30, Width - 10, Height - 30)
  2114.         G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(Width - 10, 30, 10, Height - 30))
  2115.         'G.DrawLine(Pens.Black, 10, Height - 11, Width - 10, Height - 11)
  2116.         G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, Height - 10, Width, 10))
  2117.         DrawCorners(Color.Fuchsia)
  2118.         G.DrawString(FindForm.Text, Font, Brushes.White, 5, 6)
  2119.         If Fill = True Then
  2120.             G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, 0, Width, Height))
  2121.             DrawCorners(Color.Fuchsia)
  2122.             G.DrawString(FindForm.Text, Font, Brushes.White, 5, 6)
  2123.         End If
  2124.     End Sub
  2125. End Class
  2126.  
  2127. Class TwitchCollapseBox
  2128.     Inherits ThemeContainer154
  2129.     Public Property twIsCollapsable As Boolean
  2130.     Dim hgt As Integer
  2131.     Sub New()
  2132.         ControlMode = True
  2133.         SetColor("Border", Color.Red)
  2134.         SetColor("Header", Color.Red)
  2135.         SetColor("Text", Color.Red)
  2136.         Cursor = Cursors.Hand
  2137.         AddHandler TwitchCollapseBox.Click, AddressOf BoxClicked
  2138.         Size = New Size(245, 188)
  2139.         twIsCollapsable = True
  2140.     End Sub
  2141.  
  2142.     Private Sub BoxClicked(ByVal sender As Object, ByVal e As EventArgs)
  2143.         If twIsCollapsable = True Then
  2144.             If sender.Height > 25 Then
  2145.                 hgt = sender.Height
  2146.                 For Each ctrl As Control In sender.Controls
  2147.                     ctrl.Visible = False
  2148.                 Next
  2149.                 sender.Height = 25
  2150.             Else
  2151.                 sender.Height = hgt
  2152.                 For Each ctrl As Control In sender.Controls
  2153.                     ctrl.Visible = True
  2154.                 Next
  2155.             End If
  2156.         End If
  2157.     End Sub
  2158.  
  2159.     Dim border As Pen
  2160.     Dim headercolor, textcolor As Brush
  2161.  
  2162.     Protected Overrides Sub ColorHook()
  2163.         border = GetPen("Border")
  2164.         headercolor = GetBrush("Header")
  2165.         textcolor = GetBrush("Text")
  2166.     End Sub
  2167.  
  2168.     Protected Overrides Sub PaintHook()
  2169.         G.Clear(BackColor)
  2170.         G.DrawRectangle(border, New Rectangle(0, 0, Width - 1, Height - 1))
  2171.         G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, 0, Width - 1, Height - 1))
  2172.         G.FillRectangle(New SolidBrush(Color.FromArgb(40, 40, 40)), New Rectangle(0, 0, Width, Height))
  2173.         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2174.         DrawText(New SolidBrush(Color.FromArgb(87, 87, 87)), HorizontalAlignment.Left, 4, 0)
  2175.         G.DrawLine(Pens.Black, 0, Height, Width, Height)
  2176.         G.DrawLine(Pens.Black, 0, 24, Width, 24)
  2177.         If twIsCollapsable = True Then
  2178.             For Each ctrl As Control In Controls
  2179.                 If ctrl.Visible = False Then
  2180.                     G.DrawString("v", Font, New SolidBrush(Color.FromArgb(87, 87, 87)), Width - 20, 6)
  2181.                 Else
  2182.                     G.DrawString("^", Font, New SolidBrush(Color.FromArgb(87, 87, 87)), Width - 20, 8)
  2183.                 End If
  2184.             Next
  2185.         End If
  2186.     End Sub
  2187. End Class
  2188.  
  2189. Class TwitchTextBox
  2190.     Inherits ThemeControl154
  2191.  
  2192.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  2193.     Property TextAlign() As HorizontalAlignment
  2194.         Get
  2195.             Return _TextAlign
  2196.         End Get
  2197.         Set(ByVal value As HorizontalAlignment)
  2198.             _TextAlign = value
  2199.             If Base IsNot Nothing Then
  2200.                 Base.TextAlign = value
  2201.             End If
  2202.         End Set
  2203.     End Property
  2204.     Private _MaxLength As Integer = 32767
  2205.     Property MaxLength() As Integer
  2206.         Get
  2207.             Return _MaxLength
  2208.         End Get
  2209.         Set(ByVal value As Integer)
  2210.             _MaxLength = value
  2211.             If Base IsNot Nothing Then
  2212.                 Base.MaxLength = value
  2213.             End If
  2214.         End Set
  2215.     End Property
  2216.     Private _ReadOnly As Boolean
  2217.     Property [ReadOnly]() As Boolean
  2218.         Get
  2219.             Return _ReadOnly
  2220.         End Get
  2221.         Set(ByVal value As Boolean)
  2222.             _ReadOnly = value
  2223.             If Base IsNot Nothing Then
  2224.                 Base.ReadOnly = value
  2225.             End If
  2226.         End Set
  2227.     End Property
  2228.     Private _UseSystemPasswordChar As Boolean
  2229.     Property UseSystemPasswordChar() As Boolean
  2230.         Get
  2231.             Return _UseSystemPasswordChar
  2232.         End Get
  2233.         Set(ByVal value As Boolean)
  2234.             _UseSystemPasswordChar = value
  2235.             If Base IsNot Nothing Then
  2236.                 Base.UseSystemPasswordChar = value
  2237.             End If
  2238.         End Set
  2239.     End Property
  2240.     Private _Multiline As Boolean
  2241.     Property Multiline() As Boolean
  2242.         Get
  2243.             Return _Multiline
  2244.         End Get
  2245.         Set(ByVal value As Boolean)
  2246.             _Multiline = value
  2247.             If Base IsNot Nothing Then
  2248.                 Base.Multiline = value
  2249.  
  2250.                 If value Then
  2251.                     LockHeight = 0
  2252.                     Base.Height = Height - 11
  2253.                 Else
  2254.                     LockHeight = Base.Height + 11
  2255.                 End If
  2256.             End If
  2257.         End Set
  2258.     End Property
  2259.     Overrides Property Text As String
  2260.         Get
  2261.             Return MyBase.Text
  2262.         End Get
  2263.         Set(ByVal value As String)
  2264.             MyBase.Text = value
  2265.             If Base IsNot Nothing Then
  2266.                 Base.Text = value
  2267.             End If
  2268.         End Set
  2269.     End Property
  2270.     Overrides Property Font As Font
  2271.         Get
  2272.             Return MyBase.Font
  2273.         End Get
  2274.         Set(ByVal value As Font)
  2275.             MyBase.Font = value
  2276.             If Base IsNot Nothing Then
  2277.                 Base.Font = value
  2278.                 Base.Location = New Point(3, 5)
  2279.                 Base.Width = Width - 6
  2280.  
  2281.                 If Not _Multiline Then
  2282.                     LockHeight = Base.Height + 11
  2283.                 End If
  2284.             End If
  2285.         End Set
  2286.     End Property
  2287.  
  2288.     Protected Overrides Sub OnCreation()
  2289.         If Not Controls.Contains(Base) Then
  2290.             Controls.Add(Base)
  2291.         End If
  2292.     End Sub
  2293.  
  2294.     Private Base As TextBox
  2295.     Sub New()
  2296.         Base = New TextBox
  2297.         Dim sw As New System.Drawing.Size(245, 4)
  2298.         Size = sw
  2299.         Base.Font = Font
  2300.         Base.Text = Text
  2301.         Base.MaxLength = _MaxLength
  2302.         Base.Multiline = _Multiline
  2303.         Base.ReadOnly = _ReadOnly
  2304.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  2305.  
  2306.         Base.BorderStyle = BorderStyle.None
  2307.  
  2308.         Base.Location = New Point(5, 5)
  2309.         Base.Width = Width - 10
  2310.  
  2311.         If _Multiline Then
  2312.             Base.Height = Height - 11
  2313.         Else
  2314.             LockHeight = Base.Height + 11
  2315.         End If
  2316.  
  2317.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  2318.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  2319.  
  2320.  
  2321.         SetColor("Text", Color.White)
  2322.         SetColor("Back", 0, 0, 0)
  2323.         SetColor("Border1", Color.FromArgb(30, 30, 30))
  2324.         SetColor("Border2", Color.FromArgb(30, 30, 30))
  2325.     End Sub
  2326.  
  2327.     Private C1 As Color
  2328.     Private P1, P2 As Pen
  2329.  
  2330.     Protected Overrides Sub ColorHook()
  2331.         C1 = Color.FromArgb(50, 50, 50)
  2332.  
  2333.         P1 = GetPen("Border1")
  2334.         P2 = GetPen("Border2")
  2335.  
  2336.         Base.ForeColor = Color.White
  2337.         Base.BackColor = C1
  2338.     End Sub
  2339.  
  2340.     Protected Overrides Sub PaintHook()
  2341.         G.Clear(C1)
  2342.         SetColor("Text", Color.White)
  2343.         DrawBorders(P1, 1)
  2344.     End Sub
  2345.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  2346.         Text = Base.Text
  2347.     End Sub
  2348.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  2349.         If e.Control AndAlso e.KeyCode = Keys.A Then
  2350.             Base.SelectAll()
  2351.             e.SuppressKeyPress = True
  2352.         End If
  2353.     End Sub
  2354.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  2355.         Base.Location = New Point(5, 5)
  2356.         Base.Width = Width - 10
  2357.  
  2358.         If _Multiline Then
  2359.             Base.Height = Height - 11
  2360.         End If
  2361.  
  2362.  
  2363.         MyBase.OnResize(e)
  2364.     End Sub
  2365.  
  2366. End Class
  2367.  
  2368. Class TwitchButton
  2369.     Inherits ThemeControl154
  2370.     Public Property twNoRounding As Boolean
  2371.     Sub New()
  2372.         Cursor = Cursors.Hand
  2373.         Size = New Size(105, 31)
  2374.         Tag = "purple"
  2375.         Transparent = True
  2376.         BackColor = Color.Transparent
  2377.         Font = New Font("Verdana", 8.0!, FontStyle.Regular)
  2378.         twNoRounding = False
  2379.     End Sub
  2380.  
  2381.     Protected Overrides Sub ColorHook()
  2382.  
  2383.     End Sub
  2384.  
  2385.     Protected Overrides Sub PaintHook()
  2386.         G.SmoothingMode = SmoothingMode.HighQuality
  2387.         G.Clear(BackColor)
  2388.         Select Case Tag
  2389.             Case "purple"
  2390.                 Select Case State
  2391.                     Case MouseState.Down
  2392.                         If twNoRounding = True Then
  2393.                             DrawGradient(Color.FromArgb(80, 56, 129), Color.FromArgb(58, 37, 103), New Rectangle(0, 0, Width, Height), 90.0F)
  2394.                             G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  2395.                             DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2396.                         Else
  2397.                             Dim BackGrad As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(80, 56, 129), Color.FromArgb(58, 37, 103), 90S)
  2398.                             G.FillPath(BackGrad, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 4))
  2399.                             G.DrawPath(Pens.Black, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 4))
  2400.                             'Really easy to use. Instead of DrawRectangle, use DrawPath. Then instead of a rectangle, use my Draw function.
  2401.                             'The curve should be somewhere along the lines of 3-7
  2402.                         End If
  2403.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2404.                     Case Else
  2405.                         If twNoRounding = True Then
  2406.                             DrawGradient(Color.FromArgb(124, 96, 176), Color.FromArgb(87, 59, 139), New Rectangle(0, 0, Width, Height), 90.0F)
  2407.                             G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  2408.                             DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2409.                         Else
  2410.                             Dim BackGrad As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), Color.FromArgb(124, 96, 176), Color.FromArgb(87, 59, 139), 90S)
  2411.                             G.FillPath(BackGrad, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 4))
  2412.                             G.DrawPath(Pens.Black, Draw.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 4))
  2413.                             DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2414.                         End If
  2415.                 End Select
  2416.             Case "white"
  2417.                 Select Case State
  2418.                     Case MouseState.None
  2419.                         DrawGradient(Color.FromArgb(242, 242, 242), Color.FromArgb(225, 225, 225), New Rectangle(0, 0, Width, Height), 90.0F)
  2420.                         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(158, 158, 158))), New Rectangle(0, 0, Width - 1, Height - 1))
  2421.                         DrawText(New SolidBrush(Color.FromArgb(124, 124, 124)), HorizontalAlignment.Center, 0, 0)
  2422.                     Case MouseState.Down
  2423.                         DrawGradient(Color.FromArgb(213, 213, 213), Color.FromArgb(188, 188, 188), New Rectangle(0, 0, Width, Height), 90.0F)
  2424.                         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(121, 121, 121))), New Rectangle(0, 0, Width - 1, Height - 1))
  2425.                         DrawText(New SolidBrush(Color.FromArgb(124, 124, 124)), HorizontalAlignment.Center, 0, 0)
  2426.                     Case MouseState.Over
  2427.                         DrawGradient(Color.FromArgb(242, 242, 242), Color.FromArgb(223, 223, 223), New Rectangle(0, 0, Width, Height), 90.0F)
  2428.                         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(158, 158, 158))), New Rectangle(0, 0, Width - 1, Height - 1))
  2429.                         DrawText(New SolidBrush(Color.FromArgb(124, 124, 124)), HorizontalAlignment.Center, 0, 0)
  2430.                 End Select
  2431.             Case Else
  2432.                 Select Case State
  2433.                     Case MouseState.Down
  2434.                         DrawGradient(Color.FromArgb(80, 56, 129), Color.FromArgb(58, 37, 103), New Rectangle(0, 0, Width, Height), 90.0F)
  2435.                         G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  2436.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2437.                     Case Else
  2438.                         DrawGradient(Color.FromArgb(124, 96, 176), Color.FromArgb(87, 59, 139), New Rectangle(0, 0, Width, Height), 90.0F)
  2439.                         G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  2440.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  2441.                 End Select
  2442.         End Select
  2443.     End Sub
  2444. End Class
  2445.  
  2446. Class TwitchBigButton
  2447.     Inherits ThemeControl154
  2448.     Public Property twTabPageNumber As Integer
  2449.     Public Property twTabPage As TwitchTabControl
  2450.     Public Property twDoesTurnPurple As Boolean
  2451.     Public Property twStarred As Boolean
  2452. #Region "StarBase64"
  2453.     Dim StarBase64 As String = "iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAYAAABG1c6oAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAApNJREFUeNqs1F+IjFEYx/HvOeedd/7YGbIW28iSQiFZaUOScuHCBUltblZKknKlrNRMMyn37lAuFMpSbpQLd6RobZQkf5NYrGV27ezMO3Pe87iYndlprVg89Xbq7byf3t85zzlKROhasfekUvoU/1AijmoYoESEdDrN1qW9Oa28zNSJSqnaiJr8GKFqAzzjN945cZQro5MgwI7lpxuoUgqlNIraWEcFYbxcYFlnnBcDReJ+EhHBiaNUGUEDeJ4HwK3nJ7JObF4pjVYGrQxGexOPQWuN1gb8EvuObKbqio0/F3EANXAqCpLXdchE0NpQtIMUw0HG7SDrtqSJxQ2rNiygJJ8pyxBlGULE1SJ3dHQ01sJaC8Cu1Wdyno5mtDZYG9CS/s6eg50sWtpKEARUKxWisRiRSIS3L4foO3efd8+//ww2o3vXns15JpbR2lAsf2O09In129rpPryRL0OfSSaTXDvfz/3b74j5SRzVycjNVY/f9/hQVkHe6AiJaApP+3x8P0ylEtA6rw2lFF+HR9BG4XtRFGp6sBm9PNCTBcnHoymiXgvbd6+h/85rensu0X/nNdt2rsY3s/AjiVpXTBd5uvg9XVdzI+GrzOKVCR7dfY/vxRgPxujckubN0wKmMpdiUPg92Iwe2HQ996nwKhOPtJCIzqVQ/MBY6RtzWtI4V2WsNPzryNPFv3BvTzYVn5+fPasdrQypxEJSiTYQaZwg/adntY5eebg/W7VB3olDxBGLJNHaIBOonskFUEcvPujOWlvOOxfiJEQmcBE3M3Dq7ttwAnUhTtzMIv+qT62rxxdE/hJsRm88OZq14SSq/+VSraM3nx3Lhq6SB/6sD39X1lpEhK1LjudUfbv/V2n+c/0YACoUPoqk6OEIAAAAAElFTkSuQmCC"
  2454. #End Region
  2455.  
  2456.     Sub New()
  2457.         Cursor = Cursors.Hand
  2458.         Dim sw As New System.Drawing.Size(245, 30)
  2459.         Size = sw
  2460.         AddHandler TwitchBigButton.Click, AddressOf Clicked
  2461.         Transparent = True
  2462.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  2463.         BackColor = Color.Transparent
  2464.         twDoesTurnPurple = False
  2465.         twStarred = False
  2466.         twTabPageNumber = 1
  2467.         Tag = "black"
  2468.     End Sub
  2469.  
  2470.     Private Sub Clicked(ByVal sender As Object, ByVal e As EventArgs)
  2471.         If twDoesTurnPurple = True Then
  2472.             For Each C As Control In Parent.Controls
  2473.                 If C IsNot Me AndAlso TypeOf C Is TwitchBigButton Then
  2474.                     Select Case C.Tag
  2475.                         Case "purple"
  2476.                             DirectCast(C, TwitchBigButton).Tag = "black"
  2477.                         Case "purplebottom"
  2478.                             DirectCast(C, TwitchBigButton).Tag = "blackbottom"
  2479.                     End Select
  2480.                     C.Invalidate()
  2481.                 End If
  2482.             Next
  2483.             Select Case Tag
  2484.                 Case "black"
  2485.                     Tag = "purple"
  2486.                 Case "blackbottom"
  2487.                     Tag = "purplebottom"
  2488.             End Select
  2489.         End If
  2490.         If Not twTabPageNumber = Nothing Then
  2491.             Try
  2492.                 Methods.SelectTab(twTabPageNumber, twTabPage)
  2493.             Catch ex As Exception
  2494.  
  2495.             End Try
  2496.         End If
  2497.     End Sub
  2498.  
  2499.     Protected Overrides Sub ColorHook()
  2500.  
  2501.     End Sub
  2502.  
  2503.     Protected Overrides Sub PaintHook()
  2504.         G.Clear(BackColor)
  2505.         Select Case Tag
  2506.             Case "black"
  2507.                 Select Case State
  2508.                     Case MouseState.None
  2509.                         G.FillRectangle(New SolidBrush(Color.FromArgb(30, 30, 30)), New Rectangle(0, 0, Width, Height))
  2510.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2511.                         G.DrawLine(New Pen(Color.FromArgb(38, 38, 38)), New Point(1, 1), New Point(Width - 2, 1))
  2512.                         DrawText(New SolidBrush(Color.FromArgb(170, 170, 170)), HorizontalAlignment.Left, 30, 0)
  2513.                     Case MouseState.Over
  2514.                         G.FillRectangle(New SolidBrush(Color.FromArgb(35, 35, 35)), New Rectangle(0, 0, Width, Height))
  2515.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2516.                         G.DrawLine(New Pen(Color.FromArgb(38, 38, 38)), New Point(1, 1), New Point(Width - 2, 1))
  2517.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2518.                     Case MouseState.Down
  2519.                         G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), New Rectangle(0, 0, Width, Height))
  2520.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2521.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2522.                 End Select
  2523.                 If twStarred = True Then
  2524.                     Dim imageBytes As Byte() = Convert.FromBase64String(StarBase64)
  2525.                     Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)
  2526.                     Dim star As Image = Image.FromStream(ms, True)
  2527.                     G.DrawImage(star, Width - 20, 0, star.Width, star.Height)
  2528.                 End If
  2529.             Case "purple"
  2530.                 G.Clear(BackColor)
  2531.                 G.FillRectangle(New SolidBrush(Color.FromArgb(100, 65, 165)), New Rectangle(0, 0, Width, Height))
  2532.                 G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2533.                 DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2534.             Case "blackbottom"
  2535.                 Select Case State
  2536.                     Case MouseState.None
  2537.                         G.FillRectangle(New SolidBrush(Color.FromArgb(30, 30, 30)), New Rectangle(0, 0, Width, Height))
  2538.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2539.                         G.DrawLine(Pens.Black, 0, Height - 1, Width, Height - 1)
  2540.                         G.DrawLine(New Pen(Color.FromArgb(38, 38, 38)), New Point(1, 1), New Point(Width - 2, 1))
  2541.                         DrawText(New SolidBrush(Color.FromArgb(170, 170, 170)), HorizontalAlignment.Left, 30, 0)
  2542.                     Case MouseState.Over
  2543.                         G.FillRectangle(New SolidBrush(Color.FromArgb(35, 35, 35)), New Rectangle(0, 0, Width, Height))
  2544.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2545.                         G.DrawLine(Pens.Black, 0, Height - 1, Width, Height - 1)
  2546.                         G.DrawLine(New Pen(Color.FromArgb(38, 38, 38)), New Point(1, 1), New Point(Width - 2, 1))
  2547.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2548.                     Case MouseState.Down
  2549.                         G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), New Rectangle(0, 0, Width, Height))
  2550.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2551.                         G.DrawLine(Pens.Black, 0, Height - 1, Width, Height - 1)
  2552.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2553.                 End Select
  2554.                 If twStarred = True Then
  2555.                     Dim imageBytes As Byte() = Convert.FromBase64String(StarBase64)
  2556.                     Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)
  2557.                     Dim star As Image = Image.FromStream(ms, True)
  2558.                     G.DrawImage(star, Width - 20, 0, star.Width, star.Height)
  2559.                 End If
  2560.             Case "purplebottom"
  2561.                 G.FillRectangle(New SolidBrush(Color.FromArgb(100, 65, 165)), New Rectangle(0, 0, Width, Height))
  2562.                 G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2563.                 G.DrawLine(Pens.Black, 0, Height - 1, Width, Height - 1)
  2564.                 DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2565.             Case Else
  2566.                 Select Case State
  2567.                     Case MouseState.None
  2568.                         G.FillRectangle(New SolidBrush(Color.FromArgb(30, 30, 30)), New Rectangle(0, 0, Width, Height))
  2569.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2570.                         DrawText(New SolidBrush(Color.FromArgb(170, 170, 170)), HorizontalAlignment.Left, 30, 0)
  2571.                     Case MouseState.Over
  2572.                         G.FillRectangle(New SolidBrush(Color.FromArgb(35, 35, 35)), New Rectangle(0, 0, Width, Height))
  2573.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2574.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2575.                     Case MouseState.Down
  2576.                         G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), New Rectangle(0, 0, Width, Height))
  2577.                         G.DrawLine(Pens.Black, 0, 0, Width, 0)
  2578.                         DrawText(New SolidBrush(Color.White), HorizontalAlignment.Left, 30, 0)
  2579.                 End Select
  2580.                 If twStarred = True Then
  2581.                     Dim imageBytes As Byte() = Convert.FromBase64String(StarBase64)
  2582.                     Dim ms As New MemoryStream(imageBytes, 0, imageBytes.Length)
  2583.                     Dim star As Image = Image.FromStream(ms, True)
  2584.                     G.DrawImage(star, Width - 20, 0, star.Width, star.Height)
  2585.                 End If
  2586.         End Select
  2587.  
  2588.         If Not Image Is Nothing Then G.DrawImage(Image, 10, 7, 16, 16)
  2589.     End Sub
  2590. End Class
  2591.  
  2592. Class TwitchGroupBox
  2593.     Inherits ThemeContainer154
  2594.  
  2595.     Sub New()
  2596.         ControlMode = True
  2597.         Cursor = Cursors.Default
  2598.         Dim sw As New Size(129, 23)
  2599.         Size = sw
  2600.     End Sub
  2601.  
  2602.     Protected Overrides Sub ColorHook()
  2603.  
  2604.     End Sub
  2605.  
  2606.     Protected Overrides Sub PaintHook()
  2607.         G.Clear(BackColor)
  2608.         G.FillRectangle(New SolidBrush(Color.FromArgb(44, 44, 44)), New Rectangle(0, 0, Width, Height))
  2609.         G.FillRectangle(New SolidBrush(Color.FromArgb(25, 25, 25)), New Rectangle(0, 0, Width, 26))
  2610.         G.DrawLine(Pens.Black, 0, 26, Width, 26)
  2611.         G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  2612.         DrawText(Brushes.White, HorizontalAlignment.Center, 0, 0)
  2613.     End Sub
  2614. End Class
  2615.  
  2616. Class TwitchWhiteTextBox
  2617.     Inherits ThemeControl154
  2618.  
  2619.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  2620.     Property TextAlign() As HorizontalAlignment
  2621.         Get
  2622.             Return _TextAlign
  2623.         End Get
  2624.         Set(ByVal value As HorizontalAlignment)
  2625.             _TextAlign = value
  2626.             If Base IsNot Nothing Then
  2627.                 Base.TextAlign = value
  2628.             End If
  2629.         End Set
  2630.     End Property
  2631.     Private _MaxLength As Integer = 32767
  2632.     Property MaxLength() As Integer
  2633.         Get
  2634.             Return _MaxLength
  2635.         End Get
  2636.         Set(ByVal value As Integer)
  2637.             _MaxLength = value
  2638.             If Base IsNot Nothing Then
  2639.                 Base.MaxLength = value
  2640.             End If
  2641.         End Set
  2642.     End Property
  2643.     Private _ReadOnly As Boolean
  2644.     Property [ReadOnly]() As Boolean
  2645.         Get
  2646.             Return _ReadOnly
  2647.         End Get
  2648.         Set(ByVal value As Boolean)
  2649.             _ReadOnly = value
  2650.             If Base IsNot Nothing Then
  2651.                 Base.ReadOnly = value
  2652.             End If
  2653.         End Set
  2654.     End Property
  2655.     Private _UseSystemPasswordChar As Boolean
  2656.     Property UseSystemPasswordChar() As Boolean
  2657.         Get
  2658.             Return _UseSystemPasswordChar
  2659.         End Get
  2660.         Set(ByVal value As Boolean)
  2661.             _UseSystemPasswordChar = value
  2662.             If Base IsNot Nothing Then
  2663.                 Base.UseSystemPasswordChar = value
  2664.             End If
  2665.         End Set
  2666.     End Property
  2667.     Private _Multiline As Boolean
  2668.     Property Multiline() As Boolean
  2669.         Get
  2670.             Return _Multiline
  2671.         End Get
  2672.         Set(ByVal value As Boolean)
  2673.             _Multiline = value
  2674.             If Base IsNot Nothing Then
  2675.                 Base.Multiline = value
  2676.  
  2677.                 If value Then
  2678.                     LockHeight = 0
  2679.                     Base.Height = Height - 11
  2680.                 Else
  2681.                     LockHeight = Base.Height + 11
  2682.                 End If
  2683.             End If
  2684.         End Set
  2685.     End Property
  2686.     Overrides Property Text As String
  2687.         Get
  2688.             Return MyBase.Text
  2689.         End Get
  2690.         Set(ByVal value As String)
  2691.             MyBase.Text = value
  2692.             If Base IsNot Nothing Then
  2693.                 Base.Text = value
  2694.             End If
  2695.         End Set
  2696.     End Property
  2697.  
  2698.     Overrides Property Font As Font
  2699.         Get
  2700.             Return MyBase.Font
  2701.         End Get
  2702.         Set(ByVal value As Font)
  2703.             MyBase.Font = value
  2704.             If Base IsNot Nothing Then
  2705.                 Base.Font = value
  2706.                 Base.Location = New Point(3, 5)
  2707.                 Base.Width = Width - 6
  2708.  
  2709.                 If Not _Multiline Then
  2710.                     LockHeight = Base.Height + 11
  2711.                 End If
  2712.             End If
  2713.         End Set
  2714.     End Property
  2715.  
  2716.     Protected Overrides Sub OnCreation()
  2717.         If Not Controls.Contains(Base) Then
  2718.             Controls.Add(Base)
  2719.         End If
  2720.     End Sub
  2721.  
  2722.     Public Property GhostText As String
  2723.  
  2724.     Private Base As TextBox
  2725.     Sub New()
  2726.         Base = New TextBox
  2727.         Dim sw As New System.Drawing.Size(245, 4)
  2728.         Size = sw
  2729.         Base.Font = Font
  2730.         Base.Text = Text
  2731.         Base.MaxLength = _MaxLength
  2732.         Base.Multiline = _Multiline
  2733.         Base.ReadOnly = _ReadOnly
  2734.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  2735.  
  2736.         Base.BorderStyle = BorderStyle.None
  2737.  
  2738.         Base.Location = New Point(5, 5)
  2739.         Base.Width = Width - 10
  2740.  
  2741.         If _Multiline Then
  2742.             Base.Height = Height - 11
  2743.         Else
  2744.             LockHeight = Base.Height + 11
  2745.         End If
  2746.  
  2747.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  2748.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  2749.  
  2750.  
  2751.         SetColor("Text", Color.FromArgb(73, 73, 73))
  2752.         SetColor("Back", 0, 0, 0)
  2753.         SetColor("Border1", Color.FromArgb(100, 65, 165))
  2754.         SetColor("Border2", Color.FromArgb(100, 65, 165))
  2755.     End Sub
  2756.  
  2757.     Private C1 As Color
  2758.     Private P1, P2 As Pen
  2759.  
  2760.     Protected Overrides Sub ColorHook()
  2761.         C1 = Color.White
  2762.  
  2763.         P1 = GetPen("Border1")
  2764.         P2 = GetPen("Border2")
  2765.  
  2766.         Base.ForeColor = Color.FromArgb(73, 73, 73)
  2767.         Base.BackColor = C1
  2768.     End Sub
  2769.  
  2770.     Protected Overrides Sub PaintHook()
  2771.         G.Clear(C1)
  2772.         SetColor("Text", Color.FromArgb(73, 73, 73))
  2773.         DrawBorders(P1, 1)
  2774.         G.DrawString(GhostText, Font, Brushes.Gray, 10, 5)
  2775.     End Sub
  2776.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  2777.         Text = Base.Text
  2778.     End Sub
  2779.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  2780.         If e.Control AndAlso e.KeyCode = Keys.A Then
  2781.             Base.SelectAll()
  2782.             e.SuppressKeyPress = True
  2783.         End If
  2784.     End Sub
  2785.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  2786.         Base.Location = New Point(5, 5)
  2787.         Base.Width = Width - 10
  2788.  
  2789.         If _Multiline Then
  2790.             Base.Height = Height - 11
  2791.         End If
  2792.  
  2793.  
  2794.         MyBase.OnResize(e)
  2795.     End Sub
  2796.  
  2797. End Class
  2798.  
  2799. Class TwitchColorSpace
  2800.     Inherits ThemeContainer154
  2801.  
  2802.     Sub New()
  2803.         ControlMode = True
  2804.         BackColor = Drawing.Color.White
  2805.     End Sub
  2806.  
  2807.     Protected Overrides Sub ColorHook()
  2808.  
  2809.     End Sub
  2810.  
  2811.     Protected Overrides Sub PaintHook()
  2812.         G.FillRectangle(New SolidBrush(BackColor), New Rectangle(0, 0, Width, Height))
  2813.     End Sub
  2814. End Class
  2815.  
  2816. Class TwitchTrackBar
  2817.     Inherits ThemeControl154
  2818.  
  2819.     Sub New()
  2820.         Width = 100
  2821.         Height = 10
  2822.         Transparent = True
  2823.         BackColor = Color.Transparent
  2824.         Cursor = Cursors.Hand
  2825.         Size = New Size(125, 30)
  2826.     End Sub
  2827.  
  2828.     Protected Overrides Sub ColorHook()
  2829.  
  2830.     End Sub
  2831.  
  2832.     Protected Overrides Sub PaintHook()
  2833.         G.Clear(BackColor)
  2834.         Select Case State
  2835.             Case MouseState.Over
  2836.                 DrawGradient(Color.FromArgb(222, 209, 246), Color.FromArgb(171, 134, 231), New Rectangle(0, 10, Width, 10))
  2837.                 G.DrawRectangle(Pens.Black, New Rectangle(0, 10, Width, 10))
  2838.                 DrawGradient(Color.FromArgb(245, 245, 245), Color.FromArgb(206, 206, 206), New Rectangle(Width - 7, 6, 7, 17))
  2839.                 G.DrawRectangle(Pens.Black, New Rectangle(Width - 7, 6, 7, 17))
  2840.             Case MouseState.None
  2841.                 DrawGradient(Color.FromArgb(222, 209, 246), Color.FromArgb(171, 134, 231), New Rectangle(0, 10, Width, 10))
  2842.                 G.DrawRectangle(Pens.Black, New Rectangle(0, 10, Width, 10))
  2843.                 DrawGradient(Color.FromArgb(207, 207, 207), Color.FromArgb(150, 150, 150), New Rectangle(Width - 7, 6, 7, 17))
  2844.                 G.DrawRectangle(Pens.Black, New Rectangle(Width - 7, 6, 7, 17))
  2845.             Case MouseState.Down
  2846.                 DrawGradient(Color.FromArgb(222, 209, 246), Color.FromArgb(171, 134, 231), New Rectangle(0, 10, Width, 10))
  2847.                 G.DrawRectangle(Pens.Black, New Rectangle(0, 10, Width, 10))
  2848.                 DrawGradient(Color.FromArgb(144, 144, 144), Color.FromArgb(100, 100, 100), New Rectangle(Width - 7, 6, 7, 17))
  2849.                 G.DrawRectangle(Pens.Black, New Rectangle(Width - 7, 6, 7, 17))
  2850.             Case Else
  2851.                 DrawGradient(Color.FromArgb(222, 209, 246), Color.FromArgb(171, 134, 231), New Rectangle(0, 10, Width, 10))
  2852.                 G.DrawRectangle(Pens.Black, New Rectangle(0, 10, Width, 10))
  2853.                 DrawGradient(Color.FromArgb(207, 207, 207), Color.FromArgb(150, 150, 150), New Rectangle(Width - 7, 6, 7, 17))
  2854.                 G.DrawRectangle(Pens.Black, New Rectangle(Width - 7, 6, 7, 17))
  2855.         End Select
  2856.  
  2857.     End Sub
  2858. End Class
  2859.  
  2860. Class TwitchLabel
  2861.     Inherits Label
  2862.  
  2863.     Sub New()
  2864.         BackColor = Color.Transparent
  2865.         ForeColor = Color.FromArgb(153, 153, 153)
  2866.     End Sub
  2867. End Class
  2868.  
  2869. Class TwitchTabControl
  2870.     Inherits TabControl
  2871.     Public Property Color As Color = Color.FromArgb(40, 40, 40)
  2872.  
  2873.     Sub New()
  2874.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
  2875.         DoubleBuffered = True
  2876.         SizeMode = TabSizeMode.Fixed
  2877.         ItemSize = New Size(5, 5)
  2878.         For Each Page As TabPage In TabPages
  2879.             Page.BackColor = Drawing.Color.FromArgb(40, 40, 40)
  2880.         Next
  2881.     End Sub
  2882.  
  2883.     Protected Overrides Sub CreateHandle()
  2884.         MyBase.CreateHandle()
  2885.         Alignment = TabAlignment.Left
  2886.     End Sub
  2887.  
  2888.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2889.         Dim B As New Bitmap(Width, Height)
  2890.         Dim G As Graphics = Graphics.FromImage(B)
  2891.         G.Clear(Color)
  2892.         If DesignMode = True Then
  2893.             For i = 0 To TabCount - 1
  2894.                 Dim TabRectangle As Rectangle = GetTabRect(i)
  2895.                 If i = SelectedIndex Then
  2896.                     G.FillRectangle(New SolidBrush(Color.FromArgb(100, 65, 165)), TabRectangle)
  2897.                 Else
  2898.                     G.FillRectangle(New SolidBrush(Color.FromArgb(30, 30, 30)), TabRectangle)
  2899.                 End If
  2900.             Next
  2901.         End If
  2902.  
  2903.  
  2904.         e.Graphics.DrawImage(B.Clone, 0, 0)
  2905.         G.Dispose() : B.Dispose()
  2906.         MyBase.OnPaint(e)
  2907.     End Sub
  2908. End Class
  2909.  
  2910. Public Class TwitchProgressBar : Inherits Control
  2911.     Private _Value As Integer = 0
  2912.     Public Property Value() As Integer
  2913.         Get
  2914.             Return _Value
  2915.         End Get
  2916.         Set(ByVal value As Integer)
  2917.             If value > _Maximum OrElse value < _Minimum Then
  2918.                 Throw New Exception("Property value is not valid.")
  2919.             End If
  2920.             _Value = value
  2921.             Invalidate()
  2922.         End Set
  2923.     End Property
  2924.     Private _Minimum As Integer = 0
  2925.     Public Property Minimum() As Integer
  2926.         Get
  2927.             Return _Minimum
  2928.         End Get
  2929.         Set(ByVal value As Integer)
  2930.             If value < 0 Then
  2931.                 Throw New Exception("Property value is not valid.")
  2932.             End If
  2933.             _Minimum = value
  2934.             If value > _Value Then _Value = value
  2935.             If value > _Maximum Then _Maximum = value
  2936.             Invalidate()
  2937.  
  2938.         End Set
  2939.     End Property
  2940.     Private _Maximum As Integer = 100
  2941.     Public Property Maximum() As Integer
  2942.         Get
  2943.             Return _Maximum
  2944.         End Get
  2945.         Set(ByVal value As Integer)
  2946.             If value < 0 Then
  2947.                 Throw New Exception("Property value is not valid.")
  2948.             End If
  2949.  
  2950.             _Maximum = value
  2951.             If value < _Value Then _Value = value
  2952.             If value < _Minimum Then _Minimum = value
  2953.             Invalidate()
  2954.         End Set
  2955.     End Property
  2956.     Public Sub Increment(ByVal amount As Integer)
  2957.         Value += amount
  2958.     End Sub
  2959.     Sub New()
  2960.         Size = New Size(309, 10)
  2961.         BackColor = Color.FromArgb(51, 51, 51)
  2962.     End Sub
  2963.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2964.         Dim B As New Bitmap(Width, Height)
  2965.         Dim G As Graphics = Graphics.FromImage(B)
  2966.         G.SmoothingMode = SmoothingMode.HighQuality
  2967.         Dim Progress As Integer = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width))
  2968.         'Progress is going to be your width of a rectangle/path. For example...
  2969.         MyBase.OnPaint(e)
  2970.  
  2971.         'Now just design to your heart's content.
  2972.         G.Clear(BackColor)
  2973.         G.FillRectangle(New SolidBrush(Color.FromArgb(185, 155, 235)), New Rectangle(0, 0, Progress - 1, Height - 1))
  2974.         e.Graphics.DrawImage(B, New Point(0, 0))
  2975.         G.Dispose() : B.Dispose()
  2976.     End Sub
  2977. End Class
  2978.  
  2979. Class TwitchRadiobutton
  2980.     Inherits ThemeControl154
  2981.     Private X As Integer
  2982.     Private _Checked As Boolean
  2983.  
  2984.     Property Checked() As Boolean
  2985.         Get
  2986.             Return _Checked
  2987.         End Get
  2988.         Set(ByVal value As Boolean)
  2989.             _Checked = value
  2990.             InvalidateControls()
  2991.             RaiseEvent CheckedChanged(Me)
  2992.             Invalidate()
  2993.         End Set
  2994.     End Property
  2995.  
  2996.     Event CheckedChanged(ByVal sender As Object)
  2997.  
  2998.     Protected Overrides Sub OnCreation()
  2999.         InvalidateControls()
  3000.     End Sub
  3001.  
  3002.     Private Sub InvalidateControls()
  3003.         If Not IsHandleCreated OrElse Not _Checked Then Return
  3004.  
  3005.         For Each C As Control In Parent.Controls
  3006.             If C IsNot Me AndAlso TypeOf C Is TwitchRadiobutton Then
  3007.                 DirectCast(C, TwitchRadiobutton).Checked = False
  3008.             End If
  3009.         Next
  3010.     End Sub
  3011.  
  3012.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  3013.         If Not _Checked Then Checked = True
  3014.         MyBase.OnMouseDown(e)
  3015.     End Sub
  3016.  
  3017.     Protected Overrides Sub OnMouseMove(e As System.Windows.Forms.MouseEventArgs)
  3018.         MyBase.OnMouseMove(e)
  3019.         X = e.X
  3020.         Invalidate()
  3021.     End Sub
  3022.  
  3023.     Dim textcolor As Brush
  3024.     Dim circlecolor As Pen
  3025.  
  3026.     Protected Overrides Sub ColorHook()
  3027.         textcolor = GetBrush("Text")
  3028.         circlecolor = GetPen("Circle")
  3029.     End Sub
  3030.  
  3031.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  3032.         MyBase.OnTextChanged(e)
  3033.     End Sub
  3034.  
  3035.     Protected Overrides Sub PaintHook()
  3036.         G.Clear(BackColor)
  3037.         G.SmoothingMode = SmoothingMode.HighQuality
  3038.         If _Checked Then
  3039.             G.FillRectangle(New SolidBrush(Color.FromArgb(195, 195, 195)), New Rectangle(0, 0, Width, Height))
  3040.             G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(150, 150, 150))), New Rectangle(0, 0, Width - 1, Height - 1))
  3041.             DrawText(New SolidBrush(Color.White), HorizontalAlignment.Center, 0, 0)
  3042.         Else
  3043.             DrawGradient(Color.FromArgb(242, 242, 242), Color.FromArgb(223, 223, 223), New Rectangle(0, 0, Width, Height), 90.0F)
  3044.             G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(150, 150, 150))), New Rectangle(0, 0, Width - 1, Height - 1))
  3045.             DrawText(New SolidBrush(Color.FromArgb(30, 30, 30)), HorizontalAlignment.Center, 0, 0)
  3046.         End If
  3047.     End Sub
  3048.  
  3049.     Public Sub New()
  3050.         SetColor("Text", Color.Black)
  3051.         SetColor("Circle", Color.FromArgb(0, 239, 255))
  3052.         Me.Size = New Point(147, 29)
  3053.         Cursor = Cursors.Hand
  3054.     End Sub
  3055. End Class
  3056.  
  3057. 'XZ3ROXPROJ3CTX
  3058. Public Class RedemptionControlBox : Inherits Control
  3059.  
  3060.     Sub New()
  3061.         MyBase.New()
  3062.         DoubleBuffered = True
  3063.         SetStyle(ControlStyles.AllPaintingInWmPaint, True)
  3064.         SetStyle(ControlStyles.UserPaint, True)
  3065.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  3066.         SetStyle(ControlStyles.ResizeRedraw, True)
  3067.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  3068.         ForeColor = Color.White
  3069.         BackColor = Color.Transparent
  3070.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  3071.     End Sub
  3072.     Protected Overrides Sub OnResize(e As EventArgs)
  3073.         MyBase.OnResize(e)
  3074.         Size = New Size(60, 25)
  3075.     End Sub
  3076.     Enum ButtonHover
  3077.         Minimize
  3078.         Maximize
  3079.         Close
  3080.         None
  3081.     End Enum
  3082.     Dim ButtonState As ButtonHover = ButtonHover.None
  3083.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  3084.         MyBase.OnMouseMove(e)
  3085.         Dim X As Integer = e.Location.X
  3086.         Dim Y As Integer = e.Location.Y
  3087.         If Y > 0 AndAlso Y < (Height - 2) Then
  3088.             If X > 0 AndAlso X < 30 Then
  3089.                 ButtonState = ButtonHover.Minimize
  3090.             ElseIf X > 31 AndAlso X < Width Then
  3091.                 ButtonState = ButtonHover.Close
  3092.             Else
  3093.                 ButtonState = ButtonHover.None
  3094.             End If
  3095.         Else
  3096.             ButtonState = ButtonHover.None
  3097.         End If
  3098.         Invalidate()
  3099.     End Sub
  3100.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3101.         Dim B As New Bitmap(Width, Height)
  3102.         Dim G As Graphics = Graphics.FromImage(B)
  3103.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  3104.         MyBase.OnPaint(e)
  3105.  
  3106.         G.Clear(BackColor)
  3107.         Dim ButtonFont As New Font("Marlett", 10.0F)
  3108.         G.DrawString("r", ButtonFont, New SolidBrush(Color.FromArgb(200, 200, 200)), New Point(Width - 16, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  3109.         G.DrawString("0", ButtonFont, New SolidBrush(Color.FromArgb(200, 200, 200)), New Point(20, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  3110.  
  3111.         Select Case ButtonState
  3112.             Case ButtonHover.Minimize
  3113.                 G.DrawString("0", ButtonFont, New SolidBrush(Color.White), New Point(20, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  3114.             Case ButtonHover.Close
  3115.                 G.DrawString("r", ButtonFont, New SolidBrush(Color.White), New Point(Width - 16, 7), New StringFormat With {.Alignment = StringAlignment.Center})
  3116.         End Select
  3117.  
  3118.  
  3119.  
  3120.         e.Graphics.DrawImage(B, New Point(0, 0))
  3121.         G.Dispose() : B.Dispose()
  3122.     End Sub
  3123.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  3124.         MyBase.OnMouseDown(e)
  3125.         Select Case ButtonState
  3126.             Case ButtonHover.Close
  3127.                 Parent.FindForm().Close()
  3128.             Case ButtonHover.Minimize
  3129.                 Parent.FindForm().WindowState = FormWindowState.Minimized
  3130.             Case ButtonHover.Maximize
  3131.                 Parent.FindForm().WindowState = FormWindowState.Maximized
  3132.         End Select
  3133.         Invalidate()
  3134.     End Sub
  3135.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  3136.         MyBase.OnMouseLeave(e)
  3137.         ButtonState = ButtonHover.None : Invalidate()
  3138.     End Sub
  3139. End Class
  3140.  
  3141. Class Methods
  3142.     Public Shared Sub SelectTab(ByVal Num As Integer, ByVal Control As TwitchTabControl)
  3143.         Control.SelectedIndex = Num - 1
  3144.     End Sub
  3145. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement