Advertisement
XertzHF

Elegant GDI Theme

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