Advertisement
Guest User

Untitled

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