Guest User

Untitled

a guest
Nov 12th, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System
  2. Imports System.Windows.Forms
  3. Imports System.Drawing
  4. Imports System.Drawing.Drawing2D
  5. Imports System.Drawing.Text
  6. Imports System.ComponentModel
  7. Imports System.Collections.Generic
  8. Imports System.Text
  9.  
  10. 'IMPORTANT:
  11. 'Please leave these comments in place as they help protect intellectual rights and allow
  12. 'developers to determine the version of the theme they are using. The preffered method
  13. 'of distributing this theme is through the Nimoru Software home page at nimoru.com.
  14.  
  15. 'Name: Net Seal Theme
  16. 'Created: 6/21/2013
  17. 'Version: 1.0.0.1 beta
  18. 'Site: http://nimoru.com/
  19.  
  20. 'This work is licensed under a Creative Commons Attribution 3.0 Unported License.
  21. 'To view a copy of this license, please visit http://creativecommons.org/licenses/by/3.0/
  22.  
  23. 'Copyright © 2013 Nimoru Software
  24.  
  25. Module ThemeModule
  26.  
  27.    Friend G As Graphics
  28.  
  29.    Sub New()
  30.        TextBitmap = New Bitmap(1, 1)
  31.        TextGraphics = Graphics.FromImage(TextBitmap)
  32.    End Sub
  33.  
  34.    Private TextBitmap As Bitmap
  35.    Private TextGraphics As Graphics
  36.  
  37.    Friend Function MeasureString(text As String, font As Font) As SizeF
  38.        Return TextGraphics.MeasureString(text, font)
  39.    End Function
  40.  
  41.    Friend Function MeasureString(text As String, font As Font, width As Integer) As SizeF
  42.        Return TextGraphics.MeasureString(text, font, width, StringFormat.GenericTypographic)
  43.    End Function
  44.  
  45.    Private CreateRoundPath As GraphicsPath
  46.    Private CreateRoundRectangle As Rectangle
  47.  
  48.    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
  49.        CreateRoundRectangle = New Rectangle(x, y, width, height)
  50.        Return CreateRound(CreateRoundRectangle, slope)
  51.    End Function
  52.  
  53.    Friend Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  54.        CreateRoundPath = New GraphicsPath(FillMode.Winding)
  55.        CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  56.        CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  57.        CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  58.        CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  59.        CreateRoundPath.CloseFigure()
  60.        Return CreateRoundPath
  61.    End Function
  62.  
  63. End Module
  64.  
  65. Class NSTheme
  66.    Inherits ThemeContainer154
  67.  
  68.    Private _AccentOffset As Integer = 42
  69.    Public Property AccentOffset() As Integer
  70.        Get
  71.            Return _AccentOffset
  72.        End Get
  73.        Set(ByVal value As Integer)
  74.            _AccentOffset = value
  75.            Invalidate()
  76.        End Set
  77.    End Property
  78.  
  79.    Sub New()
  80.        Header = 30
  81.        BackColor = Color.FromArgb(50, 50, 50)
  82.  
  83.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  84.        P2 = New Pen(Color.FromArgb(60, 60, 60))
  85.  
  86.        B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  87.    End Sub
  88.  
  89.    Protected Overrides Sub ColorHook()
  90.  
  91.    End Sub
  92.  
  93.    Private R1 As Rectangle
  94.  
  95.    Private P1, P2 As Pen
  96.    Private B1 As SolidBrush
  97.  
  98.    Private Pad As Integer
  99.  
  100.    Protected Overrides Sub PaintHook()
  101.        G.Clear(BackColor)
  102.        DrawBorders(P2, 1)
  103.  
  104.        G.DrawLine(P1, 0, 26, Width, 26)
  105.        G.DrawLine(P2, 0, 25, Width, 25)
  106.  
  107.        Pad = Math.Max(Measure().Width + 20, 80)
  108.        R1 = New Rectangle(Pad, 17, Width - (Pad * 2) + _AccentOffset, 8)
  109.  
  110.        G.DrawRectangle(P2, R1)
  111.        G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height)
  112.  
  113.        G.DrawLine(P1, 0, 29, Width, 29)
  114.        G.DrawLine(P2, 0, 30, Width, 30)
  115.  
  116.        DrawText(Brushes.Black, HorizontalAlignment.Left, 8, 1)
  117.        DrawText(Brushes.White, HorizontalAlignment.Left, 7, 0)
  118.  
  119.        G.FillRectangle(B1, 0, 27, Width, 2)
  120.        DrawBorders(Pens.Black)
  121.    End Sub
  122.  
  123. End Class
  124.  
  125. Class NSButton
  126.    Inherits Control
  127.  
  128.    Sub New()
  129.        SetStyle(DirectCast(139286, ControlStyles), True)
  130.        SetStyle(ControlStyles.Selectable, False)
  131.  
  132.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  133.        P2 = New Pen(Color.FromArgb(65, 65, 65))
  134.    End Sub
  135.  
  136.    Private IsMouseDown As Boolean
  137.  
  138.    Private GP1, GP2 As GraphicsPath
  139.  
  140.    Private SZ1 As SizeF
  141.    Private PT1 As PointF
  142.  
  143.    Private P1, P2 As Pen
  144.  
  145.    Private PB1 As PathGradientBrush
  146.    Private GB1 As LinearGradientBrush
  147.  
  148.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  149.        G = e.Graphics
  150.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  151.  
  152.        G.Clear(BackColor)
  153.        G.SmoothingMode = SmoothingMode.AntiAlias
  154.  
  155.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  156.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  157.  
  158.        If IsMouseDown Then
  159.            PB1 = New PathGradientBrush(GP1)
  160.            PB1.CenterColor = Color.FromArgb(60, 60, 60)
  161.            PB1.SurroundColors = {Color.FromArgb(55, 55, 55)}
  162.            PB1.FocusScales = New PointF(0.8F, 0.5F)
  163.  
  164.            G.FillPath(PB1, GP1)
  165.        Else
  166.            GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  167.            G.FillPath(GB1, GP1)
  168.        End If
  169.  
  170.        G.DrawPath(P1, GP1)
  171.        G.DrawPath(P2, GP2)
  172.  
  173.        SZ1 = G.MeasureString(Text, Font)
  174.        PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2)
  175.  
  176.        If IsMouseDown Then
  177.            PT1.X += 1.0F
  178.            PT1.Y += 1.0F
  179.        End If
  180.  
  181.        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  182.        G.DrawString(Text, Font, Brushes.White, PT1)
  183.    End Sub
  184.  
  185.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  186.        IsMouseDown = True
  187.        Invalidate()
  188.    End Sub
  189.  
  190.    Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  191.        IsMouseDown = False
  192.        Invalidate()
  193.    End Sub
  194.  
  195. End Class
  196.  
  197. Class NSProgressBar
  198.    Inherits Control
  199.  
  200.    Private _Minimum As Integer
  201.    Property Minimum() As Integer
  202.        Get
  203.            Return _Minimum
  204.        End Get
  205.        Set(ByVal value As Integer)
  206.            If value < 0 Then
  207.                Throw New Exception("Property value is not valid.")
  208.            End If
  209.  
  210.            _Minimum = value
  211.            If value > _Value Then _Value = value
  212.            If value > _Maximum Then _Maximum = value
  213.            Invalidate()
  214.        End Set
  215.    End Property
  216.  
  217.    Private _Maximum As Integer = 100
  218.    Property Maximum() As Integer
  219.        Get
  220.            Return _Maximum
  221.        End Get
  222.        Set(ByVal value As Integer)
  223.            If value < 0 Then
  224.                Throw New Exception("Property value is not valid.")
  225.            End If
  226.  
  227.            _Maximum = value
  228.            If value < _Value Then _Value = value
  229.            If value < _Minimum Then _Minimum = value
  230.            Invalidate()
  231.        End Set
  232.    End Property
  233.  
  234.    Private _Value As Integer
  235.    Property Value() As Integer
  236.        Get
  237.            Return _Value
  238.        End Get
  239.        Set(ByVal value As Integer)
  240.            If value > _Maximum OrElse value < _Minimum Then
  241.                Throw New Exception("Property value is not valid.")
  242.            End If
  243.  
  244.            _Value = value
  245.            Invalidate()
  246.        End Set
  247.    End Property
  248.  
  249.    Private Sub Increment(ByVal amount As Integer)
  250.        Value += amount
  251.    End Sub
  252.  
  253.    Sub New()
  254.        SetStyle(DirectCast(139286, ControlStyles), True)
  255.        SetStyle(ControlStyles.Selectable, False)
  256.  
  257.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  258.        P2 = New Pen(Color.FromArgb(55, 55, 55))
  259.        B1 = New SolidBrush(Color.FromArgb(200, 160, 0))
  260.    End Sub
  261.  
  262.    Private GP1, GP2, GP3 As GraphicsPath
  263.  
  264.    Private R1, R2 As Rectangle
  265.  
  266.    Private P1, P2 As Pen
  267.    Private B1 As SolidBrush
  268.    Private GB1, GB2 As LinearGradientBrush
  269.  
  270.    Private I1 As Integer
  271.  
  272.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  273.        G = e.Graphics
  274.  
  275.        G.Clear(BackColor)
  276.        G.SmoothingMode = SmoothingMode.AntiAlias
  277.  
  278.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  279.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  280.  
  281.        R1 = New Rectangle(0, 2, Width - 1, Height - 1)
  282.        GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  283.  
  284.        G.SetClip(GP1)
  285.        G.FillRectangle(GB1, R1)
  286.  
  287.        I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 3))
  288.  
  289.        If I1 > 1 Then
  290.            GP3 = CreateRound(1, 1, I1, Height - 3, 7)
  291.  
  292.            R2 = New Rectangle(1, 1, I1, Height - 3)
  293.            GB2 = New LinearGradientBrush(R2, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90.0F)
  294.  
  295.            G.FillPath(GB2, GP3)
  296.            G.DrawPath(P1, GP3)
  297.  
  298.            G.SetClip(GP3)
  299.            G.SmoothingMode = SmoothingMode.None
  300.  
  301.            G.FillRectangle(B1, R2.X, R2.Y + 1, R2.Width, R2.Height \ 2)
  302.  
  303.            G.SmoothingMode = SmoothingMode.AntiAlias
  304.            G.ResetClip()
  305.        End If
  306.  
  307.        G.DrawPath(P2, GP1)
  308.        G.DrawPath(P1, GP2)
  309.    End Sub
  310.  
  311. End Class
  312.  
  313. Class NSLabel
  314.    Inherits Control
  315.  
  316.    Sub New()
  317.        SetStyle(DirectCast(139286, ControlStyles), True)
  318.        SetStyle(ControlStyles.Selectable, False)
  319.  
  320.        Font = New Font("Segoe UI", 11.25F, FontStyle.Bold)
  321.  
  322.        B1 = New SolidBrush(Color.FromArgb(205, 150, 0))
  323.    End Sub
  324.  
  325.    Private _Value1 As String = "NET"
  326.    Public Property Value1() As String
  327.        Get
  328.            Return _Value1
  329.        End Get
  330.        Set(ByVal value As String)
  331.            _Value1 = value
  332.            Invalidate()
  333.        End Set
  334.    End Property
  335.  
  336.    Private _Value2 As String = "SEAL"
  337.    Public Property Value2() As String
  338.        Get
  339.            Return _Value2
  340.        End Get
  341.        Set(ByVal value As String)
  342.            _Value2 = value
  343.            Invalidate()
  344.        End Set
  345.    End Property
  346.  
  347.    Private B1 As SolidBrush
  348.  
  349.    Private PT1, PT2 As PointF
  350.    Private SZ1, SZ2 As SizeF
  351.  
  352.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  353.        G = e.Graphics
  354.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  355.  
  356.        G.Clear(BackColor)
  357.  
  358.        SZ1 = G.MeasureString(Value1, Font, Width, StringFormat.GenericTypographic)
  359.        SZ2 = G.MeasureString(Value2, Font, Width, StringFormat.GenericTypographic)
  360.  
  361.        PT1 = New PointF(0, Height \ 2 - SZ1.Height / 2)
  362.        PT2 = New PointF(SZ1.Width + 1, Height \ 2 - SZ1.Height / 2)
  363.  
  364.        G.DrawString(Value1, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  365.        G.DrawString(Value1, Font, Brushes.White, PT1)
  366.  
  367.        G.DrawString(Value2, Font, Brushes.Black, PT2.X + 1, PT2.Y + 1)
  368.        G.DrawString(Value2, Font, B1, PT2)
  369.    End Sub
  370.  
  371. End Class
  372.  
  373. <DefaultEvent("TextChanged")> _
  374. Class NSTextBox
  375.    Inherits Control
  376.  
  377.    Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  378.    Property TextAlign() As HorizontalAlignment
  379.        Get
  380.            Return _TextAlign
  381.        End Get
  382.        Set(ByVal value As HorizontalAlignment)
  383.            _TextAlign = value
  384.            If Base IsNot Nothing Then
  385.                Base.TextAlign = value
  386.            End If
  387.        End Set
  388.    End Property
  389.  
  390.    Private _MaxLength As Integer = 32767
  391.    Property MaxLength() As Integer
  392.        Get
  393.            Return _MaxLength
  394.        End Get
  395.        Set(ByVal value As Integer)
  396.            _MaxLength = value
  397.            If Base IsNot Nothing Then
  398.                Base.MaxLength = value
  399.            End If
  400.        End Set
  401.    End Property
  402.  
  403.    Private _ReadOnly As Boolean
  404.    Property [ReadOnly]() As Boolean
  405.        Get
  406.            Return _ReadOnly
  407.        End Get
  408.        Set(ByVal value As Boolean)
  409.            _ReadOnly = value
  410.            If Base IsNot Nothing Then
  411.                Base.ReadOnly = value
  412.            End If
  413.        End Set
  414.    End Property
  415.  
  416.    Private _UseSystemPasswordChar As Boolean
  417.    Property UseSystemPasswordChar() As Boolean
  418.        Get
  419.            Return _UseSystemPasswordChar
  420.        End Get
  421.        Set(ByVal value As Boolean)
  422.            _UseSystemPasswordChar = value
  423.            If Base IsNot Nothing Then
  424.                Base.UseSystemPasswordChar = value
  425.            End If
  426.        End Set
  427.    End Property
  428.  
  429.    Private _Multiline As Boolean
  430.    Property Multiline() As Boolean
  431.        Get
  432.            Return _Multiline
  433.        End Get
  434.        Set(ByVal value As Boolean)
  435.            _Multiline = value
  436.            If Base IsNot Nothing Then
  437.                Base.Multiline = value
  438.  
  439.                If value Then
  440.                    Base.Height = Height - 11
  441.                Else
  442.                    Height = Base.Height + 11
  443.                End If
  444.            End If
  445.        End Set
  446.    End Property
  447.  
  448.    Overrides Property Text As String
  449.        Get
  450.            Return MyBase.Text
  451.        End Get
  452.        Set(ByVal value As String)
  453.            MyBase.Text = value
  454.            If Base IsNot Nothing Then
  455.                Base.Text = value
  456.            End If
  457.        End Set
  458.    End Property
  459.  
  460.    Overrides Property Font As Font
  461.        Get
  462.            Return MyBase.Font
  463.        End Get
  464.        Set(ByVal value As Font)
  465.            MyBase.Font = value
  466.            If Base IsNot Nothing Then
  467.                Base.Font = value
  468.                Base.Location = New Point(5, 5)
  469.                Base.Width = Width - 8
  470.  
  471.                If Not _Multiline Then
  472.                    Height = Base.Height + 11
  473.                End If
  474.            End If
  475.        End Set
  476.    End Property
  477.  
  478.    Protected Overrides Sub OnHandleCreated(e As EventArgs)
  479.        If Not Controls.Contains(Base) Then
  480.            Controls.Add(Base)
  481.        End If
  482.  
  483.        MyBase.OnHandleCreated(e)
  484.    End Sub
  485.  
  486.    Private Base As TextBox
  487.    Sub New()
  488.        SetStyle(DirectCast(139286, ControlStyles), True)
  489.        SetStyle(ControlStyles.Selectable, True)
  490.  
  491.        Cursor = Cursors.IBeam
  492.  
  493.        Base = New TextBox
  494.        Base.Font = Font
  495.        Base.Text = Text
  496.        Base.MaxLength = _MaxLength
  497.        Base.Multiline = _Multiline
  498.        Base.ReadOnly = _ReadOnly
  499.        Base.UseSystemPasswordChar = _UseSystemPasswordChar
  500.  
  501.        Base.ForeColor = Color.White
  502.        Base.BackColor = Color.FromArgb(50, 50, 50)
  503.  
  504.        Base.BorderStyle = BorderStyle.None
  505.  
  506.        Base.Location = New Point(5, 5)
  507.        Base.Width = Width - 14
  508.  
  509.        If _Multiline Then
  510.            Base.Height = Height - 11
  511.        Else
  512.            Height = Base.Height + 11
  513.        End If
  514.  
  515.        AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
  516.        AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
  517.  
  518.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  519.        P2 = New Pen(Color.FromArgb(55, 55, 55))
  520.    End Sub
  521.  
  522.    Private GP1, GP2 As GraphicsPath
  523.  
  524.    Private P1, P2 As Pen
  525.    Private PB1 As PathGradientBrush
  526.  
  527.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  528.        G = e.Graphics
  529.  
  530.        G.Clear(BackColor)
  531.        G.SmoothingMode = SmoothingMode.AntiAlias
  532.  
  533.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  534.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  535.  
  536.        PB1 = New PathGradientBrush(GP1)
  537.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  538.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  539.        PB1.FocusScales = New PointF(0.9F, 0.5F)
  540.  
  541.        G.FillPath(PB1, GP1)
  542.  
  543.        G.DrawPath(P2, GP1)
  544.        G.DrawPath(P1, GP2)
  545.    End Sub
  546.  
  547.    Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  548.        Text = Base.Text
  549.    End Sub
  550.  
  551.    Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  552.        If e.Control AndAlso e.KeyCode = Keys.A Then
  553.            Base.SelectAll()
  554.            e.SuppressKeyPress = True
  555.        End If
  556.    End Sub
  557.  
  558.    Protected Overrides Sub OnResize(ByVal e As EventArgs)
  559.        Base.Location = New Point(5, 5)
  560.  
  561.        Base.Width = Width - 10
  562.        Base.Height = Height - 11
  563.  
  564.        MyBase.OnResize(e)
  565.    End Sub
  566.  
  567.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  568.        Base.Focus()
  569.        MyBase.OnMouseDown(e)
  570.    End Sub
  571.  
  572.    Protected Overrides Sub OnEnter(e As EventArgs)
  573.        Base.Focus()
  574.        Invalidate()
  575.        MyBase.OnEnter(e)
  576.    End Sub
  577.  
  578.    Protected Overrides Sub OnLeave(e As EventArgs)
  579.        Invalidate()
  580.        MyBase.OnLeave(e)
  581.    End Sub
  582.  
  583. End Class
  584.  
  585. <DefaultEvent("CheckedChanged")> _
  586. Class NSCheckBox
  587.    Inherits Control
  588.  
  589.    Event CheckedChanged(sender As Object)
  590.  
  591.    Sub New()
  592.        SetStyle(DirectCast(139286, ControlStyles), True)
  593.        SetStyle(ControlStyles.Selectable, False)
  594.  
  595.        P11 = New Pen(Color.FromArgb(55, 55, 55))
  596.        P22 = New Pen(Color.FromArgb(35, 35, 35))
  597.        P3 = New Pen(Color.Black, 2.0F)
  598.        P4 = New Pen(Color.White, 2.0F)
  599.    End Sub
  600.  
  601.    Private _Checked As Boolean
  602.    Public Property Checked() As Boolean
  603.        Get
  604.            Return _Checked
  605.        End Get
  606.        Set(ByVal value As Boolean)
  607.            _Checked = value
  608.            RaiseEvent CheckedChanged(Me)
  609.  
  610.            Invalidate()
  611.        End Set
  612.    End Property
  613.  
  614.    Private GP1, GP2 As GraphicsPath
  615.  
  616.    Private SZ1 As SizeF
  617.    Private PT1 As PointF
  618.  
  619.    Private P11, P22, P3, P4 As Pen
  620.  
  621.    Private PB1 As PathGradientBrush
  622.  
  623.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  624.        G = e.Graphics
  625.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  626.  
  627.        G.Clear(BackColor)
  628.        G.SmoothingMode = SmoothingMode.AntiAlias
  629.  
  630.        GP1 = CreateRound(0, 2, Height - 5, Height - 5, 5)
  631.        GP2 = CreateRound(1, 3, Height - 7, Height - 7, 5)
  632.  
  633.        PB1 = New PathGradientBrush(GP1)
  634.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  635.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  636.        PB1.FocusScales = New PointF(0.3F, 0.3F)
  637.  
  638.        G.FillPath(PB1, GP1)
  639.        G.DrawPath(P11, GP1)
  640.        G.DrawPath(P22, GP2)
  641.  
  642.        If _Checked Then
  643.            G.DrawLine(P3, 5, Height - 9, 8, Height - 7)
  644.            G.DrawLine(P3, 7, Height - 7, Height - 8, 7)
  645.  
  646.            G.DrawLine(P4, 4, Height - 10, 7, Height - 8)
  647.            G.DrawLine(P4, 6, Height - 8, Height - 9, 6)
  648.        End If
  649.  
  650.        SZ1 = G.MeasureString(Text, Font)
  651.        PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  652.  
  653.        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  654.        G.DrawString(Text, Font, Brushes.White, PT1)
  655.    End Sub
  656.  
  657.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  658.        Checked = Not Checked
  659.    End Sub
  660.  
  661. End Class
  662.  
  663. <DefaultEvent("CheckedChanged")> _
  664. Class NSRadioButton
  665.    Inherits Control
  666.  
  667.    Event CheckedChanged(sender As Object)
  668.  
  669.    Sub New()
  670.        SetStyle(DirectCast(139286, ControlStyles), True)
  671.        SetStyle(ControlStyles.Selectable, False)
  672.  
  673.        P1 = New Pen(Color.FromArgb(55, 55, 55))
  674.        P2 = New Pen(Color.FromArgb(35, 35, 35))
  675.    End Sub
  676.  
  677.    Private _Checked As Boolean
  678.    Public Property Checked() As Boolean
  679.        Get
  680.            Return _Checked
  681.        End Get
  682.        Set(ByVal value As Boolean)
  683.            _Checked = value
  684.  
  685.            If _Checked Then
  686.                InvalidateParent()
  687.            End If
  688.  
  689.            RaiseEvent CheckedChanged(Me)
  690.            Invalidate()
  691.        End Set
  692.    End Property
  693.  
  694.    Private Sub InvalidateParent()
  695.        If Parent Is Nothing Then Return
  696.  
  697.        For Each C As Control In Parent.Controls
  698.            If Not (C Is Me) AndAlso (TypeOf C Is NSRadioButton) Then
  699.                DirectCast(C, NSRadioButton).Checked = False
  700.            End If
  701.        Next
  702.    End Sub
  703.  
  704.    Private GP1 As GraphicsPath
  705.  
  706.    Private SZ1 As SizeF
  707.    Private PT1 As PointF
  708.  
  709.    Private P1, P2 As Pen
  710.  
  711.    Private PB1 As PathGradientBrush
  712.  
  713.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  714.        G = e.Graphics
  715.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  716.  
  717.        G.Clear(BackColor)
  718.        G.SmoothingMode = SmoothingMode.AntiAlias
  719.  
  720.        GP1 = New GraphicsPath
  721.        GP1.AddEllipse(0, 2, Height - 5, Height - 5)
  722.  
  723.        PB1 = New PathGradientBrush(GP1)
  724.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  725.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  726.        PB1.FocusScales = New PointF(0.3F, 0.3F)
  727.  
  728.        G.FillPath(PB1, GP1)
  729.  
  730.        G.DrawEllipse(P1, 0, 2, Height - 5, Height - 5)
  731.        G.DrawEllipse(P2, 1, 3, Height - 7, Height - 7)
  732.  
  733.        If _Checked Then
  734.            G.FillEllipse(Brushes.Black, 6, 8, Height - 15, Height - 15)
  735.            G.FillEllipse(Brushes.White, 5, 7, Height - 15, Height - 15)
  736.        End If
  737.  
  738.        SZ1 = G.MeasureString(Text, Font)
  739.        PT1 = New PointF(Height - 3, Height \ 2 - SZ1.Height / 2)
  740.  
  741.        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  742.        G.DrawString(Text, Font, Brushes.White, PT1)
  743.    End Sub
  744.  
  745.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  746.        Checked = True
  747.        MyBase.OnMouseDown(e)
  748.    End Sub
  749.  
  750. End Class
  751.  
  752. Class NSComboBox
  753.    Inherits ComboBox
  754.  
  755.    Sub New()
  756.        SetStyle(DirectCast(139286, ControlStyles), True)
  757.        SetStyle(ControlStyles.Selectable, False)
  758.  
  759.        DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  760.        DropDownStyle = ComboBoxStyle.DropDownList
  761.  
  762.        BackColor = Color.FromArgb(50, 50, 50)
  763.        ForeColor = Color.White
  764.  
  765.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  766.        P2 = New Pen(Color.White, 2.0F)
  767.        P3 = New Pen(Brushes.Black, 2.0F)
  768.        P4 = New Pen(Color.FromArgb(65, 65, 65))
  769.  
  770.        B1 = New SolidBrush(Color.FromArgb(65, 65, 65))
  771.        B2 = New SolidBrush(Color.FromArgb(55, 55, 55))
  772.    End Sub
  773.  
  774.    Private GP1, GP2 As GraphicsPath
  775.  
  776.    Private SZ1 As SizeF
  777.    Private PT1 As PointF
  778.  
  779.    Private P1, P2, P3, P4 As Pen
  780.    Private B1, B2 As SolidBrush
  781.  
  782.    Private GB1 As LinearGradientBrush
  783.  
  784.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  785.        G = e.Graphics
  786.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  787.  
  788.        G.Clear(BackColor)
  789.        G.SmoothingMode = SmoothingMode.AntiAlias
  790.  
  791.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  792.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  793.  
  794.        GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  795.        G.SetClip(GP1)
  796.        G.FillRectangle(GB1, ClientRectangle)
  797.        G.ResetClip()
  798.  
  799.        G.DrawPath(P1, GP1)
  800.        G.DrawPath(P4, GP2)
  801.  
  802.        SZ1 = G.MeasureString(Text, Font)
  803.        PT1 = New PointF(5, Height \ 2 - SZ1.Height / 2)
  804.  
  805.        G.DrawString(Text, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  806.        G.DrawString(Text, Font, Brushes.White, PT1)
  807.  
  808.        G.DrawLine(P3, Width - 15, 10, Width - 11, 13)
  809.        G.DrawLine(P3, Width - 7, 10, Width - 11, 13)
  810.        G.DrawLine(Pens.Black, Width - 11, 13, Width - 11, 14)
  811.  
  812.        G.DrawLine(P2, Width - 16, 9, Width - 12, 12)
  813.        G.DrawLine(P2, Width - 8, 9, Width - 12, 12)
  814.        G.DrawLine(Pens.White, Width - 12, 12, Width - 12, 13)
  815.  
  816.        G.DrawLine(P1, Width - 22, 0, Width - 22, Height)
  817.        G.DrawLine(P4, Width - 23, 1, Width - 23, Height - 2)
  818.        G.DrawLine(P4, Width - 21, 1, Width - 21, Height - 2)
  819.    End Sub
  820.  
  821.    Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  822.        e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  823.  
  824.        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  825.            e.Graphics.FillRectangle(B1, e.Bounds)
  826.        Else
  827.            e.Graphics.FillRectangle(B2, e.Bounds)
  828.        End If
  829.  
  830.        If Not e.Index = -1 Then
  831.            e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, Brushes.White, e.Bounds)
  832.        End If
  833.    End Sub
  834.  
  835. End Class
  836.  
  837. Class NSTabControl
  838.    Inherits TabControl
  839.  
  840.    Sub New()
  841.        SetStyle(DirectCast(139286, ControlStyles), True)
  842.        SetStyle(ControlStyles.Selectable, False)
  843.  
  844.        SizeMode = TabSizeMode.Fixed
  845.        Alignment = TabAlignment.Left
  846.        ItemSize = New Size(28, 115)
  847.  
  848.        DrawMode = TabDrawMode.OwnerDrawFixed
  849.  
  850.        P1 = New Pen(Color.FromArgb(55, 55, 55))
  851.        P2 = New Pen(Color.FromArgb(35, 35, 35))
  852.        P3 = New Pen(Color.FromArgb(45, 45, 45), 2)
  853.  
  854.        B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  855.        B2 = New SolidBrush(Color.FromArgb(35, 35, 35))
  856.        B3 = New SolidBrush(Color.FromArgb(205, 150, 0))
  857.        B4 = New SolidBrush(Color.FromArgb(65, 65, 65))
  858.  
  859.        SF1 = New StringFormat()
  860.        SF1.LineAlignment = StringAlignment.Center
  861.    End Sub
  862.  
  863.    Protected Overrides Sub OnControlAdded(e As ControlEventArgs)
  864.        If TypeOf e.Control Is TabPage Then
  865.            e.Control.BackColor = Color.FromArgb(50, 50, 50)
  866.        End If
  867.  
  868.        MyBase.OnControlAdded(e)
  869.    End Sub
  870.  
  871.    Private GP1, GP2, GP3, GP4 As GraphicsPath
  872.  
  873.    Private R1, R2 As Rectangle
  874.  
  875.    Private P1, P2, P3 As Pen
  876.    Private B1, B2, B3, B4 As SolidBrush
  877.  
  878.    Private PB1 As PathGradientBrush
  879.  
  880.    Private TP1 As TabPage
  881.    Private SF1 As StringFormat
  882.  
  883.    Private Offset As Integer
  884.    Private ItemHeight As Integer
  885.  
  886.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  887.        G = e.Graphics
  888.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  889.  
  890.        G.Clear(Color.FromArgb(50, 50, 50))
  891.        G.SmoothingMode = SmoothingMode.AntiAlias
  892.  
  893.        ItemHeight = ItemSize.Height + 2
  894.  
  895.        GP1 = CreateRound(0, 0, ItemHeight + 3, Height - 1, 7)
  896.        GP2 = CreateRound(1, 1, ItemHeight + 3, Height - 3, 7)
  897.  
  898.        PB1 = New PathGradientBrush(GP1)
  899.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  900.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  901.        PB1.FocusScales = New PointF(0.8F, 0.95F)
  902.  
  903.        G.FillPath(PB1, GP1)
  904.  
  905.        G.DrawPath(P1, GP1)
  906.        G.DrawPath(P2, GP2)
  907.  
  908.        For I As Integer = 0 To TabCount - 1
  909.            R1 = GetTabRect(I)
  910.            R1.Y += 2
  911.            R1.Height -= 3
  912.            R1.Width += 1
  913.            R1.X -= 1
  914.  
  915.            TP1 = TabPages(I)
  916.            Offset = 0
  917.  
  918.            If SelectedIndex = I Then
  919.                G.FillRectangle(B1, R1)
  920.  
  921.                For J As Integer = 0 To 1
  922.                    G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9)
  923.  
  924.                    G.SmoothingMode = SmoothingMode.None
  925.                    G.FillRectangle(B3, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9)
  926.                    G.SmoothingMode = SmoothingMode.AntiAlias
  927.  
  928.                    Offset += 5
  929.                Next
  930.  
  931.                G.DrawRectangle(P3, R1.X + 1, R1.Y - 1, R1.Width, R1.Height + 2)
  932.                G.DrawRectangle(P1, R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2)
  933.                G.DrawRectangle(P2, R1)
  934.            Else
  935.                For J As Integer = 0 To 1
  936.                    G.FillRectangle(B2, R1.X + 5 + (J * 5), R1.Y + 6, 2, R1.Height - 9)
  937.  
  938.                    G.SmoothingMode = SmoothingMode.None
  939.                    G.FillRectangle(B4, R1.X + 5 + (J * 5), R1.Y + 5, 2, R1.Height - 9)
  940.                    G.SmoothingMode = SmoothingMode.AntiAlias
  941.  
  942.                    Offset += 5
  943.                Next
  944.            End If
  945.  
  946.            R1.X += 5 + Offset
  947.  
  948.            R2 = R1
  949.            R2.Y += 1
  950.            R2.X += 1
  951.  
  952.            G.DrawString(TP1.Text, Font, Brushes.Black, R2, SF1)
  953.            G.DrawString(TP1.Text, Font, Brushes.White, R1, SF1)
  954.        Next
  955.  
  956.        GP3 = CreateRound(ItemHeight, 0, Width - ItemHeight - 1, Height - 1, 7)
  957.        GP4 = CreateRound(ItemHeight + 1, 1, Width - ItemHeight - 3, Height - 3, 7)
  958.  
  959.        G.DrawPath(P2, GP3)
  960.        G.DrawPath(P1, GP4)
  961.    End Sub
  962.  
  963. End Class
  964.  
  965. <DefaultEvent("CheckedChanged")> _
  966. Class NSOnOffBox
  967.    Inherits Control
  968.  
  969.    Event CheckedChanged(sender As Object)
  970.  
  971.    Sub New()
  972.        SetStyle(DirectCast(139286, ControlStyles), True)
  973.        SetStyle(ControlStyles.Selectable, False)
  974.  
  975.        P1 = New Pen(Color.FromArgb(55, 55, 55))
  976.        P2 = New Pen(Color.FromArgb(35, 35, 35))
  977.        P3 = New Pen(Color.FromArgb(65, 65, 65))
  978.  
  979.        B1 = New SolidBrush(Color.FromArgb(35, 35, 35))
  980.        B2 = New SolidBrush(Color.FromArgb(85, 85, 85))
  981.        B3 = New SolidBrush(Color.FromArgb(65, 65, 65))
  982.        B4 = New SolidBrush(Color.FromArgb(205, 150, 0))
  983.        B5 = New SolidBrush(Color.FromArgb(40, 40, 40))
  984.  
  985.        SF1 = New StringFormat()
  986.        SF1.LineAlignment = StringAlignment.Center
  987.        SF1.Alignment = StringAlignment.Near
  988.  
  989.        SF2 = New StringFormat()
  990.        SF2.LineAlignment = StringAlignment.Center
  991.        SF2.Alignment = StringAlignment.Far
  992.  
  993.        Size = New Size(56, 24)
  994.        MinimumSize = Size
  995.        MaximumSize = Size
  996.    End Sub
  997.  
  998.    Private _Checked As Boolean
  999.    Public Property Checked() As Boolean
  1000.        Get
  1001.            Return _Checked
  1002.        End Get
  1003.        Set(ByVal value As Boolean)
  1004.            _Checked = value
  1005.            RaiseEvent CheckedChanged(Me)
  1006.  
  1007.            Invalidate()
  1008.        End Set
  1009.    End Property
  1010.  
  1011.    Private GP1, GP2, GP3, GP4 As GraphicsPath
  1012.  
  1013.    Private P1, P2, P3 As Pen
  1014.    Private B1, B2, B3, B4, B5 As SolidBrush
  1015.  
  1016.    Private PB1 As PathGradientBrush
  1017.    Private GB1 As LinearGradientBrush
  1018.  
  1019.    Private R1, R2, R3 As Rectangle
  1020.    Private SF1, SF2 As StringFormat
  1021.  
  1022.    Private Offset As Integer
  1023.  
  1024.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  1025.        G = e.Graphics
  1026.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1027.  
  1028.        G.Clear(BackColor)
  1029.        G.SmoothingMode = SmoothingMode.AntiAlias
  1030.  
  1031.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  1032.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  1033.  
  1034.        PB1 = New PathGradientBrush(GP1)
  1035.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  1036.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  1037.        PB1.FocusScales = New PointF(0.3F, 0.3F)
  1038.  
  1039.        G.FillPath(PB1, GP1)
  1040.        G.DrawPath(P1, GP1)
  1041.        G.DrawPath(P2, GP2)
  1042.  
  1043.        R1 = New Rectangle(5, 0, Width - 10, Height + 2)
  1044.        R2 = New Rectangle(6, 1, Width - 10, Height + 2)
  1045.  
  1046.        R3 = New Rectangle(1, 1, (Width \ 2) - 1, Height - 3)
  1047.  
  1048.        If _Checked Then
  1049.            G.DrawString("On", Font, Brushes.Black, R2, SF1)
  1050.            G.DrawString("On", Font, Brushes.White, R1, SF1)
  1051.  
  1052.            R3.X += (Width \ 2) - 1
  1053.        Else
  1054.            G.DrawString("Off", Font, B1, R2, SF2)
  1055.            G.DrawString("Off", Font, B2, R1, SF2)
  1056.        End If
  1057.  
  1058.        GP3 = CreateRound(R3, 7)
  1059.        GP4 = CreateRound(R3.X + 1, R3.Y + 1, R3.Width - 2, R3.Height - 2, 7)
  1060.  
  1061.        GB1 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  1062.  
  1063.        G.FillPath(GB1, GP3)
  1064.        G.DrawPath(P2, GP3)
  1065.        G.DrawPath(P3, GP4)
  1066.  
  1067.        Offset = R3.X + (R3.Width \ 2) - 3
  1068.  
  1069.        For I As Integer = 0 To 1
  1070.            If _Checked Then
  1071.                G.FillRectangle(B1, Offset + (I * 5), 7, 2, Height - 14)
  1072.            Else
  1073.                G.FillRectangle(B3, Offset + (I * 5), 7, 2, Height - 14)
  1074.            End If
  1075.  
  1076.            G.SmoothingMode = SmoothingMode.None
  1077.  
  1078.            If _Checked Then
  1079.                G.FillRectangle(B4, Offset + (I * 5), 7, 2, Height - 14)
  1080.            Else
  1081.                G.FillRectangle(B5, Offset + (I * 5), 7, 2, Height - 14)
  1082.            End If
  1083.  
  1084.            G.SmoothingMode = SmoothingMode.AntiAlias
  1085.        Next
  1086.    End Sub
  1087.  
  1088.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1089.        Checked = Not Checked
  1090.        MyBase.OnMouseDown(e)
  1091.    End Sub
  1092.  
  1093. End Class
  1094.  
  1095. Class NSControlButton
  1096.    Inherits Control
  1097.  
  1098.    Enum Button As Byte
  1099.        None = 0
  1100.        Minimize = 1
  1101.        MaximizeRestore = 2
  1102.        Close = 3
  1103.    End Enum
  1104.  
  1105.    Private _ControlButton As Button = Button.Close
  1106.    Public Property ControlButton() As Button
  1107.        Get
  1108.            Return _ControlButton
  1109.        End Get
  1110.        Set(ByVal value As Button)
  1111.            _ControlButton = value
  1112.            Invalidate()
  1113.        End Set
  1114.    End Property
  1115.  
  1116.    Sub New()
  1117.        SetStyle(DirectCast(139286, ControlStyles), True)
  1118.        SetStyle(ControlStyles.Selectable, False)
  1119.  
  1120.        Anchor = AnchorStyles.Top Or AnchorStyles.Right
  1121.  
  1122.        Width = 18
  1123.        Height = 20
  1124.  
  1125.        MinimumSize = Size
  1126.        MaximumSize = Size
  1127.  
  1128.        Margin = New Padding(0)
  1129.    End Sub
  1130.  
  1131.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1132.        G = e.Graphics
  1133.        G.Clear(BackColor)
  1134.  
  1135.        Select Case _ControlButton
  1136.            Case Button.Minimize
  1137.                DrawMinimize(3, 10)
  1138.            Case Button.MaximizeRestore
  1139.                If FindForm().WindowState = FormWindowState.Normal Then
  1140.                    DrawMaximize(3, 5)
  1141.                Else
  1142.                    DrawRestore(3, 4)
  1143.                End If
  1144.            Case Button.Close
  1145.                DrawClose(4, 5)
  1146.        End Select
  1147.    End Sub
  1148.  
  1149.    Private Sub DrawMinimize(ByVal x As Integer, ByVal y As Integer)
  1150.        G.FillRectangle(Brushes.White, x, y, 12, 5)
  1151.        G.DrawRectangle(Pens.Black, x, y, 11, 4)
  1152.    End Sub
  1153.  
  1154.    Private Sub DrawMaximize(ByVal x As Integer, ByVal y As Integer)
  1155.        G.DrawRectangle(New Pen(Color.White, 2), x + 2, y + 2, 8, 6)
  1156.        G.DrawRectangle(Pens.Black, x, y, 11, 9)
  1157.        G.DrawRectangle(Pens.Black, x + 3, y + 3, 5, 3)
  1158.    End Sub
  1159.  
  1160.    Private Sub DrawRestore(ByVal x As Integer, ByVal y As Integer)
  1161.        G.FillRectangle(Brushes.White, x + 3, y + 1, 8, 4)
  1162.        G.FillRectangle(Brushes.White, x + 7, y + 5, 4, 4)
  1163.        G.DrawRectangle(Pens.Black, x + 2, y + 0, 9, 9)
  1164.  
  1165.        G.FillRectangle(Brushes.White, x + 1, y + 3, 2, 6)
  1166.        G.FillRectangle(Brushes.White, x + 1, y + 9, 8, 2)
  1167.        G.DrawRectangle(Pens.Black, x, y + 2, 9, 9)
  1168.        G.DrawRectangle(Pens.Black, x + 3, y + 5, 3, 3)
  1169.    End Sub
  1170.  
  1171.    Private ClosePath As GraphicsPath
  1172.    Private Sub DrawClose(ByVal x As Integer, ByVal y As Integer)
  1173.        If ClosePath Is Nothing Then
  1174.            ClosePath = New GraphicsPath
  1175.            ClosePath.AddLine(x + 1, y, x + 3, y)
  1176.            ClosePath.AddLine(x + 5, y + 2, x + 7, y)
  1177.            ClosePath.AddLine(x + 9, y, x + 10, y + 1)
  1178.            ClosePath.AddLine(x + 7, y + 4, x + 7, y + 5)
  1179.            ClosePath.AddLine(x + 10, y + 8, x + 9, y + 9)
  1180.            ClosePath.AddLine(x + 7, y + 9, x + 5, y + 7)
  1181.            ClosePath.AddLine(x + 3, y + 9, x + 1, y + 9)
  1182.            ClosePath.AddLine(x + 0, y + 8, x + 3, y + 5)
  1183.            ClosePath.AddLine(x + 3, y + 4, x + 0, y + 1)
  1184.        End If
  1185.  
  1186.        G.FillPath(Brushes.White, ClosePath)
  1187.        G.DrawPath(Pens.Black, ClosePath)
  1188.    End Sub
  1189.  
  1190.    Protected Overrides Sub OnMouseClick(ByVal e As MouseEventArgs)
  1191.        If e.Button = Windows.Forms.MouseButtons.Left Then
  1192.  
  1193.            Dim F As Form = FindForm()
  1194.  
  1195.            Select Case _ControlButton
  1196.                Case Button.Minimize
  1197.                    F.WindowState = FormWindowState.Minimized
  1198.                Case Button.MaximizeRestore
  1199.                    If F.WindowState = FormWindowState.Normal Then
  1200.                        F.WindowState = FormWindowState.Maximized
  1201.                    Else
  1202.                        F.WindowState = FormWindowState.Normal
  1203.                    End If
  1204.                Case Button.Close
  1205.                    F.Close()
  1206.            End Select
  1207.  
  1208.        End If
  1209.  
  1210.        Invalidate()
  1211.        MyBase.OnMouseClick(e)
  1212.    End Sub
  1213.  
  1214. End Class
  1215.  
  1216. Class NSGroupBox
  1217.    Inherits ContainerControl
  1218.  
  1219.    Private _DrawSeperator As Boolean
  1220.    Public Property DrawSeperator() As Boolean
  1221.        Get
  1222.            Return _DrawSeperator
  1223.        End Get
  1224.        Set(ByVal value As Boolean)
  1225.            _DrawSeperator = value
  1226.            Invalidate()
  1227.        End Set
  1228.    End Property
  1229.  
  1230.    Private _Title As String = "GroupBox"
  1231.    Public Property Title() As String
  1232.        Get
  1233.            Return _Title
  1234.        End Get
  1235.        Set(ByVal value As String)
  1236.            _Title = value
  1237.            Invalidate()
  1238.        End Set
  1239.    End Property
  1240.  
  1241.    Private _SubTitle As String = "Details"
  1242.    Public Property SubTitle() As String
  1243.        Get
  1244.            Return _SubTitle
  1245.        End Get
  1246.        Set(ByVal value As String)
  1247.            _SubTitle = value
  1248.            Invalidate()
  1249.        End Set
  1250.    End Property
  1251.  
  1252.    Private _TitleFont As Font
  1253.    Private _SubTitleFont As Font
  1254.  
  1255.    Sub New()
  1256.        SetStyle(DirectCast(139286, ControlStyles), True)
  1257.        SetStyle(ControlStyles.Selectable, False)
  1258.  
  1259.        _TitleFont = New Font("Verdana", 10.0F)
  1260.        _SubTitleFont = New Font("Verdana", 6.5F)
  1261.  
  1262.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  1263.        P2 = New Pen(Color.FromArgb(55, 55, 55))
  1264.  
  1265.        B1 = New SolidBrush(Color.FromArgb(205, 150, 0))
  1266.    End Sub
  1267.  
  1268.    Private GP1, GP2 As GraphicsPath
  1269.  
  1270.    Private PT1 As PointF
  1271.    Private SZ1, SZ2 As SizeF
  1272.  
  1273.    Private P1, P2 As Pen
  1274.    Private B1 As SolidBrush
  1275.  
  1276.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1277.        G = e.Graphics
  1278.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1279.  
  1280.        G.Clear(BackColor)
  1281.        G.SmoothingMode = SmoothingMode.AntiAlias
  1282.  
  1283.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  1284.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  1285.  
  1286.        G.DrawPath(P1, GP1)
  1287.        G.DrawPath(P2, GP2)
  1288.  
  1289.        SZ1 = G.MeasureString(_Title, _TitleFont, Width, StringFormat.GenericTypographic)
  1290.        SZ2 = G.MeasureString(_SubTitle, _SubTitleFont, Width, StringFormat.GenericTypographic)
  1291.  
  1292.        G.DrawString(_Title, _TitleFont, Brushes.Black, 6, 6)
  1293.        G.DrawString(_Title, _TitleFont, B1, 5, 5)
  1294.  
  1295.        PT1 = New PointF(6.0F, SZ1.Height + 4.0F)
  1296.  
  1297.        G.DrawString(_SubTitle, _SubTitleFont, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  1298.        G.DrawString(_SubTitle, _SubTitleFont, Brushes.White, PT1.X, PT1.Y)
  1299.  
  1300.        If _DrawSeperator Then
  1301.            Dim Y As Integer = CInt(PT1.Y + SZ2.Height) + 8
  1302.  
  1303.            G.DrawLine(P1, 4, Y, Width - 5, Y)
  1304.            G.DrawLine(P2, 4, Y + 1, Width - 5, Y + 1)
  1305.        End If
  1306.    End Sub
  1307.  
  1308. End Class
  1309.  
  1310. Class NSSeperator
  1311.    Inherits Control
  1312.  
  1313.    Sub New()
  1314.        SetStyle(DirectCast(139286, ControlStyles), True)
  1315.        SetStyle(ControlStyles.Selectable, False)
  1316.  
  1317.        Height = 10
  1318.  
  1319.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  1320.        P2 = New Pen(Color.FromArgb(55, 55, 55))
  1321.    End Sub
  1322.  
  1323.    Private P1, P2 As Pen
  1324.  
  1325.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1326.        G = e.Graphics
  1327.        G.Clear(BackColor)
  1328.  
  1329.        G.DrawLine(P1, 0, 5, Width, 5)
  1330.        G.DrawLine(P2, 0, 6, Width, 6)
  1331.    End Sub
  1332.  
  1333. End Class
  1334.  
  1335. <DefaultEvent("Scroll")> _
  1336. Class NSTrackBar
  1337.    Inherits Control
  1338.  
  1339.    Event Scroll(ByVal sender As Object)
  1340.  
  1341.    Private _Minimum As Integer
  1342.    Property Minimum() As Integer
  1343.        Get
  1344.            Return _Minimum
  1345.        End Get
  1346.        Set(ByVal value As Integer)
  1347.            If value < 0 Then
  1348.                Throw New Exception("Property value is not valid.")
  1349.            End If
  1350.  
  1351.            _Minimum = value
  1352.            If value > _Value Then _Value = value
  1353.            If value > _Maximum Then _Maximum = value
  1354.            Invalidate()
  1355.        End Set
  1356.    End Property
  1357.  
  1358.    Private _Maximum As Integer = 10
  1359.    Property Maximum() As Integer
  1360.        Get
  1361.            Return _Maximum
  1362.        End Get
  1363.        Set(ByVal value As Integer)
  1364.            If value < 0 Then
  1365.                Throw New Exception("Property value is not valid.")
  1366.            End If
  1367.  
  1368.            _Maximum = value
  1369.            If value < _Value Then _Value = value
  1370.            If value < _Minimum Then _Minimum = value
  1371.            Invalidate()
  1372.        End Set
  1373.    End Property
  1374.  
  1375.    Private _Value As Integer
  1376.    Property Value() As Integer
  1377.        Get
  1378.            Return _Value
  1379.        End Get
  1380.        Set(ByVal value As Integer)
  1381.            If value = _Value Then Return
  1382.  
  1383.            If value > _Maximum OrElse value < _Minimum Then
  1384.                Throw New Exception("Property value is not valid.")
  1385.            End If
  1386.  
  1387.            _Value = value
  1388.            Invalidate()
  1389.  
  1390.            RaiseEvent Scroll(Me)
  1391.        End Set
  1392.    End Property
  1393.  
  1394.    Sub New()
  1395.        SetStyle(DirectCast(139286, ControlStyles), True)
  1396.        SetStyle(ControlStyles.Selectable, False)
  1397.  
  1398.        Height = 17
  1399.  
  1400.        P1 = New Pen(Color.FromArgb(150, 110, 0), 2)
  1401.        P2 = New Pen(Color.FromArgb(55, 55, 55))
  1402.        P3 = New Pen(Color.FromArgb(35, 35, 35))
  1403.        P4 = New Pen(Color.FromArgb(65, 65, 65))
  1404.    End Sub
  1405.  
  1406.    Private GP1, GP2, GP3, GP4 As GraphicsPath
  1407.  
  1408.    Private R1, R2, R3 As Rectangle
  1409.    Private I1 As Integer
  1410.  
  1411.    Private P1, P2, P3, P4 As Pen
  1412.  
  1413.    Private GB1, GB2, GB3 As LinearGradientBrush
  1414.  
  1415.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  1416.        G = e.Graphics
  1417.  
  1418.        G.Clear(BackColor)
  1419.        G.SmoothingMode = SmoothingMode.AntiAlias
  1420.  
  1421.        GP1 = CreateRound(0, 5, Width - 1, 10, 5)
  1422.        GP2 = CreateRound(1, 6, Width - 3, 8, 5)
  1423.  
  1424.        R1 = New Rectangle(0, 7, Width - 1, 5)
  1425.        GB1 = New LinearGradientBrush(R1, Color.FromArgb(45, 45, 45), Color.FromArgb(50, 50, 50), 90.0F)
  1426.  
  1427.        I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  1428.        R2 = New Rectangle(I1, 0, 10, 20)
  1429.  
  1430.        G.SetClip(GP2)
  1431.        G.FillRectangle(GB1, R1)
  1432.  
  1433.        R3 = New Rectangle(1, 7, R2.X + R2.Width - 2, 8)
  1434.        GB2 = New LinearGradientBrush(R3, Color.FromArgb(205, 150, 0), Color.FromArgb(150, 110, 0), 90.0F)
  1435.  
  1436.        G.SmoothingMode = SmoothingMode.None
  1437.        G.FillRectangle(GB2, R3)
  1438.        G.SmoothingMode = SmoothingMode.AntiAlias
  1439.  
  1440.        For I As Integer = 0 To R3.Width - 15 Step 5
  1441.            G.DrawLine(P1, I, 0, I + 15, Height)
  1442.        Next
  1443.  
  1444.        G.ResetClip()
  1445.  
  1446.        G.DrawPath(P2, GP1)
  1447.        G.DrawPath(P3, GP2)
  1448.  
  1449.        GP3 = CreateRound(R2, 5)
  1450.        GP4 = CreateRound(R2.X + 1, R2.Y + 1, R2.Width - 2, R2.Height - 2, 5)
  1451.        GB3 = New LinearGradientBrush(ClientRectangle, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  1452.  
  1453.        G.FillPath(GB3, GP3)
  1454.        G.DrawPath(P3, GP3)
  1455.        G.DrawPath(P4, GP4)
  1456.    End Sub
  1457.  
  1458.    Private TrackDown As Boolean
  1459.    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1460.        If e.Button = Windows.Forms.MouseButtons.Left Then
  1461.            I1 = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  1462.            R2 = New Rectangle(I1, 0, 10, 20)
  1463.  
  1464.            TrackDown = R2.Contains(e.Location)
  1465.        End If
  1466.  
  1467.        MyBase.OnMouseDown(e)
  1468.    End Sub
  1469.  
  1470.    Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  1471.        If TrackDown AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  1472.            Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  1473.        End If
  1474.  
  1475.        MyBase.OnMouseMove(e)
  1476.    End Sub
  1477.  
  1478.    Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1479.        TrackDown = False
  1480.        MyBase.OnMouseUp(e)
  1481.    End Sub
  1482.  
  1483. End Class
  1484.  
  1485. <DefaultEvent("ValueChanged")> _
  1486. Class NSRandomPool
  1487.    Inherits Control
  1488.  
  1489.    Event ValueChanged(ByVal sender As Object)
  1490.  
  1491.    Private _Value As New StringBuilder
  1492.    ReadOnly Property Value() As String
  1493.        Get
  1494.            Return _Value.ToString()
  1495.        End Get
  1496.    End Property
  1497.  
  1498.    Private _FullValue As String
  1499.    ReadOnly Property FullValue() As String
  1500.        Get
  1501.            Return BitConverter.ToString(Table).Replace("-", "")
  1502.        End Get
  1503.    End Property
  1504.  
  1505.    Private RNG As New Random()
  1506.  
  1507.    Private ItemSize As Integer = 9
  1508.    Private DrawSize As Integer = 8
  1509.  
  1510.    Private WA As Rectangle
  1511.  
  1512.    Private RowSize As Integer
  1513.    Private ColumnSize As Integer
  1514.  
  1515.    Sub New()
  1516.        SetStyle(DirectCast(139286, ControlStyles), True)
  1517.        SetStyle(ControlStyles.Selectable, False)
  1518.  
  1519.        P1 = New Pen(Color.FromArgb(55, 55, 55))
  1520.        P2 = New Pen(Color.FromArgb(35, 35, 35))
  1521.  
  1522.        B1 = New SolidBrush(Color.FromArgb(30, 30, 30))
  1523.    End Sub
  1524.  
  1525.    Protected Overrides Sub OnHandleCreated(e As EventArgs)
  1526.        UpdateTable()
  1527.        MyBase.OnHandleCreated(e)
  1528.    End Sub
  1529.  
  1530.    Private Table As Byte()
  1531.    Private Sub UpdateTable()
  1532.        WA = New Rectangle(5, 5, Width - 10, Height - 10)
  1533.  
  1534.        RowSize = WA.Width \ ItemSize
  1535.        ColumnSize = WA.Height \ ItemSize
  1536.  
  1537.        WA.Width = RowSize * ItemSize
  1538.        WA.Height = ColumnSize * ItemSize
  1539.  
  1540.        WA.X = (Width \ 2) - (WA.Width \ 2)
  1541.        WA.Y = (Height \ 2) - (WA.Height \ 2)
  1542.  
  1543.        Table = New Byte((RowSize * ColumnSize) - 1) {}
  1544.  
  1545.        For I As Integer = 0 To Table.Length - 1
  1546.            Table(I) = CByte(RNG.Next(100))
  1547.        Next
  1548.  
  1549.        Invalidate()
  1550.    End Sub
  1551.  
  1552.    Protected Overrides Sub OnSizeChanged(e As EventArgs)
  1553.        UpdateTable()
  1554.    End Sub
  1555.  
  1556.    Private Index1 As Integer = -1
  1557.    Private Index2 As Integer
  1558.  
  1559.    Private InvertColors As Boolean
  1560.  
  1561.    Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  1562.        HandleDraw(e)
  1563.    End Sub
  1564.  
  1565.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1566.        HandleDraw(e)
  1567.        MyBase.OnMouseDown(e)
  1568.    End Sub
  1569.  
  1570.    Private Sub HandleDraw(e As MouseEventArgs)
  1571.        If e.Button = Windows.Forms.MouseButtons.Left OrElse e.Button = Windows.Forms.MouseButtons.Right Then
  1572.            If Not WA.Contains(e.Location) Then Return
  1573.  
  1574.            InvertColors = (e.Button = Windows.Forms.MouseButtons.Right)
  1575.  
  1576.            Index1 = GetIndex(e.X, e.Y)
  1577.            If Index1 = Index2 Then Return
  1578.  
  1579.            Dim L As Boolean = Not (Index1 Mod RowSize = 0)
  1580.            Dim R As Boolean = Not (Index1 Mod RowSize = (RowSize - 1))
  1581.  
  1582.            Randomize(Index1 - RowSize)
  1583.            If L Then Randomize(Index1 - 1)
  1584.            Randomize(Index1)
  1585.            If R Then Randomize(Index1 + 1)
  1586.            Randomize(Index1 + RowSize)
  1587.  
  1588.            _Value.Append(Table(Index1).ToString("X"))
  1589.            If _Value.Length > 32 Then _Value.Remove(0, 2)
  1590.  
  1591.            RaiseEvent ValueChanged(Me)
  1592.  
  1593.            Index2 = Index1
  1594.            Invalidate()
  1595.        End If
  1596.    End Sub
  1597.  
  1598.    Private GP1, GP2 As GraphicsPath
  1599.  
  1600.    Private P1, P2 As Pen
  1601.    Private B1, B2 As SolidBrush
  1602.  
  1603.    Private PB1 As PathGradientBrush
  1604.  
  1605.    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1606.        G = e.Graphics
  1607.  
  1608.        G.Clear(BackColor)
  1609.        G.SmoothingMode = SmoothingMode.AntiAlias
  1610.  
  1611.        GP1 = CreateRound(0, 0, Width - 1, Height - 1, 7)
  1612.        GP2 = CreateRound(1, 1, Width - 3, Height - 3, 7)
  1613.  
  1614.        PB1 = New PathGradientBrush(GP1)
  1615.        PB1.CenterColor = Color.FromArgb(50, 50, 50)
  1616.        PB1.SurroundColors = {Color.FromArgb(45, 45, 45)}
  1617.        PB1.FocusScales = New PointF(0.9F, 0.5F)
  1618.  
  1619.        G.FillPath(PB1, GP1)
  1620.  
  1621.        G.DrawPath(P1, GP1)
  1622.        G.DrawPath(P2, GP2)
  1623.  
  1624.        G.SmoothingMode = SmoothingMode.None
  1625.  
  1626.        For I As Integer = 0 To Table.Length - 1
  1627.            Dim C As Integer = Math.Max(Table(I), 75)
  1628.  
  1629.            Dim X As Integer = ((I Mod RowSize) * ItemSize) + WA.X
  1630.            Dim Y As Integer = ((I \ RowSize) * ItemSize) + WA.Y
  1631.  
  1632.            B2 = New SolidBrush(Color.FromArgb(C, C, C))
  1633.  
  1634.            G.FillRectangle(B1, X + 1, Y + 1, DrawSize, DrawSize)
  1635.            G.FillRectangle(B2, X, Y, DrawSize, DrawSize)
  1636.  
  1637.            B2.Dispose()
  1638.        Next
  1639.  
  1640.    End Sub
  1641.  
  1642.    Private Function GetIndex(ByVal x As Integer, ByVal y As Integer) As Integer
  1643.        Return (((y - WA.Y) \ ItemSize) * RowSize) + ((x - WA.X) \ ItemSize)
  1644.    End Function
  1645.  
  1646.    Private Sub Randomize(ByVal index As Integer)
  1647.        If index > -1 AndAlso index < Table.Length Then
  1648.            If InvertColors Then
  1649.                Table(index) = CByte(RNG.Next(100))
  1650.            Else
  1651.                Table(index) = CByte(RNG.Next(100, 256))
  1652.            End If
  1653.        End If
  1654.    End Sub
  1655.  
  1656. End Class
  1657.  
  1658. Class NSKeyboard
  1659.    Inherits Control
  1660.  
  1661.    Private TextBitmap As Bitmap
  1662.    Private TextGraphics As Graphics
  1663.  
  1664.    Const LowerKeys As String = "1234567890-=qwertyuiop[]asdfghjkl\;'zxcvbnm,./`"
  1665.    Const UpperKeys As String = "!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL|:""ZXCVBNM<>?~"
  1666.  
  1667.     Sub New()
  1668.         SetStyle(DirectCast(139286, ControlStyles), True)
  1669.         SetStyle(ControlStyles.Selectable, False)
  1670.  
  1671.         Font = New Font("Verdana", 8.25F)
  1672.  
  1673.         TextBitmap = New Bitmap(1, 1)
  1674.         TextGraphics = Graphics.FromImage(TextBitmap)
  1675.  
  1676.         MinimumSize = New Size(386, 162)
  1677.         MaximumSize = New Size(386, 162)
  1678.  
  1679.         Lower = LowerKeys.ToCharArray()
  1680.         Upper = UpperKeys.ToCharArray()
  1681.  
  1682.         PrepareCache()
  1683.  
  1684.         P1 = New Pen(Color.FromArgb(45, 45, 45))
  1685.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  1686.         P3 = New Pen(Color.FromArgb(35, 35, 35))
  1687.  
  1688.         B1 = New SolidBrush(Color.FromArgb(100, 100, 100))
  1689.     End Sub
  1690.  
  1691.     Private _Target As Control
  1692.     Public Property Target() As Control
  1693.         Get
  1694.             Return _Target
  1695.         End Get
  1696.         Set(ByVal value As Control)
  1697.             _Target = value
  1698.         End Set
  1699.     End Property
  1700.  
  1701.     Private Shift As Boolean
  1702.  
  1703.     Private Pressed As Integer = -1
  1704.     Private Buttons As Rectangle()
  1705.  
  1706.     Private Lower As Char()
  1707.     Private Upper As Char()
  1708.     Private Other As String() = {"Shift", "Space", "Back"}
  1709.  
  1710.     Private UpperCache As PointF()
  1711.     Private LowerCache As PointF()
  1712.  
  1713.     Private Sub PrepareCache()
  1714.         Buttons = New Rectangle(50) {}
  1715.         UpperCache = New PointF(Upper.Length - 1) {}
  1716.         LowerCache = New PointF(Lower.Length - 1) {}
  1717.  
  1718.         Dim I As Integer
  1719.  
  1720.         Dim S As SizeF
  1721.         Dim R As Rectangle
  1722.  
  1723.         For Y As Integer = 0 To 3
  1724.             For X As Integer = 0 To 11
  1725.                 I = (Y * 12) + X
  1726.                 R = New Rectangle(X * 32, Y * 32, 32, 32)
  1727.  
  1728.                 Buttons(I) = R
  1729.  
  1730.                 If Not I = 47 AndAlso Not Char.IsLetter(Upper(I)) Then
  1731.                     S = TextGraphics.MeasureString(Upper(I), Font)
  1732.                     UpperCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2)
  1733.  
  1734.                     S = TextGraphics.MeasureString(Lower(I), Font)
  1735.                     LowerCache(I) = New PointF(R.X + (R.Width \ 2 - S.Width / 2), R.Y + R.Height - S.Height - 2)
  1736.                 End If
  1737.             Next
  1738.         Next
  1739.  
  1740.         Buttons(48) = New Rectangle(0, 4 * 32, 2 * 32, 32)
  1741.         Buttons(49) = New Rectangle(Buttons(48).Right, 4 * 32, 8 * 32, 32)
  1742.         Buttons(50) = New Rectangle(Buttons(49).Right, 4 * 32, 2 * 32, 32)
  1743.     End Sub
  1744.  
  1745.     Private GP1 As GraphicsPath
  1746.  
  1747.     Private SZ1 As SizeF
  1748.     Private PT1 As PointF
  1749.  
  1750.     Private P1, P2, P3 As Pen
  1751.     Private B1 As SolidBrush
  1752.  
  1753.     Private PB1 As PathGradientBrush
  1754.     Private GB1 As LinearGradientBrush
  1755.  
  1756.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  1757.         G = e.Graphics
  1758.         G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  1759.  
  1760.         G.Clear(BackColor)
  1761.  
  1762.         Dim R As Rectangle
  1763.  
  1764.         Dim Offset As Integer
  1765.         G.DrawRectangle(P1, 0, 0, (12 * 32) + 1, (5 * 32) + 1)
  1766.  
  1767.         For I As Integer = 0 To Buttons.Length - 1
  1768.             R = Buttons(I)
  1769.  
  1770.             Offset = 0
  1771.             If I = Pressed Then
  1772.                 Offset = 1
  1773.  
  1774.                 GP1 = New GraphicsPath()
  1775.                 GP1.AddRectangle(R)
  1776.  
  1777.                 PB1 = New PathGradientBrush(GP1)
  1778.                 PB1.CenterColor = Color.FromArgb(60, 60, 60)
  1779.                 PB1.SurroundColors = {Color.FromArgb(55, 55, 55)}
  1780.                 PB1.FocusScales = New PointF(0.8F, 0.5F)
  1781.  
  1782.                 G.FillPath(PB1, GP1)
  1783.             Else
  1784.                 GB1 = New LinearGradientBrush(R, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  1785.                 G.FillRectangle(GB1, R)
  1786.             End If
  1787.  
  1788.             Select Case I
  1789.                 Case 48, 49, 50
  1790.                     SZ1 = G.MeasureString(Other(I - 48), Font)
  1791.                     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)
  1792.                     G.DrawString(Other(I - 48), Font, Brushes.White, R.X + (R.Width \ 2 - SZ1.Width / 2) + Offset, R.Y + (R.Height \ 2 - SZ1.Height / 2) + Offset)
  1793.                 Case 47
  1794.                     DrawArrow(Color.Black, R.X + Offset + 1, R.Y + Offset + 1)
  1795.                     DrawArrow(Color.White, R.X + Offset, R.Y + Offset)
  1796.                 Case Else
  1797.                     If Shift Then
  1798.                         G.DrawString(Upper(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1)
  1799.                         G.DrawString(Upper(I), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset)
  1800.  
  1801.                         If Not Char.IsLetter(Lower(I)) Then
  1802.                             PT1 = LowerCache(I)
  1803.                             G.DrawString(Lower(I), Font, B1, PT1.X + Offset, PT1.Y + Offset)
  1804.                         End If
  1805.                     Else
  1806.                         G.DrawString(Lower(I), Font, Brushes.Black, R.X + 3 + Offset + 1, R.Y + 2 + Offset + 1)
  1807.                         G.DrawString(Lower(I), Font, Brushes.White, R.X + 3 + Offset, R.Y + 2 + Offset)
  1808.  
  1809.                         If Not Char.IsLetter(Upper(I)) Then
  1810.                             PT1 = UpperCache(I)
  1811.                             G.DrawString(Upper(I), Font, B1, PT1.X + Offset, PT1.Y + Offset)
  1812.                         End If
  1813.                     End If
  1814.             End Select
  1815.  
  1816.             G.DrawRectangle(P2, R.X + 1 + Offset, R.Y + 1 + Offset, R.Width - 2, R.Height - 2)
  1817.             G.DrawRectangle(P3, R.X + Offset, R.Y + Offset, R.Width, R.Height)
  1818.  
  1819.             If I = Pressed Then
  1820.                 G.DrawLine(P1, R.X, R.Y, R.Right, R.Y)
  1821.                 G.DrawLine(P1, R.X, R.Y, R.X, R.Bottom)
  1822.             End If
  1823.         Next
  1824.     End Sub
  1825.  
  1826.     Private Sub DrawArrow(color As Color, rx As Integer, ry As Integer)
  1827.         Dim R As New Rectangle(rx + 8, ry + 8, 16, 16)
  1828.         G.SmoothingMode = SmoothingMode.AntiAlias
  1829.  
  1830.         Dim P As New Pen(color, 1)
  1831.         Dim C As New AdjustableArrowCap(3, 2)
  1832.         P.CustomEndCap = C
  1833.  
  1834.         G.DrawArc(P, R, 0.0F, 290.0F)
  1835.  
  1836.         P.Dispose()
  1837.         C.Dispose()
  1838.         G.SmoothingMode = SmoothingMode.None
  1839.     End Sub
  1840.  
  1841.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1842.         Dim Index As Integer = ((e.Y \ 32) * 12) + (e.X \ 32)
  1843.  
  1844.         If Index > 47 Then
  1845.             For I As Integer = 48 To Buttons.Length - 1
  1846.                 If Buttons(I).Contains(e.X, e.Y) Then
  1847.                     Pressed = I
  1848.                     Exit For
  1849.                 End If
  1850.             Next
  1851.         Else
  1852.             Pressed = Index
  1853.         End If
  1854.  
  1855.         HandleKey()
  1856.         Invalidate()
  1857.     End Sub
  1858.  
  1859.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1860.         Pressed = -1
  1861.         Invalidate()
  1862.     End Sub
  1863.  
  1864.     Private Sub HandleKey()
  1865.         If _Target Is Nothing Then Return
  1866.         If Pressed = -1 Then Return
  1867.  
  1868.         Select Case Pressed
  1869.             Case 47
  1870.                 _Target.Text = String.Empty
  1871.             Case 48
  1872.                 Shift = Not Shift
  1873.             Case 49
  1874.                 _Target.Text &= " "
  1875.             Case 50
  1876.                 If Not _Target.Text.Length = 0 Then
  1877.                     _Target.Text = _Target.Text.Remove(_Target.Text.Length - 1)
  1878.                 End If
  1879.             Case Else
  1880.                 If Shift Then
  1881.                     _Target.Text &= Upper(Pressed)
  1882.                 Else
  1883.                     _Target.Text &= Lower(Pressed)
  1884.                 End If
  1885.         End Select
  1886.     End Sub
  1887.  
  1888. End Class
  1889.  
  1890. <DefaultEvent("SelectedIndexChanged")> _
  1891. Class NSPaginator
  1892.     Inherits Control
  1893.  
  1894.     Public Event SelectedIndexChanged(sender As Object, e As EventArgs)
  1895.  
  1896.     Private TextBitmap As Bitmap
  1897.     Private TextGraphics As Graphics
  1898.  
  1899.     Sub New()
  1900.         SetStyle(DirectCast(139286, ControlStyles), True)
  1901.         SetStyle(ControlStyles.Selectable, False)
  1902.  
  1903.         Size = New Size(202, 26)
  1904.  
  1905.         TextBitmap = New Bitmap(1, 1)
  1906.         TextGraphics = Graphics.FromImage(TextBitmap)
  1907.  
  1908.         InvalidateItems()
  1909.  
  1910.         B1 = New SolidBrush(Color.FromArgb(50, 50, 50))
  1911.         B2 = New SolidBrush(Color.FromArgb(55, 55, 55))
  1912.  
  1913.         P1 = New Pen(Color.FromArgb(35, 35, 35))
  1914.         P2 = New Pen(Color.FromArgb(55, 55, 55))
  1915.         P3 = New Pen(Color.FromArgb(65, 65, 65))
  1916.     End Sub
  1917.  
  1918.     Private _SelectedIndex As Integer
  1919.     Public Property SelectedIndex() As Integer
  1920.         Get
  1921.             Return _SelectedIndex
  1922.         End Get
  1923.         Set(ByVal value As Integer)
  1924.             _SelectedIndex = Math.Max(Math.Min(value, MaximumIndex), 0)
  1925.             Invalidate()
  1926.         End Set
  1927.     End Property
  1928.  
  1929.     Private _NumberOfPages As Integer
  1930.     Public Property NumberOfPages() As Integer
  1931.         Get
  1932.             Return _NumberOfPages
  1933.         End Get
  1934.         Set(ByVal value As Integer)
  1935.             _NumberOfPages = value
  1936.             _SelectedIndex = Math.Max(Math.Min(_SelectedIndex, MaximumIndex), 0)
  1937.             Invalidate()
  1938.         End Set
  1939.     End Property
  1940.  
  1941.     Public ReadOnly Property MaximumIndex As Integer
  1942.         Get
  1943.             Return NumberOfPages - 1
  1944.         End Get
  1945.     End Property
  1946.  
  1947.     Private ItemWidth As Integer
  1948.  
  1949.     Public Overrides Property Font As Font
  1950.         Get
  1951.             Return MyBase.Font
  1952.         End Get
  1953.         Set(value As Font)
  1954.             MyBase.Font = value
  1955.  
  1956.             InvalidateItems()
  1957.             Invalidate()
  1958.         End Set
  1959.     End Property
  1960.  
  1961.     Private Sub InvalidateItems()
  1962.         Dim S As Size = TextGraphics.MeasureString("000 ..", Font).ToSize()
  1963.         ItemWidth = S.Width + 10
  1964.     End Sub
  1965.  
  1966.     Private GP1, GP2 As GraphicsPath
  1967.  
  1968.     Private R1 As Rectangle
  1969.  
  1970.     Private SZ1 As Size
  1971.     Private PT1 As Point
  1972.  
  1973.     Private P1, P2, P3 As Pen
  1974.     Private B1, B2 As SolidBrush
  1975.  
  1976.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  1977.         G = e.Graphics
  1978.         G.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
  1979.  
  1980.         G.Clear(BackColor)
  1981.         G.SmoothingMode = SmoothingMode.AntiAlias
  1982.  
  1983.         Dim LeftEllipse, RightEllipse As Boolean
  1984.  
  1985.         If _SelectedIndex < 4 Then
  1986.             For I As Integer = 0 To Math.Min(MaximumIndex, 4)
  1987.                 RightEllipse = (I = 4) AndAlso (MaximumIndex > 4)
  1988.                 DrawBox(I * ItemWidth, I, False, RightEllipse)
  1989.             Next
  1990.         ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then
  1991.             For I As Integer = 0 To 4
  1992.                 LeftEllipse = (I = 0)
  1993.                 RightEllipse = (I = 4)
  1994.                 DrawBox(I * ItemWidth, _SelectedIndex + I - 2, LeftEllipse, RightEllipse)
  1995.             Next
  1996.         Else
  1997.             For I As Integer = 0 To 4
  1998.                 LeftEllipse = (I = 0) AndAlso (MaximumIndex > 4)
  1999.                 DrawBox(I * ItemWidth, MaximumIndex - (4 - I), LeftEllipse, False)
  2000.             Next
  2001.         End If
  2002.     End Sub
  2003.  
  2004.     Private Sub DrawBox(x As Integer, index As Integer, leftEllipse As Boolean, rightEllipse As Boolean)
  2005.         R1 = New Rectangle(x, 0, ItemWidth - 4, Height - 1)
  2006.  
  2007.         GP1 = CreateRound(R1, 7)
  2008.         GP2 = CreateRound(R1.X + 1, R1.Y + 1, R1.Width - 2, R1.Height - 2, 7)
  2009.  
  2010.         Dim T As String = CStr(index + 1)
  2011.  
  2012.         If leftEllipse Then T = ".. " & T
  2013.         If rightEllipse Then T = T & " .."
  2014.  
  2015.         SZ1 = G.MeasureString(T, Font).ToSize()
  2016.         PT1 = New Point(R1.X + (R1.Width \ 2 - SZ1.Width \ 2), R1.Y + (R1.Height \ 2 - SZ1.Height \ 2))
  2017.  
  2018.         If index = _SelectedIndex Then
  2019.             G.FillPath(B1, GP1)
  2020.  
  2021.             Dim F As New Font(Font, FontStyle.Underline)
  2022.             G.DrawString(T, F, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2023.             G.DrawString(T, F, Brushes.White, PT1)
  2024.             F.Dispose()
  2025.  
  2026.             G.DrawPath(P1, GP2)
  2027.             G.DrawPath(P2, GP1)
  2028.         Else
  2029.             G.FillPath(B2, GP1)
  2030.  
  2031.             G.DrawString(T, Font, Brushes.Black, PT1.X + 1, PT1.Y + 1)
  2032.             G.DrawString(T, Font, Brushes.White, PT1)
  2033.  
  2034.             G.DrawPath(P3, GP2)
  2035.             G.DrawPath(P1, GP1)
  2036.         End If
  2037.     End Sub
  2038.  
  2039.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2040.         If e.Button = Windows.Forms.MouseButtons.Left Then
  2041.             Dim NewIndex As Integer
  2042.             Dim OldIndex As Integer = _SelectedIndex
  2043.  
  2044.             If _SelectedIndex < 4 Then
  2045.                 NewIndex = (e.X \ ItemWidth)
  2046.             ElseIf _SelectedIndex > 3 AndAlso _SelectedIndex < (MaximumIndex - 3) Then
  2047.                 NewIndex = (e.X \ ItemWidth)
  2048.  
  2049.                 Select Case NewIndex
  2050.                     Case 2
  2051.                         NewIndex = OldIndex
  2052.                     Case Is < 2
  2053.                         NewIndex = OldIndex - (2 - NewIndex)
  2054.                     Case Is > 2
  2055.                         NewIndex = OldIndex + (NewIndex - 2)
  2056.                 End Select
  2057.             Else
  2058.                 NewIndex = MaximumIndex - (4 - (e.X \ ItemWidth))
  2059.             End If
  2060.  
  2061.             If (NewIndex < _NumberOfPages) AndAlso (Not NewIndex = OldIndex) Then
  2062.                 SelectedIndex = NewIndex
  2063.                 RaiseEvent SelectedIndexChanged(Me, Nothing)
  2064.             End If
  2065.         End If
  2066.  
  2067.         MyBase.OnMouseDown(e)
  2068.     End Sub
  2069.  
  2070. End Class
  2071.  
  2072. <DefaultEvent("Scroll")> _
  2073. Class NSVScrollBar
  2074.     Inherits Control
  2075.  
  2076.     Event Scroll(ByVal sender As Object)
  2077.  
  2078.     Private _Minimum As Integer
  2079.     Property Minimum() As Integer
  2080.         Get
  2081.             Return _Minimum
  2082.         End Get
  2083.         Set(ByVal value As Integer)
  2084.             If value < 0 Then
  2085.                 Throw New Exception("Property value is not valid.")
  2086.             End If
  2087.  
  2088.             _Minimum = value
  2089.             If value > _Value Then _Value = value
  2090.             If value > _Maximum Then _Maximum = value
  2091.  
  2092.             InvalidateLayout()
  2093.         End Set
  2094.     End Property
  2095.  
  2096.     Private _Maximum As Integer = 100
  2097.     Property Maximum() As Integer
  2098.         Get
  2099.             Return _Maximum
  2100.         End Get
  2101.         Set(ByVal value As Integer)
  2102.             If value < 1 Then value = 1
  2103.  
  2104.             _Maximum = value
  2105.             If value < _Value Then _Value = value
  2106.             If value < _Minimum Then _Minimum = value
  2107.  
  2108.             InvalidateLayout()
  2109.         End Set
  2110.     End Property
  2111.  
  2112.     Private _Value As Integer
  2113.     Property Value() As Integer
  2114.         Get
  2115.             If Not ShowThumb Then Return _Minimum
  2116.             Return _Value
  2117.         End Get
  2118.         Set(ByVal value As Integer)
  2119.             If value = _Value Then Return
  2120.  
  2121.             If value > _Maximum OrElse value < _Minimum Then
  2122.                 Throw New Exception("Property value is not valid.")
  2123.             End If
  2124.  
  2125.             _Value = value
  2126.             InvalidatePosition()
  2127.  
  2128.             RaiseEvent Scroll(Me)
  2129.         End Set
  2130.     End Property
  2131.  
  2132.     Property _Percent As Double
  2133.     Public ReadOnly Property Percent As Double
  2134.         Get
  2135.             If Not ShowThumb Then Return 0
  2136.             Return GetProgress()
  2137.         End Get
  2138.     End Property
  2139.  
  2140.     Private _SmallChange As Integer = 1
  2141.     Public Property SmallChange() As Integer
  2142.         Get
  2143.             Return _SmallChange
  2144.         End Get
  2145.         Set(ByVal value As Integer)
  2146.             If value < 1 Then
  2147.                 Throw New Exception("Property value is not valid.")
  2148.             End If
  2149.  
  2150.             _SmallChange = value
  2151.         End Set
  2152.     End Property
  2153.  
  2154.     Private _LargeChange As Integer = 10
  2155.     Public Property LargeChange() As Integer
  2156.         Get
  2157.             Return _LargeChange
  2158.         End Get
  2159.         Set(ByVal value As Integer)
  2160.             If value < 1 Then
  2161.                 Throw New Exception("Property value is not valid.")
  2162.             End If
  2163.  
  2164.             _LargeChange = value
  2165.         End Set
  2166.     End Property
  2167.  
  2168.     Private ButtonSize As Integer = 16
  2169.     Private ThumbSize As Integer = 24 ' 14 minimum
  2170.  
  2171.    Private TSA As Rectangle
  2172.    Private BSA As Rectangle
  2173.    Private Shaft As Rectangle
  2174.    Private Thumb As Rectangle
  2175.  
  2176.    Private ShowThumb As Boolean
  2177.    Private ThumbDown As Boolean
  2178.  
  2179.    Sub New()
  2180.        SetStyle(DirectCast(139286, ControlStyles), True)
  2181.        SetStyle(ControlStyles.Selectable, False)
  2182.  
  2183.        Width = 18
  2184.  
  2185.        B1 = New SolidBrush(Color.FromArgb(55, 55, 55))
  2186.        B2 = New SolidBrush(Color.FromArgb(35, 35, 35))
  2187.  
  2188.        P1 = New Pen(Color.FromArgb(35, 35, 35))
  2189.        P2 = New Pen(Color.FromArgb(65, 65, 65))
  2190.        P3 = New Pen(Color.FromArgb(55, 55, 55))
  2191.        P4 = New Pen(Color.FromArgb(40, 40, 40))
  2192.    End Sub
  2193.  
  2194.    Private GP1, GP2, GP3, GP4 As GraphicsPath
  2195.  
  2196.    Private P1, P2, P3, P4 As Pen
  2197.    Private B1, B2 As SolidBrush
  2198.  
  2199.    Dim I1 As Integer
  2200.  
  2201.    Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2202.        G = e.Graphics
  2203.        G.Clear(BackColor)
  2204.  
  2205.        GP1 = DrawArrow(4, 6, False)
  2206.        GP2 = DrawArrow(5, 7, False)
  2207.  
  2208.        G.FillPath(B1, GP2)
  2209.        G.FillPath(B2, GP1)
  2210.  
  2211.        GP3 = DrawArrow(4, Height - 11, True)
  2212.        GP4 = DrawArrow(5, Height - 10, True)
  2213.  
  2214.        G.FillPath(B1, GP4)
  2215.        G.FillPath(B2, GP3)
  2216.  
  2217.        If ShowThumb Then
  2218.            G.FillRectangle(B1, Thumb)
  2219.            G.DrawRectangle(P1, Thumb)
  2220.            G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2)
  2221.  
  2222.            Dim Y As Integer
  2223.            Dim LY As Integer = Thumb.Y + (Thumb.Height \ 2) - 3
  2224.  
  2225.            For I As Integer = 0 To 2
  2226.                Y = LY + (I * 3)
  2227.  
  2228.                G.DrawLine(P1, Thumb.X + 5, Y, Thumb.Right - 5, Y)
  2229.                G.DrawLine(P2, Thumb.X + 5, Y + 1, Thumb.Right - 5, Y + 1)
  2230.            Next
  2231.        End If
  2232.  
  2233.        G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  2234.        G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3)
  2235.    End Sub
  2236.  
  2237.    Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  2238.        Dim GP As New GraphicsPath()
  2239.  
  2240.        Dim W As Integer = 9
  2241.        Dim H As Integer = 5
  2242.  
  2243.        If flip Then
  2244.            GP.AddLine(x + 1, y, x + W + 1, y)
  2245.            GP.AddLine(x + W, y, x + H, y + H - 1)
  2246.        Else
  2247.            GP.AddLine(x, y + H, x + W, y + H)
  2248.            GP.AddLine(x + W, y + H, x + H, y)
  2249.        End If
  2250.  
  2251.        GP.CloseFigure()
  2252.        Return GP
  2253.    End Function
  2254.  
  2255.    Protected Overrides Sub OnSizeChanged(e As EventArgs)
  2256.        InvalidateLayout()
  2257.    End Sub
  2258.  
  2259.    Private Sub InvalidateLayout()
  2260.        TSA = New Rectangle(0, 0, Width, ButtonSize)
  2261.        BSA = New Rectangle(0, Height - ButtonSize, Width, ButtonSize)
  2262.        Shaft = New Rectangle(0, TSA.Bottom + 1, Width, Height - (ButtonSize * 2) - 1)
  2263.  
  2264.        ShowThumb = ((_Maximum - _Minimum) > Shaft.Height)
  2265.  
  2266.        If ShowThumb Then
  2267.            'ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  2268.            Thumb = New Rectangle(1, 0, Width - 3, ThumbSize)
  2269.        End If
  2270.  
  2271.        RaiseEvent Scroll(Me)
  2272.        InvalidatePosition()
  2273.    End Sub
  2274.  
  2275.    Private Sub InvalidatePosition()
  2276.        Thumb.Y = CInt(GetProgress() * (Shaft.Height - ThumbSize)) + TSA.Height
  2277.        Invalidate()
  2278.    End Sub
  2279.  
  2280.    Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  2281.        If e.Button = Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then
  2282.            If TSA.Contains(e.Location) Then
  2283.                I1 = _Value - _SmallChange
  2284.            ElseIf BSA.Contains(e.Location) Then
  2285.                I1 = _Value + _SmallChange
  2286.            Else
  2287.                If Thumb.Contains(e.Location) Then
  2288.                    ThumbDown = True
  2289.                    MyBase.OnMouseDown(e)
  2290.                    Return
  2291.                Else
  2292.                    If e.Y < Thumb.Y Then
  2293.                        I1 = _Value - _LargeChange
  2294.                    Else
  2295.                        I1 = _Value + _LargeChange
  2296.                    End If
  2297.                End If
  2298.            End If
  2299.  
  2300.            Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  2301.            InvalidatePosition()
  2302.        End If
  2303.  
  2304.        MyBase.OnMouseDown(e)
  2305.    End Sub
  2306.  
  2307.    Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  2308.        If ThumbDown AndAlso ShowThumb Then
  2309.            Dim ThumbPosition As Integer = e.Y - TSA.Height - (ThumbSize \ 2)
  2310.            Dim ThumbBounds As Integer = Shaft.Height - ThumbSize
  2311.  
  2312.            I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum
  2313.  
  2314.            Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  2315.            InvalidatePosition()
  2316.        End If
  2317.  
  2318.        MyBase.OnMouseMove(e)
  2319.    End Sub
  2320.  
  2321.    Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  2322.        ThumbDown = False
  2323.        MyBase.OnMouseUp(e)
  2324.    End Sub
  2325.  
  2326.    Private Function GetProgress() As Double
  2327.        Return (_Value - _Minimum) / (_Maximum - _Minimum)
  2328.    End Function
  2329.  
  2330. End Class
  2331.  
  2332. <DefaultEvent("Scroll")> _
  2333. Class NSHScrollBar
  2334.    Inherits Control
  2335.  
  2336.    Event Scroll(ByVal sender As Object)
  2337.  
  2338.    Private _Minimum As Integer
  2339.    Property Minimum() As Integer
  2340.        Get
  2341.            Return _Minimum
  2342.        End Get
  2343.        Set(ByVal value As Integer)
  2344.            If value < 0 Then
  2345.                Throw New Exception("Property value is not valid.")
  2346.            End If
  2347.  
  2348.            _Minimum = value
  2349.            If value > _Value Then _Value = value
  2350.            If value > _Maximum Then _Maximum = value
  2351.  
  2352.            InvalidateLayout()
  2353.        End Set
  2354.    End Property
  2355.  
  2356.    Private _Maximum As Integer = 100
  2357.    Property Maximum() As Integer
  2358.        Get
  2359.            Return _Maximum
  2360.        End Get
  2361.        Set(ByVal value As Integer)
  2362.            If value < 0 Then
  2363.                Throw New Exception("Property value is not valid.")
  2364.            End If
  2365.  
  2366.            _Maximum = value
  2367.            If value < _Value Then _Value = value
  2368.            If value < _Minimum Then _Minimum = value
  2369.  
  2370.            InvalidateLayout()
  2371.        End Set
  2372.    End Property
  2373.  
  2374.    Private _Value As Integer
  2375.    Property Value() As Integer
  2376.        Get
  2377.            If Not ShowThumb Then Return _Minimum
  2378.            Return _Value
  2379.        End Get
  2380.        Set(ByVal value As Integer)
  2381.            If value = _Value Then Return
  2382.  
  2383.            If value > _Maximum OrElse value < _Minimum Then
  2384.                Throw New Exception("Property value is not valid.")
  2385.            End If
  2386.  
  2387.            _Value = value
  2388.            InvalidatePosition()
  2389.  
  2390.            RaiseEvent Scroll(Me)
  2391.        End Set
  2392.    End Property
  2393.  
  2394.    Private _SmallChange As Integer = 1
  2395.    Public Property SmallChange() As Integer
  2396.        Get
  2397.            Return _SmallChange
  2398.        End Get
  2399.        Set(ByVal value As Integer)
  2400.            If value < 1 Then
  2401.                Throw New Exception("Property value is not valid.")
  2402.            End If
  2403.  
  2404.            _SmallChange = value
  2405.        End Set
  2406.    End Property
  2407.  
  2408.    Private _LargeChange As Integer = 10
  2409.    Public Property LargeChange() As Integer
  2410.        Get
  2411.            Return _LargeChange
  2412.        End Get
  2413.        Set(ByVal value As Integer)
  2414.            If value < 1 Then
  2415.                Throw New Exception("Property value is not valid.")
  2416.            End If
  2417.  
  2418.            _LargeChange = value
  2419.        End Set
  2420.    End Property
  2421.  
  2422.    Private ButtonSize As Integer = 16
  2423.    Private ThumbSize As Integer = 24 ' 14 minimum
  2424.  
  2425.     Private LSA As Rectangle
  2426.     Private RSA As Rectangle
  2427.     Private Shaft As Rectangle
  2428.     Private Thumb As Rectangle
  2429.  
  2430.     Private ShowThumb As Boolean
  2431.     Private ThumbDown As Boolean
  2432.  
  2433.     Sub New()
  2434.         SetStyle(DirectCast(139286, ControlStyles), True)
  2435.         SetStyle(ControlStyles.Selectable, False)
  2436.  
  2437.         Height = 18
  2438.  
  2439.         B1 = New SolidBrush(Color.FromArgb(55, 55, 55))
  2440.         B2 = New SolidBrush(Color.FromArgb(35, 35, 35))
  2441.  
  2442.         P1 = New Pen(Color.FromArgb(35, 35, 35))
  2443.         P2 = New Pen(Color.FromArgb(65, 65, 65))
  2444.         P3 = New Pen(Color.FromArgb(55, 55, 55))
  2445.         P4 = New Pen(Color.FromArgb(40, 40, 40))
  2446.     End Sub
  2447.  
  2448.     Private GP1, GP2, GP3, GP4 As GraphicsPath
  2449.  
  2450.     Private P1, P2, P3, P4 As Pen
  2451.     Private B1, B2 As SolidBrush
  2452.  
  2453.     Dim I1 As Integer
  2454.  
  2455.     Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
  2456.         G = e.Graphics
  2457.         G.Clear(BackColor)
  2458.  
  2459.         GP1 = DrawArrow(6, 4, False)
  2460.         GP2 = DrawArrow(7, 5, False)
  2461.  
  2462.         G.FillPath(B1, GP2)
  2463.         G.FillPath(B2, GP1)
  2464.  
  2465.         GP3 = DrawArrow(Width - 11, 4, True)
  2466.         GP4 = DrawArrow(Width - 10, 5, True)
  2467.  
  2468.         G.FillPath(B1, GP4)
  2469.         G.FillPath(B2, GP3)
  2470.  
  2471.         If ShowThumb Then
  2472.             G.FillRectangle(B1, Thumb)
  2473.             G.DrawRectangle(P1, Thumb)
  2474.             G.DrawRectangle(P2, Thumb.X + 1, Thumb.Y + 1, Thumb.Width - 2, Thumb.Height - 2)
  2475.  
  2476.             Dim X As Integer
  2477.             Dim LX As Integer = Thumb.X + (Thumb.Width \ 2) - 3
  2478.  
  2479.             For I As Integer = 0 To 2
  2480.                 X = LX + (I * 3)
  2481.  
  2482.                 G.DrawLine(P1, X, Thumb.Y + 5, X, Thumb.Bottom - 5)
  2483.                 G.DrawLine(P2, X + 1, Thumb.Y + 5, X + 1, Thumb.Bottom - 5)
  2484.             Next
  2485.         End If
  2486.  
  2487.         G.DrawRectangle(P3, 0, 0, Width - 1, Height - 1)
  2488.         G.DrawRectangle(P4, 1, 1, Width - 3, Height - 3)
  2489.     End Sub
  2490.  
  2491.     Private Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  2492.         Dim GP As New GraphicsPath()
  2493.  
  2494.         Dim W As Integer = 5
  2495.         Dim H As Integer = 9
  2496.  
  2497.         If flip Then
  2498.             GP.AddLine(x, y + 1, x, y + H + 1)
  2499.             GP.AddLine(x, y + H, x + W - 1, y + W)
  2500.         Else
  2501.             GP.AddLine(x + W, y, x + W, y + H)
  2502.             GP.AddLine(x + W, y + H, x + 1, y + W)
  2503.         End If
  2504.  
  2505.         GP.CloseFigure()
  2506.         Return GP
  2507.     End Function
  2508.  
  2509.     Protected Overrides Sub OnSizeChanged(e As EventArgs)
  2510.         InvalidateLayout()
  2511.     End Sub
  2512.  
  2513.     Private Sub InvalidateLayout()
  2514.         LSA = New Rectangle(0, 0, ButtonSize, Height)
  2515.         RSA = New Rectangle(Width - ButtonSize, 0, ButtonSize, Height)
  2516.         Shaft = New Rectangle(LSA.Right + 1, 0, Width - (ButtonSize * 2) - 1, Height)
  2517.  
  2518.         ShowThumb = ((_Maximum - _Minimum) > Shaft.Width)
  2519.  
  2520.         If ShowThumb Then
  2521.             'ThumbSize = Math.Max(0, 14) 'TODO: Implement this.
  2522.             Thumb = New Rectangle(0, 1, ThumbSize, Height - 3)
  2523.         End If
  2524.  
  2525.         RaiseEvent Scroll(Me)
  2526.         InvalidatePosition()
  2527.     End Sub
  2528.  
  2529.     Private Sub InvalidatePosition()
  2530.         Thumb.X = CInt(GetProgress() * (Shaft.Width - ThumbSize)) + LSA.Width
  2531.         Invalidate()
  2532.     End Sub
  2533.  
  2534.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  2535.         If e.Button = Windows.Forms.MouseButtons.Left AndAlso ShowThumb Then
  2536.             If LSA.Contains(e.Location) Then
  2537.                 I1 = _Value - _SmallChange
  2538.             ElseIf RSA.Contains(e.Location) Then
  2539.                 I1 = _Value + _SmallChange
  2540.             Else
  2541.                 If Thumb.Contains(e.Location) Then
  2542.                     ThumbDown = True
  2543.                     MyBase.OnMouseDown(e)
  2544.                     Return
  2545.                 Else
  2546.                     If e.X < Thumb.X Then
  2547.                         I1 = _Value - _LargeChange
  2548.                     Else
  2549.                         I1 = _Value + _LargeChange
  2550.                     End If
  2551.                 End If
  2552.             End If
  2553.  
  2554.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  2555.             InvalidatePosition()
  2556.         End If
  2557.  
  2558.         MyBase.OnMouseDown(e)
  2559.     End Sub
  2560.  
  2561.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  2562.         If ThumbDown AndAlso ShowThumb Then
  2563.             Dim ThumbPosition As Integer = e.X - LSA.Width - (ThumbSize \ 2)
  2564.             Dim ThumbBounds As Integer = Shaft.Width - ThumbSize
  2565.  
  2566.             I1 = CInt((ThumbPosition / ThumbBounds) * (_Maximum - _Minimum)) + _Minimum
  2567.  
  2568.             Value = Math.Min(Math.Max(I1, _Minimum), _Maximum)
  2569.             InvalidatePosition()
  2570.         End If
  2571.  
  2572.         MyBase.OnMouseMove(e)
  2573.     End Sub
  2574.  
  2575.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  2576.         ThumbDown = False
  2577.         MyBase.OnMouseUp(e)
  2578.     End Sub
  2579.  
  2580.     Private Function GetProgress() As Double
  2581.         Return (_Value - _Minimum) / (_Maximum - _Minimum)
  2582.     End Function
  2583.  
  2584. End Class
  2585.  
  2586. Class NSContextMenu
  2587.     Inherits ContextMenuStrip
  2588.  
  2589.     Sub New()
  2590.         Renderer = New ToolStripProfessionalRenderer(New NSColorTable())
  2591.         ForeColor = Color.White
  2592.     End Sub
  2593.  
  2594.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2595.         e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2596.         MyBase.OnPaint(e)
  2597.     End Sub
  2598.  
  2599. End Class
  2600.  
  2601. Class NSColorTable
  2602.     Inherits ProfessionalColorTable
  2603.  
  2604.     Private BackColor As Color = Color.FromArgb(55, 55, 55)
  2605.  
  2606.     Public Overrides ReadOnly Property ButtonSelectedBorder() As Color
  2607.         Get
  2608.             Return BackColor
  2609.         End Get
  2610.     End Property
  2611.  
  2612.     Public Overrides ReadOnly Property CheckBackground() As Color
  2613.         Get
  2614.             Return BackColor
  2615.         End Get
  2616.     End Property
  2617.  
  2618.     Public Overrides ReadOnly Property CheckPressedBackground() As Color
  2619.         Get
  2620.             Return BackColor
  2621.         End Get
  2622.     End Property
  2623.  
  2624.     Public Overrides ReadOnly Property CheckSelectedBackground() As Color
  2625.         Get
  2626.             Return BackColor
  2627.         End Get
  2628.     End Property
  2629.  
  2630.     Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color
  2631.         Get
  2632.             Return BackColor
  2633.         End Get
  2634.     End Property
  2635.  
  2636.     Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color
  2637.         Get
  2638.             Return BackColor
  2639.         End Get
  2640.     End Property
  2641.  
  2642.     Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color
  2643.         Get
  2644.             Return BackColor
  2645.         End Get
  2646.     End Property
  2647.  
  2648.     Public Overrides ReadOnly Property MenuBorder() As Color
  2649.         Get
  2650.             Return Color.FromArgb(25, 25, 25)
  2651.         End Get
  2652.     End Property
  2653.  
  2654.     Public Overrides ReadOnly Property MenuItemBorder() As Color
  2655.         Get
  2656.             Return BackColor
  2657.         End Get
  2658.     End Property
  2659.  
  2660.     Public Overrides ReadOnly Property MenuItemSelected() As Color
  2661.         Get
  2662.             Return Color.FromArgb(65, 65, 65)
  2663.         End Get
  2664.     End Property
  2665.  
  2666.     Public Overrides ReadOnly Property SeparatorDark() As Color
  2667.         Get
  2668.             Return Color.FromArgb(35, 35, 35)
  2669.         End Get
  2670.     End Property
  2671.  
  2672.     Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
  2673.         Get
  2674.             Return BackColor
  2675.         End Get
  2676.     End Property
  2677.  
  2678. End Class
  2679.  
  2680. '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
  2681. 'sick act of masochism by studying the source of the ListView then, may god have mercy on your soul.
  2682. Class NSListView
  2683.    Inherits Control
  2684.  
  2685.    Class NSListViewItem
  2686.        Property Text As String
  2687.        <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  2688.        Property SubItems As New List(Of NSListViewSubItem)
  2689.  
  2690.        Protected UniqueId As Guid
  2691.  
  2692.        Sub New()
  2693.            UniqueId = Guid.NewGuid()
  2694.        End Sub
  2695.  
  2696.        Public Overrides Function ToString() As String
  2697.            Return Text
  2698.        End Function
  2699.  
  2700.        Public Overrides Function Equals(obj As Object) As Boolean
  2701.            If TypeOf obj Is NSListViewItem Then
  2702.                Return (DirectCast(obj, NSListViewItem).UniqueId = UniqueId)
  2703.            End If
  2704.  
  2705.            Return False
  2706.        End Function
  2707.  
  2708.    End Class
  2709.  
  2710.    Class NSListViewSubItem
  2711.        Property Text As String
  2712.  
  2713.        Public Overrides Function ToString() As String
  2714.            Return Text
  2715.        End Function
  2716.    End Class
  2717.  
  2718.    Class NSListViewColumnHeader
  2719.        Property Text As String
  2720.        Property Width As Integer = 60
  2721.  
  2722.        Public Overrides Function ToString() As String
  2723.            Return Text
  2724.        End Function
  2725.    End Class
  2726.  
  2727.    Private _Items As New List(Of NSListViewItem)
  2728.    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  2729.    Public Property Items() As NSListViewItem()
  2730.        Get
  2731.            Return _Items.ToArray()
  2732.        End Get
  2733.        Set(ByVal value As NSListViewItem())
  2734.            _Items = New List(Of NSListViewItem)(value)
  2735.            InvalidateScroll()
  2736.        End Set
  2737.    End Property
  2738.  
  2739.    Private _SelectedItems As New List(Of NSListViewItem)
  2740.    Public ReadOnly Property SelectedItems() As NSListViewItem()
  2741.        Get
  2742.            Return _SelectedItems.ToArray()
  2743.        End Get
  2744.    End Property
  2745.  
  2746.    Private _Columns As New List(Of NSListViewColumnHeader)
  2747.    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
  2748.    Public Property Columns() As NSListViewColumnHeader()
  2749.        Get
  2750.            Return _Columns.ToArray()
  2751.        End Get
  2752.        Set(ByVal value As NSListViewColumnHeader())
  2753.            _Columns = New List(Of NSListViewColumnHeader)(value)
  2754.            InvalidateColumns()
  2755.        End Set
  2756.    End Property
  2757.  
  2758.    Private _MultiSelect As Boolean = True
  2759.    Public Property MultiSelect() As Boolean
  2760.        Get
  2761.            Return _MultiSelect
  2762.        End Get
  2763.        Set(ByVal value As Boolean)
  2764.            _MultiSelect = value
  2765.  
  2766.            If _SelectedItems.Count > 1 Then
  2767.                _SelectedItems.RemoveRange(1, _SelectedItems.Count - 1)
  2768.            End If
  2769.  
  2770.            Invalidate()
  2771.        End Set
  2772.    End Property
  2773.  
  2774.    Private ItemHeight As Integer = 24
  2775.    Public Overrides Property Font As Font
  2776.        Get
  2777.            Return MyBase.Font
  2778.        End Get
  2779.        Set(value As Font)
  2780.            ItemHeight = CInt(Graphics.FromHwnd(Handle).MeasureString("@", Font).Height) + 6
  2781.  
  2782.            If VS IsNot Nothing Then
  2783.                VS.SmallChange = ItemHeight
  2784.                VS.LargeChange = ItemHeight
  2785.            End If
  2786.  
  2787.            MyBase.Font = value
  2788.            InvalidateLayout()
  2789.        End Set
  2790.    End Property
  2791.  
  2792. #Region " Item Helper Methods "
  2793.  
  2794.    'Ok, you've seen everything of importance at this point; I am begging you to spare yourself. You must not read any further!
  2795.  
  2796.    Public Sub AddItem(text As String, ParamArray subItems As String())
  2797.        Dim Items As New List(Of NSListViewSubItem)
  2798.        For Each I As String In subItems
  2799.            Dim SubItem As New NSListViewSubItem()
  2800.            SubItem.Text = I
  2801.            Items.Add(SubItem)
  2802.        Next
  2803.  
  2804.        Dim Item As New NSListViewItem()
  2805.        Item.Text = text
  2806.        Item.SubItems = Items
  2807.  
  2808.        _Items.Add(Item)
  2809.        InvalidateScroll()
  2810.    End Sub
  2811.  
  2812.    Public Sub RemoveItemAt(index As Integer)
  2813.        _Items.RemoveAt(index)
  2814.        InvalidateScroll()
  2815.    End Sub
  2816.  
  2817.    Public Sub RemoveItem(item As NSListViewItem)
  2818.        _Items.Remove(item)
  2819.        InvalidateScroll()
  2820.    End Sub
  2821.  
  2822.    Public Sub RemoveItems(items As NSListViewItem())
  2823.        For Each I As NSListViewItem In items
  2824.            _Items.Remove(I)
  2825.        Next
  2826.  
  2827.        InvalidateScroll()
  2828.    End Sub
  2829.  
  2830. #End Region
  2831.  
  2832.    Private VS As NSVScrollBar
  2833.  
  2834.    Sub New()
  2835.        SetStyle(DirectCast(139286, ControlStyles), True)
  2836.        SetStyle(ControlStyles.Selectable, True)
  2837.  
  2838.        P1 = New Pen(Color.FromArgb(55, 55, 55))
  2839.        P2 = New Pen(Color.FromArgb(35, 35, 35))
  2840.        P3 = New Pen(Color.FromArgb(65, 65, 65))
  2841.  
  2842.        B1 = New SolidBrush(Color.FromArgb(62, 62, 62))
  2843.        B2 = New SolidBrush(Color.FromArgb(65, 65, 65))
  2844.        B3 = New SolidBrush(Color.FromArgb(47, 47, 47))
  2845.        B4 = New SolidBrush(Color.FromArgb(50, 50, 50))
  2846.  
  2847.        VS = New NSVScrollBar
  2848.        VS.SmallChange = ItemHeight
  2849.        VS.LargeChange = ItemHeight
  2850.  
  2851.        AddHandler VS.Scroll, AddressOf HandleScroll
  2852.        AddHandler VS.MouseDown, AddressOf VS_MouseDown
  2853.        Controls.Add(VS)
  2854.  
  2855.        InvalidateLayout()
  2856.    End Sub
  2857.  
  2858.    Protected Overrides Sub OnSizeChanged(e As EventArgs)
  2859.        InvalidateLayout()
  2860.        MyBase.OnSizeChanged(e)
  2861.    End Sub
  2862.  
  2863.    Private Sub HandleScroll(sender As Object)
  2864.        Invalidate()
  2865.    End Sub
  2866.  
  2867.    Private Sub InvalidateScroll()
  2868.        VS.Maximum = (_Items.Count * ItemHeight)
  2869.        Invalidate()
  2870.    End Sub
  2871.  
  2872.    Private Sub InvalidateLayout()
  2873.        VS.Location = New Point(Width - VS.Width - 1, 1)
  2874.        VS.Size = New Size(18, Height - 2)
  2875.  
  2876.        Invalidate()
  2877.    End Sub
  2878.  
  2879.    Private ColumnOffsets As Integer()
  2880.    Private Sub InvalidateColumns()
  2881.        Dim Width As Integer = 3
  2882.        ColumnOffsets = New Integer(_Columns.Count - 1) {}
  2883.  
  2884.        For I As Integer = 0 To _Columns.Count - 1
  2885.            ColumnOffsets(I) = Width
  2886.            Width += Columns(I).Width
  2887.        Next
  2888.  
  2889.        Invalidate()
  2890.    End Sub
  2891.  
  2892.    Private Sub VS_MouseDown(sender As Object, e As MouseEventArgs)
  2893.        Focus()
  2894.    End Sub
  2895.  
  2896.    Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2897.        Focus()
  2898.  
  2899.        If e.Button = Windows.Forms.MouseButtons.Left Then
  2900.            Dim Offset As Integer = CInt(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))))
  2901.            Dim Index As Integer = ((e.Y + Offset - ItemHeight) \ ItemHeight)
  2902.  
  2903.            If Index > _Items.Count - 1 Then Index = -1
  2904.  
  2905.            If Not Index = -1 Then
  2906.                'TODO: Handle Shift key
  2907.  
  2908.                 If ModifierKeys = Keys.Control AndAlso _MultiSelect Then
  2909.                     If _SelectedItems.Contains(_Items(Index)) Then
  2910.                         _SelectedItems.Remove(_Items(Index))
  2911.                     Else
  2912.                         _SelectedItems.Add(_Items(Index))
  2913.                     End If
  2914.                 Else
  2915.                     _SelectedItems.Clear()
  2916.                     _SelectedItems.Add(_Items(Index))
  2917.                 End If
  2918.             End If
  2919.  
  2920.             Invalidate()
  2921.         End If
  2922.  
  2923.         MyBase.OnMouseDown(e)
  2924.     End Sub
  2925.  
  2926.     Private P1, P2, P3 As Pen
  2927.     Private B1, B2, B3, B4 As SolidBrush
  2928.     Private GB1 As LinearGradientBrush
  2929.  
  2930.     'I am so sorry you have to witness this. I tried warning you. ;.;
  2931.  
  2932.    Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2933.        G = e.Graphics
  2934.        G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
  2935.  
  2936.        G.Clear(BackColor)
  2937.  
  2938.        Dim X, Y As Integer
  2939.        Dim H As Single
  2940.  
  2941.        G.DrawRectangle(P1, 1, 1, Width - 3, Height - 3)
  2942.  
  2943.        Dim R1 As Rectangle
  2944.        Dim CI As NSListViewItem
  2945.  
  2946.        Dim Offset As Integer = CInt(VS.Percent * (VS.Maximum - (Height - (ItemHeight * 2))))
  2947.  
  2948.        Dim StartIndex As Integer
  2949.        If Offset = 0 Then StartIndex = 0 Else StartIndex = (Offset \ ItemHeight)
  2950.  
  2951.        Dim EndIndex As Integer = Math.Min(StartIndex + (Height \ ItemHeight), _Items.Count - 1)
  2952.  
  2953.        For I As Integer = StartIndex To EndIndex
  2954.            CI = Items(I)
  2955.  
  2956.            R1 = New Rectangle(0, ItemHeight + (I * ItemHeight) + 1 - Offset, Width, ItemHeight - 1)
  2957.  
  2958.            H = G.MeasureString(CI.Text, Font).Height
  2959.            Y = R1.Y + CInt((ItemHeight / 2) - (H / 2))
  2960.  
  2961.            If _SelectedItems.Contains(CI) Then
  2962.                If I Mod 2 = 0 Then
  2963.                    G.FillRectangle(B1, R1)
  2964.                Else
  2965.                    G.FillRectangle(B2, R1)
  2966.                End If
  2967.            Else
  2968.                If I Mod 2 = 0 Then
  2969.                    G.FillRectangle(B3, R1)
  2970.                Else
  2971.                    G.FillRectangle(B4, R1)
  2972.                End If
  2973.            End If
  2974.  
  2975.            G.DrawLine(P2, 0, R1.Bottom, Width, R1.Bottom)
  2976.  
  2977.            If Columns.Length > 0 Then
  2978.                R1.Width = Columns(0).Width
  2979.                G.SetClip(R1)
  2980.            End If
  2981.  
  2982.            'TODO: Ellipse text that overhangs seperators.
  2983.             G.DrawString(CI.Text, Font, Brushes.Black, 10, Y + 1)
  2984.             G.DrawString(CI.Text, Font, Brushes.White, 9, Y)
  2985.  
  2986.             If CI.SubItems IsNot Nothing Then
  2987.                 For I2 As Integer = 0 To Math.Min(CI.SubItems.Count, _Columns.Count) - 1
  2988.                     X = ColumnOffsets(I2 + 1) + 4
  2989.  
  2990.                     R1.X = X
  2991.                     R1.Width = Columns(I2).Width
  2992.                     G.SetClip(R1)
  2993.  
  2994.                     G.DrawString(CI.SubItems(I2).Text, Font, Brushes.Black, X + 1, Y + 1)
  2995.                     G.DrawString(CI.SubItems(I2).Text, Font, Brushes.White, X, Y)
  2996.                 Next
  2997.             End If
  2998.  
  2999.             G.ResetClip()
  3000.         Next
  3001.  
  3002.         R1 = New Rectangle(0, 0, Width, ItemHeight)
  3003.  
  3004.         GB1 = New LinearGradientBrush(R1, Color.FromArgb(60, 60, 60), Color.FromArgb(55, 55, 55), 90.0F)
  3005.         G.FillRectangle(GB1, R1)
  3006.         G.DrawRectangle(P3, 1, 1, Width - 22, ItemHeight - 2)
  3007.  
  3008.         Dim LH As Integer = Math.Min(VS.Maximum + ItemHeight - Offset, Height)
  3009.  
  3010.         Dim CC As NSListViewColumnHeader
  3011.         For I As Integer = 0 To _Columns.Count - 1
  3012.             CC = Columns(I)
  3013.  
  3014.             H = G.MeasureString(CC.Text, Font).Height
  3015.             Y = CInt((ItemHeight / 2) - (H / 2))
  3016.             X = ColumnOffsets(I)
  3017.  
  3018.             G.DrawString(CC.Text, Font, Brushes.Black, X + 1, Y + 1)
  3019.             G.DrawString(CC.Text, Font, Brushes.White, X, Y)
  3020.  
  3021.             G.DrawLine(P2, X - 3, 0, X - 3, LH)
  3022.             G.DrawLine(P3, X - 2, 0, X - 2, ItemHeight)
  3023.         Next
  3024.  
  3025.         G.DrawRectangle(P2, 0, 0, Width - 1, Height - 1)
  3026.  
  3027.         G.DrawLine(P2, 0, ItemHeight, Width, ItemHeight)
  3028.         G.DrawLine(P2, VS.Location.X - 1, 0, VS.Location.X - 1, Height)
  3029.     End Sub
  3030.  
  3031.     Protected Overrides Sub OnMouseWheel(e As MouseEventArgs)
  3032.         Dim Move As Integer = -((e.Delta * SystemInformation.MouseWheelScrollLines \ 120) * (ItemHeight \ 2))
  3033.  
  3034.         Dim Value As Integer = Math.Max(Math.Min(VS.Value + Move, VS.Maximum), VS.Minimum)
  3035.         VS.Value = Value
  3036.  
  3037.         MyBase.OnMouseWheel(e)
  3038.     End Sub
  3039.  
  3040. End Class
Add Comment
Please, Sign In to add comment