Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 62.89 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D, System.ComponentModel
  2.  
  3.  
  4. Module flatui
  5.  
  6. #Region " Variables"
  7.     Friend G As Graphics, B As Bitmap
  8.     Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
  9.     Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
  10.     Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  11. #End Region
  12.  
  13. #Region " Functions"
  14.  
  15.     Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  16.         Dim P As GraphicsPath = New GraphicsPath()
  17.         Dim ArcRectangleWidth As Integer = Curve * 2
  18.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  19.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  20.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  21.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  22.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  23.         Return P
  24.     End Function
  25.  
  26.     '-- Credit: AeonHack
  27.     Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  28.         Dim GP As New GraphicsPath()
  29.  
  30.         Dim W As Integer = 12
  31.         Dim H As Integer = 6
  32.  
  33.         If flip Then
  34.             GP.AddLine(x + 1, y, x + W + 1, y)
  35.             GP.AddLine(x + W, y, x + H, y + H - 1)
  36.         Else
  37.             GP.AddLine(x, y + H, x + W, y + H)
  38.             GP.AddLine(x + W, y + H, x + H, y)
  39.         End If
  40.  
  41.         GP.CloseFigure()
  42.         Return GP
  43.     End Function
  44.  
  45. #End Region
  46.  
  47. End Module
  48.  
  49. #Region " Mouse States"
  50.  
  51. Enum MouseState As Byte
  52.     None = 0
  53.     Over = 1
  54.     Down = 2
  55.     Block = 3
  56. End Enum
  57.  
  58. #End Region
  59.  
  60. Class FormSkin : Inherits ContainerControl
  61.  
  62. #Region " Variables"
  63.  
  64.     Private W, H As Integer
  65.     Private Cap As Boolean = False
  66.     Private _HeaderMaximize As Boolean = False
  67.     Private MousePoint As New Point(0, 0)
  68.     Private MoveHeight = 50
  69.  
  70. #End Region
  71.  
  72. #Region " Properties"
  73.  
  74. #Region " Colors"
  75.  
  76.     <Category("Colors")>
  77.     Public Property HeaderColor() As Color
  78.         Get
  79.             Return _HeaderColor
  80.         End Get
  81.         Set(value As Color)
  82.             _HeaderColor = value
  83.         End Set
  84.     End Property
  85.     <Category("Colors")>
  86.     Public Property BaseColor() As Color
  87.         Get
  88.             Return _BaseColor
  89.         End Get
  90.         Set(value As Color)
  91.             _BaseColor = value
  92.         End Set
  93.     End Property
  94.     <Category("Colors")>
  95.     Public Property BorderColor() As Color
  96.         Get
  97.             Return _BorderColor
  98.         End Get
  99.         Set(value As Color)
  100.             _BorderColor = value
  101.         End Set
  102.     End Property
  103.     <Category("Colors")>
  104.     Public Property FlatColor() As Color
  105.         Get
  106.             Return _FlatColor
  107.         End Get
  108.         Set(value As Color)
  109.             _FlatColor = value
  110.         End Set
  111.     End Property
  112.  
  113. #End Region
  114.  
  115.     <Category("Options")>
  116.     Public Property HeaderMaximize As Boolean
  117.         Get
  118.             Return _HeaderMaximize
  119.         End Get
  120.         Set(value As Boolean)
  121.             _HeaderMaximize = value
  122.         End Set
  123.     End Property
  124.  
  125.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  126.         MyBase.OnMouseDown(e)
  127.         If e.Button = System.Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  128.             Cap = True
  129.             MousePoint = e.Location
  130.         End If
  131.     End Sub
  132.  
  133.     Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
  134.         If HeaderMaximize Then
  135.             If e.Button = System.Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  136.                 If FindForm.WindowState = FormWindowState.Normal Then
  137.                     FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
  138.                 ElseIf FindForm.WindowState = FormWindowState.Maximized Then
  139.                     FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
  140.                 End If
  141.             End If
  142.         End If
  143.     End Sub
  144.  
  145.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  146.         MyBase.OnMouseUp(e) : Cap = False
  147.     End Sub
  148.  
  149.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  150.         MyBase.OnMouseMove(e)
  151.         If Cap Then
  152.             Parent.Location = MousePosition - MousePoint
  153.         End If
  154.     End Sub
  155.  
  156.     Protected Overrides Sub OnCreateControl()
  157.         MyBase.OnCreateControl()
  158.         ParentForm.FormBorderStyle = FormBorderStyle.None
  159.         ParentForm.AllowTransparency = False
  160.         ParentForm.TransparencyKey = Color.Fuchsia
  161.         ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  162.         Dock = DockStyle.Fill
  163.         Invalidate()
  164.     End Sub
  165.  
  166. #End Region
  167.  
  168. #Region " Colors"
  169.  
  170.     Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
  171.     Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  172.     Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
  173.     Private TextColor As Color = Color.FromArgb(234, 234, 234)
  174.  
  175. #End Region
  176.  
  177.     Sub New()
  178.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  179.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  180.         DoubleBuffered = True
  181.         BackColor = Color.White
  182.         Font = New Font("Segoe UI", 12)
  183.     End Sub
  184.  
  185.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  186.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  187.         W = Width : H = Height
  188.  
  189.         Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
  190.  
  191.         With G
  192.             .SmoothingMode = 2
  193.             .PixelOffsetMode = 2
  194.             .TextRenderingHint = 5
  195.             .Clear(BackColor)
  196.  
  197.             '-- Base
  198.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  199.  
  200.             '-- Header
  201.             .FillRectangle(New SolidBrush(_HeaderColor), Header)
  202.  
  203.             '-- Logo
  204.             .FillRectangle(New SolidBrush(Color.FromArgb(243, 243, 243)), New Rectangle(8, 16, 4, 18))
  205.             .FillRectangle(New SolidBrush(_FlatColor), 16, 16, 4, 18)
  206.             .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 15, W, H), NearSF)
  207.  
  208.             '-- Border
  209.             .DrawRectangle(New Pen(_BorderColor), Base)
  210.         End With
  211.  
  212.         MyBase.OnPaint(e)
  213.         G.Dispose()
  214.         e.Graphics.InterpolationMode = 7
  215.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  216.         B.Dispose()
  217.     End Sub
  218. End Class
  219.  
  220. Class FlatClose : Inherits Control
  221.  
  222. #Region " Variables"
  223.  
  224.     Private State As MouseState = MouseState.None
  225.     Private x As Integer
  226.  
  227. #End Region
  228.  
  229. #Region " Properties"
  230.  
  231. #Region " Mouse States"
  232.  
  233.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  234.         MyBase.OnMouseEnter(e)
  235.         State = MouseState.Over : Invalidate()
  236.     End Sub
  237.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  238.         MyBase.OnMouseDown(e)
  239.         State = MouseState.Down : Invalidate()
  240.     End Sub
  241.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  242.         MyBase.OnMouseLeave(e)
  243.         State = MouseState.None : Invalidate()
  244.     End Sub
  245.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  246.         MyBase.OnMouseUp(e)
  247.         State = MouseState.Over : Invalidate()
  248.     End Sub
  249.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  250.         MyBase.OnMouseMove(e)
  251.         x = e.X : Invalidate()
  252.     End Sub
  253.  
  254.     Protected Overrides Sub OnClick(e As EventArgs)
  255.         MyBase.OnClick(e)
  256.         Environment.Exit(0)
  257.     End Sub
  258.  
  259. #End Region
  260.  
  261.     Protected Overrides Sub OnResize(e As EventArgs)
  262.         MyBase.OnResize(e)
  263.         Size = New Size(18, 18)
  264.     End Sub
  265.  
  266. #Region " Colors"
  267.  
  268.     <Category("Colors")>
  269.     Public Property BaseColor As Color
  270.         Get
  271.             Return _BaseColor
  272.         End Get
  273.         Set(value As Color)
  274.             _BaseColor = value
  275.         End Set
  276.     End Property
  277.  
  278.     <Category("Colors")>
  279.     Public Property TextColor As Color
  280.         Get
  281.             Return _TextColor
  282.         End Get
  283.         Set(value As Color)
  284.             _TextColor = value
  285.         End Set
  286.     End Property
  287.  
  288. #End Region
  289.  
  290. #End Region
  291.  
  292. #Region " Colors"
  293.  
  294.     Private _BaseColor As Color = Color.FromArgb(168, 35, 35)
  295.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  296.  
  297. #End Region
  298.  
  299.     Sub New()
  300.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  301.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  302.         DoubleBuffered = True
  303.         BackColor = Color.White
  304.         Size = New Size(18, 18)
  305.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  306.         Font = New Font("Marlett", 10)
  307.     End Sub
  308.  
  309.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  310.         Dim B As New Bitmap(Width, Height)
  311.         Dim G As Graphics = Graphics.FromImage(B)
  312.  
  313.         Dim Base As New Rectangle(0, 0, Width, Height)
  314.  
  315.         With G
  316.             .SmoothingMode = 2
  317.             .PixelOffsetMode = 2
  318.             .TextRenderingHint = 5
  319.             .Clear(BackColor)
  320.  
  321.             '-- Base
  322.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  323.  
  324.             '-- X
  325.             .DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height), CenterSF)
  326.  
  327.             '-- Hover/down
  328.             Select Case State
  329.                 Case MouseState.Over
  330.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  331.                 Case MouseState.Down
  332.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  333.             End Select
  334.         End With
  335.  
  336.         MyBase.OnPaint(e)
  337.         G.Dispose()
  338.         e.Graphics.InterpolationMode = 7
  339.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  340.         B.Dispose()
  341.     End Sub
  342. End Class
  343.  
  344. Class FlatMax : Inherits Control
  345.  
  346. #Region " Variables"
  347.  
  348.     Private State As MouseState = MouseState.None
  349.     Private x As Integer
  350.  
  351. #End Region
  352.  
  353. #Region " Properties"
  354.  
  355. #Region " Mouse States"
  356.  
  357.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  358.         MyBase.OnMouseEnter(e)
  359.         State = MouseState.Over : Invalidate()
  360.     End Sub
  361.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  362.         MyBase.OnMouseDown(e)
  363.         State = MouseState.Down : Invalidate()
  364.     End Sub
  365.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  366.         MyBase.OnMouseLeave(e)
  367.         State = MouseState.None : Invalidate()
  368.     End Sub
  369.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  370.         MyBase.OnMouseUp(e)
  371.         State = MouseState.Over : Invalidate()
  372.     End Sub
  373.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  374.         MyBase.OnMouseMove(e)
  375.         x = e.X : Invalidate()
  376.     End Sub
  377.  
  378.     Protected Overrides Sub OnClick(e As EventArgs)
  379.         MyBase.OnClick(e)
  380.         Select Case FindForm.WindowState
  381.             Case FormWindowState.Maximized
  382.                 FindForm.WindowState = FormWindowState.Normal
  383.             Case FormWindowState.Normal
  384.                 FindForm.WindowState = FormWindowState.Maximized
  385.         End Select
  386.     End Sub
  387.  
  388. #End Region
  389.  
  390.     Protected Overrides Sub OnResize(e As EventArgs)
  391.         MyBase.OnResize(e)
  392.         Size = New Size(18, 18)
  393.     End Sub
  394.  
  395. #Region " Colors"
  396.  
  397.     <Category("Colors")>
  398.     Public Property BaseColor As Color
  399.         Get
  400.             Return _BaseColor
  401.         End Get
  402.         Set(value As Color)
  403.             _BaseColor = value
  404.         End Set
  405.     End Property
  406.  
  407.     <Category("Colors")>
  408.     Public Property TextColor As Color
  409.         Get
  410.             Return _TextColor
  411.         End Get
  412.         Set(value As Color)
  413.             _TextColor = value
  414.         End Set
  415.     End Property
  416.  
  417. #End Region
  418.  
  419. #End Region
  420.  
  421. #Region " Colors"
  422.  
  423.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  424.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  425.  
  426. #End Region
  427.  
  428.     Sub New()
  429.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  430.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  431.         DoubleBuffered = True
  432.         BackColor = Color.White
  433.         Size = New Size(18, 18)
  434.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  435.         Font = New Font("Marlett", 12)
  436.     End Sub
  437.  
  438.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  439.         Dim B As New Bitmap(Width, Height)
  440.         Dim G As Graphics = Graphics.FromImage(B)
  441.  
  442.         Dim Base As New Rectangle(0, 0, Width, Height)
  443.  
  444.         With G
  445.             .SmoothingMode = 2
  446.             .PixelOffsetMode = 2
  447.             .TextRenderingHint = 5
  448.             .Clear(BackColor)
  449.  
  450.             '-- Base
  451.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  452.  
  453.             '-- Maximize
  454.             If FindForm.WindowState = FormWindowState.Maximized Then
  455.                 .DrawString("1", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  456.             ElseIf FindForm.WindowState = FormWindowState.Normal Then
  457.                 .DrawString("2", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), CenterSF)
  458.             End If
  459.  
  460.             '-- Hover/down
  461.             Select Case State
  462.                 Case MouseState.Over
  463.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  464.                 Case MouseState.Down
  465.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  466.             End Select
  467.         End With
  468.  
  469.         MyBase.OnPaint(e)
  470.         G.Dispose()
  471.         e.Graphics.InterpolationMode = 7
  472.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  473.         B.Dispose()
  474.     End Sub
  475. End Class
  476.  
  477. Class FlatMini : Inherits Control
  478.  
  479. #Region " Variables"
  480.  
  481.     Private State As MouseState = MouseState.None
  482.     Private x As Integer
  483.  
  484. #End Region
  485.  
  486. #Region " Properties"
  487.  
  488. #Region " Mouse States"
  489.  
  490.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  491.         MyBase.OnMouseEnter(e)
  492.         State = MouseState.Over : Invalidate()
  493.     End Sub
  494.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  495.         MyBase.OnMouseDown(e)
  496.         State = MouseState.Down : Invalidate()
  497.     End Sub
  498.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  499.         MyBase.OnMouseLeave(e)
  500.         State = MouseState.None : Invalidate()
  501.     End Sub
  502.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  503.         MyBase.OnMouseUp(e)
  504.         State = MouseState.Over : Invalidate()
  505.     End Sub
  506.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  507.         MyBase.OnMouseMove(e)
  508.         x = e.X : Invalidate()
  509.     End Sub
  510.  
  511.     Protected Overrides Sub OnClick(e As EventArgs)
  512.         MyBase.OnClick(e)
  513.         Select Case FindForm.WindowState
  514.             Case FormWindowState.Normal
  515.                 FindForm.WindowState = FormWindowState.Minimized
  516.             Case FormWindowState.Maximized
  517.                 FindForm.WindowState = FormWindowState.Minimized
  518.         End Select
  519.     End Sub
  520.  
  521. #End Region
  522.  
  523.     Protected Overrides Sub OnResize(e As EventArgs)
  524.         MyBase.OnResize(e)
  525.         Size = New Size(18, 18)
  526.     End Sub
  527.  
  528. #Region " Colors"
  529.  
  530.     <Category("Colors")>
  531.     Public Property BaseColor As Color
  532.         Get
  533.             Return _BaseColor
  534.         End Get
  535.         Set(value As Color)
  536.             _BaseColor = value
  537.         End Set
  538.     End Property
  539.  
  540.     <Category("Colors")>
  541.     Public Property TextColor As Color
  542.         Get
  543.             Return _TextColor
  544.         End Get
  545.         Set(value As Color)
  546.             _TextColor = value
  547.         End Set
  548.     End Property
  549.  
  550. #End Region
  551.  
  552. #End Region
  553.  
  554. #Region " Colors"
  555.  
  556.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  557.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  558.  
  559. #End Region
  560.  
  561.     Sub New()
  562.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  563.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  564.         DoubleBuffered = True
  565.         BackColor = Color.White
  566.         Size = New Size(18, 18)
  567.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  568.         Font = New Font("Marlett", 12)
  569.     End Sub
  570.  
  571.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  572.         Dim B As New Bitmap(Width, Height)
  573.         Dim G As Graphics = Graphics.FromImage(B)
  574.  
  575.         Dim Base As New Rectangle(0, 0, Width, Height)
  576.  
  577.         With G
  578.             .SmoothingMode = 2
  579.             .PixelOffsetMode = 2
  580.             .TextRenderingHint = 5
  581.             .Clear(BackColor)
  582.  
  583.             '-- Base
  584.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  585.  
  586.             '-- Minimize
  587.             .DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(2, 1, Width, Height), CenterSF)
  588.  
  589.             '-- Hover/down
  590.             Select Case State
  591.                 Case MouseState.Over
  592.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
  593.                 Case MouseState.Down
  594.                     .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
  595.             End Select
  596.         End With
  597.  
  598.         MyBase.OnPaint(e)
  599.         G.Dispose()
  600.         e.Graphics.InterpolationMode = 7
  601.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  602.         B.Dispose()
  603.     End Sub
  604. End Class
  605.  
  606. Class FlatColorPalette : Inherits Control
  607.  
  608. #Region " Variables"
  609.  
  610.     Private W, H As Integer
  611.  
  612. #End Region
  613.  
  614. #Region " Properties"
  615.  
  616.     Protected Overrides Sub OnResize(e As EventArgs)
  617.         MyBase.OnResize(e)
  618.         Width = 180
  619.         Height = 80
  620.     End Sub
  621.  
  622. #Region " Colors"
  623.  
  624.     <Category("Colors")>
  625.     Public Property Red As Color
  626.         Get
  627.             Return _Red
  628.         End Get
  629.         Set(value As Color)
  630.             _Red = value
  631.         End Set
  632.     End Property
  633.  
  634.     <Category("Colors")>
  635.     Public Property Cyan As Color
  636.         Get
  637.             Return _Cyan
  638.         End Get
  639.         Set(value As Color)
  640.             _Cyan = value
  641.         End Set
  642.     End Property
  643.  
  644.     <Category("Colors")>
  645.     Public Property Blue As Color
  646.         Get
  647.             Return _Blue
  648.         End Get
  649.         Set(value As Color)
  650.             _Blue = value
  651.         End Set
  652.     End Property
  653.  
  654.     <Category("Colors")>
  655.     Public Property LimeGreen As Color
  656.         Get
  657.             Return _LimeGreen
  658.         End Get
  659.         Set(value As Color)
  660.             _LimeGreen = value
  661.         End Set
  662.     End Property
  663.  
  664.     <Category("Colors")>
  665.     Public Property Orange As Color
  666.         Get
  667.             Return _Orange
  668.         End Get
  669.         Set(value As Color)
  670.             _Orange = value
  671.         End Set
  672.     End Property
  673.  
  674.     <Category("Colors")>
  675.     Public Property Purple As Color
  676.         Get
  677.             Return _Purple
  678.         End Get
  679.         Set(value As Color)
  680.             _Purple = value
  681.         End Set
  682.     End Property
  683.  
  684.     <Category("Colors")>
  685.     Public Property Black As Color
  686.         Get
  687.             Return _Black
  688.         End Get
  689.         Set(value As Color)
  690.             _Black = value
  691.         End Set
  692.     End Property
  693.  
  694.     <Category("Colors")>
  695.     Public Property Gray As Color
  696.         Get
  697.             Return _Gray
  698.         End Get
  699.         Set(value As Color)
  700.             _Gray = value
  701.         End Set
  702.     End Property
  703.  
  704.     <Category("Colors")>
  705.     Public Property White As Color
  706.         Get
  707.             Return _White
  708.         End Get
  709.         Set(value As Color)
  710.             _White = value
  711.         End Set
  712.     End Property
  713.  
  714. #End Region
  715.  
  716. #End Region
  717.  
  718. #Region " Colors"
  719.  
  720.     Private _Red As Color = Color.FromArgb(220, 85, 96)
  721.     Private _Cyan As Color = Color.FromArgb(10, 154, 157)
  722.     Private _Blue As Color = Color.FromArgb(0, 128, 255)
  723.     Private _LimeGreen As Color = Color.FromArgb(35, 168, 109)
  724.     Private _Orange As Color = Color.FromArgb(253, 181, 63)
  725.     Private _Purple As Color = Color.FromArgb(155, 88, 181)
  726.     Private _Black As Color = Color.FromArgb(45, 47, 49)
  727.     Private _Gray As Color = Color.FromArgb(63, 70, 73)
  728.     Private _White As Color = Color.FromArgb(243, 243, 243)
  729.  
  730. #End Region
  731.  
  732.     Sub New()
  733.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  734.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  735.         DoubleBuffered = True
  736.         BackColor = Color.FromArgb(60, 70, 73)
  737.         Size = New Size(160, 80)
  738.         Font = New Font("Segoe UI", 12)
  739.     End Sub
  740.  
  741.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  742.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  743.         W = Width - 1 : H = Height - 1
  744.  
  745.         With G
  746.             .SmoothingMode = 2
  747.             .PixelOffsetMode = 2
  748.             .TextRenderingHint = 5
  749.             .Clear(BackColor)
  750.  
  751.             '-- Colors
  752.             .FillRectangle(New SolidBrush(_Red), New Rectangle(0, 0, 20, 40))
  753.             .FillRectangle(New SolidBrush(_Cyan), New Rectangle(20, 0, 20, 40))
  754.             .FillRectangle(New SolidBrush(_Blue), New Rectangle(40, 0, 20, 40))
  755.             .FillRectangle(New SolidBrush(_LimeGreen), New Rectangle(60, 0, 20, 40))
  756.             .FillRectangle(New SolidBrush(_Orange), New Rectangle(80, 0, 20, 40))
  757.             .FillRectangle(New SolidBrush(_Purple), New Rectangle(100, 0, 20, 40))
  758.             .FillRectangle(New SolidBrush(_Black), New Rectangle(120, 0, 20, 40))
  759.             .FillRectangle(New SolidBrush(_Gray), New Rectangle(140, 0, 20, 40))
  760.             .FillRectangle(New SolidBrush(_White), New Rectangle(160, 0, 20, 40))
  761.  
  762.             '-- Text
  763.             .DrawString("Color Palette", Font, New SolidBrush(_White), New Rectangle(0, 22, W, H), CenterSF)
  764.         End With
  765.  
  766.         MyBase.OnPaint(e)
  767.         G.Dispose()
  768.         e.Graphics.InterpolationMode = 7
  769.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  770.         B.Dispose()
  771.     End Sub
  772. End Class
  773.  
  774. Class FlatGroupBox : Inherits ContainerControl
  775.  
  776. #Region " Variables"
  777.  
  778.     Private W, H As Integer
  779.     Private _ShowText As Boolean = True
  780.  
  781. #End Region
  782.  
  783. #Region " Properties"
  784.  
  785.     <Category("Colors")>
  786.     Public Property BaseColor As Color
  787.         Get
  788.             Return _BaseColor
  789.         End Get
  790.         Set(value As Color)
  791.             _BaseColor = value
  792.         End Set
  793.     End Property
  794.  
  795.     Public Property ShowText As Boolean
  796.         Get
  797.             Return _ShowText
  798.         End Get
  799.         Set(value As Boolean)
  800.             _ShowText = value
  801.         End Set
  802.     End Property
  803.  
  804. #End Region
  805.  
  806. #Region " Colors"
  807.  
  808.     Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  809.  
  810. #End Region
  811.  
  812.     Sub New()
  813.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  814.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or
  815.                  ControlStyles.SupportsTransparentBackColor, True)
  816.         DoubleBuffered = True
  817.         BackColor = Color.Transparent
  818.         Size = New Size(240, 180)
  819.         Font = New Font("Segoe ui", 10)
  820.     End Sub
  821.  
  822.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  823.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  824.         W = Width - 1 : H = Height - 1
  825.  
  826.         Dim GP, GP2, GP3 As New GraphicsPath
  827.         Dim Base As New Rectangle(8, 8, W - 16, H - 16)
  828.  
  829.         With G
  830.             .SmoothingMode = 2
  831.             .PixelOffsetMode = 2
  832.             .TextRenderingHint = 5
  833.             .Clear(BackColor)
  834.  
  835.             '-- Base
  836.             GP = flatui.RoundRec(Base, 8)
  837.             .FillPath(New SolidBrush(_BaseColor), GP)
  838.  
  839.             '-- Arrows
  840.             GP2 = flatui.DrawArrow(28, 2, False)
  841.             .FillPath(New SolidBrush(_BaseColor), GP2)
  842.             GP3 = flatui.DrawArrow(28, 8, True)
  843.             .FillPath(New SolidBrush(Color.FromArgb(60, 70, 73)), GP3)
  844.  
  845.             '-- if ShowText
  846.             If ShowText Then
  847.                 .DrawString(Text, Font, New SolidBrush(_FlatColor), New Rectangle(16, 16, W, H), NearSF)
  848.             End If
  849.         End With
  850.  
  851.         MyBase.OnPaint(e)
  852.         G.Dispose()
  853.         e.Graphics.InterpolationMode = 7
  854.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  855.         B.Dispose()
  856.     End Sub
  857. End Class
  858.  
  859. Class FlatButton : Inherits Control
  860.  
  861. #Region " Variables"
  862.  
  863.     Private W, H As Integer
  864.     Private _Rounded As Boolean = False
  865.     Private State As MouseState = MouseState.None
  866.  
  867. #End Region
  868.  
  869. #Region " Properties"
  870.  
  871. #Region " Colors"
  872.  
  873.     <Category("Colors")>
  874.     Public Property BaseColor As Color
  875.         Get
  876.             Return _BaseColor
  877.         End Get
  878.         Set(value As Color)
  879.             _BaseColor = value
  880.         End Set
  881.     End Property
  882.  
  883.     <Category("Colors")>
  884.     Public Property TextColor As Color
  885.         Get
  886.             Return _TextColor
  887.         End Get
  888.         Set(value As Color)
  889.             _TextColor = value
  890.         End Set
  891.     End Property
  892.  
  893.     <Category("Options")>
  894.     Public Property Rounded As Boolean
  895.         Get
  896.             Return _Rounded
  897.         End Get
  898.         Set(value As Boolean)
  899.             _Rounded = value
  900.         End Set
  901.     End Property
  902.  
  903. #End Region
  904.  
  905. #Region " Mouse States"
  906.  
  907.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  908.         MyBase.OnMouseDown(e)
  909.         State = MouseState.Down : Invalidate()
  910.     End Sub
  911.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  912.         MyBase.OnMouseUp(e)
  913.         State = MouseState.Over : Invalidate()
  914.     End Sub
  915.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  916.         MyBase.OnMouseEnter(e)
  917.         State = MouseState.Over : Invalidate()
  918.     End Sub
  919.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  920.         MyBase.OnMouseLeave(e)
  921.         State = MouseState.None : Invalidate()
  922.     End Sub
  923.  
  924. #End Region
  925.  
  926. #End Region
  927.  
  928. #Region " Colors"
  929.  
  930.     Private _BaseColor As Color = _FlatColor
  931.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  932.  
  933. #End Region
  934.  
  935.     Sub New()
  936.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  937.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or
  938.                  ControlStyles.SupportsTransparentBackColor, True)
  939.         DoubleBuffered = True
  940.         Size = New Size(106, 32)
  941.         BackColor = Color.Transparent
  942.         Font = New Font("Segoe UI", 12)
  943.         Cursor = Cursors.Hand
  944.     End Sub
  945.  
  946.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  947.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  948.         W = Width - 1 : H = Height - 1
  949.  
  950.         Dim GP As New GraphicsPath
  951.         Dim Base As New Rectangle(0, 0, W, H)
  952.  
  953.         With G
  954.             .SmoothingMode = 2
  955.             .PixelOffsetMode = 2
  956.             .TextRenderingHint = 5
  957.             .Clear(BackColor)
  958.  
  959.             Select Case State
  960.                 Case MouseState.None
  961.                     If Rounded Then
  962.                         '-- Base
  963.                         GP = flatui.RoundRec(Base, 6)
  964.                         .FillPath(New SolidBrush(_BaseColor), GP)
  965.  
  966.                         '-- Text
  967.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  968.                     Else
  969.                         '-- Base
  970.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  971.  
  972.                         '-- Text
  973.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  974.                     End If
  975.                 Case MouseState.Over
  976.                     If Rounded Then
  977.                         '-- Base
  978.                         GP = flatui.RoundRec(Base, 6)
  979.                         .FillPath(New SolidBrush(_BaseColor), GP)
  980.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  981.  
  982.                         '-- Text
  983.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  984.                     Else
  985.                         '-- Base
  986.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  987.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  988.  
  989.                         '-- Text
  990.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  991.                     End If
  992.                 Case MouseState.Down
  993.                     If Rounded Then
  994.                         '-- Base
  995.                         GP = flatui.RoundRec(Base, 6)
  996.                         .FillPath(New SolidBrush(_BaseColor), GP)
  997.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  998.  
  999.                         '-- Text
  1000.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1001.                     Else
  1002.                         '-- Base
  1003.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  1004.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  1005.  
  1006.                         '-- Text
  1007.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  1008.                     End If
  1009.             End Select
  1010.         End With
  1011.  
  1012.         MyBase.OnPaint(e)
  1013.         G.Dispose()
  1014.         e.Graphics.InterpolationMode = 7
  1015.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1016.         B.Dispose()
  1017.     End Sub
  1018. End Class
  1019.  
  1020. <DefaultEvent("CheckedChanged")> Class FlatToggle : Inherits Control
  1021.  
  1022. #Region " Variables"
  1023.  
  1024.     Private W, H As Integer
  1025.     Private O As _Options
  1026.     Private _Checked As Boolean = False
  1027.     Private State As MouseState = MouseState.None
  1028.  
  1029. #End Region
  1030.  
  1031. #Region " Properties"
  1032.     Public Event CheckedChanged(ByVal sender As Object)
  1033.  
  1034.     <Flags()>
  1035.     Enum _Options
  1036.         Style1
  1037.         Style2
  1038.         Style3
  1039.         Style4 '-- TODO: New Style
  1040.         Style5 '-- TODO: New Style
  1041.     End Enum
  1042.  
  1043. #Region " Options"
  1044.  
  1045.     <Category("Options")>
  1046.     Public Property Options As _Options
  1047.         Get
  1048.             Return O
  1049.         End Get
  1050.         Set(value As _Options)
  1051.             O = value
  1052.         End Set
  1053.     End Property
  1054.  
  1055.     <Category("Options")>
  1056.     Public Property Checked As Boolean
  1057.         Get
  1058.             Return _Checked
  1059.         End Get
  1060.         Set(value As Boolean)
  1061.             _Checked = value
  1062.         End Set
  1063.     End Property
  1064.  
  1065. #End Region
  1066.  
  1067.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  1068.         MyBase.OnTextChanged(e) : Invalidate()
  1069.     End Sub
  1070.  
  1071.     Protected Overrides Sub OnResize(e As EventArgs)
  1072.         MyBase.OnResize(e)
  1073.         Width = 76
  1074.         Height = 33
  1075.     End Sub
  1076.  
  1077. #Region " Mouse States"
  1078.  
  1079.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  1080.         MyBase.OnMouseEnter(e)
  1081.         State = MouseState.Over : Invalidate()
  1082.     End Sub
  1083.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  1084.         MyBase.OnMouseDown(e)
  1085.         State = MouseState.Down : Invalidate()
  1086.     End Sub
  1087.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  1088.         MyBase.OnMouseLeave(e)
  1089.         State = MouseState.None : Invalidate()
  1090.     End Sub
  1091.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  1092.         MyBase.OnMouseUp(e)
  1093.         State = MouseState.Over : Invalidate()
  1094.     End Sub
  1095.     Protected Overrides Sub OnClick(e As EventArgs)
  1096.         MyBase.OnClick(e)
  1097.         _Checked = Not _Checked
  1098.         RaiseEvent CheckedChanged(Me)
  1099.     End Sub
  1100.  
  1101. #End Region
  1102.  
  1103. #End Region
  1104.  
  1105. #Region " Colors"
  1106.  
  1107.     Private BaseColor As Color = _FlatColor
  1108.     Private BaseColorRed As Color = Color.FromArgb(220, 85, 96)
  1109.     Private BGColor As Color = Color.FromArgb(84, 85, 86)
  1110.     Private ToggleColor As Color = Color.FromArgb(45, 47, 49)
  1111.     Private TextColor As Color = Color.FromArgb(243, 243, 243)
  1112.  
  1113. #End Region
  1114.  
  1115.     Sub New()
  1116.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  1117.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or
  1118.                  ControlStyles.SupportsTransparentBackColor, True)
  1119.         DoubleBuffered = True
  1120.         BackColor = Color.Transparent
  1121.         Size = New Size(44, Height + 1)
  1122.         Cursor = Cursors.Hand
  1123.         Font = New Font("Segoe UI", 10)
  1124.         Size = New Size(76, 33)
  1125.     End Sub
  1126.  
  1127.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1128.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1129.         W = Width - 1 : H = Height - 1
  1130.  
  1131.         Dim GP, GP2 As New GraphicsPath
  1132.         Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H)
  1133.  
  1134.         With G
  1135.             .SmoothingMode = 2
  1136.             .PixelOffsetMode = 2
  1137.             .TextRenderingHint = 5
  1138.             .Clear(BackColor)
  1139.  
  1140.             Select Case O
  1141.                 Case _Options.Style1   '-- Style 1
  1142.                     '-- Base
  1143.                     GP = flatui.RoundRec(Base, 6)
  1144.                     GP2 = flatui.RoundRec(Toggle, 6)
  1145.                     .FillPath(New SolidBrush(BGColor), GP)
  1146.                     .FillPath(New SolidBrush(ToggleColor), GP2)
  1147.  
  1148.                     '-- Text
  1149.                     .DrawString("OFF", Font, New SolidBrush(BGColor), New Rectangle(19, 1, W, H), CenterSF)
  1150.  
  1151.                     If Checked Then
  1152.                         '-- Base
  1153.                         GP = flatui.RoundRec(Base, 6)
  1154.                         GP2 = flatui.RoundRec(New Rectangle(CInt(W \ 2), 0, 38, H), 6)
  1155.                         .FillPath(New SolidBrush(ToggleColor), GP)
  1156.                         .FillPath(New SolidBrush(BaseColor), GP2)
  1157.  
  1158.                         '-- Text
  1159.                         .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(8, 7, W, H), NearSF)
  1160.                     End If
  1161.                 Case _Options.Style2   '-- Style 2
  1162.                     '-- Base
  1163.                     GP = flatui.RoundRec(Base, 6)
  1164.                     Toggle = New Rectangle(4, 4, 36, H - 8)
  1165.                     GP2 = flatui.RoundRec(Toggle, 4)
  1166.                     .FillPath(New SolidBrush(BaseColorRed), GP)
  1167.                     .FillPath(New SolidBrush(ToggleColor), GP2)
  1168.  
  1169.                     '-- Lines
  1170.                     .DrawLine(New Pen(BGColor), 18, 20, 18, 12)
  1171.                     .DrawLine(New Pen(BGColor), 22, 20, 22, 12)
  1172.                     .DrawLine(New Pen(BGColor), 26, 20, 26, 12)
  1173.  
  1174.                     '-- Text
  1175.                     .DrawString("r", New Font("Marlett", 8), New SolidBrush(TextColor), New Rectangle(19, 2, Width, Height), CenterSF)
  1176.  
  1177.                     If Checked Then
  1178.                         GP = flatui.RoundRec(Base, 6)
  1179.                         Toggle = New Rectangle(CInt(W \ 2) - 2, 4, 36, H - 8)
  1180.                         GP2 = flatui.RoundRec(Toggle, 4)
  1181.                         .FillPath(New SolidBrush(BaseColor), GP)
  1182.                         .FillPath(New SolidBrush(ToggleColor), GP2)
  1183.  
  1184.                         '-- Lines
  1185.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 12, 20, CInt(W \ 2) + 12, 12)
  1186.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 16, 20, CInt(W \ 2) + 16, 12)
  1187.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 20, 20, CInt(W \ 2) + 20, 12)
  1188.  
  1189.                         '-- Text
  1190.                         .DrawString("?", New Font("Wingdings", 14), New SolidBrush(TextColor), New Rectangle(8, 7, Width, Height), NearSF)
  1191.                     End If
  1192.                 Case _Options.Style3   '-- Style 3
  1193.                     '-- Base
  1194.                     GP = flatui.RoundRec(Base, 16)
  1195.                     Toggle = New Rectangle(W - 28, 4, 22, H - 8)
  1196.                     GP2.AddEllipse(Toggle)
  1197.                     .FillPath(New SolidBrush(ToggleColor), GP)
  1198.                     .FillPath(New SolidBrush(BaseColorRed), GP2)
  1199.  
  1200.                     '-- Text
  1201.                     .DrawString("OFF", Font, New SolidBrush(BaseColorRed), New Rectangle(-12, 2, W, H), CenterSF)
  1202.  
  1203.                     If Checked Then
  1204.                         '-- Base
  1205.                         GP = flatui.RoundRec(Base, 16)
  1206.                         Toggle = New Rectangle(6, 4, 22, H - 8)
  1207.                         GP2.Reset()
  1208.                         GP2.AddEllipse(Toggle)
  1209.                         .FillPath(New SolidBrush(ToggleColor), GP)
  1210.                         .FillPath(New SolidBrush(BaseColor), GP2)
  1211.  
  1212.                         '-- Text
  1213.                         .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(12, 2, W, H), CenterSF)
  1214.                     End If
  1215.                 Case _Options.Style4
  1216.                     '-- TODO: New Styles
  1217.                     If Checked Then
  1218.                         '--
  1219.                     End If
  1220.                 Case _Options.Style5
  1221.                     '-- TODO: New Styles
  1222.                     If Checked Then
  1223.                         '--
  1224.                     End If
  1225.             End Select
  1226.  
  1227.         End With
  1228.  
  1229.         MyBase.OnPaint(e)
  1230.         G.Dispose()
  1231.         e.Graphics.InterpolationMode = 7
  1232.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1233.         B.Dispose()
  1234.     End Sub
  1235. End Class
  1236.  
  1237. <DefaultEvent("CheckedChanged")> Class FlatRadioButton : Inherits Control
  1238.  
  1239. #Region " Variables"
  1240.  
  1241.     Private State As MouseState = MouseState.None
  1242.     Private W, H As Integer
  1243.     Private O As _Options
  1244.     Private _Checked As Boolean
  1245.  
  1246. #End Region
  1247.  
  1248. #Region " Properties"
  1249.  
  1250.     Event CheckedChanged(ByVal sender As Object)
  1251.     Property Checked() As Boolean
  1252.         Get
  1253.             Return _Checked
  1254.         End Get
  1255.         Set(value As Boolean)
  1256.             _Checked = value
  1257.             InvalidateControls()
  1258.             RaiseEvent CheckedChanged(Me)
  1259.             Invalidate()
  1260.         End Set
  1261.     End Property
  1262.  
  1263.     Protected Overrides Sub OnClick(e As EventArgs)
  1264.         If Not _Checked Then Checked = True
  1265.         MyBase.OnClick(e)
  1266.     End Sub
  1267.  
  1268.     Private Sub InvalidateControls()
  1269.         If Not IsHandleCreated OrElse Not _Checked Then Return
  1270.         For Each C As Control In Parent.Controls
  1271.             If C IsNot Me AndAlso TypeOf C Is RadioButton Then
  1272.                 DirectCast(C, RadioButton).Checked = False
  1273.                 Invalidate()
  1274.             End If
  1275.         Next
  1276.     End Sub
  1277.  
  1278.     Protected Overrides Sub OnCreateControl()
  1279.         MyBase.OnCreateControl()
  1280.         InvalidateControls()
  1281.     End Sub
  1282.  
  1283.     <Flags>
  1284.     Enum _Options
  1285.         Style1
  1286.         Style2
  1287.     End Enum
  1288.  
  1289.     <Category("Options")>
  1290.     Public Property Options As _Options
  1291.         Get
  1292.             Return O
  1293.         End Get
  1294.         Set(value As _Options)
  1295.             O = value
  1296.         End Set
  1297.     End Property
  1298.  
  1299.     Protected Overrides Sub OnResize(e As EventArgs)
  1300.         MyBase.OnResize(e)
  1301.         Height = 22
  1302.     End Sub
  1303.  
  1304. #Region " Colors"
  1305.  
  1306.     <Category("Colors")>
  1307.     Public Property BaseColor As Color
  1308.         Get
  1309.             Return _BaseColor
  1310.         End Get
  1311.         Set(value As Color)
  1312.             _BaseColor = value
  1313.         End Set
  1314.     End Property
  1315.  
  1316.     <Category("Colors")>
  1317.     Public Property BorderColor As Color
  1318.         Get
  1319.             Return _BorderColor
  1320.         End Get
  1321.         Set(value As Color)
  1322.             _BorderColor = value
  1323.         End Set
  1324.     End Property
  1325.  
  1326. #End Region
  1327.  
  1328. #Region " Mouse States"
  1329.  
  1330.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1331.         MyBase.OnMouseDown(e)
  1332.         State = MouseState.Down : Invalidate()
  1333.     End Sub
  1334.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1335.         MyBase.OnMouseUp(e)
  1336.         State = MouseState.Over : Invalidate()
  1337.     End Sub
  1338.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1339.         MyBase.OnMouseEnter(e)
  1340.         State = MouseState.Over : Invalidate()
  1341.     End Sub
  1342.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1343.         MyBase.OnMouseLeave(e)
  1344.         State = MouseState.None : Invalidate()
  1345.     End Sub
  1346.  
  1347. #End Region
  1348.  
  1349. #End Region
  1350.  
  1351. #Region " Colors"
  1352.  
  1353.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1354.     Private _BorderColor As Color = _FlatColor
  1355.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1356.  
  1357. #End Region
  1358.  
  1359.     Sub New()
  1360.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  1361.                    ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1362.         DoubleBuffered = True
  1363.         Cursor = Cursors.Hand
  1364.         Size = New Size(100, 22)
  1365.         BackColor = Color.FromArgb(60, 70, 73)
  1366.         Font = New Font("Segoe UI", 10)
  1367.     End Sub
  1368.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1369.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1370.         W = Width - 1 : H = Height - 1
  1371.  
  1372.         Dim Base As New Rectangle(0, 2, Height - 5, Height - 5), Dot As New Rectangle(4, 6, H - 12, H - 12)
  1373.  
  1374.         With G
  1375.             .SmoothingMode = 2
  1376.             .TextRenderingHint = 5
  1377.             .Clear(BackColor)
  1378.  
  1379.             Select Case O
  1380.                 Case _Options.Style1 '-- Style 1
  1381.                     '-- Base
  1382.                     .FillEllipse(New SolidBrush(_BaseColor), Base)
  1383.  
  1384.                     Select Case State '-- Mouse States
  1385.                         Case MouseState.Over
  1386.                             '-- Base
  1387.                             .DrawEllipse(New Pen(_BorderColor), Base)
  1388.                         Case MouseState.Down
  1389.                             '-- Base
  1390.                             .DrawEllipse(New Pen(_BorderColor), Base)
  1391.                     End Select
  1392.  
  1393.                     '-- If Checked
  1394.                     If Checked Then
  1395.                         '-- Base
  1396.                         .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1397.                     End If
  1398.  
  1399.                     '-- If Enabled
  1400.                     If Me.Enabled = False Then
  1401.                         '-- Base
  1402.                         .FillEllipse(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1403.                         '-- Text
  1404.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1405.                     End If
  1406.  
  1407.                     '-- Text
  1408.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1409.                 Case _Options.Style2 '-- Style 2
  1410.                     '-- Base
  1411.                     .FillEllipse(New SolidBrush(_BaseColor), Base)
  1412.  
  1413.                     Select Case State
  1414.                         Case MouseState.Over '-- Mouse States
  1415.                             '-- Base
  1416.                             .DrawEllipse(New Pen(_BorderColor), Base)
  1417.                             .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1418.                         Case MouseState.Down
  1419.                             '-- Base
  1420.                             .DrawEllipse(New Pen(_BorderColor), Base)
  1421.                             .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1422.                     End Select
  1423.  
  1424.                     '-- If Checked
  1425.                     If Checked Then
  1426.                         '-- Base
  1427.                         .FillEllipse(New SolidBrush(_BorderColor), Dot)
  1428.                     End If
  1429.  
  1430.                     '-- If Enabled
  1431.                     If Me.Enabled = False Then
  1432.                         '-- Base
  1433.                         .FillEllipse(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1434.                         '-- Text
  1435.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1436.                     End If
  1437.  
  1438.                     '-- Text
  1439.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1440.             End Select
  1441.         End With
  1442.  
  1443.         MyBase.OnPaint(e)
  1444.         G.Dispose()
  1445.         e.Graphics.InterpolationMode = 7
  1446.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1447.         B.Dispose()
  1448.     End Sub
  1449. End Class
  1450.  
  1451. <DefaultEvent("CheckedChanged")> Class FlatCheckBox : Inherits Control
  1452.  
  1453. #Region " Variables"
  1454.  
  1455.     Private W, H As Integer
  1456.     Private State As MouseState = MouseState.None
  1457.     Private O As _Options
  1458.     Private _Checked As Boolean
  1459.  
  1460. #End Region
  1461.  
  1462. #Region " Properties"
  1463.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1464.         MyBase.OnTextChanged(e)
  1465.         Invalidate()
  1466.     End Sub
  1467.  
  1468.     Property Checked() As Boolean
  1469.         Get
  1470.             Return _Checked
  1471.         End Get
  1472.         Set(ByVal value As Boolean)
  1473.             _Checked = value
  1474.             Invalidate()
  1475.         End Set
  1476.     End Property
  1477.  
  1478.     Event CheckedChanged(ByVal sender As Object)
  1479.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  1480.         _Checked = Not _Checked
  1481.         RaiseEvent CheckedChanged(Me)
  1482.         MyBase.OnClick(e)
  1483.     End Sub
  1484.  
  1485.     <Flags>
  1486.     Enum _Options
  1487.         Style1
  1488.         Style2
  1489.     End Enum
  1490.  
  1491.     <Category("Options")>
  1492.     Public Property Options As _Options
  1493.         Get
  1494.             Return O
  1495.         End Get
  1496.         Set(value As _Options)
  1497.             O = value
  1498.         End Set
  1499.     End Property
  1500.  
  1501.     Protected Overrides Sub OnResize(e As EventArgs)
  1502.         MyBase.OnResize(e)
  1503.         Height = 22
  1504.     End Sub
  1505.  
  1506. #Region " Colors"
  1507.  
  1508.     <Category("Colors")>
  1509.     Public Property BaseColor As Color
  1510.         Get
  1511.             Return _BaseColor
  1512.         End Get
  1513.         Set(value As Color)
  1514.             _BaseColor = value
  1515.         End Set
  1516.     End Property
  1517.  
  1518.     <Category("Colors")>
  1519.     Public Property BorderColor As Color
  1520.         Get
  1521.             Return _BorderColor
  1522.         End Get
  1523.         Set(value As Color)
  1524.             _BorderColor = value
  1525.         End Set
  1526.     End Property
  1527.  
  1528. #End Region
  1529.  
  1530. #Region " Mouse States"
  1531.  
  1532.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1533.         MyBase.OnMouseDown(e)
  1534.         State = MouseState.Down : Invalidate()
  1535.     End Sub
  1536.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1537.         MyBase.OnMouseUp(e)
  1538.         State = MouseState.Over : Invalidate()
  1539.     End Sub
  1540.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1541.         MyBase.OnMouseEnter(e)
  1542.         State = MouseState.Over : Invalidate()
  1543.     End Sub
  1544.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1545.         MyBase.OnMouseLeave(e)
  1546.         State = MouseState.None : Invalidate()
  1547.     End Sub
  1548.  
  1549. #End Region
  1550.  
  1551. #End Region
  1552.  
  1553. #Region " Colors"
  1554.  
  1555.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1556.     Private _BorderColor As Color = _FlatColor
  1557.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  1558.  
  1559. #End Region
  1560.  
  1561.     Sub New()
  1562.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  1563.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1564.         DoubleBuffered = True
  1565.         BackColor = Color.FromArgb(60, 70, 73)
  1566.         Cursor = Cursors.Hand
  1567.         Font = New Font("Segoe UI", 10)
  1568.         Size = New Size(112, 22)
  1569.     End Sub
  1570.  
  1571.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1572.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1573.         W = Width - 1 : H = Height - 1
  1574.  
  1575.         Dim Base As New Rectangle(0, 2, Height - 5, Height - 5)
  1576.  
  1577.         With G
  1578.             .SmoothingMode = 2
  1579.             .TextRenderingHint = 5
  1580.             .Clear(BackColor)
  1581.             Select Case O
  1582.                 Case _Options.Style1 '-- Style 1
  1583.                     '-- Base
  1584.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  1585.  
  1586.                     Select Case State
  1587.                         Case MouseState.Over
  1588.                             '-- Base
  1589.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1590.                         Case MouseState.Down
  1591.                             '-- Base
  1592.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1593.                     End Select
  1594.  
  1595.                     '-- If Checked
  1596.                     If Checked Then
  1597.                         .DrawString("?", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1598.                     End If
  1599.  
  1600.                     '-- If Enabled
  1601.                     If Me.Enabled = False Then
  1602.                         .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1603.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1604.                     End If
  1605.  
  1606.                     '-- Text
  1607.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1608.                 Case _Options.Style2 '-- Style 2
  1609.                     '-- Base
  1610.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  1611.  
  1612.                     Select Case State
  1613.                         Case MouseState.Over
  1614.                             '-- Base
  1615.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1616.                             .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1617.                         Case MouseState.Down
  1618.                             '-- Base
  1619.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1620.                             .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1621.                     End Select
  1622.  
  1623.                     '-- If Checked
  1624.                     If Checked Then
  1625.                         .DrawString("?", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1626.                     End If
  1627.  
  1628.                     '-- If Enabled
  1629.                     If Me.Enabled = False Then
  1630.                         .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1631.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1632.                     End If
  1633.  
  1634.                     '-- Text
  1635.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1636.             End Select
  1637.         End With
  1638.  
  1639.         MyBase.OnPaint(e)
  1640.         G.Dispose()
  1641.         e.Graphics.InterpolationMode = 7
  1642.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1643.         B.Dispose()
  1644.     End Sub
  1645. End Class
  1646.  
  1647. <DefaultEvent("TextChanged")> Class FlatTextBox : Inherits Control
  1648.  
  1649. #Region " Variables"
  1650.  
  1651.     Private W, H As Integer
  1652.     Private State As MouseState = MouseState.None
  1653.     Private WithEvents TB As System.Windows.Forms.TextBox
  1654.  
  1655. #End Region
  1656.  
  1657. #Region " Properties"
  1658.  
  1659. #Region " TextBox Properties"
  1660.  
  1661.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  1662.     <Category("Options")>
  1663.     Property TextAlign() As HorizontalAlignment
  1664.         Get
  1665.             Return _TextAlign
  1666.         End Get
  1667.         Set(ByVal value As HorizontalAlignment)
  1668.             _TextAlign = value
  1669.             If TB IsNot Nothing Then
  1670.                 TB.TextAlign = value
  1671.             End If
  1672.         End Set
  1673.     End Property
  1674.     Private _MaxLength As Integer = 32767
  1675.     <Category("Options")>
  1676.     Property MaxLength() As Integer
  1677.         Get
  1678.             Return _MaxLength
  1679.         End Get
  1680.         Set(ByVal value As Integer)
  1681.             _MaxLength = value
  1682.             If TB IsNot Nothing Then
  1683.                 TB.MaxLength = value
  1684.             End If
  1685.         End Set
  1686.     End Property
  1687.     Private _ReadOnly As Boolean
  1688.     <Category("Options")>
  1689.     Property [ReadOnly]() As Boolean
  1690.         Get
  1691.             Return _ReadOnly
  1692.         End Get
  1693.         Set(ByVal value As Boolean)
  1694.             _ReadOnly = value
  1695.             If TB IsNot Nothing Then
  1696.                 TB.ReadOnly = value
  1697.             End If
  1698.         End Set
  1699.     End Property
  1700.     Private _UseSystemPasswordChar As Boolean
  1701.     <Category("Options")>
  1702.     Property UseSystemPasswordChar() As Boolean
  1703.         Get
  1704.             Return _UseSystemPasswordChar
  1705.         End Get
  1706.         Set(ByVal value As Boolean)
  1707.             _UseSystemPasswordChar = value
  1708.             If TB IsNot Nothing Then
  1709.                 TB.UseSystemPasswordChar = value
  1710.             End If
  1711.         End Set
  1712.     End Property
  1713.     Private _Multiline As Boolean
  1714.     <Category("Options")>
  1715.     Property Multiline() As Boolean
  1716.         Get
  1717.             Return _Multiline
  1718.         End Get
  1719.         Set(ByVal value As Boolean)
  1720.             _Multiline = value
  1721.             If TB IsNot Nothing Then
  1722.                 TB.Multiline = value
  1723.  
  1724.                 If value Then
  1725.                     TB.Height = Height - 11
  1726.                 Else
  1727.                     Height = TB.Height + 11
  1728.                 End If
  1729.  
  1730.             End If
  1731.         End Set
  1732.     End Property
  1733.     <Category("Options")>
  1734.     Overrides Property Text As String
  1735.         Get
  1736.             Return MyBase.Text
  1737.         End Get
  1738.         Set(ByVal value As String)
  1739.             MyBase.Text = value
  1740.             If TB IsNot Nothing Then
  1741.                 TB.Text = value
  1742.             End If
  1743.         End Set
  1744.     End Property
  1745.     <Category("Options")>
  1746.     Overrides Property Font As Font
  1747.         Get
  1748.             Return MyBase.Font
  1749.         End Get
  1750.         Set(ByVal value As Font)
  1751.             MyBase.Font = value
  1752.             If TB IsNot Nothing Then
  1753.                 TB.Font = value
  1754.                 TB.Location = New Point(3, 5)
  1755.                 TB.Width = Width - 6
  1756.  
  1757.                 If Not _Multiline Then
  1758.                     Height = TB.Height + 11
  1759.                 End If
  1760.             End If
  1761.         End Set
  1762.     End Property
  1763.  
  1764.     Protected Overrides Sub OnCreateControl()
  1765.         MyBase.OnCreateControl()
  1766.         If Not Controls.Contains(TB) Then
  1767.             Controls.Add(TB)
  1768.         End If
  1769.     End Sub
  1770.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  1771.  
  1772.     End Sub
  1773.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  1774.         If e.Control AndAlso e.KeyCode = Keys.A Then
  1775.             TB.SelectAll()
  1776.             e.SuppressKeyPress = True
  1777.         End If
  1778.         If e.Control AndAlso e.KeyCode = Keys.C Then
  1779.             TB.Copy()
  1780.             e.SuppressKeyPress = True
  1781.         End If
  1782.     End Sub
  1783.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1784.         TB.Location = New Point(5, 5)
  1785.         TB.Width = Width - 10
  1786.  
  1787.         If _Multiline Then
  1788.             TB.Height = Height - 11
  1789.         Else
  1790.             Height = TB.Height + 11
  1791.         End If
  1792.  
  1793.         MyBase.OnResize(e)
  1794.     End Sub
  1795.  
  1796. #End Region
  1797.  
  1798. #Region " Colors"
  1799.  
  1800.     <Category("Colors")>
  1801.     Public Property TextColor As Color
  1802.         Get
  1803.             Return _TextColor
  1804.         End Get
  1805.         Set(value As Color)
  1806.             _TextColor = value
  1807.         End Set
  1808.     End Property
  1809.  
  1810.     Public Overrides Property ForeColor() As Color
  1811.         Get
  1812.             Return _TextColor
  1813.         End Get
  1814.         Set(value As Color)
  1815.             _TextColor = value
  1816.         End Set
  1817.     End Property
  1818.  
  1819. #End Region
  1820.  
  1821. #Region " Mouse States"
  1822.  
  1823.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1824.         MyBase.OnMouseDown(e)
  1825.         State = MouseState.Down : Invalidate()
  1826.     End Sub
  1827.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1828.         MyBase.OnMouseUp(e)
  1829.         State = MouseState.Over : TB.Focus() : Invalidate()
  1830.     End Sub
  1831.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1832.         MyBase.OnMouseEnter(e)
  1833.         State = MouseState.Over : TB.Focus() : Invalidate()
  1834.     End Sub
  1835.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1836.         MyBase.OnMouseLeave(e)
  1837.         State = MouseState.None : Invalidate()
  1838.     End Sub
  1839.  
  1840. #End Region
  1841.  
  1842. #End Region
  1843.  
  1844. #Region " Colors"
  1845.  
  1846.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1847.     Private _TextColor As Color = Color.FromArgb(192, 192, 192)
  1848.     Private _BorderColor As Color = _FlatColor
  1849.  
  1850. #End Region
  1851.  
  1852.     Sub New()
  1853.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  1854.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or
  1855.                  ControlStyles.SupportsTransparentBackColor, True)
  1856.         DoubleBuffered = True
  1857.  
  1858.         BackColor = Color.Transparent
  1859.  
  1860.         TB = New System.Windows.Forms.TextBox
  1861.         TB.Font = New Font("Segoe UI", 10)
  1862.         TB.Text = Text
  1863.         TB.BackColor = _BaseColor
  1864.         TB.ForeColor = _TextColor
  1865.         TB.MaxLength = _MaxLength
  1866.         TB.Multiline = _Multiline
  1867.         TB.ReadOnly = _ReadOnly
  1868.         TB.UseSystemPasswordChar = _UseSystemPasswordChar
  1869.         TB.BorderStyle = BorderStyle.None
  1870.         TB.Location = New Point(5, 5)
  1871.         TB.Width = Width - 10
  1872.  
  1873.         TB.Cursor = Cursors.IBeam
  1874.  
  1875.         If _Multiline Then
  1876.             TB.Height = Height - 11
  1877.         Else
  1878.             Height = TB.Height + 11
  1879.         End If
  1880.  
  1881.         AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  1882.         AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  1883.     End Sub
  1884.  
  1885.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1886.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1887.         W = Width - 1 : H = Height - 1
  1888.  
  1889.         Dim Base As New Rectangle(0, 0, W, H)
  1890.  
  1891.         With G
  1892.             .SmoothingMode = 2
  1893.             .PixelOffsetMode = 2
  1894.             .TextRenderingHint = 5
  1895.             .Clear(BackColor)
  1896.  
  1897.             '-- Colors
  1898.             TB.BackColor = _BaseColor
  1899.             TB.ForeColor = _TextColor
  1900.  
  1901.             '-- Base
  1902.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  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.  
  1912. End Class
  1913.  
  1914. Class FlatTabControl : Inherits TabControl
  1915.  
  1916. #Region " Variables"
  1917.  
  1918.     Private W, H As Integer
  1919.  
  1920. #End Region
  1921.  
  1922. #Region " Properties"
  1923.  
  1924.     Protected Overrides Sub CreateHandle()
  1925.         MyBase.CreateHandle()
  1926.         Alignment = TabAlignment.Top
  1927.     End Sub
  1928.  
  1929. #Region " Colors"
  1930.  
  1931.     <Category("Colors")>
  1932.     Public Property ActiveColor As Color
  1933.         Get
  1934.             Return _ActiveColor
  1935.         End Get
  1936.         Set(value As Color)
  1937.             _ActiveColor = value
  1938.         End Set
  1939.     End Property
  1940.  
  1941.     '<Category("Colors")> _ '-- Arrow
  1942.     'Public Property IndicatorColor As Color
  1943.     '    Get
  1944.     '        Return _IndicatorColor
  1945.     '    End Get
  1946.     '    Set(value As Color)
  1947.     '        _IndicatorColor = value
  1948.     '    End Set
  1949.     'End Property
  1950.  
  1951. #End Region
  1952.  
  1953. #End Region
  1954.  
  1955. #Region " Colors"
  1956.  
  1957.     Private BaseColor As Color = Color.FromArgb(60, 70, 73)
  1958.     Private _ActiveColor As Color = _FlatColor
  1959.     'Private _IndicatorColor As Color = Color.FromArgb(44, 56, 54) '-- Arrow
  1960.  
  1961. #End Region
  1962.  
  1963.     Sub New()
  1964.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
  1965.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1966.         DoubleBuffered = True
  1967.         BackColor = Color.FromArgb(60, 70, 73)
  1968.  
  1969.         Font = New Font("Segoe UI", 10)
  1970.         SizeMode = TabSizeMode.Fixed
  1971.         ItemSize = New Size(120, 40)
  1972.     End Sub
  1973.  
  1974.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1975.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1976.         W = Width - 1 : H = Height - 1
  1977.  
  1978.         Dim GP As New GraphicsPath
  1979.         Dim PGB As PathGradientBrush
  1980.  
  1981.         With G
  1982.             .SmoothingMode = 2
  1983.             .PixelOffsetMode = 2
  1984.             .TextRenderingHint = 5
  1985.             .Clear(_ActiveColor)
  1986.  
  1987.             Try : SelectedTab.BackColor = BaseColor : Catch : End Try
  1988.  
  1989.             For i = 0 To TabCount - 1
  1990.                 Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
  1991.                 Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
  1992.  
  1993.                 If i = SelectedIndex Then
  1994.                     '-- Base
  1995.                     .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  1996.  
  1997.                     GP.Reset()
  1998.                     GP.AddRectangle(BaseSize)
  1999.  
  2000.                     '-- Gradiant
  2001.                     PGB = New PathGradientBrush(GP)
  2002.                     With PGB
  2003.                         .CenterColor = _ActiveColor
  2004.                         .SurroundColors = {Color.FromArgb(45, BaseColor)}
  2005.                         .FocusScales = New PointF(0.5F, 0.5F)
  2006.                     End With
  2007.                     .FillPath(PGB, GP)
  2008.  
  2009.                     '-- ImageList
  2010.                     If ImageList IsNot Nothing Then
  2011.                         Try
  2012.                             If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  2013.                                 '-- Image
  2014.                                 .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  2015.                                 '-- Text
  2016.                                 .DrawString("      " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  2017.                             Else
  2018.                                 '-- Text
  2019.                                 .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  2020.                             End If
  2021.                         Catch ex As Exception
  2022.                             Throw New Exception(ex.Message)
  2023.                         End Try
  2024.                     Else
  2025.                         '-- Text
  2026.                         .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  2027.                     End If
  2028.                 Else
  2029.                     '-- Base
  2030.                     .FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  2031.  
  2032.                     '-- ImageList
  2033.                     If ImageList IsNot Nothing Then
  2034.                         Try
  2035.                             If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  2036.                                 '-- Image
  2037.                                 .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  2038.                                 '-- Text
  2039.                                 .DrawString("      " & TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2040.                             Else
  2041.                                 '-- Text
  2042.                                 .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2043.                             End If
  2044.                         Catch ex As Exception
  2045.                             Throw New Exception(ex.Message)
  2046.                         End Try
  2047.                     Else
  2048.                         '-- Text
  2049.                         .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  2050.                     End If
  2051.                 End If
  2052.             Next
  2053.         End With
  2054.  
  2055.         MyBase.OnPaint(e)
  2056.         G.Dispose()
  2057.         e.Graphics.InterpolationMode = 7
  2058.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2059.         B.Dispose()
  2060.     End Sub
  2061. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement