Advertisement
RudaGabriel

Qube Theme With TB

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