AkoSiNovi

[VB.NET]CarbonFibreTheme

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