XertzHF

Visual Studio GDI+ Theme

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