Advertisement
Guest User

Influx Theme

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