daily pastebin goal
44%
SHARE
TWEET

Untitled

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