SHARE
TWEET

Untitled

a guest Aug 14th, 2016 411 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System
  2. Imports System.Windows.Forms
  3. Imports System.Drawing
  4. Imports System.Drawing.Drawing2D
  5. Imports System.Drawing.Text
  6. Imports System.ComponentModel
  7. Imports System.Collections.Generic
  8. Imports System.Text
  9. Imports System.Runtime.InteropServices
  10. Imports System.Drawing.Imaging
  11. Imports System.IO
  12.  
  13. '------------------
  14. 'Creator: aeonhack
  15. 'Site: elitevs.net
  16. 'Created: 08/02/2011
  17. 'Changed: 12/06/2011
  18. 'Version: 1.5.4
  19. '------------------
  20.  
  21. MustInherit Class ThemeContainer154
  22.     Inherits ContainerControl
  23.  
  24. #Region " Initialization "
  25.  
  26.     Protected G As Graphics, B As Bitmap
  27.  
  28.     Sub New()
  29.         SetStyle(DirectCast(139270, ControlStyles), True)
  30.  
  31.         _ImageSize = Size.Empty
  32.         Font = New Font("Verdana", 8S)
  33.  
  34.         MeasureBitmap = New Bitmap(1, 1)
  35.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  36.  
  37.         DrawRadialPath = New GraphicsPath
  38.  
  39.         InvalidateCustimization()
  40.     End Sub
  41.  
  42.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  43.         If DoneCreation Then InitializeMessages()
  44.  
  45.         InvalidateCustimization()
  46.         ColorHook()
  47.  
  48.         If Not _LockWidth = 0 Then Width = _LockWidth
  49.         If Not _LockHeight = 0 Then Height = _LockHeight
  50.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  51.  
  52.         Transparent = _Transparent
  53.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  54.  
  55.         MyBase.OnHandleCreated(e)
  56.     End Sub
  57.  
  58.     Private DoneCreation As Boolean
  59.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  60.         MyBase.OnParentChanged(e)
  61.  
  62.         If Parent Is Nothing Then Return
  63.         _IsParentForm = TypeOf Parent Is Form
  64.  
  65.         If Not _ControlMode Then
  66.             InitializeMessages()
  67.  
  68.             If _IsParentForm Then
  69.                 ParentForm.FormBorderStyle = _BorderStyle
  70.                 ParentForm.TransparencyKey = _TransparencyKey
  71.  
  72.                 If Not DesignMode Then
  73.                     AddHandler ParentForm.Shown, AddressOf FormShown
  74.                 End If
  75.             End If
  76.  
  77.             Parent.BackColor = BackColor
  78.         End If
  79.  
  80.         OnCreation()
  81.         DoneCreation = True
  82.         InvalidateTimer()
  83.     End Sub
  84.  
  85. #End Region
  86.  
  87.     Private Sub DoAnimation(ByVal i As Boolean)
  88.         OnAnimation()
  89.         If i Then Invalidate()
  90.     End Sub
  91.  
  92.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  93.         If Width = 0 OrElse Height = 0 Then Return
  94.  
  95.         If _Transparent AndAlso _ControlMode Then
  96.             PaintHook()
  97.             e.Graphics.DrawImage(B, 0, 0)
  98.         Else
  99.             G = e.Graphics
  100.             PaintHook()
  101.         End If
  102.     End Sub
  103.  
  104.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  105.         RemoveAnimationCallback(AddressOf DoAnimation)
  106.         MyBase.OnHandleDestroyed(e)
  107.     End Sub
  108.  
  109.     Private HasShown As Boolean
  110.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  111.         If _ControlMode OrElse HasShown Then Return
  112.  
  113.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  114.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  115.             Dim CB As Rectangle = ParentForm.Bounds
  116.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  117.         End If
  118.  
  119.         HasShown = True
  120.     End Sub
  121.  
  122.  
  123. #Region " Size Handling "
  124.  
  125.     Private Frame As Rectangle
  126.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  127.         If _Movable AndAlso Not _ControlMode Then
  128.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  129.         End If
  130.  
  131.         InvalidateBitmap()
  132.         Invalidate()
  133.  
  134.         MyBase.OnSizeChanged(e)
  135.     End Sub
  136.  
  137.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  138.         If Not _LockWidth = 0 Then width = _LockWidth
  139.         If Not _LockHeight = 0 Then height = _LockHeight
  140.         MyBase.SetBoundsCore(x, y, width, height, specified)
  141.     End Sub
  142.  
  143. #End Region
  144.  
  145. #Region " State Handling "
  146.  
  147.     Protected State As MouseState
  148.     Private Sub SetState(ByVal current As MouseState)
  149.         State = current
  150.         Invalidate()
  151.     End Sub
  152.  
  153.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  154.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  155.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  156.         End If
  157.  
  158.         MyBase.OnMouseMove(e)
  159.     End Sub
  160.  
  161.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  162.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  163.         MyBase.OnEnabledChanged(e)
  164.     End Sub
  165.  
  166.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  167.         SetState(MouseState.Over)
  168.         MyBase.OnMouseEnter(e)
  169.     End Sub
  170.  
  171.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  172.         SetState(MouseState.Over)
  173.         MyBase.OnMouseUp(e)
  174.     End Sub
  175.  
  176.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  177.         SetState(MouseState.None)
  178.  
  179.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  180.             If _Sizable AndAlso Not _ControlMode Then
  181.                 Cursor = Cursors.Default
  182.                 Previous = 0
  183.             End If
  184.         End If
  185.  
  186.         MyBase.OnMouseLeave(e)
  187.     End Sub
  188.  
  189.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  190.         If e.Button = System.Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  191.  
  192.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  193.             If _Movable AndAlso Frame.Contains(e.Location) Then
  194.                 Capture = False
  195.                 WM_LMBUTTONDOWN = True
  196.                 DefWndProc(Messages(0))
  197.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  198.                 Capture = False
  199.                 WM_LMBUTTONDOWN = True
  200.                 DefWndProc(Messages(Previous))
  201.             End If
  202.         End If
  203.  
  204.         MyBase.OnMouseDown(e)
  205.     End Sub
  206.  
  207.     Private WM_LMBUTTONDOWN As Boolean
  208.     Protected Overrides Sub WndProc(ByRef m As Message)
  209.         MyBase.WndProc(m)
  210.  
  211.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  212.             WM_LMBUTTONDOWN = False
  213.  
  214.             SetState(MouseState.Over)
  215.             If Not _SmartBounds Then Return
  216.  
  217.             If IsParentMdi Then
  218.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  219.             Else
  220.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  221.             End If
  222.         End If
  223.     End Sub
  224.  
  225.     Private GetIndexPoint As Point
  226.     Private B1, B2, B3, B4 As Boolean
  227.     Private Function GetIndex() As Integer
  228.         GetIndexPoint = PointToClient(MousePosition)
  229.         B1 = GetIndexPoint.X < 7
  230.         B2 = GetIndexPoint.X > Width - 7
  231.         B3 = GetIndexPoint.Y < 7
  232.         B4 = GetIndexPoint.Y > Height - 7
  233.  
  234.         If B1 AndAlso B3 Then Return 4
  235.         If B1 AndAlso B4 Then Return 7
  236.         If B2 AndAlso B3 Then Return 5
  237.         If B2 AndAlso B4 Then Return 8
  238.         If B1 Then Return 1
  239.         If B2 Then Return 2
  240.         If B3 Then Return 3
  241.         If B4 Then Return 6
  242.         Return 0
  243.     End Function
  244.  
  245.     Private Current, Previous As Integer
  246.     Private Sub InvalidateMouse()
  247.         Current = GetIndex()
  248.         If Current = Previous Then Return
  249.  
  250.         Previous = Current
  251.         Select Case Previous
  252.             Case 0
  253.                 Cursor = Cursors.Default
  254.             Case 1, 2
  255.                 Cursor = Cursors.SizeWE
  256.             Case 3, 6
  257.                 Cursor = Cursors.SizeNS
  258.             Case 4, 8
  259.                 Cursor = Cursors.SizeNWSE
  260.             Case 5, 7
  261.                 Cursor = Cursors.SizeNESW
  262.         End Select
  263.     End Sub
  264.  
  265.     Private Messages(8) As Message
  266.     Private Sub InitializeMessages()
  267.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  268.         For I As Integer = 1 To 8
  269.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  270.         Next
  271.     End Sub
  272.  
  273.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  274.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  275.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  276.  
  277.         Dim X As Integer = Parent.Location.X
  278.         Dim Y As Integer = Parent.Location.Y
  279.  
  280.         If X < bounds.X Then X = bounds.X
  281.         If Y < bounds.Y Then Y = bounds.Y
  282.  
  283.         Dim Width As Integer = bounds.X + bounds.Width
  284.         Dim Height As Integer = bounds.Y + bounds.Height
  285.  
  286.         If X + Parent.Width > Width Then X = Width - Parent.Width
  287.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  288.  
  289.         Parent.Location = New Point(X, Y)
  290.     End Sub
  291.  
  292. #End Region
  293.  
  294.  
  295. #Region " Base Properties "
  296.  
  297.     Overrides Property Dock As DockStyle
  298.         Get
  299.             Return MyBase.Dock
  300.         End Get
  301.         Set(ByVal value As DockStyle)
  302.             If Not _ControlMode Then Return
  303.             MyBase.Dock = value
  304.         End Set
  305.     End Property
  306.  
  307.     Private _BackColor As Boolean
  308.     <Category("Misc")>
  309.     Overrides Property BackColor() As Color
  310.         Get
  311.             Return MyBase.BackColor
  312.         End Get
  313.         Set(ByVal value As Color)
  314.             If value = MyBase.BackColor Then Return
  315.  
  316.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  317.                 _BackColor = True
  318.                 Return
  319.             End If
  320.  
  321.             MyBase.BackColor = value
  322.             If Parent IsNot Nothing Then
  323.                 If Not _ControlMode Then Parent.BackColor = value
  324.                 ColorHook()
  325.             End If
  326.         End Set
  327.     End Property
  328.  
  329.     Overrides Property MinimumSize As Size
  330.         Get
  331.             Return MyBase.MinimumSize
  332.         End Get
  333.         Set(ByVal value As Size)
  334.             MyBase.MinimumSize = value
  335.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  336.         End Set
  337.     End Property
  338.  
  339.     Overrides Property MaximumSize As Size
  340.         Get
  341.             Return MyBase.MaximumSize
  342.         End Get
  343.         Set(ByVal value As Size)
  344.             MyBase.MaximumSize = value
  345.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  346.         End Set
  347.     End Property
  348.  
  349.     Overrides Property Text() As String
  350.         Get
  351.             Return MyBase.Text
  352.         End Get
  353.         Set(ByVal value As String)
  354.             MyBase.Text = value
  355.             Invalidate()
  356.         End Set
  357.     End Property
  358.  
  359.     Overrides Property Font() As Font
  360.         Get
  361.             Return MyBase.Font
  362.         End Get
  363.         Set(ByVal value As Font)
  364.             MyBase.Font = value
  365.             Invalidate()
  366.         End Set
  367.     End Property
  368.  
  369.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  370.     Overrides Property ForeColor() As Color
  371.         Get
  372.             Return Color.Empty
  373.         End Get
  374.         Set(ByVal value As Color)
  375.         End Set
  376.     End Property
  377.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  378.     Overrides Property BackgroundImage() As Image
  379.         Get
  380.             Return Nothing
  381.         End Get
  382.         Set(ByVal value As Image)
  383.         End Set
  384.     End Property
  385.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  386.     Overrides Property BackgroundImageLayout() As ImageLayout
  387.         Get
  388.             Return ImageLayout.None
  389.         End Get
  390.         Set(ByVal value As ImageLayout)
  391.         End Set
  392.     End Property
  393.  
  394. #End Region
  395.  
  396. #Region " Public Properties "
  397.  
  398.     Private _SmartBounds As Boolean = True
  399.     Property SmartBounds() As Boolean
  400.         Get
  401.             Return _SmartBounds
  402.         End Get
  403.         Set(ByVal value As Boolean)
  404.             _SmartBounds = value
  405.         End Set
  406.     End Property
  407.  
  408.     Private _Movable As Boolean = True
  409.     Property Movable() As Boolean
  410.         Get
  411.             Return _Movable
  412.         End Get
  413.         Set(ByVal value As Boolean)
  414.             _Movable = value
  415.         End Set
  416.     End Property
  417.  
  418.     Private _Sizable As Boolean = True
  419.     Property Sizable() As Boolean
  420.         Get
  421.             Return _Sizable
  422.         End Get
  423.         Set(ByVal value As Boolean)
  424.             _Sizable = value
  425.         End Set
  426.     End Property
  427.  
  428.     Private _TransparencyKey As Color
  429.     Property TransparencyKey() As Color
  430.         Get
  431.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  432.         End Get
  433.         Set(ByVal value As Color)
  434.             If value = _TransparencyKey Then Return
  435.             _TransparencyKey = value
  436.  
  437.             If _IsParentForm AndAlso Not _ControlMode Then
  438.                 ParentForm.TransparencyKey = value
  439.                 ColorHook()
  440.             End If
  441.         End Set
  442.     End Property
  443.  
  444.     Private _BorderStyle As FormBorderStyle
  445.     Property BorderStyle() As FormBorderStyle
  446.         Get
  447.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  448.         End Get
  449.         Set(ByVal value As FormBorderStyle)
  450.             _BorderStyle = value
  451.  
  452.             If _IsParentForm AndAlso Not _ControlMode Then
  453.                 ParentForm.FormBorderStyle = value
  454.  
  455.                 If Not value = FormBorderStyle.None Then
  456.                     Movable = False
  457.                     Sizable = False
  458.                 End If
  459.             End If
  460.         End Set
  461.     End Property
  462.  
  463.     Private _StartPosition As FormStartPosition
  464.     Property StartPosition As FormStartPosition
  465.         Get
  466.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  467.         End Get
  468.         Set(ByVal value As FormStartPosition)
  469.             _StartPosition = value
  470.  
  471.             If _IsParentForm AndAlso Not _ControlMode Then
  472.                 ParentForm.StartPosition = value
  473.             End If
  474.         End Set
  475.     End Property
  476.  
  477.     Private _NoRounding As Boolean
  478.     Property NoRounding() As Boolean
  479.         Get
  480.             Return _NoRounding
  481.         End Get
  482.         Set(ByVal v As Boolean)
  483.             _NoRounding = v
  484.             Invalidate()
  485.         End Set
  486.     End Property
  487.  
  488.     Private _Image As Image
  489.     Property Image() As Image
  490.         Get
  491.             Return _Image
  492.         End Get
  493.         Set(ByVal value As Image)
  494.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  495.  
  496.             _Image = value
  497.             Invalidate()
  498.         End Set
  499.     End Property
  500.  
  501.     Private Items As New Dictionary(Of String, Color)
  502.     Property Colors() As Bloom()
  503.         Get
  504.             Dim T As New List(Of Bloom)
  505.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  506.  
  507.             While E.MoveNext
  508.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  509.             End While
  510.  
  511.             Return T.ToArray
  512.         End Get
  513.         Set(ByVal value As Bloom())
  514.             For Each B As Bloom In value
  515.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  516.             Next
  517.  
  518.             InvalidateCustimization()
  519.             ColorHook()
  520.             Invalidate()
  521.         End Set
  522.     End Property
  523.  
  524.     Private _Customization As String
  525.     Property Customization() As String
  526.         Get
  527.             Return _Customization
  528.         End Get
  529.         Set(ByVal value As String)
  530.             If value = _Customization Then Return
  531.  
  532.             Dim Data As Byte()
  533.             Dim Items As Bloom() = Colors
  534.  
  535.             Try
  536.                 Data = Convert.FromBase64String(value)
  537.                 For I As Integer = 0 To Items.Length - 1
  538.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  539.                 Next
  540.             Catch
  541.                 Return
  542.             End Try
  543.  
  544.             _Customization = value
  545.  
  546.             Colors = Items
  547.             ColorHook()
  548.             Invalidate()
  549.         End Set
  550.     End Property
  551.  
  552.     Private _Transparent As Boolean
  553.     Property Transparent() As Boolean
  554.         Get
  555.             Return _Transparent
  556.         End Get
  557.         Set(ByVal value As Boolean)
  558.             _Transparent = value
  559.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  560.  
  561.             If Not value AndAlso Not BackColor.A = 255 Then
  562.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  563.             End If
  564.  
  565.             SetStyle(ControlStyles.Opaque, Not value)
  566.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  567.  
  568.             InvalidateBitmap()
  569.             Invalidate()
  570.         End Set
  571.     End Property
  572.  
  573. #End Region
  574.  
  575. #Region " Private Properties "
  576.  
  577.     Private _ImageSize As Size
  578.     Protected ReadOnly Property ImageSize() As Size
  579.         Get
  580.             Return _ImageSize
  581.         End Get
  582.     End Property
  583.  
  584.     Private _IsParentForm As Boolean
  585.     Protected ReadOnly Property IsParentForm As Boolean
  586.         Get
  587.             Return _IsParentForm
  588.         End Get
  589.     End Property
  590.  
  591.     Protected ReadOnly Property IsParentMdi As Boolean
  592.         Get
  593.             If Parent Is Nothing Then Return False
  594.             Return Parent.Parent IsNot Nothing
  595.         End Get
  596.     End Property
  597.  
  598.     Private _LockWidth As Integer
  599.     Protected Property LockWidth() As Integer
  600.         Get
  601.             Return _LockWidth
  602.         End Get
  603.         Set(ByVal value As Integer)
  604.             _LockWidth = value
  605.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  606.         End Set
  607.     End Property
  608.  
  609.     Private _LockHeight As Integer
  610.     Protected Property LockHeight() As Integer
  611.         Get
  612.             Return _LockHeight
  613.         End Get
  614.         Set(ByVal value As Integer)
  615.             _LockHeight = value
  616.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  617.         End Set
  618.     End Property
  619.  
  620.     Private _Header As Integer = 24
  621.     Protected Property Header() As Integer
  622.         Get
  623.             Return _Header
  624.         End Get
  625.         Set(ByVal v As Integer)
  626.             _Header = v
  627.  
  628.             If Not _ControlMode Then
  629.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  630.                 Invalidate()
  631.             End If
  632.         End Set
  633.     End Property
  634.  
  635.     Private _ControlMode As Boolean
  636.     Protected Property ControlMode() As Boolean
  637.         Get
  638.             Return _ControlMode
  639.         End Get
  640.         Set(ByVal v As Boolean)
  641.             _ControlMode = v
  642.  
  643.             Transparent = _Transparent
  644.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  645.  
  646.             InvalidateBitmap()
  647.             Invalidate()
  648.         End Set
  649.     End Property
  650.  
  651.     Private _IsAnimated As Boolean
  652.     Protected Property IsAnimated() As Boolean
  653.         Get
  654.             Return _IsAnimated
  655.         End Get
  656.         Set(ByVal value As Boolean)
  657.             _IsAnimated = value
  658.             InvalidateTimer()
  659.         End Set
  660.     End Property
  661.  
  662. #End Region
  663.  
  664.  
  665. #Region " Property Helpers "
  666.  
  667.     Protected Function GetPen(ByVal name As String) As Pen
  668.         Return New Pen(Items(name))
  669.     End Function
  670.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  671.         Return New Pen(Items(name), width)
  672.     End Function
  673.  
  674.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  675.         Return New SolidBrush(Items(name))
  676.     End Function
  677.  
  678.     Protected Function GetColor(ByVal name As String) As Color
  679.         Return Items(name)
  680.     End Function
  681.  
  682.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  683.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  684.     End Sub
  685.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  686.         SetColor(name, Color.FromArgb(r, g, b))
  687.     End Sub
  688.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  689.         SetColor(name, Color.FromArgb(a, r, g, b))
  690.     End Sub
  691.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  692.         SetColor(name, Color.FromArgb(a, value))
  693.     End Sub
  694.  
  695.     Private Sub InvalidateBitmap()
  696.         If _Transparent AndAlso _ControlMode Then
  697.             If Width = 0 OrElse Height = 0 Then Return
  698.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  699.             G = Graphics.FromImage(B)
  700.         Else
  701.             G = Nothing
  702.             B = Nothing
  703.         End If
  704.     End Sub
  705.  
  706.     Private Sub InvalidateCustimization()
  707.         Dim M As New MemoryStream(Items.Count * 4)
  708.  
  709.         For Each B As Bloom In Colors
  710.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  711.         Next
  712.  
  713.         M.Close()
  714.         _Customization = Convert.ToBase64String(M.ToArray)
  715.     End Sub
  716.  
  717.     Private Sub InvalidateTimer()
  718.         If DesignMode OrElse Not DoneCreation Then Return
  719.  
  720.         If _IsAnimated Then
  721.             AddAnimationCallback(AddressOf DoAnimation)
  722.         Else
  723.             RemoveAnimationCallback(AddressOf DoAnimation)
  724.         End If
  725.     End Sub
  726.  
  727. #End Region
  728.  
  729.  
  730. #Region " User Hooks "
  731.  
  732.     Protected MustOverride Sub ColorHook()
  733.     Protected MustOverride Sub PaintHook()
  734.  
  735.     Protected Overridable Sub OnCreation()
  736.     End Sub
  737.  
  738.     Protected Overridable Sub OnAnimation()
  739.     End Sub
  740.  
  741. #End Region
  742.  
  743.  
  744. #Region " Offset "
  745.  
  746.     Private OffsetReturnRectangle As Rectangle
  747.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  748.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  749.         Return OffsetReturnRectangle
  750.     End Function
  751.  
  752.     Private OffsetReturnSize As Size
  753.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  754.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  755.         Return OffsetReturnSize
  756.     End Function
  757.  
  758.     Private OffsetReturnPoint As Point
  759.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  760.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  761.         Return OffsetReturnPoint
  762.     End Function
  763.  
  764. #End Region
  765.  
  766. #Region " Center "
  767.  
  768.     Private CenterReturn As Point
  769.  
  770.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  771.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  772.         Return CenterReturn
  773.     End Function
  774.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  775.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  776.         Return CenterReturn
  777.     End Function
  778.  
  779.     Protected Function Center(ByVal child As Rectangle) As Point
  780.         Return Center(Width, Height, child.Width, child.Height)
  781.     End Function
  782.     Protected Function Center(ByVal child As Size) As Point
  783.         Return Center(Width, Height, child.Width, child.Height)
  784.     End Function
  785.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  786.         Return Center(Width, Height, childWidth, childHeight)
  787.     End Function
  788.  
  789.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  790.         Return Center(p.Width, p.Height, c.Width, c.Height)
  791.     End Function
  792.  
  793.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  794.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  795.         Return CenterReturn
  796.     End Function
  797.  
  798. #End Region
  799.  
  800. #Region " Measure "
  801.  
  802.     Private MeasureBitmap As Bitmap
  803.     Private MeasureGraphics As Graphics
  804.  
  805.     Protected Function Measure() As Size
  806.         SyncLock MeasureGraphics
  807.             Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  808.         End SyncLock
  809.     End Function
  810.     Protected Function Measure(ByVal text As String) As Size
  811.         SyncLock MeasureGraphics
  812.             Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  813.         End SyncLock
  814.     End Function
  815.  
  816. #End Region
  817.  
  818.  
  819. #Region " DrawPixel "
  820.  
  821.     Private DrawPixelBrush As SolidBrush
  822.  
  823.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  824.         If _Transparent Then
  825.             B.SetPixel(x, y, c1)
  826.         Else
  827.             DrawPixelBrush = New SolidBrush(c1)
  828.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  829.         End If
  830.     End Sub
  831.  
  832. #End Region
  833.  
  834. #Region " DrawCorners "
  835.  
  836.     Private DrawCornersBrush As SolidBrush
  837.  
  838.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  839.         DrawCorners(c1, 0, 0, Width, Height, offset)
  840.     End Sub
  841.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  842.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  843.     End Sub
  844.     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)
  845.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  846.     End Sub
  847.  
  848.     Protected Sub DrawCorners(ByVal c1 As Color)
  849.         DrawCorners(c1, 0, 0, Width, Height)
  850.     End Sub
  851.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  852.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  853.     End Sub
  854.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  855.         If _NoRounding Then Return
  856.  
  857.         If _Transparent Then
  858.             B.SetPixel(x, y, c1)
  859.             B.SetPixel(x + (width - 1), y, c1)
  860.             B.SetPixel(x, y + (height - 1), c1)
  861.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  862.         Else
  863.             DrawCornersBrush = New SolidBrush(c1)
  864.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  865.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  866.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  867.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  868.         End If
  869.     End Sub
  870.  
  871. #End Region
  872.  
  873. #Region " DrawBorders "
  874.  
  875.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  876.         DrawBorders(p1, 0, 0, Width, Height, offset)
  877.     End Sub
  878.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  879.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  880.     End Sub
  881.     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)
  882.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  883.     End Sub
  884.  
  885.     Protected Sub DrawBorders(ByVal p1 As Pen)
  886.         DrawBorders(p1, 0, 0, Width, Height)
  887.     End Sub
  888.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  889.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  890.     End Sub
  891.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  892.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  893.     End Sub
  894.  
  895. #End Region
  896.  
  897. #Region " DrawText "
  898.  
  899.     Private DrawTextPoint As Point
  900.     Private DrawTextSize As Size
  901.  
  902.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  903.         DrawText(b1, Text, a, x, y)
  904.     End Sub
  905.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  906.         If text.Length = 0 Then Return
  907.  
  908.         DrawTextSize = Measure(text)
  909.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  910.  
  911.         Select Case a
  912.             Case HorizontalAlignment.Left
  913.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  914.             Case HorizontalAlignment.Center
  915.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  916.             Case HorizontalAlignment.Right
  917.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  918.         End Select
  919.     End Sub
  920.  
  921.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  922.         If Text.Length = 0 Then Return
  923.         G.DrawString(Text, Font, b1, p1)
  924.     End Sub
  925.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  926.         If Text.Length = 0 Then Return
  927.         G.DrawString(Text, Font, b1, x, y)
  928.     End Sub
  929.  
  930. #End Region
  931.  
  932. #Region " DrawImage "
  933.  
  934.     Private DrawImagePoint As Point
  935.  
  936.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  937.         DrawImage(_Image, a, x, y)
  938.     End Sub
  939.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  940.         If image Is Nothing Then Return
  941.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  942.  
  943.         Select Case a
  944.             Case HorizontalAlignment.Left
  945.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  946.             Case HorizontalAlignment.Center
  947.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  948.             Case HorizontalAlignment.Right
  949.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  950.         End Select
  951.     End Sub
  952.  
  953.     Protected Sub DrawImage(ByVal p1 As Point)
  954.         DrawImage(_Image, p1.X, p1.Y)
  955.     End Sub
  956.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  957.         DrawImage(_Image, x, y)
  958.     End Sub
  959.  
  960.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  961.         DrawImage(image, p1.X, p1.Y)
  962.     End Sub
  963.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  964.         If image Is Nothing Then Return
  965.         G.DrawImage(image, x, y, image.Width, image.Height)
  966.     End Sub
  967.  
  968. #End Region
  969.  
  970. #Region " DrawGradient "
  971.  
  972.     Private DrawGradientBrush As LinearGradientBrush
  973.     Private DrawGradientRectangle As Rectangle
  974.  
  975.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  976.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  977.         DrawGradient(blend, DrawGradientRectangle)
  978.     End Sub
  979.     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)
  980.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  981.         DrawGradient(blend, DrawGradientRectangle, angle)
  982.     End Sub
  983.  
  984.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  985.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  986.         DrawGradientBrush.InterpolationColors = blend
  987.         G.FillRectangle(DrawGradientBrush, r)
  988.     End Sub
  989.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  990.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  991.         DrawGradientBrush.InterpolationColors = blend
  992.         G.FillRectangle(DrawGradientBrush, r)
  993.     End Sub
  994.  
  995.  
  996.     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)
  997.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  998.         DrawGradient(c1, c2, DrawGradientRectangle)
  999.     End Sub
  1000.     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)
  1001.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1002.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1003.     End Sub
  1004.  
  1005.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1006.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1007.         G.FillRectangle(DrawGradientBrush, r)
  1008.     End Sub
  1009.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1010.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1011.         G.FillRectangle(DrawGradientBrush, r)
  1012.     End Sub
  1013.  
  1014. #End Region
  1015.  
  1016. #Region " DrawRadial "
  1017.  
  1018.     Private DrawRadialPath As GraphicsPath
  1019.     Private DrawRadialBrush1 As PathGradientBrush
  1020.     Private DrawRadialBrush2 As LinearGradientBrush
  1021.     Private DrawRadialRectangle As Rectangle
  1022.  
  1023.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1024.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1025.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1026.     End Sub
  1027.     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)
  1028.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1029.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1030.     End Sub
  1031.     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)
  1032.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1033.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1034.     End Sub
  1035.  
  1036.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1037.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1038.     End Sub
  1039.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1040.         DrawRadial(blend, r, center.X, center.Y)
  1041.     End Sub
  1042.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1043.         DrawRadialPath.Reset()
  1044.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1045.  
  1046.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1047.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1048.         DrawRadialBrush1.InterpolationColors = blend
  1049.  
  1050.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1051.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1052.         Else
  1053.             G.FillEllipse(DrawRadialBrush1, r)
  1054.         End If
  1055.     End Sub
  1056.  
  1057.  
  1058.     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)
  1059.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1060.         DrawRadial(c1, c2, DrawGradientRectangle)
  1061.     End Sub
  1062.     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)
  1063.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1064.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  1065.     End Sub
  1066.  
  1067.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1068.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1069.         G.FillRectangle(DrawGradientBrush, r)
  1070.     End Sub
  1071.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1072.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1073.         G.FillEllipse(DrawGradientBrush, r)
  1074.     End Sub
  1075.  
  1076. #End Region
  1077.  
  1078. #Region " CreateRound "
  1079.  
  1080.     Private CreateRoundPath As GraphicsPath
  1081.     Private CreateRoundRectangle As Rectangle
  1082.  
  1083.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1084.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1085.         Return CreateRound(CreateRoundRectangle, slope)
  1086.     End Function
  1087.  
  1088.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1089.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1090.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1091.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1092.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1093.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1094.         CreateRoundPath.CloseFigure()
  1095.         Return CreateRoundPath
  1096.     End Function
  1097.  
  1098. #End Region
  1099.  
  1100. End Class
  1101.  
  1102. MustInherit Class ThemeControl154
  1103.     Inherits Control
  1104.  
  1105.  
  1106. #Region " Initialization "
  1107.  
  1108.     Protected G As Graphics, B As Bitmap
  1109.  
  1110.     Sub New()
  1111.         SetStyle(DirectCast(139270, ControlStyles), True)
  1112.  
  1113.         _ImageSize = Size.Empty
  1114.         Font = New Font("Verdana", 8S)
  1115.  
  1116.         MeasureBitmap = New Bitmap(1, 1)
  1117.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  1118.  
  1119.         DrawRadialPath = New GraphicsPath
  1120.  
  1121.         InvalidateCustimization() 'Remove?
  1122.     End Sub
  1123.  
  1124.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  1125.         InvalidateCustimization()
  1126.         ColorHook()
  1127.  
  1128.         If Not _LockWidth = 0 Then Width = _LockWidth
  1129.         If Not _LockHeight = 0 Then Height = _LockHeight
  1130.  
  1131.         Transparent = _Transparent
  1132.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  1133.  
  1134.         MyBase.OnHandleCreated(e)
  1135.     End Sub
  1136.  
  1137.     Private DoneCreation As Boolean
  1138.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  1139.         If Parent IsNot Nothing Then
  1140.             OnCreation()
  1141.             DoneCreation = True
  1142.             InvalidateTimer()
  1143.         End If
  1144.  
  1145.         MyBase.OnParentChanged(e)
  1146.     End Sub
  1147.  
  1148. #End Region
  1149.  
  1150.     Private Sub DoAnimation(ByVal i As Boolean)
  1151.         OnAnimation()
  1152.         If i Then Invalidate()
  1153.     End Sub
  1154.  
  1155.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1156.         If Width = 0 OrElse Height = 0 Then Return
  1157.  
  1158.         If _Transparent Then
  1159.             PaintHook()
  1160.             e.Graphics.DrawImage(B, 0, 0)
  1161.         Else
  1162.             G = e.Graphics
  1163.             PaintHook()
  1164.         End If
  1165.     End Sub
  1166.  
  1167.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  1168.         RemoveAnimationCallback(AddressOf DoAnimation)
  1169.         MyBase.OnHandleDestroyed(e)
  1170.     End Sub
  1171.  
  1172. #Region " Size Handling "
  1173.  
  1174.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  1175.         If _Transparent Then
  1176.             InvalidateBitmap()
  1177.         End If
  1178.  
  1179.         Invalidate()
  1180.         MyBase.OnSizeChanged(e)
  1181.     End Sub
  1182.  
  1183.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  1184.         If Not _LockWidth = 0 Then width = _LockWidth
  1185.         If Not _LockHeight = 0 Then height = _LockHeight
  1186.         MyBase.SetBoundsCore(x, y, width, height, specified)
  1187.     End Sub
  1188.  
  1189. #End Region
  1190.  
  1191. #Region " State Handling "
  1192.  
  1193.     Private InPosition As Boolean
  1194.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1195.         InPosition = True
  1196.         SetState(MouseState.Over)
  1197.         MyBase.OnMouseEnter(e)
  1198.     End Sub
  1199.  
  1200.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1201.         If InPosition Then SetState(MouseState.Over)
  1202.         MyBase.OnMouseUp(e)
  1203.     End Sub
  1204.  
  1205.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1206.         If e.Button = System.Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  1207.         MyBase.OnMouseDown(e)
  1208.     End Sub
  1209.  
  1210.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1211.         InPosition = False
  1212.         SetState(MouseState.None)
  1213.         MyBase.OnMouseLeave(e)
  1214.     End Sub
  1215.  
  1216.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  1217.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  1218.         MyBase.OnEnabledChanged(e)
  1219.     End Sub
  1220.  
  1221.     Protected State As MouseState
  1222.     Private Sub SetState(ByVal current As MouseState)
  1223.         State = current
  1224.         Invalidate()
  1225.     End Sub
  1226.  
  1227. #End Region
  1228.  
  1229.  
  1230. #Region " Base Properties "
  1231.  
  1232.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  1233.     Overrides Property ForeColor() As Color
  1234.         Get
  1235.             Return Color.Empty
  1236.         End Get
  1237.         Set(ByVal value As Color)
  1238.         End Set
  1239.     End Property
  1240.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  1241.     Overrides Property BackgroundImage() As Image
  1242.         Get
  1243.             Return Nothing
  1244.         End Get
  1245.         Set(ByVal value As Image)
  1246.         End Set
  1247.     End Property
  1248.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)>
  1249.     Overrides Property BackgroundImageLayout() As ImageLayout
  1250.         Get
  1251.             Return ImageLayout.None
  1252.         End Get
  1253.         Set(ByVal value As ImageLayout)
  1254.         End Set
  1255.     End Property
  1256.  
  1257.     Overrides Property Text() As String
  1258.         Get
  1259.             Return MyBase.Text
  1260.         End Get
  1261.         Set(ByVal value As String)
  1262.             MyBase.Text = value
  1263.             Invalidate()
  1264.         End Set
  1265.     End Property
  1266.     Overrides Property Font() As Font
  1267.         Get
  1268.             Return MyBase.Font
  1269.         End Get
  1270.         Set(ByVal value As Font)
  1271.             MyBase.Font = value
  1272.             Invalidate()
  1273.         End Set
  1274.     End Property
  1275.  
  1276.     Private _BackColor As Boolean
  1277.     <Category("Misc")>
  1278.     Overrides Property BackColor() As Color
  1279.         Get
  1280.             Return MyBase.BackColor
  1281.         End Get
  1282.         Set(ByVal value As Color)
  1283.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  1284.                 _BackColor = True
  1285.                 Return
  1286.             End If
  1287.  
  1288.             MyBase.BackColor = value
  1289.             If Parent IsNot Nothing Then ColorHook()
  1290.         End Set
  1291.     End Property
  1292.  
  1293. #End Region
  1294.  
  1295. #Region " Public Properties "
  1296.  
  1297.     Private _NoRounding As Boolean
  1298.     Property NoRounding() As Boolean
  1299.         Get
  1300.             Return _NoRounding
  1301.         End Get
  1302.         Set(ByVal v As Boolean)
  1303.             _NoRounding = v
  1304.             Invalidate()
  1305.         End Set
  1306.     End Property
  1307.  
  1308.     Private _Image As Image
  1309.     Property Image() As Image
  1310.         Get
  1311.             Return _Image
  1312.         End Get
  1313.         Set(ByVal value As Image)
  1314.             If value Is Nothing Then
  1315.                 _ImageSize = Size.Empty
  1316.             Else
  1317.                 _ImageSize = value.Size
  1318.             End If
  1319.  
  1320.             _Image = value
  1321.             Invalidate()
  1322.         End Set
  1323.     End Property
  1324.  
  1325.     Private _Transparent As Boolean
  1326.     Property Transparent() As Boolean
  1327.         Get
  1328.             Return _Transparent
  1329.         End Get
  1330.         Set(ByVal value As Boolean)
  1331.             _Transparent = value
  1332.             If Not IsHandleCreated Then Return
  1333.  
  1334.             If Not value AndAlso Not BackColor.A = 255 Then
  1335.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  1336.             End If
  1337.  
  1338.             SetStyle(ControlStyles.Opaque, Not value)
  1339.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  1340.  
  1341.             If value Then InvalidateBitmap() Else B = Nothing
  1342.             Invalidate()
  1343.         End Set
  1344.     End Property
  1345.  
  1346.     Private Items As New Dictionary(Of String, Color)
  1347.     Property Colors() As Bloom()
  1348.         Get
  1349.             Dim T As New List(Of Bloom)
  1350.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  1351.  
  1352.             While E.MoveNext
  1353.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  1354.             End While
  1355.  
  1356.             Return T.ToArray
  1357.         End Get
  1358.         Set(ByVal value As Bloom())
  1359.             For Each B As Bloom In value
  1360.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  1361.             Next
  1362.  
  1363.             InvalidateCustimization()
  1364.             ColorHook()
  1365.             Invalidate()
  1366.         End Set
  1367.     End Property
  1368.  
  1369.     Private _Customization As String
  1370.     Property Customization() As String
  1371.         Get
  1372.             Return _Customization
  1373.         End Get
  1374.         Set(ByVal value As String)
  1375.             If value = _Customization Then Return
  1376.  
  1377.             Dim Data As Byte()
  1378.             Dim Items As Bloom() = Colors
  1379.  
  1380.             Try
  1381.                 Data = Convert.FromBase64String(value)
  1382.                 For I As Integer = 0 To Items.Length - 1
  1383.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  1384.                 Next
  1385.             Catch
  1386.                 Return
  1387.             End Try
  1388.  
  1389.             _Customization = value
  1390.  
  1391.             Colors = Items
  1392.             ColorHook()
  1393.             Invalidate()
  1394.         End Set
  1395.     End Property
  1396.  
  1397. #End Region
  1398.  
  1399. #Region " Private Properties "
  1400.  
  1401.     Private _ImageSize As Size
  1402.     Protected ReadOnly Property ImageSize() As Size
  1403.         Get
  1404.             Return _ImageSize
  1405.         End Get
  1406.     End Property
  1407.  
  1408.     Private _LockWidth As Integer
  1409.     Protected Property LockWidth() As Integer
  1410.         Get
  1411.             Return _LockWidth
  1412.         End Get
  1413.         Set(ByVal value As Integer)
  1414.             _LockWidth = value
  1415.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  1416.         End Set
  1417.     End Property
  1418.  
  1419.     Private _LockHeight As Integer
  1420.     Protected Property LockHeight() As Integer
  1421.         Get
  1422.             Return _LockHeight
  1423.         End Get
  1424.         Set(ByVal value As Integer)
  1425.             _LockHeight = value
  1426.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  1427.         End Set
  1428.     End Property
  1429.  
  1430.     Private _IsAnimated As Boolean
  1431.     Protected Property IsAnimated() As Boolean
  1432.         Get
  1433.             Return _IsAnimated
  1434.         End Get
  1435.         Set(ByVal value As Boolean)
  1436.             _IsAnimated = value
  1437.             InvalidateTimer()
  1438.         End Set
  1439.     End Property
  1440.  
  1441. #End Region
  1442.  
  1443.  
  1444. #Region " Property Helpers "
  1445.  
  1446.     Protected Function GetPen(ByVal name As String) As Pen
  1447.         Return New Pen(Items(name))
  1448.     End Function
  1449.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  1450.         Return New Pen(Items(name), width)
  1451.     End Function
  1452.  
  1453.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  1454.         Return New SolidBrush(Items(name))
  1455.     End Function
  1456.  
  1457.     Protected Function GetColor(ByVal name As String) As Color
  1458.         Return Items(name)
  1459.     End Function
  1460.  
  1461.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  1462.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  1463.     End Sub
  1464.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1465.         SetColor(name, Color.FromArgb(r, g, b))
  1466.     End Sub
  1467.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  1468.         SetColor(name, Color.FromArgb(a, r, g, b))
  1469.     End Sub
  1470.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  1471.         SetColor(name, Color.FromArgb(a, value))
  1472.     End Sub
  1473.  
  1474.     Private Sub InvalidateBitmap()
  1475.         If Width = 0 OrElse Height = 0 Then Return
  1476.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  1477.         G = Graphics.FromImage(B)
  1478.     End Sub
  1479.  
  1480.     Private Sub InvalidateCustimization()
  1481.         Dim M As New MemoryStream(Items.Count * 4)
  1482.  
  1483.         For Each B As Bloom In Colors
  1484.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  1485.         Next
  1486.  
  1487.         M.Close()
  1488.         _Customization = Convert.ToBase64String(M.ToArray)
  1489.     End Sub
  1490.  
  1491.     Private Sub InvalidateTimer()
  1492.         If DesignMode OrElse Not DoneCreation Then Return
  1493.  
  1494.         If _IsAnimated Then
  1495.             AddAnimationCallback(AddressOf DoAnimation)
  1496.         Else
  1497.             RemoveAnimationCallback(AddressOf DoAnimation)
  1498.         End If
  1499.     End Sub
  1500. #End Region
  1501.  
  1502.  
  1503. #Region " User Hooks "
  1504.  
  1505.     Protected MustOverride Sub ColorHook()
  1506.     Protected MustOverride Sub PaintHook()
  1507.  
  1508.     Protected Overridable Sub OnCreation()
  1509.     End Sub
  1510.  
  1511.     Protected Overridable Sub OnAnimation()
  1512.     End Sub
  1513.  
  1514. #End Region
  1515.  
  1516.  
  1517. #Region " Offset "
  1518.  
  1519.     Private OffsetReturnRectangle As Rectangle
  1520.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  1521.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  1522.         Return OffsetReturnRectangle
  1523.     End Function
  1524.  
  1525.     Private OffsetReturnSize As Size
  1526.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  1527.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  1528.         Return OffsetReturnSize
  1529.     End Function
  1530.  
  1531.     Private OffsetReturnPoint As Point
  1532.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  1533.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  1534.         Return OffsetReturnPoint
  1535.     End Function
  1536.  
  1537. #End Region
  1538.  
  1539. #Region " Center "
  1540.  
  1541.     Private CenterReturn As Point
  1542.  
  1543.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  1544.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  1545.         Return CenterReturn
  1546.     End Function
  1547.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  1548.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  1549.         Return CenterReturn
  1550.     End Function
  1551.  
  1552.     Protected Function Center(ByVal child As Rectangle) As Point
  1553.         Return Center(Width, Height, child.Width, child.Height)
  1554.     End Function
  1555.     Protected Function Center(ByVal child As Size) As Point
  1556.         Return Center(Width, Height, child.Width, child.Height)
  1557.     End Function
  1558.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  1559.         Return Center(Width, Height, childWidth, childHeight)
  1560.     End Function
  1561.  
  1562.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  1563.         Return Center(p.Width, p.Height, c.Width, c.Height)
  1564.     End Function
  1565.  
  1566.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  1567.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  1568.         Return CenterReturn
  1569.     End Function
  1570.  
  1571. #End Region
  1572.  
  1573. #Region " Measure "
  1574.  
  1575.     Private MeasureBitmap As Bitmap
  1576.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  1577.  
  1578.     Protected Function Measure() As Size
  1579.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  1580.     End Function
  1581.     Protected Function Measure(ByVal text As String) As Size
  1582.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  1583.     End Function
  1584.  
  1585. #End Region
  1586.  
  1587.  
  1588. #Region " DrawPixel "
  1589.  
  1590.     Private DrawPixelBrush As SolidBrush
  1591.  
  1592.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  1593.         If _Transparent Then
  1594.             B.SetPixel(x, y, c1)
  1595.         Else
  1596.             DrawPixelBrush = New SolidBrush(c1)
  1597.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  1598.         End If
  1599.     End Sub
  1600.  
  1601. #End Region
  1602.  
  1603. #Region " DrawCorners "
  1604.  
  1605.     Private DrawCornersBrush As SolidBrush
  1606.  
  1607.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  1608.         DrawCorners(c1, 0, 0, Width, Height, offset)
  1609.     End Sub
  1610.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  1611.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  1612.     End Sub
  1613.     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)
  1614.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1615.     End Sub
  1616.  
  1617.     Protected Sub DrawCorners(ByVal c1 As Color)
  1618.         DrawCorners(c1, 0, 0, Width, Height)
  1619.     End Sub
  1620.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  1621.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  1622.     End Sub
  1623.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1624.         If _NoRounding Then Return
  1625.  
  1626.         If _Transparent Then
  1627.             B.SetPixel(x, y, c1)
  1628.             B.SetPixel(x + (width - 1), y, c1)
  1629.             B.SetPixel(x, y + (height - 1), c1)
  1630.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  1631.         Else
  1632.             DrawCornersBrush = New SolidBrush(c1)
  1633.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  1634.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  1635.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  1636.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  1637.         End If
  1638.     End Sub
  1639.  
  1640. #End Region
  1641.  
  1642. #Region " DrawBorders "
  1643.  
  1644.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  1645.         DrawBorders(p1, 0, 0, Width, Height, offset)
  1646.     End Sub
  1647.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  1648.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  1649.     End Sub
  1650.     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)
  1651.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  1652.     End Sub
  1653.  
  1654.     Protected Sub DrawBorders(ByVal p1 As Pen)
  1655.         DrawBorders(p1, 0, 0, Width, Height)
  1656.     End Sub
  1657.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  1658.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  1659.     End Sub
  1660.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1661.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  1662.     End Sub
  1663.  
  1664. #End Region
  1665.  
  1666. #Region " DrawText "
  1667.  
  1668.     Private DrawTextPoint As Point
  1669.     Private DrawTextSize As Size
  1670.  
  1671.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1672.         DrawText(b1, Text, a, x, y)
  1673.     End Sub
  1674.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1675.         If text.Length = 0 Then Return
  1676.  
  1677.         DrawTextSize = Measure(text)
  1678.         DrawTextPoint = Center(DrawTextSize)
  1679.  
  1680.         Select Case a
  1681.             Case HorizontalAlignment.Left
  1682.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  1683.             Case HorizontalAlignment.Center
  1684.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  1685.             Case HorizontalAlignment.Right
  1686.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  1687.         End Select
  1688.     End Sub
  1689.  
  1690.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  1691.         If Text.Length = 0 Then Return
  1692.         G.DrawString(Text, Font, b1, p1)
  1693.     End Sub
  1694.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  1695.         If Text.Length = 0 Then Return
  1696.         G.DrawString(Text, Font, b1, x, y)
  1697.     End Sub
  1698.  
  1699. #End Region
  1700.  
  1701. #Region " DrawImage "
  1702.  
  1703.     Private DrawImagePoint As Point
  1704.  
  1705.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1706.         DrawImage(_Image, a, x, y)
  1707.     End Sub
  1708.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  1709.         If image Is Nothing Then Return
  1710.         DrawImagePoint = Center(image.Size)
  1711.  
  1712.         Select Case a
  1713.             Case HorizontalAlignment.Left
  1714.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  1715.             Case HorizontalAlignment.Center
  1716.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  1717.             Case HorizontalAlignment.Right
  1718.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  1719.         End Select
  1720.     End Sub
  1721.  
  1722.     Protected Sub DrawImage(ByVal p1 As Point)
  1723.         DrawImage(_Image, p1.X, p1.Y)
  1724.     End Sub
  1725.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  1726.         DrawImage(_Image, x, y)
  1727.     End Sub
  1728.  
  1729.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  1730.         DrawImage(image, p1.X, p1.Y)
  1731.     End Sub
  1732.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  1733.         If image Is Nothing Then Return
  1734.         G.DrawImage(image, x, y, image.Width, image.Height)
  1735.     End Sub
  1736.  
  1737. #End Region
  1738.  
  1739. #Region " DrawGradient "
  1740.  
  1741.     Private DrawGradientBrush As LinearGradientBrush
  1742.     Private DrawGradientRectangle As Rectangle
  1743.  
  1744.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1745.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1746.         DrawGradient(blend, DrawGradientRectangle)
  1747.     End Sub
  1748.     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)
  1749.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1750.         DrawGradient(blend, DrawGradientRectangle, angle)
  1751.     End Sub
  1752.  
  1753.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1754.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  1755.         DrawGradientBrush.InterpolationColors = blend
  1756.         G.FillRectangle(DrawGradientBrush, r)
  1757.     End Sub
  1758.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  1759.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  1760.         DrawGradientBrush.InterpolationColors = blend
  1761.         G.FillRectangle(DrawGradientBrush, r)
  1762.     End Sub
  1763.  
  1764.  
  1765.     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)
  1766.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1767.         DrawGradient(c1, c2, DrawGradientRectangle)
  1768.     End Sub
  1769.     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)
  1770.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  1771.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  1772.     End Sub
  1773.  
  1774.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1775.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  1776.         G.FillRectangle(DrawGradientBrush, r)
  1777.     End Sub
  1778.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1779.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  1780.         G.FillRectangle(DrawGradientBrush, r)
  1781.     End Sub
  1782.  
  1783. #End Region
  1784.  
  1785. #Region " DrawRadial "
  1786.  
  1787.     Private DrawRadialPath As GraphicsPath
  1788.     Private DrawRadialBrush1 As PathGradientBrush
  1789.     Private DrawRadialBrush2 As LinearGradientBrush
  1790.     Private DrawRadialRectangle As Rectangle
  1791.  
  1792.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  1793.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1794.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  1795.     End Sub
  1796.     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)
  1797.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1798.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  1799.     End Sub
  1800.     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)
  1801.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1802.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  1803.     End Sub
  1804.  
  1805.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  1806.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  1807.     End Sub
  1808.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  1809.         DrawRadial(blend, r, center.X, center.Y)
  1810.     End Sub
  1811.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  1812.         DrawRadialPath.Reset()
  1813.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  1814.  
  1815.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  1816.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  1817.         DrawRadialBrush1.InterpolationColors = blend
  1818.  
  1819.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  1820.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  1821.         Else
  1822.             G.FillEllipse(DrawRadialBrush1, r)
  1823.         End If
  1824.     End Sub
  1825.  
  1826.  
  1827.     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)
  1828.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1829.         DrawRadial(c1, c2, DrawRadialRectangle)
  1830.     End Sub
  1831.     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)
  1832.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  1833.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  1834.     End Sub
  1835.  
  1836.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  1837.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  1838.         G.FillEllipse(DrawRadialBrush2, r)
  1839.     End Sub
  1840.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  1841.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  1842.         G.FillEllipse(DrawRadialBrush2, r)
  1843.     End Sub
  1844.  
  1845. #End Region
  1846.  
  1847. #Region " CreateRound "
  1848.  
  1849.     Private CreateRoundPath As GraphicsPath
  1850.     Private CreateRoundRectangle As Rectangle
  1851.  
  1852.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  1853.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  1854.         Return CreateRound(CreateRoundRectangle, slope)
  1855.     End Function
  1856.  
  1857.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  1858.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  1859.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  1860.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  1861.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  1862.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  1863.         CreateRoundPath.CloseFigure()
  1864.         Return CreateRoundPath
  1865.     End Function
  1866.  
  1867. #End Region
  1868.  
  1869. End Class
  1870.  
  1871. Module ThemeShare
  1872.  
  1873. #Region " Animation "
  1874.  
  1875.     Private Frames As Integer
  1876.     Private Invalidate As Boolean
  1877.     Public ThemeTimer As New PrecisionTimer
  1878.  
  1879.     Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  1880.     Private Const Rate As Integer = 10
  1881.  
  1882.     Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  1883.  
  1884.     Private Callbacks As New List(Of AnimationDelegate)
  1885.  
  1886.     Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  1887.         Invalidate = (Frames >= FPS)
  1888.         If Invalidate Then Frames = 0
  1889.  
  1890.         SyncLock Callbacks
  1891.             For I As Integer = 0 To Callbacks.Count - 1
  1892.                 Callbacks(I).Invoke(Invalidate)
  1893.             Next
  1894.         End SyncLock
  1895.  
  1896.         Frames += Rate
  1897.     End Sub
  1898.  
  1899.     Private Sub InvalidateThemeTimer()
  1900.         If Callbacks.Count = 0 Then
  1901.             ThemeTimer.Delete()
  1902.         Else
  1903.             ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  1904.         End If
  1905.     End Sub
  1906.  
  1907.     Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  1908.         SyncLock Callbacks
  1909.             If Callbacks.Contains(callback) Then Return
  1910.  
  1911.             Callbacks.Add(callback)
  1912.             InvalidateThemeTimer()
  1913.         End SyncLock
  1914.     End Sub
  1915.  
  1916.     Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  1917.         SyncLock Callbacks
  1918.             If Not Callbacks.Contains(callback) Then Return
  1919.  
  1920.             Callbacks.Remove(callback)
  1921.             InvalidateThemeTimer()
  1922.         End SyncLock
  1923.     End Sub
  1924.  
  1925. #End Region
  1926.  
  1927. End Module
  1928.  
  1929. Enum MouseState As Byte
  1930.     None = 0
  1931.     Over = 1
  1932.     Down = 2
  1933.     Block = 3
  1934. End Enum
  1935.  
  1936. Structure Bloom
  1937.  
  1938.     Public _Name As String
  1939.     ReadOnly Property Name() As String
  1940.         Get
  1941.             Return _Name
  1942.         End Get
  1943.     End Property
  1944.  
  1945.     Private _Value As Color
  1946.     Property Value() As Color
  1947.         Get
  1948.             Return _Value
  1949.         End Get
  1950.         Set(ByVal value As Color)
  1951.             _Value = value
  1952.         End Set
  1953.     End Property
  1954.  
  1955.     Property ValueHex() As String
  1956.         Get
  1957.             Return String.Concat("#",
  1958.             _Value.R.ToString("X2", Nothing),
  1959.             _Value.G.ToString("X2", Nothing),
  1960.             _Value.B.ToString("X2", Nothing))
  1961.         End Get
  1962.         Set(ByVal value As String)
  1963.             Try
  1964.                 _Value = ColorTranslator.FromHtml(value)
  1965.             Catch
  1966.                 Return
  1967.             End Try
  1968.         End Set
  1969.     End Property
  1970.  
  1971.  
  1972.     Sub New(ByVal name As String, ByVal value As Color)
  1973.         _Name = name
  1974.         _Value = value
  1975.     End Sub
  1976. End Structure
  1977.  
  1978. '------------------
  1979. 'Creator: aeonhack
  1980. 'Site: elitevs.net
  1981. 'Created: 11/30/2011
  1982. 'Changed: 11/30/2011
  1983. 'Version: 1.0.0
  1984. '------------------
  1985. Class PrecisionTimer
  1986.     Implements IDisposable
  1987.  
  1988.     Private _Enabled As Boolean
  1989.     ReadOnly Property Enabled() As Boolean
  1990.         Get
  1991.             Return _Enabled
  1992.         End Get
  1993.     End Property
  1994.  
  1995.     Private Handle As IntPtr
  1996.     Private TimerCallback As TimerDelegate
  1997.  
  1998.     <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")>
  1999.     Private Shared Function CreateTimerQueueTimer(
  2000.     ByRef handle As IntPtr,
  2001.     ByVal queue As IntPtr,
  2002.     ByVal callback As TimerDelegate,
  2003.     ByVal state As IntPtr,
  2004.     ByVal dueTime As UInteger,
  2005.     ByVal period As UInteger,
  2006.     ByVal flags As UInteger) As Boolean
  2007.     End Function
  2008.  
  2009.     <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")>
  2010.     Private Shared Function DeleteTimerQueueTimer(
  2011.     ByVal queue As IntPtr,
  2012.     ByVal handle As IntPtr,
  2013.     ByVal callback As IntPtr) As Boolean
  2014.     End Function
  2015.  
  2016.     Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  2017.  
  2018.     Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  2019.         If _Enabled Then Return
  2020.  
  2021.         TimerCallback = callback
  2022.         Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  2023.  
  2024.         If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  2025.         _Enabled = Success
  2026.     End Sub
  2027.  
  2028.     Sub Delete()
  2029.         If Not _Enabled Then Return
  2030.         Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  2031.  
  2032.         If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  2033.             ThrowNewException("DeleteTimerQueueTimer")
  2034.         End If
  2035.  
  2036.         _Enabled = Not Success
  2037.     End Sub
  2038.  
  2039.     Private Sub ThrowNewException(ByVal name As String)
  2040.         Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  2041.     End Sub
  2042.  
  2043.     Public Sub Dispose() Implements IDisposable.Dispose
  2044.         Delete()
  2045.     End Sub
  2046. End Class
  2047.  
  2048. 'IMPORTANT:
  2049. 'Please leave these comments in place as they help protect intellectual rights and allow
  2050. 'developers to determine the version of the theme they are using. The preffered method
  2051. 'of distributing this theme is through the Nimoru Software home page at nimoru.com.
  2052.  
  2053. 'Name: Net Seal Theme
  2054. 'Created: 6/21/2013
  2055. 'Version: 1.0.0.1 beta
  2056. 'Site: http://nimoru.com/
  2057.  
  2058. 'This work is licensed under a Creative Commons Attribution 3.0 Unported License.
  2059. 'To view a copy of this license, please visit http://creativecommons.org/licenses/by/3.0/
  2060.  
  2061. 'Copyright © 2013 Nimoru Software
  2062.  
  2063. Module ThemeModule
  2064.  
  2065.  
  2066.     Friend G As Graphics
  2067.  
  2068.     Sub New()
  2069.         TextBitmap = New Bitmap(1, 1)
  2070.         TextGraphics = Graphics.FromImage(TextBitmap)
  2071.     End Sub
  2072.  
  2073.     Private TextBitmap As Bitmap
  2074.     Private TextGraphics As Graphics
  2075.  
  2076.     Friend Function MeasureString(text As String, font As Font) As SizeF
  2077.         Return TextGraphics.MeasureString(text, font)
  2078.     End Function
  2079.  
  2080.     Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF
  2081.         Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic)
  2082.     End Function
  2083.  
  2084.     Private CreateRoundPath As GraphicsPath
  2085.     Private CreateRoundRectangle As Rectangle
  2086.  
  2087.     Friend Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  2088.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  2089.         Return CreateRound(CreateRoundRectangle, slope)
  2090.     End Function
  2091.  
  2092.     Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  2093.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  2094.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  2095.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  2096.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  2097.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  2098.         CreateRoundPath.CloseFigure()
  2099.         Return CreateRoundPath
  2100.     End Function
  2101.  
  2102. End Module
  2103.  
  2104. Class NSTheme
  2105.  
  2106.     Inherits ThemeContainer154
  2107.  
  2108.     Private _AccentOffset As Integer = 42
  2109.     Public Property AccentOffset() As Integer
  2110.         Get
  2111.             Return _AccentOffset
  2112.         End Get
  2113.         Set(ByVal value As Integer)
  2114.             _AccentOffset = value
  2115.             Invalidate()
  2116.         End Set
  2117.     End Property
  2118.  
  2119.     Sub New()
  2120.         Header = 30
  2121.         BackColor = Color.FromArgb(50, 50, 50)
  2122.  
  2123.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  2124.         P2 = New Pen(Color.FromArgb(60, 60, 60))
  2125.  
  2126.         B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  2127.     End Sub
  2128.  
  2129.     Protected Overrides Sub ColorHook()
  2130.  
  2131.     End Sub
  2132.  
  2133.     Private R1 As Rectangle
  2134.  
  2135.     Private P1, P2 As Pen
  2136.     Private B1 As SolidBrush
  2137.  
  2138.     Private Pad As Integer
  2139.  
  2140.     Protected Overrides Sub PaintHook()
  2141.         G.Clear(BackColor)
  2142.         DrawBorders(P2, 1)
  2143.  
  2144.         G.DrawLine(P1, 0, 26, Width, 26)
  2145.         G.DrawLine(P2, 0, 25, Width, 25)
  2146.  
  2147.         Pad = Math.Max(Measure().Width + 20, 80)
  2148.         R1 = New Rectangle(Pad, 17, Width - (Pad * 2) + _AccentOffset, 8)
  2149.  
  2150.         G.DrawRectangle(P2, R1)
  2151.         G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height)
  2152.  
  2153.         G.DrawLine(P1, 0, 29, Width, 29)
  2154.         G.DrawLine(P2, 0, 30, Width, 30)
  2155.  
  2156.  
  2157.  
  2158.  
  2159.         DrawText(Brushes.Black, HorizontalAlignment.Left, 8, 1)
  2160.         DrawText(Brushes.WhiteSmoke, HorizontalAlignment.Left, 7, 0)
  2161.  
  2162.         G.FillRectangle(B1, 0, 27, Width, 2)
  2163.         DrawBorders(Pens.Black)
  2164.     End Sub
  2165.  
  2166. End Class
  2167.  
  2168. Class NSButton
  2169.     Inherits Control
  2170.  
  2171.     Sub New()
  2172.         SetStyle(DirectCast(139286, ControlStyles), True)
  2173.         SetStyle(ControlStyles.Selectable, False)
  2174.  
  2175.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  2176.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  2177.     End Sub
  2178.  
  2179.     Private IsMouseDown As Boolean
  2180.  
  2181.     Private GP1, GP2 As GraphicsPath
  2182.  
  2183.     Private SZ1 As SizeF
  2184.     Private PT1 As PointF
  2185.  
  2186.     Private P1, P2 As Pen
  2187.  
  2188.     Private PB1 As PathGradientBrush
  2189.     Private GB1 As LinearGradientBrush
  2190.  
  2191.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2192.         G = e.Graphics
  2193.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2194.  
  2195.         G.Clear(BackColor)
  2196.         G.SmoothingMode = SmoothingMode.AntiAlias
  2197.  
  2198.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  2199.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  2200.  
  2201.         If IsMouseDown Then
  2202.             PB1 = New PathGradientBrush(GP1)
  2203.             PB1.CenterColor = Color.FromArgb(60, 60, 60)
  2204.             PB1.SurroundColors = {Color.FromArgb(55, 55, 55)}
  2205.             PB1.FocusScales = New PointF(0.8F, 0.5F)
  2206.  
  2207.             G.FillPath(PB1, GP1)
  2208.         Else
  2209.             GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  2210.             G.FillPath(GB1, GP1)
  2211.         End If
  2212.  
  2213.         G.DrawPath(P1, GP1)
  2214.         G.DrawPath(P2, GP2)
  2215.  
  2216.         SZ1 = G.MeasureString(Text, Font)
  2217.         PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2)
  2218.  
  2219.         If IsMouseDown Then
  2220.             PT1.X += 1.0F
  2221.             PT1.Y += 1.0F
  2222.         End If
  2223.  
  2224.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2225.         G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1)
  2226.     End Sub
  2227.  
  2228.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2229.         IsMouseDown = True
  2230.         Invalidate()
  2231.     End Sub
  2232.  
  2233.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2234.         IsMouseDown = False
  2235.         Invalidate()
  2236.     End Sub
  2237.  
  2238. End Class
  2239.  
  2240. Class NSProgressBar
  2241.     Inherits Control
  2242.  
  2243.     Private _Minimum As Integer
  2244.     Property Minimum() As Integer
  2245.         Get
  2246.             Return _Minimum
  2247.         End Get
  2248.         Set(ByVal value As Integer)
  2249.             If value < 0 Then
  2250.                 Throw New Exception("Property value is not valid.")
  2251.             End If
  2252.  
  2253.             _Minimum = value
  2254.             If value > _Value Then _Value = value
  2255.             If value > _Maximum Then _Maximum = value
  2256.             Invalidate()
  2257.         End Set
  2258.     End Property
  2259.  
  2260.     Private _Maximum As Integer = 100
  2261.     Property Maximum() As Integer
  2262.         Get
  2263.             Return _Maximum
  2264.         End Get
  2265.         Set(ByVal value As Integer)
  2266.             If value < 0 Then
  2267.                 Throw New Exception("Property value is not valid.")
  2268.             End If
  2269.  
  2270.             _Maximum = value
  2271.             If value < _Value Then _Value = value
  2272.             If value < _Minimum Then _Minimum = value
  2273.             Invalidate()
  2274.         End Set
  2275.     End Property
  2276.  
  2277.     Private _Value As Integer
  2278.     Property Value() As Integer
  2279.         Get
  2280.             Return _Value
  2281.         End Get
  2282.         Set(ByVal value As Integer)
  2283.             If value > _Maximum OrElse value < _Minimum Then
  2284.                 Throw New Exception("Property value is not valid.")
  2285.             End If
  2286.  
  2287.             _Value = value
  2288.             Invalidate()
  2289.         End Set
  2290.     End Property
  2291.  
  2292.     Private Sub Increment(ByVal amount As Integer)
  2293.         Value += amount
  2294.     End Sub
  2295.  
  2296.     Sub New()
  2297.         SetStyle(DirectCast(139286, ControlStyles), True)
  2298.         SetStyle(ControlStyles.Selectable, False)
  2299.  
  2300.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  2301.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  2302.         B1 = New SolidBrush(Color.FromArgb(51, 181, 229))
  2303.     End Sub
  2304.  
  2305.     Private GP1, GP2, GP3 As GraphicsPath
  2306.  
  2307.     Private R1, R2 As Rectangle
  2308.  
  2309.     Private P1, P2 As Pen
  2310.     Private B1 As SolidBrush
  2311.     Private GB1, GB2 As LinearGradientBrush
  2312.  
  2313.     Private I1 As Integer
  2314.  
  2315.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2316.         G = e.Graphics
  2317.  
  2318.         G.Clear(BackColor)
  2319.         G.SmoothingMode = SmoothingMode.AntiAlias
  2320.  
  2321.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  2322.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  2323.  
  2324.         R1 = New Rectangle(0, 2, Width - 1, Height - 1)
  2325.         GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  2326.  
  2327.         G.SetClip(GP1)
  2328.         G.FillRectangle(GB1, R1)
  2329.  
  2330.         I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3))
  2331.  
  2332.         If I1 > 1 Then
  2333.             GP3 = CreateRound(1, 1, I1, Height - 3, 7)
  2334.  
  2335.             R2 = New Rectangle(1, 1, I1, Height - 3)
  2336.             GB2 = New LinearGradientBrush(R2, Color.FromArgb(51, 181, 229), Color.FromArgb(0, 153, 204), 90.0F)
  2337.  
  2338.             G.FillPath(GB2, GP3)
  2339.             G.DrawPath(P1, GP3)
  2340.  
  2341.             G.SetClip(GP3)
  2342.             G.SmoothingMode = SmoothingMode.None
  2343.  
  2344.             G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height \ 2)
  2345.  
  2346.             G.SmoothingMode = SmoothingMode.AntiAlias
  2347.             G.ResetClip()
  2348.         End If
  2349.  
  2350.         G.DrawPath(P2, GP1)
  2351.         G.DrawPath(P1, GP2)
  2352.     End Sub
  2353.  
  2354. End Class
  2355.  
  2356. Class NSLabel
  2357.     Inherits Control
  2358.  
  2359.     Sub New()
  2360.         SetStyle(DirectCast(139286, ControlStyles), True)
  2361.         SetStyle(ControlStyles.Selectable, False)
  2362.  
  2363.         Font = New Font("Segoe UI", 11.25F, FontStyle.Bold)
  2364.  
  2365.         B1 = New SolidBrush(Color.FromArgb(51, 181, 229))
  2366.     End Sub
  2367.  
  2368.     Private _Value1 As String = "NET"
  2369.     Public Property Value1() As String
  2370.         Get
  2371.             Return _Value1
  2372.         End Get
  2373.         Set(ByVal value As String)
  2374.             _Value1 = value
  2375.             Invalidate()
  2376.         End Set
  2377.     End Property
  2378.  
  2379.     Private _Value2 As String = "SEAL"
  2380.     Public Property Value2() As String
  2381.         Get
  2382.             Return _Value2
  2383.         End Get
  2384.         Set(ByVal value As String)
  2385.             _Value2 = value
  2386.             Invalidate()
  2387.         End Set
  2388.     End Property
  2389.  
  2390.     Private B1 As SolidBrush
  2391.  
  2392.     Private PT1, PT2 As PointF
  2393.     Private SZ1, SZ2 As SizeF
  2394.  
  2395.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2396.         G = e.Graphics
  2397.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2398.  
  2399.         G.Clear(BackColor)
  2400.  
  2401.         SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic)
  2402.         SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic)
  2403.  
  2404.         PT1 = New PointF(0, Height \ 2 - SZ1.Height / 2)
  2405.         PT2 = New PointF(SZ1.Width + 1, Height \ 2 - SZ1.Height / 2)
  2406.  
  2407.         G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2408.         G.DrawString(Value1, Font, Brushes.WhiteSmoke, PT1)
  2409.  
  2410.         G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1)
  2411.         G.DrawString(Value2, Font, B1, PT2)
  2412.     End Sub
  2413.  
  2414. End Class
  2415.  
  2416. Class KachClazz
  2417.     Inherits Control
  2418.  
  2419.     Sub New()
  2420.         SetStyle(DirectCast(139286, ControlStyles), True)
  2421.         SetStyle(ControlStyles.Selectable, False)
  2422.  
  2423.         Font = New Font("Segoe UI", 11.25F, FontStyle.Bold)
  2424.  
  2425.         B1 = New SolidBrush(Color.FromArgb(51, 181, 229))
  2426.     End Sub
  2427.  
  2428.     Private _Value1 As String = "Ќąȼh"
  2429.     Public Property Value1() As String
  2430.         Get
  2431.             Return _Value1
  2432.         End Get
  2433.         Set(ByVal value As String)
  2434.             _Value1 = value
  2435.             Invalidate()
  2436.         End Set
  2437.     End Property
  2438.  
  2439.     Private _Value2 As String = "ȼℓąƶƶ"
  2440.     Public Property Value2() As String
  2441.         Get
  2442.             Return _Value2
  2443.         End Get
  2444.         Set(ByVal value As String)
  2445.             _Value2 = value
  2446.             Invalidate()
  2447.         End Set
  2448.     End Property
  2449.  
  2450.     Private B1 As SolidBrush
  2451.  
  2452.     Private PT1, PT2 As PointF
  2453.     Private SZ1, SZ2 As SizeF
  2454.  
  2455.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  2456.         G = e.Graphics
  2457.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2458.  
  2459.         G.Clear(BackColor)
  2460.  
  2461.         SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic)
  2462.         SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic)
  2463.  
  2464.         PT1 = New PointF(0, Height \ 2 - SZ1.Height / 2)
  2465.         PT2 = New PointF(SZ1.Width + 1, Height \ 2 - SZ1.Height / 2)
  2466.  
  2467.         G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2468.         G.DrawString(Value1, Font, Brushes.WhiteSmoke, PT1)
  2469.  
  2470.         G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1)
  2471.         G.DrawString(Value2, Font, B1, PT2)
  2472.     End Sub
  2473.  
  2474. End Class
  2475.  
  2476.  
  2477. <DefaultEvent("TextChanged")>
  2478. Class NSTextBox
  2479.     Inherits Control
  2480.  
  2481.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  2482.     Property TextAlign() As HorizontalAlignment
  2483.         Get
  2484.             Return _TextAlign
  2485.         End Get
  2486.         Set(ByVal value As HorizontalAlignment)
  2487.             _TextAlign = value
  2488.             If Base IsNot Nothing Then
  2489.                 Base.TextAlign = value
  2490.             End If
  2491.         End Set
  2492.     End Property
  2493.  
  2494.     Private _MaxLength As Integer = 32767
  2495.     Property MaxLength() As Integer
  2496.         Get
  2497.             Return _MaxLength
  2498.         End Get
  2499.         Set(ByVal value As Integer)
  2500.             _MaxLength = value
  2501.             If Base IsNot Nothing Then
  2502.                 Base.MaxLength = value
  2503.             End If
  2504.         End Set
  2505.     End Property
  2506.  
  2507.     Private _ReadOnly As Boolean
  2508.     Property [ReadOnly]() As Boolean
  2509.         Get
  2510.             Return _ReadOnly
  2511.         End Get
  2512.         Set(ByVal value As Boolean)
  2513.             _ReadOnly = value
  2514.             If Base IsNot Nothing Then
  2515.                 Base.ReadOnly = value
  2516.             End If
  2517.         End Set
  2518.     End Property
  2519.  
  2520.     Private _UseSystemPasswordChar As Boolean
  2521.     Property UseSystemPasswordChar() As Boolean
  2522.         Get
  2523.             Return _UseSystemPasswordChar
  2524.         End Get
  2525.         Set(ByVal value As Boolean)
  2526.             _UseSystemPasswordChar = value
  2527.             If Base IsNot Nothing Then
  2528.                 Base.UseSystemPasswordChar = value
  2529.             End If
  2530.         End Set
  2531.     End Property
  2532.  
  2533.     Private _Multiline As Boolean
  2534.     Property Multiline() As Boolean
  2535.         Get
  2536.             Return _Multiline
  2537.         End Get
  2538.         Set(ByVal value As Boolean)
  2539.             _Multiline = value
  2540.             If Base IsNot Nothing Then
  2541.                 Base.Multiline = value
  2542.  
  2543.                 If value Then
  2544.                     Base.Height = Height - 11
  2545.                 Else
  2546.                     Height = Base.Height + 11
  2547.                 End If
  2548.             End If
  2549.         End Set
  2550.     End Property
  2551.  
  2552.     Overrides Property Text As String
  2553.         Get
  2554.             Return MyBase.Text
  2555.         End Get
  2556.         Set(ByVal value As String)
  2557.             MyBase.Text = value
  2558.             If Base IsNot Nothing Then
  2559.                 Base.Text = value
  2560.             End If
  2561.         End Set
  2562.     End Property
  2563.  
  2564.     Overrides Property Font As Font
  2565.         Get
  2566.             Return MyBase.Font
  2567.         End Get
  2568.         Set(ByVal value As Font)
  2569.             MyBase.Font = value
  2570.             If Base IsNot Nothing Then
  2571.                 Base.Font = value
  2572.                 Base.Location = New Point(5, 5)
  2573.                 Base.Width = Width - 8
  2574.  
  2575.                 If Not _Multiline Then
  2576.                     Height = Base.Height + 11
  2577.                 End If
  2578.             End If
  2579.         End Set
  2580.     End Property
  2581.  
  2582.     Protected Overrides Sub OnHandleCreated(e As EventArgs)
  2583.         If Not Controls.Contains(Base) Then
  2584.             Controls.Add(Base)
  2585.         End If
  2586.  
  2587.         MyBase.OnHandleCreated(e)
  2588.     End Sub
  2589.  
  2590.     Private Base As TextBox
  2591.     Sub New()
  2592.         SetStyle(DirectCast(139286, ControlStyles), True)
  2593.         SetStyle(ControlStyles.Selectable, True)
  2594.  
  2595.         Cursor = Cursors.IBeam
  2596.  
  2597.         Base = New TextBox
  2598.         Base.Font = Font
  2599.         Base.Text = Text
  2600.         Base.MaxLength = _MaxLength
  2601.         Base.Multiline = _Multiline
  2602.         Base.ReadOnly = _ReadOnly
  2603.         Base.UseSystemPasswordChar = _UseSystemPasswordChar
  2604.  
  2605.         Base.ForeColor = Color.FromArgb(235, 235, 235)
  2606.         Base.BackColor = Color.FromArgb(50, 50, 50)
  2607.  
  2608.         Base.BorderStyle = BorderStyle.None
  2609.  
  2610.         Base.Location = New Point(5, 5)
  2611.         Base.Width = Width - 14
  2612.  
  2613.         If _Multiline Then
  2614.             Base.Height = Height - 11
  2615.         Else
  2616.             Height = Base.Height + 11
  2617.         End If
  2618.  
  2619.         AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  2620.         AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  2621.  
  2622.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  2623.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  2624.     End Sub
  2625.  
  2626.     Private GP1, GP2 As GraphicsPath
  2627.  
  2628.     Private P1, P2 As Pen
  2629.     Private PB1 As PathGradientBrush
  2630.  
  2631.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  2632.         G = e.Graphics
  2633.  
  2634.         G.Clear(BackColor)
  2635.         G.SmoothingMode = SmoothingMode.AntiAlias
  2636.  
  2637.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  2638.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  2639.  
  2640.         PB1 = New PathGradientBrush(GP1)
  2641.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  2642.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  2643.         PB1.FocusScales = New PointF(0.9F, 0.5F)
  2644.  
  2645.         G.FillPath(PB1, GP1)
  2646.  
  2647.         G.DrawPath(P2, GP1)
  2648.         G.DrawPath(P1, GP2)
  2649.     End Sub
  2650.  
  2651.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  2652.         Text = Base.Text
  2653.     End Sub
  2654.  
  2655.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  2656.         If e.Control AndAlso e.KeyCode = Keys.A Then
  2657.             Base.SelectAll()
  2658.             e.SuppressKeyPress = True
  2659.         End If
  2660.     End Sub
  2661.  
  2662.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  2663.         Base.Location = New Point(5, 5)
  2664.  
  2665.         Base.Width = Width - 10
  2666.         Base.Height = Height - 11
  2667.  
  2668.         MyBase.OnResize(e)
  2669.     End Sub
  2670.  
  2671.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2672.         Base.Focus()
  2673.         MyBase.OnMouseDown(e)
  2674.     End Sub
  2675.  
  2676.     Protected Overrides Sub OnEnter(e As EventArgs)
  2677.         Base.Focus()
  2678.         Invalidate()
  2679.         MyBase.OnEnter(e)
  2680.     End Sub
  2681.  
  2682.     Protected Overrides Sub OnLeave(e As EventArgs)
  2683.         Invalidate()
  2684.         MyBase.OnLeave(e)
  2685.     End Sub
  2686.  
  2687. End Class
  2688.  
  2689. <DefaultEvent("CheckedChanged")>
  2690. Class NSCheckBox
  2691.     Inherits Control
  2692.  
  2693.     Event CheckedChanged(sender As Object)
  2694.  
  2695.     Sub New()
  2696.         SetStyle(DirectCast(139286, ControlStyles), True)
  2697.         SetStyle(ControlStyles.Selectable, False)
  2698.  
  2699.         P11 = New Pen(Color.FromArgb(55, 55, 55))
  2700.         P22 = New Pen(Color.FromArgb(24, 24, 24))
  2701.         P3 = New Pen(Color.Black, 2.0F)
  2702.         P4 = New Pen(Color.FromArgb(235, 235, 235), 2.0F)
  2703.     End Sub
  2704.  
  2705.     Private _Checked As Boolean
  2706.     Public Property Checked() As Boolean
  2707.         Get
  2708.             Return _Checked
  2709.         End Get
  2710.         Set(ByVal value As Boolean)
  2711.             _Checked = value
  2712.             RaiseEvent CheckedChanged(Me)
  2713.  
  2714.             Invalidate()
  2715.         End Set
  2716.     End Property
  2717.  
  2718.     Private GP1, GP2 As GraphicsPath
  2719.  
  2720.     Private SZ1 As SizeF
  2721.     Private PT1 As PointF
  2722.  
  2723.     Private P11, P22, P3, P4 As Pen
  2724.  
  2725.     Private PB1 As PathGradientBrush
  2726.  
  2727.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  2728.         G = e.Graphics
  2729.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2730.  
  2731.         G.Clear(BackColor)
  2732.         G.SmoothingMode = SmoothingMode.AntiAlias
  2733.  
  2734.         GP1 = CreateRound(0, 2, Height - 5, Height - 5, 5)
  2735.         GP2 = CreateRound(1, 3, Height - 7, Height - 7, 5)
  2736.  
  2737.         PB1 = New PathGradientBrush(GP1)
  2738.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  2739.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  2740.         PB1.FocusScales = New PointF(0.3F, 0.3F)
  2741.  
  2742.         G.FillPath(PB1, GP1)
  2743.         G.DrawPath(P11, GP1)
  2744.         G.DrawPath(P22, GP2)
  2745.  
  2746.         If _Checked Then
  2747.             G.DrawLine(P3, 5, Height - 9, 8, Height - 7)
  2748.             G.DrawLine(P3, 7, Height - 7, Height - 8, 7)
  2749.  
  2750.             G.DrawLine(P4, 4, Height - 10, 7, Height - 8)
  2751.             G.DrawLine(P4, 6, Height - 8, Height - 9, 6)
  2752.         End If
  2753.  
  2754.         SZ1 = G.MeasureString(Text, Font)
  2755.         PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  2756.  
  2757.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2758.         G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1)
  2759.     End Sub
  2760.  
  2761.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2762.         Checked = Not Checked
  2763.     End Sub
  2764.  
  2765. End Class
  2766.  
  2767. <DefaultEvent("CheckedChanged")>
  2768. Class NSRadioButton
  2769.     Inherits Control
  2770.  
  2771.     Event CheckedChanged(sender As Object)
  2772.  
  2773.     Sub New()
  2774.         SetStyle(DirectCast(139286, ControlStyles), True)
  2775.         SetStyle(ControlStyles.Selectable, False)
  2776.  
  2777.         P1 = New Pen(Color.FromArgb(55, 55, 55))
  2778.         P2 = New Pen(Color.FromArgb(24, 24, 24))
  2779.     End Sub
  2780.  
  2781.     Private _Checked As Boolean
  2782.     Public Property Checked() As Boolean
  2783.         Get
  2784.             Return _Checked
  2785.         End Get
  2786.         Set(ByVal value As Boolean)
  2787.             _Checked = value
  2788.  
  2789.             If _Checked Then
  2790.                 InvalidateParent()
  2791.             End If
  2792.  
  2793.             RaiseEvent CheckedChanged(Me)
  2794.             Invalidate()
  2795.         End Set
  2796.     End Property
  2797.  
  2798.     Private Sub InvalidateParent()
  2799.         If Parent Is Nothing Then Return
  2800.  
  2801.         For Each C As Control In Parent.Controls
  2802.             If Not (C Is Me) AndAlso (TypeOf C Is NSRadioButton) Then
  2803.                 DirectCast(C, NSRadioButton).Checked = False
  2804.             End If
  2805.         Next
  2806.     End Sub
  2807.  
  2808.     Private GP1 As GraphicsPath
  2809.  
  2810.     Private SZ1 As SizeF
  2811.     Private PT1 As PointF
  2812.  
  2813.     Private P1, P2 As Pen
  2814.  
  2815.     Private PB1 As PathGradientBrush
  2816.  
  2817.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  2818.         G = e.Graphics
  2819.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2820.  
  2821.         G.Clear(BackColor)
  2822.         G.SmoothingMode = SmoothingMode.AntiAlias
  2823.  
  2824.         GP1 = New GraphicsPath
  2825.         GP1.AddEllipse(0, 2, Height - 5, Height - 5)
  2826.  
  2827.         PB1 = New PathGradientBrush(GP1)
  2828.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  2829.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  2830.         PB1.FocusScales = New PointF(0.3F, 0.3F)
  2831.  
  2832.         G.FillPath(PB1, GP1)
  2833.  
  2834.         G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5)
  2835.         G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7)
  2836.  
  2837.         If _Checked Then
  2838.             G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15)
  2839.             G.FillEllipse(Brushes.WhiteSmoke, 5, 7, Height - 15, Height - 15)
  2840.         End If
  2841.  
  2842.         SZ1 = G.MeasureString(Text, Font)
  2843.         PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  2844.  
  2845.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2846.         G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1)
  2847.     End Sub
  2848.  
  2849.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2850.         Checked = True
  2851.         MyBase.OnMouseDown(e)
  2852.     End Sub
  2853.  
  2854. End Class
  2855.  
  2856. Class NSComboBox
  2857.     Inherits ComboBox
  2858.  
  2859.     Sub New()
  2860.         SetStyle(DirectCast(139286, ControlStyles), True)
  2861.         SetStyle(ControlStyles.Selectable, False)
  2862.  
  2863.         DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
  2864.         DropDownStyle = ComboBoxStyle.DropDownList
  2865.  
  2866.         BackColor = Color.FromArgb(50, 50, 50)
  2867.         ForeColor = Color.FromArgb(235, 235, 235)
  2868.  
  2869.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  2870.         P2 = New Pen(Color.FromArgb(235, 235, 235), 2.0F)
  2871.         P3 = New Pen(Brushes.Black, 2.0F)
  2872.         P4 = New Pen(Color.FromArgb(65, 65, 65))
  2873.  
  2874.         B1 = New SolidBrush(Color.FromArgb(65, 65, 65))
  2875.         B2 = New SolidBrush(Color.FromArgb(55, 55, 55))
  2876.     End Sub
  2877.  
  2878.     Private GP1, GP2 As GraphicsPath
  2879.  
  2880.     Private SZ1 As SizeF
  2881.     Private PT1 As PointF
  2882.  
  2883.     Private P1, P2, P3, P4 As Pen
  2884.     Private B1, B2 As SolidBrush
  2885.  
  2886.     Private GB1 As LinearGradientBrush
  2887.  
  2888.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2889.         G = e.Graphics
  2890.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2891.  
  2892.         G.Clear(BackColor)
  2893.         G.SmoothingMode = SmoothingMode.AntiAlias
  2894.  
  2895.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  2896.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  2897.  
  2898.         GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  2899.         G.SetClip(GP1)
  2900.         G.FillRectangle(GB1, ClientRectangle)
  2901.         G.ResetClip()
  2902.  
  2903.         G.DrawPath(P1, GP1)
  2904.         G.DrawPath(P4, GP2)
  2905.  
  2906.         SZ1 = G.MeasureString(Text, Font)
  2907.         PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2)
  2908.  
  2909.         G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2910.         G.DrawString(Text, Font, Brushes.WhiteSmoke, PT1)
  2911.  
  2912.         G.DrawLine(P3, Width - 15, 10, Width - 11, 13)
  2913.         G.DrawLine(P3, Width - 7, 10, Width - 11, 13)
  2914.         G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14)
  2915.  
  2916.         G.DrawLine(P2, Width - 16, 9, Width - 12, 12)
  2917.         G.DrawLine(P2, Width - 8, 9, Width - 12, 12)
  2918.         G.DrawLine(Pens.WhiteSmoke, Width - 12, 12, Width - 12, 13)
  2919.  
  2920.         G.DrawLine(P1, Width - 22, 0, Width - 22, Height)
  2921.         G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2)
  2922.         G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2)
  2923.     End Sub
  2924.  
  2925.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  2926.         e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2927.  
  2928.         If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2929.             e.Graphics.FillRectangle(B1, e.Bounds)
  2930.         Else
  2931.             e.Graphics.FillRectangle(B2, e.Bounds)
  2932.         End If
  2933.  
  2934.         If Not e.Index = -1 Then
  2935.             e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, Brushes.WhiteSmoke, e.Bounds)
  2936.         End If
  2937.     End Sub
  2938.  
  2939. End Class
  2940.  
  2941. Class NSTabControl
  2942.     Inherits TabControl
  2943.  
  2944.     Sub New()
  2945.         SetStyle(DirectCast(139286, ControlStyles), True)
  2946.         SetStyle(ControlStyles.Selectable, False)
  2947.  
  2948.         SizeMode = TabSizeMode.Fixed
  2949.         Alignment = TabAlignment.Left
  2950.         ItemSize = New Size(28, 115)
  2951.  
  2952.         DrawMode = TabDrawMode.OwnerDrawFixed
  2953.  
  2954.         P1 = New Pen(Color.FromArgb(55, 55, 55))
  2955.         P2 = New Pen(Color.FromArgb(24, 24, 24))
  2956.         P3 = New Pen(Color.FromArgb(45, 45, 45), 2)
  2957.  
  2958.         B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  2959.         B2 = New SolidBrush(Color.FromArgb(24, 24, 24))
  2960.         B3 = New SolidBrush(Color.FromArgb(51, 181, 229))
  2961.         B4 = New SolidBrush(Color.FromArgb(65, 65, 65))
  2962.  
  2963.         SF1 = New StringFormat()
  2964.         SF1.LineAlignment = StringAlignment.Center
  2965.     End Sub
  2966.  
  2967.     Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  2968.         If TypeOf e.Control Is TabPage Then
  2969.             e.Control.BackColor = Color.FromArgb(50, 50, 50)
  2970.         End If
  2971.  
  2972.         MyBase.OnControlAdded(e)
  2973.     End Sub
  2974.  
  2975.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  2976.  
  2977.     Private R1, R2 As Rectangle
  2978.  
  2979.     Private P1, P2, P3 As Pen
  2980.     Private B1, B2, B3, B4 As SolidBrush
  2981.  
  2982.     Private PB1 As PathGradientBrush
  2983.  
  2984.     Private TP1 As TabPage
  2985.     Private SF1 As StringFormat
  2986.  
  2987.     Private Offset As Integer
  2988.     Private ItemHeight As Integer
  2989.  
  2990.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2991.         G = e.Graphics
  2992.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2993.  
  2994.         G.Clear(Color.FromArgb(50, 50, 50))
  2995.         G.SmoothingMode = SmoothingMode.AntiAlias
  2996.  
  2997.         ItemHeight = ItemSize.Height + 2
  2998.  
  2999.         GP1 = CreateRound(0, 0, ItemHeight + 3, Height - 1, 7)
  3000.         GP2 = CreateRound(1, 1, ItemHeight + 3, Height - 3, 7)
  3001.  
  3002.         PB1 = New PathGradientBrush(GP1)
  3003.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  3004.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  3005.         PB1.FocusScales = New PointF(0.8F, 0.95F)
  3006.  
  3007.         G.FillPath(PB1, GP1)
  3008.  
  3009.         G.DrawPath(P1, GP1)
  3010.         G.DrawPath(P2, GP2)
  3011.  
  3012.         For I As Integer = 0 To TabCount - 1
  3013.             R1 = GetTabRect(I)
  3014.             R1.Y += 2
  3015.             R1.Height -= 3
  3016.             R1.Width += 1
  3017.             R1.X -= 1
  3018.  
  3019.             TP1 = TabPages(I)
  3020.             Offset = 0
  3021.  
  3022.             If SelectedIndex = I Then
  3023.                 G.FillRectangle(B1, R1)
  3024.  
  3025.                 For J As Integer = 0 To 1
  3026.                     G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9)
  3027.  
  3028.                     G.SmoothingMode = SmoothingMode.None
  3029.                     G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9)
  3030.                     G.SmoothingMode = SmoothingMode.AntiAlias
  3031.  
  3032.                     Offset += 5
  3033.                 Next
  3034.  
  3035.                 G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2)
  3036.                 G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2)
  3037.                 G.DrawRectangle(P2, R1)
  3038.             Else
  3039.                 For J As Integer = 0 To 1
  3040.                     G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9)
  3041.  
  3042.                     G.SmoothingMode = SmoothingMode.None
  3043.                     G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9)
  3044.                     G.SmoothingMode = SmoothingMode.AntiAlias
  3045.  
  3046.                     Offset += 5
  3047.                 Next
  3048.             End If
  3049.  
  3050.             R1.X += 5 + Offset
  3051.  
  3052.             R2 = R1
  3053.             R2.Y += 1
  3054.             R2.X += 1
  3055.  
  3056.             G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1)
  3057.             G.DrawString(TP1.Text, Font, Brushes.WhiteSmoke, R1, SF1)
  3058.         Next
  3059.  
  3060.         GP3 = CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7)
  3061.         GP4 = CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7)
  3062.  
  3063.         G.DrawPath(P2, GP3)
  3064.         G.DrawPath(P1, GP4)
  3065.     End Sub
  3066.  
  3067. End Class
  3068.  
  3069. <DefaultEvent("CheckedChanged")>
  3070. Class NSOnOffBox
  3071.     Inherits Control
  3072.  
  3073.     Event CheckedChanged(sender As Object)
  3074.  
  3075.     Sub New()
  3076.         SetStyle(DirectCast(139286, ControlStyles), True)
  3077.         SetStyle(ControlStyles.Selectable, False)
  3078.  
  3079.         P1 = New Pen(Color.FromArgb(55, 55, 55))
  3080.         P2 = New Pen(Color.FromArgb(24, 24, 24))
  3081.         P3 = New Pen(Color.FromArgb(65, 65, 65))
  3082.  
  3083.         B1 = New SolidBrush(Color.FromArgb(24, 24, 24))
  3084.         B2 = New SolidBrush(Color.FromArgb(85, 85, 85))
  3085.         B3 = New SolidBrush(Color.FromArgb(65, 65, 65))
  3086.         B4 = New SolidBrush(Color.FromArgb(51, 181, 229))
  3087.         B5 = New SolidBrush(Color.FromArgb(40, 40, 40))
  3088.  
  3089.         SF1 = New StringFormat()
  3090.         SF1.LineAlignment = StringAlignment.Center
  3091.         SF1.Alignment = StringAlignment.Near
  3092.  
  3093.         SF2 = New StringFormat()
  3094.         SF2.LineAlignment = StringAlignment.Center
  3095.         SF2.Alignment = StringAlignment.Far
  3096.  
  3097.         Size = New Size(56, 24)
  3098.         MinimumSize = Size
  3099.         MaximumSize = Size
  3100.     End Sub
  3101.  
  3102.     Private _Checked As Boolean
  3103.     Public Property Checked() As Boolean
  3104.         Get
  3105.             Return _Checked
  3106.         End Get
  3107.         Set(ByVal value As Boolean)
  3108.             _Checked = value
  3109.             RaiseEvent CheckedChanged(Me)
  3110.  
  3111.             Invalidate()
  3112.         End Set
  3113.     End Property
  3114.  
  3115.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  3116.  
  3117.     Private P1, P2, P3 As Pen
  3118.     Private B1, B2, B3, B4, B5 As SolidBrush
  3119.  
  3120.     Private PB1 As PathGradientBrush
  3121.     Private GB1 As LinearGradientBrush
  3122.  
  3123.     Private R1, R2, R3 As Rectangle
  3124.     Private SF1, SF2 As StringFormat
  3125.  
  3126.     Private Offset As Integer
  3127.  
  3128.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  3129.         G = e.Graphics
  3130.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  3131.  
  3132.         G.Clear(BackColor)
  3133.         G.SmoothingMode = SmoothingMode.AntiAlias
  3134.  
  3135.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  3136.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  3137.  
  3138.         PB1 = New PathGradientBrush(GP1)
  3139.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  3140.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  3141.         PB1.FocusScales = New PointF(0.3F, 0.3F)
  3142.  
  3143.         G.FillPath(PB1, GP1)
  3144.         G.DrawPath(P1, GP1)
  3145.         G.DrawPath(P2, GP2)
  3146.  
  3147.         R1 = New Rectangle(5, 0, Width - 10, Height + 2)
  3148.         R2 = New Rectangle(6, 1, Width - 10, Height + 2)
  3149.  
  3150.         R3 = New Rectangle(1, 1, (Width \ 2) - 1, Height - 3)
  3151.  
  3152.         If _Checked Then
  3153.             G.DrawString("On", Font, Brushes.Black, R2, SF1)
  3154.             G.DrawString("On", Font, Brushes.WhiteSmoke, R1, SF1)
  3155.  
  3156.             R3.X += (Width \ 2) - 1
  3157.         Else
  3158.             G.DrawString("Off", Font, B1, R2, SF2)
  3159.             G.DrawString("Off", Font, B2, R1, SF2)
  3160.         End If
  3161.  
  3162.         GP3 = CreateRound(R3, 7)
  3163.         GP4 = CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7)
  3164.  
  3165.         GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  3166.  
  3167.         G.FillPath(GB1, GP3)
  3168.         G.DrawPath(P2, GP3)
  3169.         G.DrawPath(P3, GP4)
  3170.  
  3171.         Offset = R3.X + (R3.Width \ 2) - 3
  3172.  
  3173.         For I As Integer = 0 To 1
  3174.             If _Checked Then
  3175.                 G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14)
  3176.             Else
  3177.                 G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14)
  3178.             End If
  3179.  
  3180.             G.SmoothingMode = SmoothingMode.None
  3181.  
  3182.             If _Checked Then
  3183.                 G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14)
  3184.             Else
  3185.                 G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14)
  3186.             End If
  3187.  
  3188.             G.SmoothingMode = SmoothingMode.AntiAlias
  3189.         Next
  3190.     End Sub
  3191.  
  3192.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  3193.         Checked = Not Checked
  3194.         MyBase.OnMouseDown(e)
  3195.     End Sub
  3196.  
  3197. End Class
  3198.  
  3199. Class NSControlButton
  3200.     Inherits Control
  3201.  
  3202.     Enum Button As Byte
  3203.         None = 0
  3204.         Minimize = 1
  3205.         MaximizeRestore = 2
  3206.         Close = 3
  3207.     End Enum
  3208.  
  3209.     Private _ControlButton As Button = Button.Close
  3210.     Public Property ControlButton() As Button
  3211.         Get
  3212.             Return _ControlButton
  3213.         End Get
  3214.         Set(ByVal value As Button)
  3215.             _ControlButton = value
  3216.             Invalidate()
  3217.         End Set
  3218.     End Property
  3219.  
  3220.     Sub New()
  3221.         SetStyle(DirectCast(139286, ControlStyles), True)
  3222.         SetStyle(ControlStyles.Selectable, False)
  3223.  
  3224.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  3225.  
  3226.         Width = 18
  3227.         Height = 20
  3228.  
  3229.         MinimumSize = Size
  3230.         MaximumSize = Size
  3231.  
  3232.         Margin = New Padding(0)
  3233.     End Sub
  3234.  
  3235.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  3236.         G = e.Graphics
  3237.         G.Clear(BackColor)
  3238.  
  3239.         Select Case _ControlButton
  3240.             Case Button.Minimize
  3241.                 DrawMinimize(3, 10)
  3242.             Case Button.MaximizeRestore
  3243.                 If FindForm().WindowState = FormWindowState.Normal Then
  3244.                     DrawMaximize(3, 5)
  3245.                 Else
  3246.                     DrawRestore(3, 4)
  3247.                 End If
  3248.             Case Button.Close
  3249.                 DrawClose(4, 5)
  3250.         End Select
  3251.     End Sub
  3252.  
  3253.     Private Sub DrawMinimize(ByVal x As Integer, ByVal y As Integer)
  3254.         G.FillRectangle(Brushes.WhiteSmoke, x, y, 12, 5)
  3255.         G.DrawRectangle(Pens.Black, x, y, 11, 4)
  3256.     End Sub
  3257.  
  3258.     Private Sub DrawMaximize(ByVal x As Integer, ByVal y As Integer)
  3259.         G.DrawRectangle(New Pen(Color.FromArgb(235, 235, 235), 2), x + 2, y + 2, 8, 6)
  3260.         G.DrawRectangle(Pens.Black, x, y, 11, 9)
  3261.         G.DrawRectangle(Pens.Black, x + 3, y + 3, 5, 3)
  3262.     End Sub
  3263.  
  3264.     Private Sub DrawRestore(ByVal x As Integer, ByVal y As Integer)
  3265.         G.FillRectangle(Brushes.WhiteSmoke, x + 3, y + 1, 8, 4)
  3266.         G.FillRectangle(Brushes.WhiteSmoke, x + 7, y + 5, 4, 4)
  3267.         G.DrawRectangle(Pens.Black, x + 2, y + 0, 9, 9)
  3268.  
  3269.         G.FillRectangle(Brushes.WhiteSmoke, x + 1, y + 3, 2, 6)
  3270.         G.FillRectangle(Brushes.WhiteSmoke, x + 1, y + 9, 8, 2)
  3271.         G.DrawRectangle(Pens.Black, x, y + 2, 9, 9)
  3272.         G.DrawRectangle(Pens.Black, x + 3, y + 5, 3, 3)
  3273.     End Sub
  3274.  
  3275.     Private ClosePath As GraphicsPath
  3276.     Private Sub DrawClose(ByVal x As Integer, ByVal y As Integer)
  3277.         If ClosePath Is Nothing Then
  3278.             ClosePath = New GraphicsPath
  3279.             ClosePath.AddLine(x + 1, y, x + 3, y)
  3280.             ClosePath.AddLine(x + 5, y + 2, x + 7, y)
  3281.             ClosePath.AddLine(x + 9, y, x + 10, y + 1)
  3282.             ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5)
  3283.             ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9)
  3284.             ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7)
  3285.             ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9)
  3286.             ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5)
  3287.             ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1)
  3288.         End If
  3289.         G.FillPath(Brushes.WhiteSmoke, ClosePath)
  3290.         G.DrawPath(Pens.Black, ClosePath)
  3291.     End Sub
  3292.  
  3293.     Protected Overrides Sub OnMouseClick(ByVal e As MouseEventArgs)
  3294.         If e.Button = System.Windows.Forms.MouseButtons.Left Then
  3295.  
  3296.             Dim F As Form = FindForm()
  3297.  
  3298.             Select Case _ControlButton
  3299.                 Case Button.Minimize
  3300.                     F.WindowState = FormWindowState.Minimized
  3301.                 Case Button.MaximizeRestore
  3302.                     If F.WindowState = FormWindowState.Normal Then
  3303.                         F.WindowState = FormWindowState.Maximized
  3304.                     Else
  3305.                         F.WindowState = FormWindowState.Normal
  3306.                     End If
  3307.                 Case Button.Close
  3308.                     F.Close()
  3309.             End Select
  3310.  
  3311.         End If
  3312.  
  3313.         Invalidate()
  3314.         MyBase.OnMouseClick(e)
  3315.     End Sub
  3316.  
  3317. End Class
  3318.  
  3319. Class NSGroupBox
  3320.     Inherits ContainerControl
  3321.  
  3322.     Private _DrawSeperator As Boolean
  3323.     Public Property DrawSeperator() As Boolean
  3324.         Get
  3325.             Return _DrawSeperator
  3326.         End Get
  3327.         Set(ByVal value As Boolean)
  3328.             _DrawSeperator = value
  3329.             Invalidate()
  3330.         End Set
  3331.     End Property
  3332.  
  3333.     Private _Title As String = "GroupBox"
  3334.     Public Property Title() As String
  3335.         Get
  3336.             Return _Title
  3337.         End Get
  3338.         Set(ByVal value As String)
  3339.             _Title = value
  3340.             Invalidate()
  3341.         End Set
  3342.     End Property
  3343.  
  3344.     Private _SubTitle As String = "Details"
  3345.     Public Property SubTitle() As String
  3346.         Get
  3347.             Return _SubTitle
  3348.         End Get
  3349.         Set(ByVal value As String)
  3350.             _SubTitle = value
  3351.             Invalidate()
  3352.         End Set
  3353.     End Property
  3354.  
  3355.     Private _TitleFont As Font
  3356.     Private _SubTitleFont As Font
  3357.  
  3358.     Sub New()
  3359.         SetStyle(DirectCast(139286, ControlStyles), True)
  3360.         SetStyle(ControlStyles.Selectable, False)
  3361.  
  3362.         _TitleFont = New Font("Verdana", 10.0F)
  3363.         _SubTitleFont = New Font("Verdana", 6.5F)
  3364.  
  3365.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  3366.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  3367.  
  3368.         B1 = New SolidBrush(Color.FromArgb(51, 181, 229))
  3369.     End Sub
  3370.  
  3371.     Private GP1, GP2 As GraphicsPath
  3372.  
  3373.     Private PT1 As PointF
  3374.     Private SZ1, SZ2 As SizeF
  3375.  
  3376.     Private P1, P2 As Pen
  3377.     Private B1 As SolidBrush
  3378.  
  3379.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  3380.         G = e.Graphics
  3381.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  3382.  
  3383.         G.Clear(BackColor)
  3384.         G.SmoothingMode = SmoothingMode.AntiAlias
  3385.  
  3386.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  3387.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  3388.  
  3389.         G.DrawPath(P1, GP1)
  3390.         G.DrawPath(P2, GP2)
  3391.  
  3392.         SZ1 = G.MeasureString(_Title, _TitleFont, Width, StringFormat.GenericTypographic)
  3393.         SZ2 = G.MeasureString(_SubTitle, _SubTitleFont, Width, StringFormat.GenericTypographic)
  3394.  
  3395.         G.DrawString(_Title, _TitleFont, Brushes.Black, 6, 6)
  3396.         G.DrawString(_Title, _TitleFont, B1, 5, 5)
  3397.  
  3398.         PT1 = New PointF(6.0F, SZ1.Height + 4.0F)
  3399.  
  3400.         G.DrawString(_SubTitle, _SubTitleFont, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  3401.         G.DrawString(_SubTitle, _SubTitleFont, Brushes.WhiteSmoke, PT1.X, PT1.Y)
  3402.  
  3403.         If _DrawSeperator Then
  3404.             Dim Y As Integer = CInt(PT1.Y + SZ2.Height) + 8
  3405.  
  3406.             G.DrawLine(P1, 4, Y, Width - 5, Y)
  3407.             G.DrawLine(P2, 4, Y + 1, Width - 5, Y + 1)
  3408.         End If
  3409.     End Sub
  3410.  
  3411. End Class
  3412.  
  3413. Class NSSeperator
  3414.     Inherits Control
  3415.  
  3416.     Sub New()
  3417.         SetStyle(DirectCast(139286, ControlStyles), True)
  3418.         SetStyle(ControlStyles.Selectable, False)
  3419.  
  3420.         Height = 10
  3421.  
  3422.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  3423.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  3424.     End Sub
  3425.  
  3426.     Private P1, P2 As Pen
  3427.  
  3428.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  3429.         G = e.Graphics
  3430.         G.Clear(BackColor)
  3431.  
  3432.         G.DrawLine(P1, 0, 5, Width, 5)
  3433.         G.DrawLine(P2, 0, 6, Width, 6)
  3434.     End Sub
  3435.  
  3436. End Class
  3437.  
  3438. <DefaultEvent("Scroll")>
  3439. Class NSTrackBar
  3440.     Inherits Control
  3441.  
  3442.     Event Scroll(ByVal sender As Object)
  3443.  
  3444.     Private _Minimum As Integer
  3445.     Property Minimum() As Integer
  3446.         Get
  3447.             Return _Minimum
  3448.         End Get
  3449.         Set(ByVal value As Integer)
  3450.             If value < 0 Then
  3451.                 Throw New Exception("Property value is not valid.")
  3452.             End If
  3453.  
  3454.             _Minimum = value
  3455.             If value > _Value Then _Value = value
  3456.             If value > _Maximum Then _Maximum = value
  3457.             Invalidate()
  3458.         End Set
  3459.     End Property
  3460.  
  3461.     Private _Maximum As Integer = 10
  3462.     Property Maximum() As Integer
  3463.         Get
  3464.             Return _Maximum
  3465.         End Get
  3466.         Set(ByVal value As Integer)
  3467.             If value < 0 Then
  3468.                 Throw New Exception("Property value is not valid.")
  3469.             End If
  3470.  
  3471.             _Maximum = value
  3472.             If value < _Value Then _Value = value
  3473.             If value < _Minimum Then _Minimum = value
  3474.             Invalidate()
  3475.         End Set
  3476.     End Property
  3477.  
  3478.     Private _Value As Integer
  3479.     Property Value() As Integer
  3480.         Get
  3481.             Return _Value
  3482.         End Get
  3483.         Set(ByVal value As Integer)
  3484.             If value = _Value Then Return
  3485.  
  3486.             If value > _Maximum OrElse value < _Minimum Then
  3487.                 Throw New Exception("Property value is not valid.")
  3488.             End If
  3489.  
  3490.             _Value = value
  3491.             Invalidate()
  3492.  
  3493.             RaiseEvent Scroll(Me)
  3494.         End Set
  3495.     End Property
  3496.  
  3497.     Sub New()
  3498.         SetStyle(DirectCast(139286, ControlStyles), True)
  3499.         SetStyle(ControlStyles.Selectable, False)
  3500.  
  3501.         Height = 17
  3502.  
  3503.         P1 = New Pen(Color.FromArgb(0, 153, 204), 2)
  3504.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  3505.         P3 = New Pen(Color.FromArgb(24, 24, 24))
  3506.         P4 = New Pen(Color.FromArgb(65, 65, 65))
  3507.     End Sub
  3508.  
  3509.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  3510.  
  3511.     Private R1, R2, R3 As Rectangle
  3512.     Private I1 As Integer
  3513.  
  3514.     Private P1, P2, P3, P4 As Pen
  3515.  
  3516.     Private GB1, GB2, GB3 As LinearGradientBrush
  3517.  
  3518.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  3519.         G = e.Graphics
  3520.  
  3521.         G.Clear(BackColor)
  3522.         G.SmoothingMode = SmoothingMode.AntiAlias
  3523.  
  3524.         GP1 = CreateRound(0, 5, Width - 1, 10, 5)
  3525.         GP2 = CreateRound(1, 6, Width - 3, 8, 5)
  3526.  
  3527.         R1 = New Rectangle(0, 7, Width - 1, 5)
  3528.         GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  3529.  
  3530.         I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  3531.         R2 = New Rectangle(I1, 0, 10, 20)
  3532.  
  3533.         G.SetClip(GP2)
  3534.         G.FillRectangle(GB1, R1)
  3535.  
  3536.         R3 = New Rectangle(1, 7, R2.X + R2.Width - 2, 8)
  3537.         GB2 = New LinearGradientBrush(R3, Color.FromArgb(51, 181, 229), Color.FromArgb(0, 153, 204), 90.0F)
  3538.  
  3539.         G.SmoothingMode = SmoothingMode.None
  3540.         G.FillRectangle(GB2, R3)
  3541.         G.SmoothingMode = SmoothingMode.AntiAlias
  3542.  
  3543.         For I As Integer = 0 To R3.Width - 15 Step 5
  3544.             G.DrawLine(P1, I, 0, I + 15, Height)
  3545.         Next
  3546.  
  3547.         G.ResetClip()
  3548.  
  3549.         G.DrawPath(P2, GP1)
  3550.         G.DrawPath(P3, GP2)
  3551.  
  3552.         GP3 = CreateRound(R2, 5)
  3553.         GP4 = CreateRound(R2.X + 1, R2.Y + 1, R2.Width - 2, R2.Height - 2, 5)
  3554.         GB3 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  3555.  
  3556.         G.FillPath(GB3, GP3)
  3557.         G.DrawPath(P3, GP3)
  3558.         G.DrawPath(P4, GP4)
  3559.     End Sub
  3560.  
  3561.     Private TrackDown As Boolean
  3562.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  3563.         If e.Button = System.Windows.Forms.MouseButtons.Left Then
  3564.             I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  3565.             R2 = New Rectangle(I1, 0, 10, 20)
  3566.  
  3567.             TrackDown = R2.Contains(e.Location)
  3568.         End If
  3569.  
  3570.         MyBase.OnMouseDown(e)
  3571.     End Sub
  3572.  
  3573.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  3574.         If TrackDown AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  3575.             Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  3576.         End If
  3577.  
  3578.         MyBase.OnMouseMove(e)
  3579.     End Sub
  3580.  
  3581.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  3582.         TrackDown = False
  3583.         MyBase.OnMouseUp(e)
  3584.     End Sub
  3585.  
  3586. End Class
  3587.  
  3588. <DefaultEvent("ValueChanged")>
  3589. Class NSRandomPool
  3590.     Inherits Control
  3591.  
  3592.     Event ValueChanged(ByVal sender As Object)
  3593.  
  3594.     Private _Value As New StringBuilder
  3595.     ReadOnly Property Value() As String
  3596.         Get
  3597.             Return _Value.ToString()
  3598.         End Get
  3599.     End Property
  3600.  
  3601.     Private _FullValue As String
  3602.     ReadOnly Property FullValue() As String
  3603.         Get
  3604.             Return BitConverter.ToString(Table).Replace("-", "")
  3605.         End Get
  3606.     End Property
  3607.  
  3608.     Private RNG As New Random()
  3609.  
  3610.     Private ItemSize As Integer = 9
  3611.     Private DrawSize As Integer = 8
  3612.  
  3613.     Private WA As Rectangle
  3614.  
  3615.     Private RowSize As Integer
  3616.     Private ColumnSize As Integer
  3617.  
  3618.     Sub New()
  3619.         SetStyle(DirectCast(139286, ControlStyles), True)
  3620.         SetStyle(ControlStyles.Selectable, False)
  3621.  
  3622.         P1 = New Pen(Color.FromArgb(55, 55, 55))
  3623.         P2 = New Pen(Color.FromArgb(24, 24, 24))
  3624.  
  3625.         B1 = New SolidBrush(Color.FromArgb(30, 30, 30))
  3626.     End Sub
  3627.  
  3628.     Protected Overrides Sub OnHandleCreated(e As EventArgs)
  3629.         UpdateTable()
  3630.         MyBase.OnHandleCreated(e)
  3631.     End Sub
  3632.  
  3633.     Private Table As Byte()
  3634.     Private Sub UpdateTable()
  3635.         WA = New Rectangle(5, 5, Width - 10, Height - 10)
  3636.  
  3637.         RowSize = WA.Width \ ItemSize
  3638.         ColumnSize = WA.Height \ ItemSize
  3639.  
  3640.         WA.Width = RowSize * ItemSize
  3641.         WA.Height = ColumnSize * ItemSize
  3642.  
  3643.         WA.X = (Width \ 2) - (WA.Width \ 2)
  3644.         WA.Y = (Height \ 2) - (WA.Height \ 2)
  3645.  
  3646.         Table = New Byte((RowSize * ColumnSize) - 1) {}
  3647.  
  3648.         For I As Integer = 0 To Table.Length - 1
  3649.             Table(I) = CByte(RNG.Next(100))
  3650.         Next
  3651.  
  3652.         Invalidate()
  3653.     End Sub
  3654.  
  3655.     Protected Overrides Sub OnSizeChanged(e As EventArgs)
  3656.         UpdateTable()
  3657.     End Sub
  3658.  
  3659.     Private Index1 As Integer = -1
  3660.     Private Index2 As Integer
  3661.  
  3662.     Private InvertColors As Boolean
  3663.  
  3664.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  3665.         HandleDraw(e)
  3666.     End Sub
  3667.  
  3668.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  3669.         HandleDraw(e)
  3670.         MyBase.OnMouseDown(e)
  3671.     End Sub
  3672.  
  3673.     Private Sub HandleDraw(e As MouseEventArgs)
  3674.         If e.Button = System.Windows.Forms.MouseButtons.Left OrElse e.Button = System.Windows.Forms.MouseButtons.Right Then
  3675.             If Not WA.Contains(e.Location) Then Return
  3676.  
  3677.             InvertColors = (e.Button = System.Windows.Forms.MouseButtons.Right)
  3678.  
  3679.             Index1 = GetIndex(e.X, e.Y)
  3680.             If Index1 = Index2 Then Return
  3681.  
  3682.             Dim L As Boolean = Not (Index1 Mod RowSize = 0)
  3683.             Dim R As Boolean = Not (Index1 Mod RowSize = (RowSize - 1))
  3684.  
  3685.             Randomize(Index1 - RowSize)
  3686.             If L Then Randomize(Index1 - 1)
  3687.             Randomize(Index1)
  3688.             If R Then Randomize(Index1 + 1)
  3689.             Randomize(Index1 + RowSize)
  3690.  
  3691.             _Value.Append(Table(Index1).ToString("X"))
  3692.             If _Value.Length > 32 Then _Value.Remove(0, 2)
  3693.  
  3694.             RaiseEvent ValueChanged(Me)
  3695.  
  3696.             Index2 = Index1
  3697.             Invalidate()
  3698.         End If
  3699.     End Sub
  3700.  
  3701.     Private GP1, GP2 As GraphicsPath
  3702.  
  3703.     Private P1, P2 As Pen
  3704.     Private B1, B2 As SolidBrush
  3705.  
  3706.     Private PB1 As PathGradientBrush
  3707.  
  3708.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  3709.         G = e.Graphics
  3710.  
  3711.         G.Clear(BackColor)
  3712.         G.SmoothingMode = SmoothingMode.AntiAlias
  3713.  
  3714.         GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  3715.         GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  3716.  
  3717.         PB1 = New PathGradientBrush(GP1)
  3718.         PB1.CenterColor = Color.FromArgb(50, 50, 50)
  3719.         PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  3720.         PB1.FocusScales = New PointF(0.9F, 0.5F)
  3721.  
  3722.         G.FillPath(PB1, GP1)
  3723.  
  3724.         G.DrawPath(P1, GP1)
  3725.         G.DrawPath(P2, GP2)
  3726.  
  3727.         G.SmoothingMode = SmoothingMode.None
  3728.  
  3729.         For I As Integer = 0 To Table.Length - 1
  3730.             Dim C As Integer = Math.Max(Table(I), 75)
  3731.  
  3732.             Dim X As Integer = ((I Mod RowSize) * ItemSize) + WA.X
  3733.             Dim Y As Integer = ((I \ RowSize) * ItemSize) + WA.Y
  3734.  
  3735.             B2 = New SolidBrush(Color.FromArgb(C, C, C))
  3736.  
  3737.             G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize)
  3738.             G.FillRectangle(B2, X, Y, DrawSize, DrawSize)
  3739.  
  3740.             B2.Dispose()
  3741.         Next
  3742.  
  3743.     End Sub
  3744.  
  3745.     Private Function GetIndex(ByVal x As Integer, ByVal y As Integer) As Integer
  3746.         Return (((y - WA.Y) \ ItemSize) * RowSize) + ((x - WA.X) \ ItemSize)
  3747.     End Function
  3748.  
  3749.     Private Sub Randomize(ByVal index As Integer)
  3750.         If index > -1 AndAlso index < Table.Length Then
  3751.             If InvertColors Then
  3752.                 Table(index) = CByte(RNG.Next(100))
  3753.             Else
  3754.                 Table(index) = CByte(RNG.Next(100, 256))
  3755.             End If
  3756.         End If
  3757.     End Sub
  3758.  
  3759. End Class
  3760.  
  3761. Class NSKeyboard
  3762.     Inherits Control
  3763.  
  3764.     Private TextBitmap As Bitmap
  3765.     Private TextGraphics As Graphics
  3766.  
  3767.     Const LowerKeys As String = "1234567890-=qwertyuiop[]asdfghjkl\;'zxcvbnm,./`"
  3768.     Const UpperKeys As String = "!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL|:""ZXCVBNM<>?~"
  3769.  
  3770.     Sub New()
  3771.         SetStyle(DirectCast(139286, ControlStyles), True)
  3772.         SetStyle(ControlStyles.Selectable, False)
  3773.  
  3774.         Font = New Font("Verdana", 8.25F)
  3775.  
  3776.         TextBitmap = New Bitmap(1, 1)
  3777.         TextGraphics = Graphics.FromImage(TextBitmap)
  3778.  
  3779.         MinimumSize = New Size(386, 162)
  3780.         MaximumSize = New Size(386, 162)
  3781.  
  3782.         Lower = LowerKeys.ToCharArray()
  3783.         Upper = UpperKeys.ToCharArray()
  3784.  
  3785.         PrepareCache()
  3786.  
  3787.         P1 = New Pen(Color.FromArgb(45, 45, 45))
  3788.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  3789.         P3 = New Pen(Color.FromArgb(24, 24, 24))
  3790.  
  3791.         B1 = New SolidBrush(Color.FromArgb(100, 100, 100))
  3792.     End Sub
  3793.  
  3794.     Private _Target As Control
  3795.     Public Property Target() As Control
  3796.         Get
  3797.             Return _Target
  3798.         End Get
  3799.         Set(ByVal value As Control)
  3800.             _Target = value
  3801.         End Set
  3802.     End Property
  3803.  
  3804.     Private Shift As Boolean
  3805.  
  3806.     Private Pressed As Integer = -1
  3807.     Private Buttons As Rectangle()
  3808.  
  3809.     Private Lower As Char()
  3810.     Private Upper As Char()
  3811.     Private Other As String() = {"Shift", "Space", "Back"}
  3812.  
  3813.     Private UpperCache As PointF()
  3814.     Private LowerCache As PointF()
  3815.  
  3816.     Private Sub PrepareCache()
  3817.         Buttons = New Rectangle(50) {}
  3818.         UpperCache = New PointF(Upper.Length - 1) {}
  3819.         LowerCache = New PointF(Lower.Length - 1) {}
  3820.  
  3821.         Dim I As Integer
  3822.  
  3823.         Dim S As SizeF
  3824.         Dim R As Rectangle
  3825.  
  3826.         For Y As Integer = 0 To 3
  3827.             For X As Integer = 0 To 11
  3828.                 I = (Y * 12) + X
  3829.                 R = New Rectangle(X * 32, Y * 32, 32, 32)
  3830.  
  3831.                 Buttons(I) = R
  3832.  
  3833.                 If Not I = 47 AndAlso Not Char.IsLetter(Upper(I)) Then
  3834.                     S = TextGraphics.MeasureString(Upper(I), Font)
  3835.                     UpperCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2)
  3836.  
  3837.                     S = TextGraphics.MeasureString(Lower(I), Font)
  3838.                     LowerCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2)
  3839.                 End If
  3840.             Next
  3841.         Next
  3842.  
  3843.         Buttons(48) = New Rectangle(0, 4 * 32, 2 * 32, 32)
  3844.         Buttons(49) = New Rectangle(Buttons(48).Right, 4 * 32, 8 * 32, 32)
  3845.         Buttons(50) = New Rectangle(Buttons(49).Right, 4 * 32, 2 * 32, 32)
  3846.     End Sub
  3847.  
  3848.     Private GP1 As GraphicsPath
  3849.  
  3850.     Private SZ1 As SizeF
  3851.     Private PT1 As PointF
  3852.  
  3853.     Private P1, P2, P3 As Pen
  3854.     Private B1 As SolidBrush
  3855.  
  3856.     Private PB1 As PathGradientBrush
  3857.     Private GB1 As LinearGradientBrush
  3858.  
  3859.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  3860.         G = e.Graphics
  3861.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  3862.  
  3863.         G.Clear(BackColor)
  3864.  
  3865.         Dim R As Rectangle
  3866.  
  3867.         Dim Offset As Integer
  3868.         G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1)
  3869.  
  3870.         For I As Integer = 0 To Buttons.Length - 1
  3871.             R = Buttons(I)
  3872.  
  3873.             Offset = 0
  3874.             If I = Pressed Then
  3875.                 Offset = 1
  3876.  
  3877.                 GP1 = New GraphicsPath()
  3878.                 GP1.AddRectangle(R)
  3879.  
  3880.                 PB1 = New PathGradientBrush(GP1)
  3881.                 PB1.CenterColor = Color.FromArgb(60, 60, 60)
  3882.                 PB1.SurroundColors = {Color.FromArgb(55, 55, 55)}
  3883.                 PB1.FocusScales = New PointF(0.8F, 0.5F)
  3884.  
  3885.                 G.FillPath(PB1, GP1)
  3886.             Else
  3887.                 GB1 = New LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  3888.                 G.FillRectangle(GB1, R)
  3889.             End If
  3890.  
  3891.             Select Case I
  3892.                 Case 48, 49, 50
  3893.                     SZ1 = G.MeasureString(Other(I - 48), Font)
  3894.                     G.DrawString(Other(I - 48), Font, Brushes.Black, R.X + (R.Width \ 2 - SZ1.Width / 2) + Offset + 1, R.Y + (R.Height \ 2 - SZ1.Height / 2) + Offset + 1)
  3895.                     G.DrawString(Other(I - 48), Font, Brushes.WhiteSmoke, R.X + (R.Width \ 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height \ 2 - SZ1.Height / 2) + Offset)
  3896.                 Case 47
  3897.                     DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1)
  3898.                     DrawArrow(Color.FromArgb(235, 235, 235), R.X + Offset, R.Y + Offset)
  3899.                 Case Else
  3900.                     If Shift Then
  3901.                         G.DrawString(Upper(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1)
  3902.                         G.DrawString(Upper(I), Font, Brushes.WhiteSmoke, R.X + 3 + Offset, R.Y + 2 + Offset)
  3903.  
  3904.                         If Not Char.IsLetter(Lower(I)) Then
  3905.                             PT1 = LowerCache(I)
  3906.                             G.DrawString(Lower(I), Font, B1, PT1.X + Offset, PT1.Y + Offset)
  3907.                         End If
  3908.                     Else
  3909.                         G.DrawString(Lower(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1)
  3910.                         G.DrawString(Lower(I), Font, Brushes.WhiteSmoke, R.X + 3 + Offset, R.Y + 2 + Offset)
  3911.  
  3912.                         If Not Char.IsLetter(Upper(I)) Then
  3913.                             PT1 = UpperCache(I)
  3914.                             G.DrawString(Upper(I), Font, B1, PT1.X + Offset, PT1.Y + Offset)
  3915.                         End If
  3916.                     End If
  3917.             End Select
  3918.  
  3919.             G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2)
  3920.             G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height)
  3921.  
  3922.             If I = Pressed Then
  3923.                 G.DrawLine(P1, R.X, R.Y, R.Right, R.Y)
  3924.                 G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom)
  3925.             End If
  3926.         Next
  3927.     End Sub
  3928.  
  3929.     Private Sub DrawArrow(color As Color, rx As Integer, ry As Integer)
  3930.         Dim R As New Rectangle(rx + 8, ry + 8, 16, 16)
  3931.         G.SmoothingMode = SmoothingMode.AntiAlias
  3932.  
  3933.         Dim P As New Pen(color, 1)
  3934.         Dim C As New AdjustableArrowCap(3, 2)
  3935.         P.CustomEndCap = C
  3936.  
  3937.         G.DrawArc(P, R, 0.0F, 290.0F)
  3938.  
  3939.         P.Dispose()
  3940.         C.Dispose()
  3941.         G.SmoothingMode = SmoothingMode.None
  3942.     End Sub
  3943.  
  3944.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  3945.         Dim Index As Integer = ((e.Y \ 32) * 12) + (e.X \ 32)
  3946.  
  3947.         If Index > 47 Then
  3948.             For I As Integer = 48 To Buttons.Length - 1
  3949.                 If Buttons(I).Contains(e.X, e.Y) Then
  3950.                     Pressed = I
  3951.                     Exit For
  3952.                 End If
  3953.             Next
  3954.         Else
  3955.             Pressed = Index
  3956.         End If
  3957.  
  3958.         HandleKey()
  3959.         Invalidate()
  3960.     End Sub
  3961.  
  3962.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  3963.         Pressed = -1
  3964.         Invalidate()
  3965.     End Sub
  3966.  
  3967.     Private Sub HandleKey()
  3968.         If _Target Is Nothing Then Return
  3969.         If Pressed = -1 Then Return
  3970.  
  3971.         Select Case Pressed
  3972.             Case 47
  3973.                 _Target.Text = String.Empty
  3974.             Case 48
  3975.                 Shift = Not Shift
  3976.             Case 49
  3977.                 _Target.Text &= " "
  3978.             Case 50
  3979.                 If Not _Target.Text.Length = 0 Then
  3980.                     _Target.Text = _Target.Text.Remove(_Target.Text.Length - 1)
  3981.                 End If
  3982.             Case Else
  3983.                 If Shift Then
  3984.                     _Target.Text &= Upper(Pressed)
  3985.                 Else
  3986.                     _Target.Text &= Lower(Pressed)
  3987.                 End If
  3988.         End Select
  3989.     End Sub
  3990.  
  3991. End Class
  3992.  
  3993. <DefaultEvent("SelectedIndexChanged")>
  3994. Class NSPaginator
  3995.     Inherits Control
  3996.  
  3997.     Public Event SelectedIndexChanged(sender As Object, e As EventArgs)
  3998.  
  3999.     Private TextBitmap As Bitmap
  4000.     Private TextGraphics As Graphics
  4001.  
  4002.     Sub New()
  4003.         SetStyle(DirectCast(139286, ControlStyles), True)
  4004.         SetStyle(ControlStyles.Selectable, False)
  4005.  
  4006.         Size = New Size(202, 26)
  4007.  
  4008.         TextBitmap = New Bitmap(1, 1)
  4009.         TextGraphics = Graphics.FromImage(TextBitmap)
  4010.  
  4011.         InvalidateItems()
  4012.  
  4013.         B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  4014.         B2 = New SolidBrush(Color.FromArgb(55, 55, 55))
  4015.  
  4016.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  4017.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  4018.         P3 = New Pen(Color.FromArgb(65, 65, 65))
  4019.     End Sub
  4020.  
  4021.     Private _SelectedIndex As Integer
  4022.     Public Property SelectedIndex() As Integer
  4023.         Get
  4024.             Return _SelectedIndex
  4025.         End Get
  4026.         Set(ByVal value As Integer)
  4027.             _SelectedIndex = Math.Max(Math.Min(value, MaximumIndex), 0)
  4028.             Invalidate()
  4029.         End Set
  4030.     End Property
  4031.  
  4032.     Private _NumberOfPages As Integer
  4033.     Public Property NumberOfPages() As Integer
  4034.         Get
  4035.             Return _NumberOfPages
  4036.         End Get
  4037.         Set(ByVal value As Integer)
  4038.             _NumberOfPages = value
  4039.             _SelectedIndex = Math.Max(Math.Min(_SelectedIndex, MaximumIndex), 0)
  4040.             Invalidate()
  4041.         End Set
  4042.     End Property
  4043.  
  4044.     Public ReadOnly Property MaximumIndex As Integer
  4045.         Get
  4046.             Return NumberOfPages - 1
  4047.         End Get
  4048.     End Property
  4049.  
  4050.     Private ItemWidth As Integer
  4051.  
  4052.     Public Overrides Property Font As Font
  4053.         Get
  4054.             Return MyBase.Font
  4055.         End Get
  4056.         Set(value As Font)
  4057.             MyBase.Font = value
  4058.  
  4059.             InvalidateItems()
  4060.             Invalidate()
  4061.         End Set
  4062.     End Property
  4063.  
  4064.     Private Sub InvalidateItems()
  4065.         Dim S As Size = TextGraphics.MeasureString("000 ..", Font).ToSize()
  4066.         ItemWidth = S.Width + 10
  4067.     End Sub
  4068.  
  4069.     Private GP1, GP2 As GraphicsPath
  4070.  
  4071.     Private R1 As Rectangle
  4072.  
  4073.     Private SZ1 As Size
  4074.     Private PT1 As Point
  4075.  
  4076.     Private P1, P2, P3 As Pen
  4077.     Private B1, B2 As SolidBrush
  4078.  
  4079.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  4080.         G = e.Graphics
  4081.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  4082.  
  4083.         G.Clear(BackColor)
  4084.         G.SmoothingMode = SmoothingMode.AntiAlias
  4085.  
  4086.         Dim LeftEllipse, RightEllipse As Boolean
  4087.  
  4088.         If _SelectedIndex < 4 Then
  4089.             For I As Integer = 0 To Math.Min(MaximumIndex, 4)
  4090.                 RightEllipse = (I = 4) AndAlso (MaximumIndex > 4)
  4091.                 DrawBox(I * ItemWidth, I, False, RightEllipse)
  4092.             Next
  4093.         ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then
  4094.             For I As Integer = 0 To 4
  4095.                 LeftEllipse = (I = 0)
  4096.                 RightEllipse = (I = 4)
  4097.                 DrawBox(I * ItemWidth, _SelectedIndex + I - 2, LeftEllipse, RightEllipse)
  4098.             Next
  4099.         Else
  4100.             For I As Integer = 0 To 4
  4101.                 LeftEllipse = (I = 0) AndAlso (MaximumIndex > 4)
  4102.                 DrawBox(I * ItemWidth, MaximumIndex - (4 - I), LeftEllipse, False)
  4103.             Next
  4104.         End If
  4105.     End Sub
  4106.  
  4107.     Private Sub DrawBox(x As Integer, index As Integer, leftEllipse As Boolean, rightEllipse As Boolean)
  4108.         R1 = New Rectangle(x, 0, ItemWidth - 4, Height - 1)
  4109.  
  4110.         GP1 = CreateRound(R1, 7)
  4111.         GP2 = CreateRound(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2, 7)
  4112.  
  4113.         Dim T As String = CStr(index + 1)
  4114.  
  4115.         If leftEllipse Then T = ".. " & T
  4116.         If rightEllipse Then T = T & " .."
  4117.  
  4118.         SZ1 = G.MeasureString(T, Font).ToSize()
  4119.         PT1 = New Point(R1.X + (R1.Width \ 2 - SZ1.Width \ 2), R1.Y + (R1.Height \ 2 - SZ1.Height \ 2))
  4120.  
  4121.         If index = _SelectedIndex Then
  4122.             G.FillPath(B1, GP1)
  4123.  
  4124.             Dim F As New Font(Font, FontStyle.Underline)
  4125.             G.DrawString(T, F, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  4126.             G.DrawString(T, F, Brushes.WhiteSmoke, PT1)
  4127.             F.Dispose()
  4128.  
  4129.             G.DrawPath(P1, GP2)
  4130.             G.DrawPath(P2, GP1)
  4131.         Else
  4132.             G.FillPath(B2, GP1)
  4133.  
  4134.             G.DrawString(T, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  4135.             G.DrawString(T, Font, Brushes.WhiteSmoke, PT1)
  4136.  
  4137.             G.DrawPath(P3, GP2)
  4138.             G.DrawPath(P1, GP1)
  4139.         End If
  4140.     End Sub
  4141.  
  4142.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  4143.         If e.Button = System.Windows.Forms.MouseButtons.Left Then
  4144.             Dim NewIndex As Integer
  4145.             Dim OldIndex As Integer = _SelectedIndex
  4146.  
  4147.             If _SelectedIndex < 4 Then
  4148.                 NewIndex = (e.X \ ItemWidth)
  4149.             ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then
  4150.                 NewIndex = (e.X \ ItemWidth)
  4151.  
  4152.                 Select Case NewIndex
  4153.                     Case 2
  4154.                         NewIndex = OldIndex
  4155.                     Case Is < 2
  4156.                         NewIndex = OldIndex - (2 - NewIndex)
  4157.                     Case Is > 2
  4158.                         NewIndex = OldIndex + (NewIndex - 2)
  4159.                 End Select
  4160.             Else
  4161.                 NewIndex = MaximumIndex - (4 - (e.X \ ItemWidth))
  4162.             End If
  4163.  
  4164.             If (NewIndex < _NumberOfPages) AndAlso (Not NewIndex = OldIndex) Then
  4165.                 SelectedIndex = NewIndex
  4166.                 RaiseEvent SelectedIndexChanged(Me, Nothing)
  4167.             End If
  4168.         End If
  4169.  
  4170.         MyBase.OnMouseDown(e)
  4171.     End Sub
  4172.  
  4173. End Class
  4174.  
  4175. <DefaultEvent("Scroll")>
  4176. Class NSVScrollBar
  4177.     Inherits Control
  4178.  
  4179.     Event Scroll(ByVal sender As Object)
  4180.  
  4181.     Private _Minimum As Integer
  4182.     Property Minimum() As Integer
  4183.         Get
  4184.             Return _Minimum
  4185.         End Get
  4186.         Set(ByVal value As Integer)
  4187.             If value < 0 Then
  4188.                 Throw New Exception("Property value is not valid.")
  4189.             End If
  4190.  
  4191.             _Minimum = value
  4192.             If value > _Value Then _Value = value
  4193.             If value > _Maximum Then _Maximum = value
  4194.  
  4195.             InvalidateLayout()
  4196.         End Set
  4197.     End Property
  4198.  
  4199.     Private _Maximum As Integer = 100
  4200.     Property Maximum() As Integer
  4201.         Get
  4202.             Return _Maximum
  4203.         End Get
  4204.         Set(ByVal value As Integer)
  4205.             If value < 1 Then value = 1
  4206.  
  4207.             _Maximum = value
  4208.             If value < _Value Then _Value = value
  4209.             If value < _Minimum Then _Minimum = value
  4210.  
  4211.             InvalidateLayout()
  4212.         End Set
  4213.     End Property
  4214.  
  4215.     Private _Value As Integer
  4216.     Property Value() As Integer
  4217.         Get
  4218.             If Not ShowThumb Then Return _Minimum
  4219.             Return _Value
  4220.         End Get
  4221.         Set(ByVal value As Integer)
  4222.             If value = _Value Then Return
  4223.  
  4224.             If value > _Maximum OrElse value < _Minimum Then
  4225.                 Throw New Exception("Property value is not valid.")
  4226.             End If
  4227.  
  4228.             _Value = value
  4229.             InvalidatePosition()
  4230.  
  4231.             RaiseEvent Scroll(Me)
  4232.         End Set
  4233.     End Property
  4234.  
  4235.     Property _Percent As Double
  4236.     Public ReadOnly Property Percent As Double
  4237.         Get
  4238.             If Not ShowThumb Then Return 0
  4239.             Return GetProgress()
  4240.         End Get
  4241.     End Property
  4242.  
  4243.     Private _SmallChange As Integer = 1
  4244.     Public Property SmallChange() As Integer
  4245.         Get
  4246.             Return _SmallChange
  4247.         End Get
  4248.         Set(ByVal value As Integer)
  4249.             If value < 1 Then
  4250.                 Throw New Exception("Property value is not valid.")
  4251.             End If
  4252.  
  4253.             _SmallChange = value
  4254.         End Set
  4255.     End Property
  4256.  
  4257.     Private _LargeChange As Integer = 10
  4258.     Public Property LargeChange() As Integer
  4259.         Get
  4260.             Return _LargeChange
  4261.         End Get
  4262.         Set(ByVal value As Integer)
  4263.             If value < 1 Then
  4264.                 Throw New Exception("Property value is not valid.")
  4265.             End If
  4266.  
  4267.             _LargeChange = value
  4268.         End Set
  4269.     End Property
  4270.  
  4271.     Private ButtonSize As Integer = 16
  4272.     Private ThumbSize As Integer = 24 ' 14 minimum
  4273.  
  4274.     Private TSA As Rectangle
  4275.     Private BSA As Rectangle
  4276.     Private Shaft As Rectangle
  4277.     Private Thumb As Rectangle
  4278.  
  4279.     Private ShowThumb As Boolean
  4280.     Private ThumbDown As Boolean
  4281.  
  4282.     Sub New()
  4283.         SetStyle(DirectCast(139286, ControlStyles), True)
  4284.         SetStyle(ControlStyles.Selectable, False)
  4285.  
  4286.         Width = 18
  4287.  
  4288.         B1 = New SolidBrush(Color.FromArgb(55, 55, 55))
  4289.         B2 = New SolidBrush(Color.FromArgb(24, 24, 24))
  4290.  
  4291.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  4292.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  4293.         P3 = New Pen(Color.FromArgb(55, 55, 55))
  4294.         P4 = New Pen(Color.FromArgb(40, 40, 40))
  4295.     End Sub
  4296.  
  4297.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  4298.  
  4299.     Private P1, P2, P3, P4 As Pen
  4300.     Private B1, B2 As SolidBrush
  4301.  
  4302.     Dim I1 As Integer
  4303.  
  4304.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  4305.         G = e.Graphics
  4306.         G.Clear(BackColor)
  4307.  
  4308.         GP1 = DrawArrow(4, 6, False)
  4309.         GP2 = DrawArrow(5, 7, False)
  4310.  
  4311.         G.FillPath(B1, GP2)
  4312.         G.FillPath(B2, GP1)
  4313.  
  4314.         GP3 = DrawArrow(4, Height - 11, True)
  4315.         GP4 = DrawArrow(5, Height - 10, True)
  4316.  
  4317.         G.FillPath(B1, GP4)
  4318.         G.FillPath(B2, GP3)
  4319.  
  4320.         If ShowThumb Then
  4321.             G.FillRectangle(B1, Thumb)
  4322.             G.DrawRectangle(P1, Thumb)
  4323.             G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2)
  4324.  
  4325.             Dim Y As Integer
  4326.             Dim LY As Integer = Thumb.Y + (Thumb.Height \ 2) - 3
  4327.  
  4328.             For I As Integer = 0 To 2
  4329.                 Y = LY + (I * 3)
  4330.  
  4331.                 G.DrawLine(P1, Thumb.X + 5, Y, Thumb.Right - 5, Y)
  4332.                 G.DrawLine(P2, Thumb.X + 5, Y + 1, Thumb.Right - 5, Y + 1)
  4333.             Next
  4334.         End If
  4335.  
  4336.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  4337.         G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3)
  4338.     End Sub
  4339.  
  4340.     Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  4341.         Dim GP As New GraphicsPath()
  4342.  
  4343.         Dim W As Integer = 9
  4344.         Dim H As Integer = 5
  4345.  
  4346.         If flip Then
  4347.             GP.AddLine(x + 1, y, x + W + 1, y)
  4348.             GP.AddLine(x + W, y, x + H, y + H - 1)
  4349.         Else
  4350.             GP.AddLine(x, y + H, x + W, y + H)
  4351.             GP.AddLine(x + W, y + H, x + H, y)
  4352.         End If
  4353.  
  4354.         GP.CloseFigure()
  4355.         Return GP
  4356.     End Function
  4357.  
  4358.     Protected Overrides Sub OnSizeChanged(e As EventArgs)
  4359.         InvalidateLayout()
  4360.     End Sub
  4361.  
  4362.     Private Sub InvalidateLayout()
  4363.         TSA = New Rectangle(0, 0, Width, ButtonSize)
  4364.         BSA = New Rectangle(0, Height - ButtonSize, Width, ButtonSize)
  4365.         Shaft = New Rectangle(0, TSA.Bottom + 1, Width, Height - (ButtonSize * 2) - 1)
  4366.  
  4367.         ShowThumb = ((_Maximum - _Minimum) > Shaft.Height)
  4368.  
  4369.         If ShowThumb Then
  4370.             'ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  4371.             Thumb = New Rectangle(1, 0, Width - 3, ThumbSize)
  4372.         End If
  4373.  
  4374.         RaiseEvent Scroll(Me)
  4375.         InvalidatePosition()
  4376.     End Sub
  4377.  
  4378.     Private Sub InvalidatePosition()
  4379.         Thumb.Y = CInt(GetProgress() * (Shaft.Height - ThumbSize)) + TSA.Height
  4380.         Invalidate()
  4381.     End Sub
  4382.  
  4383.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  4384.         If e.Button = System.Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then
  4385.             If TSA.Contains(e.Location) Then
  4386.                 I1 = _Value - _SmallChange
  4387.             ElseIf BSA.Contains(e.Location) Then
  4388.                 I1 = _Value + _SmallChange
  4389.             Else
  4390.                 If Thumb.Contains(e.Location) Then
  4391.                     ThumbDown = True
  4392.                     MyBase.OnMouseDown(e)
  4393.                     Return
  4394.                 Else
  4395.                     If e.Y < Thumb.Y Then
  4396.                         I1 = _Value - _LargeChange
  4397.                     Else
  4398.                         I1 = _Value + _LargeChange
  4399.                     End If
  4400.                 End If
  4401.             End If
  4402.  
  4403.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  4404.             InvalidatePosition()
  4405.         End If
  4406.  
  4407.         MyBase.OnMouseDown(e)
  4408.     End Sub
  4409.  
  4410.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  4411.         If ThumbDown AndAlso ShowThumb Then
  4412.             Dim ThumbPosition As Integer = e.Y - TSA.Height - (ThumbSize \ 2)
  4413.             Dim ThumbBounds As Integer = Shaft.Height - ThumbSize
  4414.  
  4415.             I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum
  4416.  
  4417.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  4418.             InvalidatePosition()
  4419.         End If
  4420.  
  4421.         MyBase.OnMouseMove(e)
  4422.     End Sub
  4423.  
  4424.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  4425.         ThumbDown = False
  4426.         MyBase.OnMouseUp(e)
  4427.     End Sub
  4428.  
  4429.     Private Function GetProgress() As Double
  4430.         Return (_Value - _Minimum) / (_Maximum - _Minimum)
  4431.     End Function
  4432.  
  4433. End Class
  4434.  
  4435. <DefaultEvent("Scroll")>
  4436. Class NSHScrollBar
  4437.     Inherits Control
  4438.  
  4439.     Event Scroll(ByVal sender As Object)
  4440.  
  4441.     Private _Minimum As Integer
  4442.     Property Minimum() As Integer
  4443.         Get
  4444.             Return _Minimum
  4445.         End Get
  4446.         Set(ByVal value As Integer)
  4447.             If value < 0 Then
  4448.                 Throw New Exception("Property value is not valid.")
  4449.             End If
  4450.  
  4451.             _Minimum = value
  4452.             If value > _Value Then _Value = value
  4453.             If value > _Maximum Then _Maximum = value
  4454.  
  4455.             InvalidateLayout()
  4456.         End Set
  4457.     End Property
  4458.  
  4459.     Private _Maximum As Integer = 100
  4460.     Property Maximum() As Integer
  4461.         Get
  4462.             Return _Maximum
  4463.         End Get
  4464.         Set(ByVal value As Integer)
  4465.             If value < 0 Then
  4466.                 Throw New Exception("Property value is not valid.")
  4467.             End If
  4468.  
  4469.             _Maximum = value
  4470.             If value < _Value Then _Value = value
  4471.             If value < _Minimum Then _Minimum = value
  4472.  
  4473.             InvalidateLayout()
  4474.         End Set
  4475.     End Property
  4476.  
  4477.     Private _Value As Integer
  4478.     Property Value() As Integer
  4479.         Get
  4480.             If Not ShowThumb Then Return _Minimum
  4481.             Return _Value
  4482.         End Get
  4483.         Set(ByVal value As Integer)
  4484.             If value = _Value Then Return
  4485.  
  4486.             If value > _Maximum OrElse value < _Minimum Then
  4487.                 Throw New Exception("Property value is not valid.")
  4488.             End If
  4489.  
  4490.             _Value = value
  4491.             InvalidatePosition()
  4492.  
  4493.             RaiseEvent Scroll(Me)
  4494.         End Set
  4495.     End Property
  4496.  
  4497.     Private _SmallChange As Integer = 1
  4498.     Public Property SmallChange() As Integer
  4499.         Get
  4500.             Return _SmallChange
  4501.         End Get
  4502.         Set(ByVal value As Integer)
  4503.             If value < 1 Then
  4504.                 Throw New Exception("Property value is not valid.")
  4505.             End If
  4506.  
  4507.             _SmallChange = value
  4508.         End Set
  4509.     End Property
  4510.  
  4511.     Private _LargeChange As Integer = 10
  4512.     Public Property LargeChange() As Integer
  4513.         Get
  4514.             Return _LargeChange
  4515.         End Get
  4516.         Set(ByVal value As Integer)
  4517.             If value < 1 Then
  4518.                 Throw New Exception("Property value is not valid.")
  4519.             End If
  4520.  
  4521.             _LargeChange = value
  4522.         End Set
  4523.     End Property
  4524.  
  4525.     Private ButtonSize As Integer = 16
  4526.     Private ThumbSize As Integer = 24 ' 14 minimum
  4527.  
  4528.     Private LSA As Rectangle
  4529.     Private RSA As Rectangle
  4530.     Private Shaft As Rectangle
  4531.     Private Thumb As Rectangle
  4532.  
  4533.     Private ShowThumb As Boolean
  4534.     Private ThumbDown As Boolean
  4535.  
  4536.     Sub New()
  4537.         SetStyle(DirectCast(139286, ControlStyles), True)
  4538.         SetStyle(ControlStyles.Selectable, False)
  4539.  
  4540.         Height = 18
  4541.  
  4542.         B1 = New SolidBrush(Color.FromArgb(55, 55, 55))
  4543.         B2 = New SolidBrush(Color.FromArgb(24, 24, 24))
  4544.  
  4545.         P1 = New Pen(Color.FromArgb(24, 24, 24))
  4546.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  4547.         P3 = New Pen(Color.FromArgb(55, 55, 55))
  4548.         P4 = New Pen(Color.FromArgb(40, 40, 40))
  4549.     End Sub
  4550.  
  4551.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  4552.  
  4553.     Private P1, P2, P3, P4 As Pen
  4554.     Private B1, B2 As SolidBrush
  4555.  
  4556.     Dim I1 As Integer
  4557.  
  4558.     Protected Overrides Sub OnPaint(e As system.Windows.Forms.PaintEventArgs)
  4559.         G = e.Graphics
  4560.         G.Clear(BackColor)
  4561.  
  4562.         GP1 = DrawArrow(6, 4, False)
  4563.         GP2 = DrawArrow(7, 5, False)
  4564.  
  4565.         G.FillPath(B1, GP2)
  4566.         G.FillPath(B2, GP1)
  4567.  
  4568.         GP3 = DrawArrow(Width - 11, 4, True)
  4569.         GP4 = DrawArrow(Width - 10, 5, True)
  4570.  
  4571.         G.FillPath(B1, GP4)
  4572.         G.FillPath(B2, GP3)
  4573.  
  4574.         If ShowThumb Then
  4575.             G.FillRectangle(B1, Thumb)
  4576.             G.DrawRectangle(P1, Thumb)
  4577.             G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2)
  4578.  
  4579.             Dim X As Integer
  4580.             Dim LX As Integer = Thumb.X + (Thumb.Width \ 2) - 3
  4581.  
  4582.             For I As Integer = 0 To 2
  4583.                 X = LX + (I * 3)
  4584.  
  4585.                 G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5)
  4586.                 G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5)
  4587.             Next
  4588.         End If
  4589.  
  4590.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  4591.         G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3)
  4592.     End Sub
  4593.  
  4594.     Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  4595.         Dim GP As New GraphicsPath()
  4596.  
  4597.         Dim W As Integer = 5
  4598.         Dim H As Integer = 9
  4599.  
  4600.         If flip Then
  4601.             GP.AddLine(x, y + 1, x, y + H + 1)
  4602.             GP.AddLine(x, y + H, x + W - 1, y + W)
  4603.         Else
  4604.             GP.AddLine(x + W, y, x + W, y + H)
  4605.             GP.AddLine(x + W, y + H, x + 1, y + W)
  4606.         End If
  4607.  
  4608.         GP.CloseFigure()
  4609.         Return GP
  4610.     End Function
  4611.  
  4612.     Protected Overrides Sub OnSizeChanged(e As EventArgs)
  4613.         InvalidateLayout()
  4614.     End Sub
  4615.  
  4616.     Private Sub InvalidateLayout()
  4617.         LSA = New Rectangle(0, 0, ButtonSize, Height)
  4618.         RSA = New Rectangle(Width - ButtonSize, 0, ButtonSize, Height)
  4619.         Shaft = New Rectangle(LSA.Right + 1, 0, Width - (ButtonSize * 2) - 1, Height)
  4620.  
  4621.         ShowThumb = ((_Maximum - _Minimum) > Shaft.Width)
  4622.  
  4623.         If ShowThumb Then
  4624.             'ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  4625.             Thumb = New Rectangle(0, 1, ThumbSize, Height - 3)
  4626.         End If
  4627.  
  4628.         RaiseEvent Scroll(Me)
  4629.         InvalidatePosition()
  4630.     End Sub
  4631.  
  4632.     Private Sub InvalidatePosition()
  4633.         Thumb.X = CInt(GetProgress() * (Shaft.Width - ThumbSize)) + LSA.Width
  4634.         Invalidate()
  4635.     End Sub
  4636.  
  4637.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  4638.         If e.Button = System.Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then
  4639.             If LSA.Contains(e.Location) Then
  4640.                 I1 = _Value - _SmallChange
  4641.             ElseIf RSA.Contains(e.Location) Then
  4642.                 I1 = _Value + _SmallChange
  4643.             Else
  4644.                 If Thumb.Contains(e.Location) Then
  4645.                     ThumbDown = True
  4646.                     MyBase.OnMouseDown(e)
  4647.                     Return
  4648.                 Else
  4649.                     If e.X < Thumb.X Then
  4650.                         I1 = _Value - _LargeChange
  4651.                     Else
  4652.                         I1 = _Value + _LargeChange
  4653.                     End If
  4654.                 End If
  4655.             End If
  4656.  
  4657.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  4658.             InvalidatePosition()
  4659.         End If
  4660.  
  4661.         MyBase.OnMouseDown(e)
  4662.     End Sub
  4663.  
  4664.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  4665.         If ThumbDown AndAlso ShowThumb Then
  4666.             Dim ThumbPosition As Integer = e.X - LSA.Width - (ThumbSize \ 2)
  4667.             Dim ThumbBounds As Integer = Shaft.Width - ThumbSize
  4668.  
  4669.             I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum
  4670.  
  4671.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  4672.             InvalidatePosition()
  4673.         End If
  4674.  
  4675.         MyBase.OnMouseMove(e)
  4676.     End Sub
  4677.  
  4678.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  4679.         ThumbDown = False
  4680.         MyBase.OnMouseUp(e)
  4681.     End Sub
  4682.  
  4683.     Private Function GetProgress() As Double
  4684.         Return (_Value - _Minimum) / (_Maximum - _Minimum)
  4685.     End Function
  4686.  
  4687. End Class
  4688.  
  4689. Class NSContextMenu
  4690.     Inherits ContextMenuStrip
  4691.  
  4692.     Sub New()
  4693.         Renderer = New ToolStripProfessionalRenderer(New NSColorTable())
  4694.         ForeColor = Color.FromArgb(235, 235, 235)
  4695.     End Sub
  4696.  
  4697.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  4698.         e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  4699.         MyBase.OnPaint(e)
  4700.     End Sub
  4701.  
  4702. End Class
  4703.  
  4704. Class NSColorTable
  4705.     Inherits ProfessionalColorTable
  4706.  
  4707.     Private BackColor As Color = Color.FromArgb(55, 55, 55)
  4708.  
  4709.     Public Overrides ReadOnly Property ButtonSelectedBorder() As Color
  4710.         Get
  4711.             Return BackColor
  4712.         End Get
  4713.     End Property
  4714.  
  4715.     Public Overrides ReadOnly Property CheckBackground() As Color
  4716.         Get
  4717.             Return BackColor
  4718.         End Get
  4719.     End Property
  4720.  
  4721.     Public Overrides ReadOnly Property CheckPressedBackground() As Color
  4722.         Get
  4723.             Return BackColor
  4724.         End Get
  4725.     End Property
  4726.  
  4727.     Public Overrides ReadOnly Property CheckSelectedBackground() As Color
  4728.         Get
  4729.             Return BackColor
  4730.         End Get
  4731.     End Property
  4732.  
  4733.     Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color
  4734.         Get
  4735.             Return BackColor
  4736.         End Get
  4737.     End Property
  4738.  
  4739.     Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color
  4740.         Get
  4741.             Return BackColor
  4742.         End Get
  4743.     End Property
  4744.  
  4745.     Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color
  4746.         Get
  4747.             Return BackColor
  4748.         End Get
  4749.     End Property
  4750.  
  4751.     Public Overrides ReadOnly Property MenuBorder() As Color
  4752.         Get
  4753.             Return Color.FromArgb(25, 25, 25)
  4754.         End Get
  4755.     End Property
  4756.  
  4757.     Public Overrides ReadOnly Property MenuItemBorder() As Color
  4758.         Get
  4759.             Return BackColor
  4760.         End Get
  4761.     End Property
  4762.  
  4763.     Public Overrides ReadOnly Property MenuItemSelected() As Color
  4764.         Get
  4765.             Return Color.FromArgb(65, 65, 65)
  4766.         End Get
  4767.     End Property
  4768.  
  4769.     Public Overrides ReadOnly Property SeparatorDark() As Color
  4770.         Get
  4771.             Return Color.FromArgb(24, 24, 24)
  4772.         End Get
  4773.     End Property
  4774.  
  4775.     Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
  4776.         Get
  4777.             Return BackColor
  4778.         End Get
  4779.     End Property
  4780.  
  4781. End Class
  4782.  
  4783. 'If you have made it this far it's not too late to turn back, you must not continue on! If you are trying to fullfill some
  4784. 'sick act of masochism by studying the source of the ListView then, may god have mercy on your soul.
  4785. Class NSListView
  4786.     Inherits Control
  4787.  
  4788.     Class NSListViewItem
  4789.         Property Text As String
  4790.         <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
  4791.         Property SubItems As New List(Of NSListViewSubItem)
  4792.  
  4793.         Protected UniqueId As Guid
  4794.  
  4795.         Sub New()
  4796.             UniqueId = Guid.NewGuid()
  4797.         End Sub
  4798.  
  4799.         Public Overrides Function ToString() As String
  4800.             Return Text
  4801.         End Function
  4802.  
  4803.         Public Overrides Function Equals(obj As Object) As Boolean
  4804.             If TypeOf obj Is NSListViewItem Then
  4805.                 Return (DirectCast(obj, NSListViewItem).UniqueId = UniqueId)
  4806.             End If
  4807.  
  4808.             Return False
  4809.         End Function
  4810.  
  4811.     End Class
  4812.  
  4813.     Class NSListViewSubItem
  4814.         Property Text As String
  4815.  
  4816.         Public Overrides Function ToString() As String
  4817.             Return Text
  4818.         End Function
  4819.     End Class
  4820.  
  4821.     Class NSListViewColumnHeader
  4822.         Property Text As String
  4823.         Property Width As Integer = 60
  4824.  
  4825.         Public Overrides Function ToString() As String
  4826.             Return Text
  4827.         End Function
  4828.     End Class
  4829.  
  4830.     Private _Items As New List(Of NSListViewItem)
  4831.     <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
  4832.     Public Property Items() As NSListViewItem()
  4833.         Get
  4834.             Return _Items.ToArray()
  4835.         End Get
  4836.         Set(ByVal value As NSListViewItem())
  4837.             _Items = New List(Of NSListViewItem)(value)
  4838.             InvalidateScroll()
  4839.         End Set
  4840.     End Property
  4841.  
  4842.     Private _SelectedItems As New List(Of NSListViewItem)
  4843.     Public ReadOnly Property SelectedItems() As NSListViewItem()
  4844.         Get
  4845.             Return _SelectedItems.ToArray()
  4846.         End Get
  4847.     End Property
  4848.  
  4849.     Private _Columns As New List(Of NSListViewColumnHeader)
  4850.     <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
  4851.     Public Property Columns() As NSListViewColumnHeader()
  4852.         Get
  4853.             Return _Columns.ToArray()
  4854.         End Get
  4855.         Set(ByVal value As NSListViewColumnHeader())
  4856.             _Columns = New List(Of NSListViewColumnHeader)(value)
  4857.             InvalidateColumns()
  4858.         End Set
  4859.     End Property
  4860.  
  4861.     Private _MultiSelect As Boolean = True
  4862.     Public Property MultiSelect() As Boolean
  4863.         Get
  4864.             Return _MultiSelect
  4865.         End Get
  4866.         Set(ByVal value As Boolean)
  4867.             _MultiSelect = value
  4868.  
  4869.             If _SelectedItems.Count > 1 Then
  4870.                 _SelectedItems.RemoveRange(1, _SelectedItems.Count - 1)
  4871.             End If
  4872.  
  4873.             Invalidate()
  4874.         End Set
  4875.     End Property
  4876.  
  4877.     Private ItemHeight As Integer = 24
  4878.     Public Overrides Property Font As Font
  4879.         Get
  4880.             Return MyBase.Font
  4881.         End Get
  4882.         Set(value As Font)
  4883.             ItemHeight = CInt(Graphics.FromHwnd(Handle).MeasureString("@", Font).Height) + 6
  4884.  
  4885.             If VS IsNot Nothing Then
  4886.                 VS.SmallChange = ItemHeight
  4887.                 VS.LargeChange = ItemHeight
  4888.             End If
  4889.  
  4890.             MyBase.Font = value
  4891.             InvalidateLayout()
  4892.         End Set
  4893.     End Property
  4894.  
  4895. #Region " Item Helper Methods "
  4896.  
  4897.     'Ok, you've seen everything of importance at this point; I am begging you to spare yourself. You must not read any further!
  4898.  
  4899.     Public Sub AddItem(text As String, ParamArray subItems As String())
  4900.         Dim Items As New List(Of NSListViewSubItem)
  4901.         For Each I As String In subItems
  4902.             Dim SubItem As New NSListViewSubItem()
  4903.             SubItem.Text = I
  4904.             Items.Add(SubItem)
  4905.         Next
  4906.  
  4907.         Dim Item As New NSListViewItem()
  4908.         Item.Text = text
  4909.         Item.SubItems = Items
  4910.  
  4911.         _Items.Add(Item)
  4912.         InvalidateScroll()
  4913.     End Sub
  4914.  
  4915.     Public Sub RemoveItemAt(index As Integer)
  4916.         _Items.RemoveAt(index)
  4917.         InvalidateScroll()
  4918.     End Sub
  4919.  
  4920.     Public Sub RemoveItem(item As NSListViewItem)
  4921.         _Items.Remove(item)
  4922.         InvalidateScroll()
  4923.     End Sub
  4924.  
  4925.     Public Sub RemoveItems(items As NSListViewItem())
  4926.         For Each I As NSListViewItem In items
  4927.             _Items.Remove(I)
  4928.         Next
  4929.  
  4930.         InvalidateScroll()
  4931.     End Sub
  4932.  
  4933. #End Region
  4934.  
  4935.     Private VS As NSVScrollBar
  4936.  
  4937.     Sub New()
  4938.         SetStyle(DirectCast(139286, ControlStyles), True)
  4939.         SetStyle(ControlStyles.Selectable, True)
  4940.  
  4941.         P1 = New Pen(Color.FromArgb(55, 55, 55))
  4942.         P2 = New Pen(Color.FromArgb(24, 24, 24))
  4943.         P3 = New Pen(Color.FromArgb(65, 65, 65))
  4944.  
  4945.         B1 = New SolidBrush(Color.FromArgb(62, 62, 62))
  4946.         B2 = New SolidBrush(Color.FromArgb(65, 65, 65))
  4947.         B3 = New SolidBrush(Color.FromArgb(47, 47, 47))
  4948.         B4 = New SolidBrush(Color.FromArgb(50, 50, 50))
  4949.  
  4950.         VS = New NSVScrollBar
  4951.         VS.SmallChange = ItemHeight
  4952.         VS.LargeChange = ItemHeight
  4953.  
  4954.         AddHandler VS.Scroll, AddressOf HandleScroll
  4955.         AddHandler VS.MouseDown, AddressOf VS_MouseDown
  4956.         Controls.Add(VS)
  4957.  
  4958.         InvalidateLayout()
  4959.     End Sub
  4960.  
  4961.     Protected Overrides Sub OnSizeChanged(e As EventArgs)
  4962.         InvalidateLayout()
  4963.         MyBase.OnSizeChanged(e)
  4964.     End Sub
  4965.  
  4966.     Private Sub HandleScroll(sender As Object)
  4967.         Invalidate()
  4968.     End Sub
  4969.  
  4970.     Private Sub InvalidateScroll()
  4971.         VS.Maximum = (_Items.Count * ItemHeight)
  4972.         Invalidate()
  4973.     End Sub
  4974.  
  4975.     Private Sub InvalidateLayout()
  4976.         VS.Location = New Point(Width - VS.Width - 1, 1)
  4977.         VS.Size = New Size(18, Height - 2)
  4978.  
  4979.         Invalidate()
  4980.     End Sub
  4981.  
  4982.     Private ColumnOffsets As Integer()
  4983.     Private Sub InvalidateColumns()
  4984.         Dim Width As Integer = 3
  4985.         ColumnOffsets = New Integer(_Columns.Count - 1) {}
  4986.  
  4987.         For I As Integer = 0 To _Columns.Count - 1
  4988.             ColumnOffsets(I) = Width
  4989.             Width += Columns(I).Width
  4990.         Next
  4991.  
  4992.         Invalidate()
  4993.     End Sub
  4994.  
  4995.     Private Sub VS_MouseDown(sender As Object, e As MouseEventArgs)
  4996.         Focus()
  4997.     End Sub
  4998.  
  4999.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  5000.         Focus()
  5001.  
  5002.         If e.Button = System.Windows.Forms.MouseButtons.Left Then
  5003.             Dim Offset As Integer = CInt(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))))
  5004.             Dim Index As Integer = ((e.Y + Offset - ItemHeight) \ ItemHeight)
  5005.  
  5006.             If Index > _Items.Count - 1 Then Index = -1
  5007.  
  5008.             If Not Index = -1 Then
  5009.                 'TODO: Handle Shift key
  5010.  
  5011.                 If ModifierKeys = Keys.Control AndAlso _MultiSelect Then
  5012.                     If _SelectedItems.Contains(_Items(Index)) Then
  5013.                         _SelectedItems.Remove(_Items(Index))
  5014.                     Else
  5015.                         _SelectedItems.Add(_Items(Index))
  5016.                     End If
  5017.                 Else
  5018.                     _SelectedItems.Clear()
  5019.                     _SelectedItems.Add(_Items(Index))
  5020.                 End If
  5021.             End If
  5022.  
  5023.             Invalidate()
  5024.         End If
  5025.  
  5026.         MyBase.OnMouseDown(e)
  5027.     End Sub
  5028.  
  5029.     Private P1, P2, P3 As Pen
  5030.     Private B1, B2, B3, B4 As SolidBrush
  5031.     Private GB1 As LinearGradientBrush
  5032.  
  5033.     'I am so sorry you have to witness this. I tried warning you. ;.;
  5034.  
  5035.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  5036.         G = e.Graphics
  5037.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  5038.  
  5039.         G.Clear(BackColor)
  5040.  
  5041.         Dim X, Y As Integer
  5042.         Dim H As Single
  5043.  
  5044.         G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3)
  5045.  
  5046.         Dim R1 As Rectangle
  5047.         Dim CI As NSListViewItem
  5048.  
  5049.         Dim Offset As Integer = CInt(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))))
  5050.  
  5051.         Dim StartIndex As Integer
  5052.         If Offset = 0 Then StartIndex = 0 Else StartIndex = (Offset \ ItemHeight)
  5053.  
  5054.         Dim EndIndex As Integer = Math.Min(StartIndex + (Height \ ItemHeight), _Items.Count - 1)
  5055.  
  5056.         For I As Integer = StartIndex To EndIndex
  5057.             CI = Items(I)
  5058.  
  5059.             R1 = New Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width, ItemHeight - 1)
  5060.  
  5061.             H = G.MeasureString(CI.Text, Font).Height
  5062.             Y = R1.Y + CInt((ItemHeight / 2) - (H / 2))
  5063.  
  5064.             If _SelectedItems.Contains(CI) Then
  5065.                 If I Mod 2 = 0 Then
  5066.                     G.FillRectangle(B1, R1)
  5067.                 Else
  5068.                     G.FillRectangle(B2, R1)
  5069.                 End If
  5070.             Else
  5071.                 If I Mod 2 = 0 Then
  5072.                     G.FillRectangle(B3, R1)
  5073.                 Else
  5074.                     G.FillRectangle(B4, R1)
  5075.                 End If
  5076.             End If
  5077.  
  5078.             G.DrawLine(P2, 0, R1.Bottom, Width, R1.Bottom)
  5079.  
  5080.             If Columns.Length > 0 Then
  5081.                 R1.Width = Columns(0).Width
  5082.                 G.SetClip(R1)
  5083.             End If
  5084.  
  5085.             'TODO: Ellipse text that overhangs seperators.
  5086.             G.DrawString(CI.Text, Font, Brushes.Black, 10, Y + 1)
  5087.             G.DrawString(CI.Text, Font, Brushes.WhiteSmoke, 9, Y)
  5088.  
  5089.             If CI.SubItems IsNot Nothing Then
  5090.                 For I2 As Integer = 0 To Math.Min(CI.SubItems.Count, _Columns.Count) - 1
  5091.                     X = ColumnOffsets(I2 + 1) + 4
  5092.  
  5093.                     R1.X = X
  5094.                     R1.Width = Columns(I2).Width
  5095.                     G.SetClip(R1)
  5096.  
  5097.                     G.DrawString(CI.SubItems(I2).Text, Font, Brushes.Black, X + 1, Y + 1)
  5098.                     G.DrawString(CI.SubItems(I2).Text, Font, Brushes.WhiteSmoke, X, Y)
  5099.                 Next
  5100.             End If
  5101.  
  5102.             G.ResetClip()
  5103.         Next
  5104.  
  5105.         R1 = New Rectangle(0, 0, Width, ItemHeight)
  5106.  
  5107.         GB1 = New LinearGradientBrush(R1, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  5108.         G.FillRectangle(GB1, R1)
  5109.         G.DrawRectangle(P3, 1, 1, Width - 22, ItemHeight - 2)
  5110.  
  5111.         Dim LH As Integer = Math.Min(VS.Maximum + ItemHeight - Offset, Height)
  5112.  
  5113.         Dim CC As NSListViewColumnHeader
  5114.         For I As Integer = 0 To _Columns.Count - 1
  5115.             CC = Columns(I)
  5116.  
  5117.             H = G.MeasureString(CC.Text, Font).Height
  5118.             Y = CInt((ItemHeight / 2) - (H / 2))
  5119.             X = ColumnOffsets(I)
  5120.             G.DrawString(CC.Text, Font, Brushes.Black, X + 1, Y + 1)
  5121.             G.DrawString(CC.Text, Font, Brushes.WhiteSmoke, X, Y)
  5122.  
  5123.             G.DrawLine(P2, X - 3, 0, X - 3, LH)
  5124.             G.DrawLine(P3, X - 2, 0, X - 2, ItemHeight)
  5125.         Next
  5126.  
  5127.         G.DrawRectangle(P2, 0, 0, Width - 1, Height - 1)
  5128.  
  5129.         G.DrawLine(P2, 0, ItemHeight, Width, ItemHeight)
  5130.         G.DrawLine(P2, VS.Location.X - 1, 0, VS.Location.X - 1, Height)
  5131.     End Sub
  5132.  
  5133.     Protected Overrides Sub OnMouseWheel(e As MouseEventArgs)
  5134.         Dim Move As Integer = -((e.Delta * SystemInformation.MouseWheelScrollLines \ 120) * (ItemHeight \ 2))
  5135.  
  5136.         Dim Value As Integer = Math.Max(Math.Min(VS.Value + Move, VS.Maximum), VS.Minimum)
  5137.         VS.Value = Value
  5138.  
  5139.         MyBase.OnMouseWheel(e)
  5140.     End Sub
  5141.  
  5142. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top