Stoffel

Untitled

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