Advertisement
t3cho

Net Seal Theme

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