XenocodeRCE

Metro UI Theme

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