Advertisement
AkoSiNovi

[VB.NET] OrainsTheme

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