Advertisement
DinoDz

DARK FLAT UI

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