Advertisement
imaking31

Metrodisk 1.0.6

Mar 26th, 2014
4,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 187.70 KB | None | 0 0
  1. Imports System.Drawing.Drawing2D, System.ComponentModel, System.Windows.Forms
  2. Imports System, System.IO, System.Collections.Generic
  3. Imports System.Drawing
  4. Imports System.Runtime.InteropServices
  5. Imports System.Drawing.Imaging
  6. ''' <summary>
  7. ''' MetroDisk
  8. ''' Created by: iSynthesis (HF)
  9. ''' Modified by: King Aldrin
  10. ''' Version: 1.0.6
  11. ''' Date Crafted: 26/01/2014
  12. ''' For any bugs / errors, PM me.
  13. ''' </summary>
  14. ''' <remarks></remarks>
  15. ''' to remove the text, goto line 99
  16.  
  17. Module Helpers
  18.  
  19. #Region " Variables"
  20.     Friend G As Graphics, B As Bitmap
  21.     Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
  22.     Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
  23.     Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
  24. #End Region
  25.  
  26. #Region " Functions"
  27.  
  28.     Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  29.         Dim P As GraphicsPath = New GraphicsPath()
  30.         Dim ArcRectangleWidth As Integer = Curve * 2
  31.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  32.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  33.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  34.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  35.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  36.         Return P
  37.     End Function
  38.  
  39.     Public Function RoundRect(x!, y!, w!, h!, Optional r! = 0.3, Optional TL As Boolean = True, Optional TR As Boolean = True, Optional BR As Boolean = True, Optional BL As Boolean = True) As GraphicsPath
  40.         Dim d! = Math.Min(w, h) * r, xw = x + w, yh = y + h
  41.         RoundRect = New GraphicsPath
  42.  
  43.         With RoundRect
  44.             If TL Then .AddArc(x, y, d, d, 180, 90) Else .AddLine(x, y, x, y)
  45.             If TR Then .AddArc(xw - d, y, d, d, 270, 90) Else .AddLine(xw, y, xw, y)
  46.             If BR Then .AddArc(xw - d, yh - d, d, d, 0, 90) Else .AddLine(xw, yh, xw, yh)
  47.             If BL Then .AddArc(x, yh - d, d, d, 90, 90) Else .AddLine(x, yh, x, yh)
  48.  
  49.             .CloseFigure()
  50.         End With
  51.     End Function
  52.  
  53.     '-- Credit: AeonHack
  54.     Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
  55.         Dim GP As New GraphicsPath()
  56.  
  57.         Dim W As Integer = 12
  58.         Dim H As Integer = 6
  59.  
  60.         If flip Then
  61.             GP.AddLine(x + 1, y, x + W + 1, y)
  62.             GP.AddLine(x + W, y, x + H, y + H - 1)
  63.         Else
  64.             GP.AddLine(x, y + H, x + W, y + H)
  65.             GP.AddLine(x + W, y + H, x + H, y)
  66.         End If
  67.  
  68.         GP.CloseFigure()
  69.         Return GP
  70.     End Function
  71.  
  72. #End Region
  73.  
  74. End Module
  75.  
  76. #Region " Mouse States"
  77.  
  78. Enum MouseState As Byte
  79.     None = 0
  80.     Over = 1
  81.     Down = 2
  82.     Block = 3
  83. End Enum
  84.  
  85. #End Region
  86.  
  87. #Region "Controls"
  88.  
  89. Class FormSkin : Inherits ContainerControl
  90.  
  91. #Region " Variables"
  92.  
  93.     Private W, H As Integer
  94.     Private Cap As Boolean = False
  95.     Private _HeaderMaximize As Boolean = False
  96.     Private MousePoint As New Point(0, 0)
  97.     Private MoveHeight = 50
  98.     Private _Theme As Boolean
  99.     Private _MDcolor As Color
  100.     Private _text As String = ""
  101.     Private _Font = New Font("tahoma", 7)
  102. #End Region
  103.  
  104. #Region " Properties"
  105.  
  106. #Region " Colors"
  107.  
  108.     <Category("Colors")> _
  109.     Public Property HeaderColor() As Color
  110.         Get
  111.             Return _HeaderColor
  112.         End Get
  113.         Set(value As Color)
  114.             _HeaderColor = value
  115.         End Set
  116.     End Property
  117.     <Category("Colors")> _
  118.     Public Property BaseColor() As Color
  119.         Get
  120.             Return _BaseColor
  121.         End Get
  122.         Set(value As Color)
  123.             _BaseColor = value
  124.         End Set
  125.     End Property
  126.     <Category("Colors")> _
  127.     Public Property BorderColor() As Color
  128.         Get
  129.             Return _BorderColor
  130.         End Get
  131.         Set(value As Color)
  132.             _BorderColor = value
  133.         End Set
  134.     End Property
  135.     <Category("Colors")> _
  136.     Public Property FlatColor() As Color
  137.         Get
  138.             Return _FlatColor
  139.         End Get
  140.         Set(value As Color)
  141.             _FlatColor = value
  142.         End Set
  143.     End Property
  144.  
  145. #End Region
  146.  
  147. #Region " Options"
  148.  
  149.     <Category("Options")> _
  150.     Public Property HeaderMaximize As Boolean
  151.         Get
  152.             Return _HeaderMaximize
  153.         End Get
  154.         Set(value As Boolean)
  155.             _HeaderMaximize = value
  156.         End Set
  157.     End Property
  158.  
  159. #End Region
  160.  
  161.     Public Property LightTheme As Boolean
  162.         Get
  163.             Return _Theme
  164.         End Get
  165.         Set(value As Boolean)
  166.             _Theme = value
  167.         End Set
  168.     End Property
  169.  
  170.     Public Property MDColor As Color
  171.         Get
  172.             Return _MDcolor
  173.         End Get
  174.         Set(value As Color)
  175.             _MDcolor = value
  176.         End Set
  177.     End Property
  178.  
  179.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  180.         MyBase.OnMouseDown(e)
  181.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  182.             Cap = True
  183.             MousePoint = e.Location
  184.         End If
  185.     End Sub
  186.  
  187.     Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
  188.         If HeaderMaximize Then
  189.             If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  190.                 If FindForm.WindowState = FormWindowState.Normal Then
  191.                     FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
  192.                 ElseIf FindForm.WindowState = FormWindowState.Maximized Then
  193.                     FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
  194.                 End If
  195.             End If
  196.         End If
  197.     End Sub
  198.  
  199.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  200.         MyBase.OnMouseUp(e) : Cap = False
  201.     End Sub
  202.  
  203.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  204.         MyBase.OnMouseMove(e)
  205.         If Cap Then
  206.             Parent.Location = MousePosition - MousePoint
  207.         End If
  208.     End Sub
  209.  
  210.     Protected Overrides Sub OnCreateControl()
  211.         MyBase.OnCreateControl()
  212.         ParentForm.FormBorderStyle = FormBorderStyle.None
  213.         ParentForm.AllowTransparency = False
  214.         ParentForm.TransparencyKey = Color.Fuchsia
  215.         ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  216.         Dock = DockStyle.Fill
  217.         Invalidate()
  218.     End Sub
  219.  
  220. #End Region
  221.  
  222. #Region " Colors"
  223.  
  224. #Region " Dark Colors"
  225.  
  226.     Private _HeaderColor As Color = Color.FromArgb(60, 200, 80)
  227.     Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  228.     Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
  229.     Private TextColor As Color = Color.FromArgb(234, 234, 234)
  230.  
  231. #End Region
  232.  
  233. #Region " Light Colors"
  234.  
  235.     Private _HeaderLight As Color = Color.FromArgb(171, 171, 172)
  236.     Private _BaseLight As Color = Color.FromArgb(196, 199, 200)
  237.     Public TextLight As Color = Color.FromArgb(45, 47, 49)
  238.  
  239. #End Region
  240.  
  241. #End Region
  242.  
  243.     Sub New()
  244.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  245.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  246.         _MDcolor = Color.FromArgb(45, 150, 45)
  247.         DoubleBuffered = True
  248.         BackColor = Color.White
  249.         Font = New Font("Segoe UI", 12)
  250.  
  251.     End Sub
  252.  
  253.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  254.         If _Theme = True Then
  255.             'light
  256.             _HeaderColor = Color.FromArgb(255, 255, 255)
  257.             _BaseColor = Color.FromArgb(255, 255, 255)
  258.             _BorderColor = Color.FromArgb(0, 0, 0)
  259.             _BorderColor = Color.FromArgb(0, 0, 0)
  260.         Else
  261.             'dark
  262.             _HeaderColor = Color.FromArgb(0, 0, 0)
  263.             _BaseColor = Color.FromArgb(0, 0, 0)
  264.             _BorderColor = Color.FromArgb(200, 200, 200)
  265.             _BorderColor = Color.FromArgb(200, 200, 200)
  266.         End If
  267.  
  268.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  269.         W = Width : H = Height
  270.         Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 40)
  271.  
  272.         With G
  273.             .SmoothingMode = 2
  274.             .PixelOffsetMode = 2
  275.             .TextRenderingHint = 5
  276.             .Clear(BackColor)
  277.  
  278.             '-- Base
  279.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  280.  
  281.             '-- Header
  282.             .FillRectangle(New SolidBrush(_HeaderColor), Header)
  283.  
  284.             '-- Logo
  285.             .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(23, 10, W, H), NearSF)
  286.             .DrawString(_text, _Font, New SolidBrush(Color.DimGray), New Rectangle(W - 120, H - 15, W, H), NearSF)
  287.             .FillRectangle(New SolidBrush(_MDcolor), New Rectangle(1, 40, 12, 50))
  288.  
  289.             '-- Border
  290.             .DrawRectangle(New Pen(_BorderColor), Base)
  291.         End With
  292.  
  293.         MyBase.OnPaint(e)
  294.         G.Dispose()
  295.         e.Graphics.InterpolationMode = 7
  296.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  297.         B.Dispose()
  298.     End Sub
  299. End Class
  300.  
  301. Class MDGroupBox : Inherits ContainerControl
  302.  
  303. #Region " Variables"
  304.  
  305.     Private W, H As Integer
  306.     Private _ShowText As Boolean = True
  307.     Private _Arrows As Boolean = True
  308.     Private _LightTheme As Boolean
  309.     Private _Curve As Integer = 1
  310. #End Region
  311.  
  312. #Region " Properties"
  313.  
  314.     <Category("Colors")> _
  315.     Public Property BaseColor As Color
  316.         Get
  317.             Return _BaseColor
  318.         End Get
  319.         Set(value As Color)
  320.             _BaseColor = value
  321.         End Set
  322.     End Property
  323.  
  324.     Public Property ShowText As Boolean
  325.         Get
  326.             Return _ShowText
  327.         End Get
  328.         Set(value As Boolean)
  329.             _ShowText = value
  330.         End Set
  331.     End Property
  332.  
  333.     Public Property Arrows As Boolean
  334.         Get
  335.             Return _Arrows
  336.         End Get
  337.         Set(value As Boolean)
  338.             _Arrows = value
  339.         End Set
  340.     End Property
  341.  
  342.     Public Property LightTheme As Boolean
  343.         Get
  344.             Return _LightTheme
  345.         End Get
  346.         Set(value As Boolean)
  347.             _LightTheme = value
  348.         End Set
  349.     End Property
  350.  
  351.     Public Property Curve As Integer
  352.         Get
  353.             Return _Curve
  354.         End Get
  355.         Set(value As Integer)
  356.             _Curve = value
  357.         End Set
  358.     End Property
  359.  
  360. #End Region
  361.  
  362. #Region " Colors"
  363.  
  364.     Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  365.  
  366. #End Region
  367.  
  368.     Sub New()
  369.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  370.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  371.                  ControlStyles.SupportsTransparentBackColor, True)
  372.         DoubleBuffered = True
  373.         BackColor = Color.Transparent
  374.         Size = New Size(240, 180)
  375.         Font = New Font("Segoe ui", 10)
  376.     End Sub
  377.  
  378.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  379.         If _LightTheme Then
  380.             'light
  381.             _BaseColor = Color.FromArgb(240, 240, 240)
  382.         Else
  383.             'dark
  384.             _BaseColor = Color.FromArgb(20, 20, 20)
  385.         End If
  386.  
  387.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  388.         W = Width - 1 : H = Height - 1
  389.  
  390.         Dim GP, GP2, GP3 As New GraphicsPath
  391.         Dim Base As New Rectangle(8, 8, W - 16, H - 16)
  392.  
  393.         With G
  394.             .SmoothingMode = 2
  395.             .PixelOffsetMode = 2
  396.             .TextRenderingHint = 5
  397.             .Clear(BackColor)
  398.  
  399.             '-- Base
  400.  
  401.             GP = Helpers.RoundRec(Base, _Curve)
  402.             .FillPath(New SolidBrush(_BaseColor), GP)
  403.             'curve here
  404.  
  405.  
  406.             If _Arrows Then
  407.                 '-- Arrows
  408.                 GP2 = Helpers.DrawArrow(28, 2, False)
  409.                 .FillPath(New SolidBrush(_BaseColor), GP2)
  410.                 GP3 = Helpers.DrawArrow(28, 8, True)
  411.                 If _LightTheme Then
  412.                     .FillPath(New SolidBrush(Color.FromArgb(240, 240, 240)), GP3)
  413.                 Else
  414.                     .FillPath(New SolidBrush(Color.FromArgb(20, 20, 20)), GP3)
  415.                 End If
  416.  
  417.             End If
  418.  
  419.  
  420.             '-- if ShowText
  421.             If ShowText Then
  422.                 .DrawString(Text, Font, New SolidBrush(_FlatColor), New Rectangle(16, 16, W, H), NearSF)
  423.             End If
  424.         End With
  425.  
  426.         MyBase.OnPaint(e)
  427.         G.Dispose()
  428.         e.Graphics.InterpolationMode = 7
  429.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  430.         B.Dispose()
  431.     End Sub
  432. End Class
  433.  
  434. Class MDButton : Inherits Control
  435.  
  436. #Region " Variables"
  437.  
  438.     Private W, H As Integer
  439.     Private _Rounded As Boolean = False
  440.     Private State As MouseState = MouseState.None
  441.  
  442. #End Region
  443.  
  444. #Region " Properties"
  445.  
  446. #Region " Colors"
  447.  
  448.     <Category("Colors")> _
  449.     Public Property BaseColor As Color
  450.         Get
  451.             Return _BaseColor
  452.         End Get
  453.         Set(value As Color)
  454.             _BaseColor = value
  455.         End Set
  456.     End Property
  457.  
  458.     <Category("Colors")> _
  459.     Public Property TextColor As Color
  460.         Get
  461.             Return _TextColor
  462.         End Get
  463.         Set(value As Color)
  464.             _TextColor = value
  465.         End Set
  466.     End Property
  467.  
  468.     <Category("Options")> _
  469.     Public Property Rounded As Boolean
  470.         Get
  471.             Return _Rounded
  472.         End Get
  473.         Set(value As Boolean)
  474.             _Rounded = value
  475.         End Set
  476.     End Property
  477.  
  478. #End Region
  479.  
  480. #Region " Mouse States"
  481.  
  482.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  483.         MyBase.OnMouseDown(e)
  484.         State = MouseState.Down : Invalidate()
  485.     End Sub
  486.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  487.         MyBase.OnMouseUp(e)
  488.         State = MouseState.Over : Invalidate()
  489.     End Sub
  490.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  491.         MyBase.OnMouseEnter(e)
  492.         State = MouseState.Over : Invalidate()
  493.     End Sub
  494.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  495.         MyBase.OnMouseLeave(e)
  496.         State = MouseState.None : Invalidate()
  497.     End Sub
  498.  
  499. #End Region
  500.  
  501. #End Region
  502.  
  503. #Region " Colors"
  504.  
  505.     Private _BaseColor As Color = _FlatColor
  506.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  507.  
  508. #End Region
  509.  
  510.     Sub New()
  511.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  512.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  513.                  ControlStyles.SupportsTransparentBackColor, True)
  514.         DoubleBuffered = True
  515.         Size = New Size(106, 32)
  516.         BackColor = Color.Transparent
  517.         Font = New Font("Segoe UI", 12)
  518.         Cursor = Cursors.Hand
  519.     End Sub
  520.  
  521.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  522.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  523.         W = Width - 1 : H = Height - 1
  524.  
  525.         Dim GP As New GraphicsPath
  526.         Dim Base As New Rectangle(0, 0, W, H)
  527.  
  528.         With G
  529.             .SmoothingMode = 2
  530.             .PixelOffsetMode = 2
  531.             .TextRenderingHint = 5
  532.             .Clear(BackColor)
  533.  
  534.             Select Case State
  535.                 Case MouseState.None
  536.                     If Rounded Then
  537.                         '-- Base
  538.                         GP = Helpers.RoundRec(Base, 6)
  539.                         .FillPath(New SolidBrush(_BaseColor), GP)
  540.  
  541.                         '-- Text
  542.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  543.                     Else
  544.                         '-- Base
  545.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  546.  
  547.                         '-- Text
  548.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  549.                     End If
  550.                 Case MouseState.Over
  551.                     If Rounded Then
  552.                         '-- Base
  553.                         GP = Helpers.RoundRec(Base, 6)
  554.                         .FillPath(New SolidBrush(_BaseColor), GP)
  555.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  556.  
  557.                         '-- Text
  558.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  559.                     Else
  560.                         '-- Base
  561.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  562.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  563.  
  564.                         '-- Text
  565.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  566.                     End If
  567.                 Case MouseState.Down
  568.                     If Rounded Then
  569.                         '-- Base
  570.                         GP = Helpers.RoundRec(Base, 6)
  571.                         .FillPath(New SolidBrush(_BaseColor), GP)
  572.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  573.  
  574.                         '-- Text
  575.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  576.                     Else
  577.                         '-- Base
  578.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  579.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  580.  
  581.                         '-- Text
  582.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  583.                     End If
  584.             End Select
  585.         End With
  586.  
  587.         MyBase.OnPaint(e)
  588.         G.Dispose()
  589.         e.Graphics.InterpolationMode = 7
  590.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  591.         B.Dispose()
  592.     End Sub
  593. End Class
  594.  
  595. <DefaultEvent("CheckedChanged")> Class MDToggle : Inherits Control
  596.  
  597. #Region " Variables"
  598.  
  599.     Private W, H As Integer
  600.     Private O As _Options
  601.     Private _Checked As Boolean = False
  602.     Private State As MouseState = MouseState.None
  603.  
  604. #End Region
  605.  
  606. #Region " Properties"
  607.     Public Event CheckedChanged(ByVal sender As Object)
  608.  
  609.     <Flags()> _
  610.     Enum _Options
  611.         Style1
  612.         Style2
  613.         Style3
  614.         Style4 '-- TODO: New Style
  615.         Style5 '-- TODO: New Style
  616.     End Enum
  617.  
  618. #Region " Options"
  619.  
  620.     <Category("Options")> _
  621.     Public Property Options As _Options
  622.         Get
  623.             Return O
  624.         End Get
  625.         Set(value As _Options)
  626.             O = value
  627.         End Set
  628.     End Property
  629.  
  630.     <Category("Options")> _
  631.     Public Property Checked As Boolean
  632.         Get
  633.             Return _Checked
  634.         End Get
  635.         Set(value As Boolean)
  636.             _Checked = value
  637.         End Set
  638.     End Property
  639.  
  640. #End Region
  641.  
  642.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  643.         MyBase.OnTextChanged(e) : Invalidate()
  644.     End Sub
  645.  
  646.     Protected Overrides Sub OnResize(e As EventArgs)
  647.         MyBase.OnResize(e)
  648.         Width = 76
  649.         Height = 33
  650.     End Sub
  651.  
  652. #Region " Mouse States"
  653.  
  654.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  655.         MyBase.OnMouseEnter(e)
  656.         State = MouseState.Over : Invalidate()
  657.     End Sub
  658.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  659.         MyBase.OnMouseDown(e)
  660.         State = MouseState.Down : Invalidate()
  661.     End Sub
  662.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  663.         MyBase.OnMouseLeave(e)
  664.         State = MouseState.None : Invalidate()
  665.     End Sub
  666.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  667.         MyBase.OnMouseUp(e)
  668.         State = MouseState.Over : Invalidate()
  669.     End Sub
  670.     Protected Overrides Sub OnClick(e As EventArgs)
  671.         MyBase.OnClick(e)
  672.         _Checked = Not _Checked
  673.         RaiseEvent CheckedChanged(Me)
  674.     End Sub
  675.  
  676. #End Region
  677.  
  678. #End Region
  679.  
  680. #Region " Colors"
  681.  
  682.     Private BaseColor As Color = _FlatColor
  683.     Private BaseColorRed As Color = Color.FromArgb(220, 85, 96)
  684.     Private BGColor As Color = Color.FromArgb(84, 85, 86)
  685.     Private ToggleColor As Color = Color.FromArgb(45, 47, 49)
  686.     Private TextColor As Color = Color.FromArgb(243, 243, 243)
  687.  
  688. #End Region
  689.  
  690.     Sub New()
  691.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  692.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  693.                  ControlStyles.SupportsTransparentBackColor, True)
  694.         DoubleBuffered = True
  695.         BackColor = Color.Transparent
  696.         Size = New Size(44, Height + 1)
  697.         Cursor = Cursors.Hand
  698.         Font = New Font("Segoe UI", 10)
  699.         Size = New Size(76, 33)
  700.     End Sub
  701.  
  702.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  703.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  704.         W = Width - 1 : H = Height - 1
  705.  
  706.         Dim GP, GP2 As New GraphicsPath
  707.         Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H)
  708.  
  709.         With G
  710.             .SmoothingMode = 2
  711.             .PixelOffsetMode = 2
  712.             .TextRenderingHint = 5
  713.             .Clear(BackColor)
  714.  
  715.             Select Case O
  716.                 Case _Options.Style1   '-- Style 1
  717.                     '-- Base
  718.                     GP = Helpers.RoundRec(Base, 6)
  719.                     GP2 = Helpers.RoundRec(Toggle, 6)
  720.                     .FillPath(New SolidBrush(BGColor), GP)
  721.                     .FillPath(New SolidBrush(ToggleColor), GP2)
  722.  
  723.                     '-- Text
  724.                     .DrawString("OFF", Font, New SolidBrush(BGColor), New Rectangle(19, 1, W, H), CenterSF)
  725.  
  726.                     If Checked Then
  727.                         '-- Base
  728.                         GP = Helpers.RoundRec(Base, 6)
  729.                         GP2 = Helpers.RoundRec(New Rectangle(CInt(W \ 2), 0, 38, H), 6)
  730.                         .FillPath(New SolidBrush(ToggleColor), GP)
  731.                         .FillPath(New SolidBrush(BaseColor), GP2)
  732.  
  733.                         '-- Text
  734.                         .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(8, 7, W, H), NearSF)
  735.                     End If
  736.                 Case _Options.Style2   '-- Style 2
  737.                     '-- Base
  738.                     GP = Helpers.RoundRec(Base, 6)
  739.                     Toggle = New Rectangle(4, 4, 36, H - 8)
  740.                     GP2 = Helpers.RoundRec(Toggle, 4)
  741.                     .FillPath(New SolidBrush(BaseColorRed), GP)
  742.                     .FillPath(New SolidBrush(ToggleColor), GP2)
  743.  
  744.                     '-- Lines
  745.                     .DrawLine(New Pen(BGColor), 18, 20, 18, 12)
  746.                     .DrawLine(New Pen(BGColor), 22, 20, 22, 12)
  747.                     .DrawLine(New Pen(BGColor), 26, 20, 26, 12)
  748.  
  749.                     '-- Text
  750.                     .DrawString("r", New Font("Marlett", 8), New SolidBrush(TextColor), New Rectangle(19, 2, Width, Height), CenterSF)
  751.  
  752.                     If Checked Then
  753.                         GP = Helpers.RoundRec(Base, 6)
  754.                         Toggle = New Rectangle(CInt(W \ 2) - 2, 4, 36, H - 8)
  755.                         GP2 = Helpers.RoundRec(Toggle, 4)
  756.                         .FillPath(New SolidBrush(BaseColor), GP)
  757.                         .FillPath(New SolidBrush(ToggleColor), GP2)
  758.  
  759.                         '-- Lines
  760.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 12, 20, CInt(W \ 2) + 12, 12)
  761.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 16, 20, CInt(W \ 2) + 16, 12)
  762.                         .DrawLine(New Pen(BGColor), CInt(W \ 2) + 20, 20, CInt(W \ 2) + 20, 12)
  763.  
  764.                         '-- Text
  765.                         .DrawString("ü", New Font("Wingdings", 14), New SolidBrush(TextColor), New Rectangle(8, 7, Width, Height), NearSF)
  766.                     End If
  767.                 Case _Options.Style3   '-- Style 3
  768.                     '-- Base
  769.                     GP = Helpers.RoundRec(Base, 16)
  770.                     Toggle = New Rectangle(W - 28, 4, 22, H - 8)
  771.                     GP2.AddEllipse(Toggle)
  772.                     .FillPath(New SolidBrush(ToggleColor), GP)
  773.                     .FillPath(New SolidBrush(BaseColorRed), GP2)
  774.  
  775.                     '-- Text
  776.                     .DrawString("OFF", Font, New SolidBrush(BaseColorRed), New Rectangle(-12, 2, W, H), CenterSF)
  777.  
  778.                     If Checked Then
  779.                         '-- Base
  780.                         GP = Helpers.RoundRec(Base, 16)
  781.                         Toggle = New Rectangle(6, 4, 22, H - 8)
  782.                         GP2.Reset()
  783.                         GP2.AddEllipse(Toggle)
  784.                         .FillPath(New SolidBrush(ToggleColor), GP)
  785.                         .FillPath(New SolidBrush(BaseColor), GP2)
  786.  
  787.                         '-- Text
  788.                         .DrawString("ON", Font, New SolidBrush(BaseColor), New Rectangle(12, 2, W, H), CenterSF)
  789.                     End If
  790.                 Case _Options.Style4
  791.                     '-- TODO: New Styles
  792.                     If Checked Then
  793.                         '--
  794.                     End If
  795.                 Case _Options.Style5
  796.                     '-- TODO: New Styles
  797.                     If Checked Then
  798.                         '--
  799.                     End If
  800.             End Select
  801.  
  802.         End With
  803.  
  804.         MyBase.OnPaint(e)
  805.         G.Dispose()
  806.         e.Graphics.InterpolationMode = 7
  807.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  808.         B.Dispose()
  809.     End Sub
  810. End Class
  811.  
  812. <DefaultEvent("CheckedChanged")> Class MDRadioButton : Inherits Control
  813.  
  814. #Region " Variables"
  815.  
  816.     Private State As MouseState = MouseState.None
  817.     Private W, H As Integer
  818.     Private O As _Options
  819.     Private _Checked As Boolean
  820.  
  821. #End Region
  822.  
  823. #Region " Properties"
  824.     Property Checked() As Boolean
  825.         Get
  826.             Return _Checked
  827.         End Get
  828.         Set(value As Boolean)
  829.             _Checked = value
  830.             InvalidateControls()
  831.             RaiseEvent CheckedChanged(Me)
  832.             Invalidate()
  833.         End Set
  834.     End Property
  835.     Event CheckedChanged(ByVal sender As Object)
  836.     Protected Overrides Sub OnClick(e As EventArgs)
  837.         If Not _Checked Then Checked = True
  838.         MyBase.OnClick(e)
  839.     End Sub
  840.     Private Sub InvalidateControls()
  841.         If Not IsHandleCreated OrElse Not _Checked Then Return
  842.         For Each C As Control In Parent.Controls
  843.             If C IsNot Me AndAlso TypeOf C Is RadioButton Then
  844.                 DirectCast(C, RadioButton).Checked = False
  845.                 Invalidate()
  846.             End If
  847.         Next
  848.     End Sub
  849.     Protected Overrides Sub OnCreateControl()
  850.         MyBase.OnCreateControl()
  851.         InvalidateControls()
  852.     End Sub
  853.  
  854.     <Flags> _
  855.     Enum _Options
  856.         Style1
  857.         Style2
  858.     End Enum
  859.  
  860.     <Category("Options")> _
  861.     Public Property Options As _Options
  862.         Get
  863.             Return O
  864.         End Get
  865.         Set(value As _Options)
  866.             O = value
  867.         End Set
  868.     End Property
  869.  
  870.     Protected Overrides Sub OnResize(e As EventArgs)
  871.         MyBase.OnResize(e)
  872.         Height = 22
  873.     End Sub
  874.  
  875. #Region " Mouse States"
  876.  
  877.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  878.         MyBase.OnMouseDown(e)
  879.         State = MouseState.Down : Invalidate()
  880.     End Sub
  881.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  882.         MyBase.OnMouseUp(e)
  883.         State = MouseState.Over : Invalidate()
  884.     End Sub
  885.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  886.         MyBase.OnMouseEnter(e)
  887.         State = MouseState.Over : Invalidate()
  888.     End Sub
  889.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  890.         MyBase.OnMouseLeave(e)
  891.         State = MouseState.None : Invalidate()
  892.     End Sub
  893.  
  894. #End Region
  895. #End Region
  896.  
  897. #Region " Colors"
  898.  
  899.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  900.     Private _BorderColor As Color = Color.FromArgb(100, 100, 100)
  901.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  902.  
  903. #End Region
  904.  
  905.     Sub New()
  906.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  907.                    ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  908.         DoubleBuffered = True
  909.         Cursor = Cursors.Hand
  910.         Size = New Size(100, 22)
  911.         BackColor = Color.FromArgb(60, 70, 73)
  912.         Font = New Font("Segoe UI", 10)
  913.     End Sub
  914.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  915.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  916.         W = Width - 1 : H = Height - 1
  917.  
  918.         Dim Base As New Rectangle(0, 2, Height - 5, Height - 5), Dot As New Rectangle(4, 6, H - 12, H - 12)
  919.  
  920.         With G
  921.             .SmoothingMode = 2
  922.             .TextRenderingHint = 5
  923.             .Clear(BackColor)
  924.  
  925.             Select Case O
  926.                 Case _Options.Style1
  927.                     '-- Base
  928.                     .FillEllipse(New SolidBrush(_BaseColor), Base)
  929.  
  930.                     Select Case State
  931.                         Case MouseState.Over
  932.                             .DrawEllipse(New Pen(_BorderColor), Base)
  933.                         Case MouseState.Down
  934.                             .DrawEllipse(New Pen(_BorderColor), Base)
  935.                     End Select
  936.  
  937.                     '-- If Checked
  938.                     If Checked Then
  939.                         .FillEllipse(New SolidBrush(_BorderColor), Dot)
  940.                     End If
  941.                 Case _Options.Style2
  942.                     '-- Base
  943.                     .FillEllipse(New SolidBrush(_BaseColor), Base)
  944.  
  945.                     Select Case State
  946.                         Case MouseState.Over
  947.                             '-- Base
  948.                             .DrawEllipse(New Pen(_BorderColor), Base)
  949.                             .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  950.                         Case MouseState.Down
  951.                             '-- Base
  952.                             .DrawEllipse(New Pen(_BorderColor), Base)
  953.                             .FillEllipse(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  954.                     End Select
  955.  
  956.                     '-- If Checked
  957.                     If Checked Then
  958.                         '-- Base
  959.                         .FillEllipse(New SolidBrush(_BorderColor), Dot)
  960.                     End If
  961.             End Select
  962.  
  963.             .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  964.         End With
  965.  
  966.         MyBase.OnPaint(e)
  967.         G.Dispose()
  968.         e.Graphics.InterpolationMode = 7
  969.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  970.         B.Dispose()
  971.     End Sub
  972. End Class
  973.  
  974. <DefaultEvent("CheckedChanged")> Class MDCheckBox : Inherits Control
  975.  
  976. #Region " Variables"
  977.  
  978.     Private W, H As Integer
  979.     Private State As MouseState = MouseState.None
  980.     Private O As _Options
  981.     Private _Checked As Boolean
  982.  
  983. #End Region
  984.  
  985. #Region " Properties"
  986.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  987.         MyBase.OnTextChanged(e)
  988.         Invalidate()
  989.     End Sub
  990.  
  991.     Property Checked() As Boolean
  992.         Get
  993.             Return _Checked
  994.         End Get
  995.         Set(ByVal value As Boolean)
  996.             _Checked = value
  997.             Invalidate()
  998.         End Set
  999.     End Property
  1000.  
  1001.     Event CheckedChanged(ByVal sender As Object)
  1002.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  1003.         _Checked = Not _Checked
  1004.         RaiseEvent CheckedChanged(Me)
  1005.         MyBase.OnClick(e)
  1006.     End Sub
  1007.  
  1008.     <Flags> _
  1009.     Enum _Options
  1010.         Style1
  1011.         Style2
  1012.     End Enum
  1013.  
  1014.     <Category("Options")> _
  1015.     Public Property Options As _Options
  1016.         Get
  1017.             Return O
  1018.         End Get
  1019.         Set(value As _Options)
  1020.             O = value
  1021.         End Set
  1022.     End Property
  1023.  
  1024.     Protected Overrides Sub OnResize(e As EventArgs)
  1025.         MyBase.OnResize(e)
  1026.         Height = 22
  1027.     End Sub
  1028.  
  1029. #Region " Colors"
  1030.  
  1031.     <Category("Colors")> _
  1032.     Public Property BaseColor As Color
  1033.         Get
  1034.             Return _BaseColor
  1035.         End Get
  1036.         Set(value As Color)
  1037.             _BaseColor = value
  1038.         End Set
  1039.     End Property
  1040.  
  1041.     <Category("Colors")> _
  1042.     Public Property BorderColor As Color
  1043.         Get
  1044.             Return _BorderColor
  1045.         End Get
  1046.         Set(value As Color)
  1047.             _BorderColor = value
  1048.         End Set
  1049.     End Property
  1050.  
  1051. #End Region
  1052.  
  1053. #Region " Mouse States"
  1054.  
  1055.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1056.         MyBase.OnMouseDown(e)
  1057.         State = MouseState.Down : Invalidate()
  1058.     End Sub
  1059.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1060.         MyBase.OnMouseUp(e)
  1061.         State = MouseState.Over : Invalidate()
  1062.     End Sub
  1063.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1064.         MyBase.OnMouseEnter(e)
  1065.         State = MouseState.Over : Invalidate()
  1066.     End Sub
  1067.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1068.         MyBase.OnMouseLeave(e)
  1069.         State = MouseState.None : Invalidate()
  1070.     End Sub
  1071.  
  1072. #End Region
  1073.  
  1074. #End Region
  1075.  
  1076. #Region " Colors"
  1077.  
  1078.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1079.     Private _BorderColor As Color = _FlatColor
  1080.     Private _TextColor As Color
  1081.  
  1082. #End Region
  1083.  
  1084.     Sub New()
  1085.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1086.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1087.         DoubleBuffered = True
  1088.         BackColor = Color.FromArgb(60, 70, 73)
  1089.         Cursor = Cursors.Hand
  1090.         Font = New Font("Segoe UI", 10)
  1091.         Size = New Size(112, 22)
  1092.     End Sub
  1093.  
  1094.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1095.         _TextColor = ForeColor
  1096.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1097.         W = Width - 1 : H = Height - 1
  1098.  
  1099.         Dim Base As New Rectangle(0, 2, Height - 5, Height - 5)
  1100.  
  1101.         With G
  1102.             .SmoothingMode = 2
  1103.             .TextRenderingHint = 5
  1104.             .Clear(BackColor)
  1105.             Select Case O
  1106.                 Case _Options.Style1 '-- Style 1
  1107.                     '-- Base
  1108.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  1109.  
  1110.                     Select Case State
  1111.                         Case MouseState.Over
  1112.                             '-- Base
  1113.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1114.                         Case MouseState.Down
  1115.                             '-- Base
  1116.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1117.                     End Select
  1118.  
  1119.                     '-- If Checked
  1120.                     If Checked Then
  1121.                         .DrawString("P", New Font("Wingdings 2", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1122.                     End If
  1123.  
  1124.                     '-- If Enabled
  1125.                     If Me.Enabled = False Then
  1126.                         .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1127.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(140, 142, 143)), New Rectangle(20, 2, W, H), NearSF)
  1128.                     End If
  1129.  
  1130.                     '-- Text
  1131.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1132.                 Case _Options.Style2 '-- Style 2
  1133.                     '-- Base
  1134.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  1135.  
  1136.                     Select Case State
  1137.                         Case MouseState.Over
  1138.                             '-- Base
  1139.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1140.                             .FillRectangle(New SolidBrush(Color.FromArgb(118, 213, 170)), Base)
  1141.                         Case MouseState.Down
  1142.                             '-- Base
  1143.                             .DrawRectangle(New Pen(_BorderColor), Base)
  1144.                             .FillRectangle(New SolidBrush(Color.FromArgb(45, 47, 49)), Base)
  1145.                     End Select
  1146.  
  1147.                     '-- If Checked
  1148.                     If Checked Then
  1149.                         .DrawString("ü", New Font("Wingdings", 18), New SolidBrush(_BorderColor), New Rectangle(5, 7, H - 9, H - 9), CenterSF)
  1150.                     End If
  1151.  
  1152.                     '-- If Enabled
  1153.                     If Me.Enabled = False Then
  1154.                         .FillRectangle(New SolidBrush(Color.FromArgb(54, 58, 61)), Base)
  1155.                         .DrawString(Text, Font, New SolidBrush(Color.FromArgb(48, 119, 91)), New Rectangle(20, 2, W, H), NearSF)
  1156.                     End If
  1157.  
  1158.                     '-- Text
  1159.                     .DrawString(Text, Font, New SolidBrush(_TextColor), New Rectangle(20, 2, W, H), NearSF)
  1160.             End Select
  1161.         End With
  1162.  
  1163.         MyBase.OnPaint(e)
  1164.         G.Dispose()
  1165.         e.Graphics.InterpolationMode = 7
  1166.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1167.         B.Dispose()
  1168.     End Sub
  1169. End Class
  1170.  
  1171. <DefaultEvent("TextChanged")> Class MDTextBox : Inherits Control
  1172.  
  1173. #Region " Variables"
  1174.  
  1175.     Private W, H As Integer
  1176.     Private State As MouseState = MouseState.None
  1177.     Private WithEvents TB As Windows.Forms.TextBox
  1178.     Private _Theme As Boolean
  1179.  
  1180. #End Region
  1181.  
  1182. #Region " Properties"
  1183.  
  1184. #Region " TextBox Properties"
  1185.  
  1186.     Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
  1187.     <Category("Options")> _
  1188.     Property TextAlign() As HorizontalAlignment
  1189.         Get
  1190.             Return _TextAlign
  1191.         End Get
  1192.         Set(ByVal value As HorizontalAlignment)
  1193.             _TextAlign = value
  1194.             If TB IsNot Nothing Then
  1195.                 TB.TextAlign = value
  1196.             End If
  1197.         End Set
  1198.     End Property
  1199.     Private _MaxLength As Integer = 32767
  1200.     <Category("Options")> _
  1201.     Property MaxLength() As Integer
  1202.         Get
  1203.             Return _MaxLength
  1204.         End Get
  1205.         Set(ByVal value As Integer)
  1206.             _MaxLength = value
  1207.             If TB IsNot Nothing Then
  1208.                 TB.MaxLength = value
  1209.             End If
  1210.         End Set
  1211.     End Property
  1212.     Private _ReadOnly As Boolean
  1213.     <Category("Options")> _
  1214.     Property [ReadOnly]() As Boolean
  1215.         Get
  1216.             Return _ReadOnly
  1217.         End Get
  1218.         Set(ByVal value As Boolean)
  1219.             _ReadOnly = value
  1220.             If TB IsNot Nothing Then
  1221.                 TB.ReadOnly = value
  1222.             End If
  1223.         End Set
  1224.     End Property
  1225.     Private _UseSystemPasswordChar As Boolean
  1226.     <Category("Options")> _
  1227.     Property UseSystemPasswordChar() As Boolean
  1228.         Get
  1229.             Return _UseSystemPasswordChar
  1230.         End Get
  1231.         Set(ByVal value As Boolean)
  1232.             _UseSystemPasswordChar = value
  1233.             If TB IsNot Nothing Then
  1234.                 TB.UseSystemPasswordChar = value
  1235.             End If
  1236.         End Set
  1237.     End Property
  1238.     Private _Multiline As Boolean
  1239.     <Category("Options")> _
  1240.     Property Multiline() As Boolean
  1241.         Get
  1242.             Return _Multiline
  1243.         End Get
  1244.         Set(ByVal value As Boolean)
  1245.             _Multiline = value
  1246.             If TB IsNot Nothing Then
  1247.                 TB.Multiline = value
  1248.  
  1249.                 If value Then
  1250.                     TB.Height = Height - 11
  1251.                 Else
  1252.                     Height = TB.Height + 11
  1253.                 End If
  1254.  
  1255.             End If
  1256.         End Set
  1257.     End Property
  1258.     <Category("Options")> _
  1259.     Overrides Property Text As String
  1260.         Get
  1261.             Return MyBase.Text
  1262.         End Get
  1263.         Set(ByVal value As String)
  1264.             MyBase.Text = value
  1265.             If TB IsNot Nothing Then
  1266.                 TB.Text = value
  1267.             End If
  1268.         End Set
  1269.     End Property
  1270.     <Category("Options")> _
  1271.     Overrides Property Font As Font
  1272.         Get
  1273.             Return MyBase.Font
  1274.         End Get
  1275.         Set(ByVal value As Font)
  1276.             MyBase.Font = value
  1277.             If TB IsNot Nothing Then
  1278.                 TB.Font = value
  1279.                 TB.Location = New Point(3, 5)
  1280.                 TB.Width = Width - 6
  1281.  
  1282.                 If Not _Multiline Then
  1283.                     Height = TB.Height + 11
  1284.                 End If
  1285.             End If
  1286.         End Set
  1287.     End Property
  1288.  
  1289.     Protected Overrides Sub OnCreateControl()
  1290.         MyBase.OnCreateControl()
  1291.         If Not Controls.Contains(TB) Then
  1292.             Controls.Add(TB)
  1293.         End If
  1294.     End Sub
  1295.     Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
  1296.         Text = TB.Text
  1297.     End Sub
  1298.     Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
  1299.         If e.Control AndAlso e.KeyCode = Keys.A Then
  1300.             TB.SelectAll()
  1301.             e.SuppressKeyPress = True
  1302.         End If
  1303.         If e.Control AndAlso e.KeyCode = Keys.C Then
  1304.             TB.Copy()
  1305.             e.SuppressKeyPress = True
  1306.         End If
  1307.     End Sub
  1308.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1309.         TB.Location = New Point(5, 5)
  1310.         TB.Width = Width - 10
  1311.  
  1312.         If _Multiline Then
  1313.             TB.Height = Height - 11
  1314.         Else
  1315.             Height = TB.Height + 11
  1316.         End If
  1317.  
  1318.         MyBase.OnResize(e)
  1319.     End Sub
  1320.  
  1321.     Public Property LightTheme As Boolean
  1322.         Get
  1323.             Return _Theme
  1324.         End Get
  1325.         Set(value As Boolean)
  1326.             _Theme = value
  1327.         End Set
  1328.     End Property
  1329.  
  1330. #End Region
  1331.  
  1332. #Region " Colors"
  1333.  
  1334.     <Category("Colors")> _
  1335.     Public Property TextColor As Color
  1336.         Get
  1337.             Return _TextColor
  1338.         End Get
  1339.         Set(value As Color)
  1340.             _TextColor = value
  1341.         End Set
  1342.     End Property
  1343.  
  1344.     Public Overrides Property ForeColor() As Color
  1345.         Get
  1346.             Return _TextColor
  1347.         End Get
  1348.         Set(value As Color)
  1349.             _TextColor = value
  1350.         End Set
  1351.     End Property
  1352.  
  1353. #End Region
  1354.  
  1355. #Region " Mouse States"
  1356.  
  1357.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1358.         MyBase.OnMouseDown(e)
  1359.         State = MouseState.Down : Invalidate()
  1360.     End Sub
  1361.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1362.         MyBase.OnMouseUp(e)
  1363.         State = MouseState.Over : Invalidate()
  1364.     End Sub
  1365.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1366.         MyBase.OnMouseEnter(e)
  1367.         State = MouseState.Over : Invalidate()
  1368.     End Sub
  1369.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1370.         MyBase.OnMouseLeave(e)
  1371.         State = MouseState.None : Invalidate()
  1372.     End Sub
  1373.  
  1374. #End Region
  1375.  
  1376. #End Region
  1377.  
  1378. #Region " Colors"
  1379.  
  1380.     'true = light | false = dark
  1381.  
  1382.     Private _BaseColor As Color = Color.FromArgb(200, 200, 200)
  1383.     Private _TextColor As Color = Color.FromArgb(192, 192, 192)
  1384.     Private _BorderColor As Color = _FlatColor
  1385.  
  1386. #End Region
  1387.  
  1388.     Sub New()
  1389.         If _Theme = True Then
  1390.             _BaseColor = Color.FromArgb(200, 200, 200)
  1391.             _TextColor = Color.FromArgb(0, 0, 0)
  1392.             _BorderColor = Color.Black
  1393.  
  1394.             SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1395.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  1396.                  ControlStyles.SupportsTransparentBackColor, True)
  1397.             DoubleBuffered = True
  1398.  
  1399.             BackColor = Color.Transparent
  1400.  
  1401.             TB = New Windows.Forms.TextBox
  1402.             TB.Font = New Font("Segoe UI", 10, FontStyle.Bold)
  1403.             TB.Text = Text
  1404.             TB.BackColor = _BaseColor
  1405.             TB.ForeColor = _TextColor
  1406.             TB.MaxLength = _MaxLength
  1407.             TB.Multiline = _Multiline
  1408.             TB.ReadOnly = _ReadOnly
  1409.             TB.UseSystemPasswordChar = _UseSystemPasswordChar
  1410.             TB.BorderStyle = BorderStyle.None
  1411.             TB.Location = New Point(5, 5)
  1412.             TB.Width = Width - 10
  1413.  
  1414.             TB.Cursor = Cursors.IBeam
  1415.  
  1416.             If _Multiline Then
  1417.                 TB.Height = Height - 11
  1418.             Else
  1419.                 Height = TB.Height + 11
  1420.             End If
  1421.  
  1422.             AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  1423.             AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  1424.         Else
  1425.             _BaseColor = Color.FromArgb(0, 0, 0)
  1426.             _TextColor = Color.FromArgb(200, 200, 200)
  1427.  
  1428.             SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1429.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  1430.                  ControlStyles.SupportsTransparentBackColor, True)
  1431.             DoubleBuffered = True
  1432.  
  1433.             BackColor = Color.Transparent
  1434.  
  1435.             TB = New Windows.Forms.TextBox
  1436.             TB.Font = New Font("Segoe UI", 10, FontStyle.Bold)
  1437.             TB.Text = Text
  1438.             TB.BackColor = _BaseColor
  1439.             TB.ForeColor = _TextColor
  1440.             TB.MaxLength = _MaxLength
  1441.             TB.Multiline = _Multiline
  1442.             TB.ReadOnly = _ReadOnly
  1443.             TB.UseSystemPasswordChar = _UseSystemPasswordChar
  1444.             TB.BorderStyle = BorderStyle.None
  1445.             TB.Location = New Point(5, 5)
  1446.             TB.Width = Width - 10
  1447.  
  1448.             TB.Cursor = Cursors.IBeam
  1449.  
  1450.             If _Multiline Then
  1451.                 TB.Height = Height - 11
  1452.             Else
  1453.                 Height = TB.Height + 11
  1454.             End If
  1455.  
  1456.             AddHandler TB.TextChanged, AddressOf OnBaseTextChanged
  1457.             AddHandler TB.KeyDown, AddressOf OnBaseKeyDown
  1458.         End If
  1459.     End Sub
  1460.  
  1461.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1462.  
  1463.         If _Theme = True Then
  1464.             _BaseColor = Color.FromArgb(255, 255, 255)
  1465.             _TextColor = Color.FromArgb(175, 175, 175)
  1466.             _FlatColor = Color.FromArgb(0, 0, 0)
  1467.             B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1468.             W = Width - 1 : H = Height - 1
  1469.  
  1470.             Dim Base As New Rectangle(0, 0, W, H)
  1471.  
  1472.             With G
  1473.                 .SmoothingMode = 2
  1474.                 .PixelOffsetMode = 2
  1475.                 .TextRenderingHint = 5
  1476.                 .Clear(BackColor)
  1477.  
  1478.                 '-- Colors
  1479.                 TB.BackColor = _BaseColor
  1480.                 TB.ForeColor = _TextColor
  1481.  
  1482.                 '-- Base
  1483.                 .FillRectangle(New SolidBrush(_BaseColor), Base)
  1484.  
  1485.                 .DrawRectangle(New Pen(Color.FromArgb(200, 200, 200)), New Rectangle(0, 0, W, H))
  1486.             End With
  1487.  
  1488.             MyBase.OnPaint(e)
  1489.             G.Dispose()
  1490.             e.Graphics.InterpolationMode = 7
  1491.             e.Graphics.DrawImageUnscaled(B, 0, 0)
  1492.             B.Dispose()
  1493.         Else
  1494.             _BaseColor = Color.FromArgb(50, 50, 50)
  1495.             _TextColor = Color.FromArgb(200, 200, 200)
  1496.             B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1497.             W = Width - 1 : H = Height - 1
  1498.  
  1499.             Dim Base As New Rectangle(0, 0, W, H)
  1500.  
  1501.             With G
  1502.                 .SmoothingMode = 2
  1503.                 .PixelOffsetMode = 2
  1504.                 .TextRenderingHint = 5
  1505.                 .Clear(BackColor)
  1506.  
  1507.                 '-- Colors
  1508.                 TB.BackColor = _BaseColor
  1509.                 TB.ForeColor = _TextColor
  1510.  
  1511.                 '-- Base
  1512.                 .FillRectangle(New SolidBrush(_BaseColor), Base)
  1513.  
  1514.                 .DrawRectangle(New Pen(Color.FromArgb(25, 25, 25)), New Rectangle(0, 0, W, H))
  1515.             End With
  1516.  
  1517.             MyBase.OnPaint(e)
  1518.             G.Dispose()
  1519.             e.Graphics.InterpolationMode = 7
  1520.             e.Graphics.DrawImageUnscaled(B, 0, 0)
  1521.             B.Dispose()
  1522.         End If
  1523.     End Sub
  1524.  
  1525. End Class
  1526.  
  1527. Class MDTabControl : Inherits TabControl
  1528.  
  1529. #Region " Variables"
  1530.  
  1531.     Private W, H As Integer
  1532.     Private _Theme As Boolean
  1533.  
  1534. #End Region
  1535.  
  1536. #Region " Properties"
  1537.  
  1538.     Public Property LightTheme As Boolean
  1539.         Get
  1540.             Return _Theme
  1541.         End Get
  1542.         Set(value As Boolean)
  1543.             _Theme = value
  1544.         End Set
  1545.     End Property
  1546.  
  1547.     Protected Overrides Sub CreateHandle()
  1548.         MyBase.CreateHandle()
  1549.         Alignment = TabAlignment.Top
  1550.     End Sub
  1551.  
  1552. #Region " Colors"
  1553.  
  1554.     <Category("Colors")> _
  1555.     Public Property BaseColor As Color
  1556.         Get
  1557.             Return _BaseColor
  1558.         End Get
  1559.         Set(value As Color)
  1560.             _BaseColor = value
  1561.         End Set
  1562.     End Property
  1563.  
  1564.     <Category("Colors")> _
  1565.     Public Property ActiveColor As Color
  1566.         Get
  1567.             Return _ActiveColor
  1568.         End Get
  1569.         Set(value As Color)
  1570.             _ActiveColor = value
  1571.         End Set
  1572.     End Property
  1573.  
  1574. #End Region
  1575.  
  1576. #End Region
  1577.  
  1578. #Region " Colors"
  1579.  
  1580.     Private BGColor As Color = Color.FromArgb(0, 0, 0)
  1581.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  1582.     Private _ActiveColor As Color = _FlatColor
  1583.     Private _unactive As Brush
  1584.     Private _active As Brush
  1585.     Private unactive As Color
  1586.     Private active As Color
  1587.  
  1588. #End Region
  1589.  
  1590.     Sub New()
  1591.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1592.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1593.         DoubleBuffered = True
  1594.         BackColor = Color.FromArgb(60, 70, 73)
  1595.  
  1596.         Font = New Font("Segoe UI", 15)
  1597.         SizeMode = TabSizeMode.Fixed
  1598.         ItemSize = New Size(140, 40)
  1599.  
  1600.     End Sub
  1601.  
  1602.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1603.  
  1604.         If _Theme = True Then
  1605.             'light
  1606.             BGColor = Color.FromArgb(255, 255, 255)
  1607.             _BaseColor = Color.FromArgb(255, 255, 255)
  1608.             ActiveColor = Color.FromArgb(225, 225, 225)
  1609.             _active = Brushes.Silver
  1610.             _unactive = Brushes.DimGray
  1611.             active = Color.Silver
  1612.             unactive = Color.DimGray
  1613.  
  1614.         Else
  1615.             'dark
  1616.             BGColor = Color.FromArgb(0, 0, 0)
  1617.             _BaseColor = Color.FromArgb(0, 0, 0)
  1618.             ActiveColor = Color.FromArgb(25, 25, 25)
  1619.             _active = Brushes.DimGray
  1620.             _active = Brushes.Silver
  1621.             active = Color.DimGray
  1622.             unactive = Color.Silver
  1623.         End If
  1624.  
  1625.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1626.         W = Width - 1 : H = Height - 1
  1627.  
  1628.         With G
  1629.             .SmoothingMode = 2
  1630.             .PixelOffsetMode = 2
  1631.             .TextRenderingHint = 5
  1632.             .Clear(_BaseColor)
  1633.  
  1634.             Try : SelectedTab.BackColor = BGColor : Catch : End Try
  1635.  
  1636.             For i = 0 To TabCount - 1
  1637.                 Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
  1638.                 Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
  1639.  
  1640.                 If i = SelectedIndex Then
  1641.                     '-- Base
  1642.                     '.FillRectangle(New SolidBrush(_BaseColor), BaseSize)
  1643.  
  1644.                     '-- Gradiant
  1645.                     '.fill
  1646.                     '.FillRectangle(New SolidBrush(_ActiveColor), BaseSize)
  1647.  
  1648.                     '-- ImageList
  1649.                     If ImageList IsNot Nothing Then
  1650.                         Try
  1651.                             If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  1652.                                 '-- Image
  1653.                                 .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  1654.                                 '-- Text
  1655.                                 .DrawString("      " & "MD" & TabPages(i).Text, Font, _unactive, BaseSize, CenterSF)
  1656.                             Else
  1657.                                 '-- Text
  1658.                                 .DrawString(TabPages(i).Text, Font, _active, BaseSize, CenterSF)
  1659.                             End If
  1660.                         Catch ex As Exception
  1661.                             Throw New Exception(ex.Message)
  1662.                         End Try
  1663.                     Else
  1664.                         '-- Text
  1665.                         '.DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
  1666.                         .DrawString(TabPages(i).Text, Font, New SolidBrush(unactive), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1667.                     End If
  1668.                 Else
  1669.                     '-- Base
  1670.                     .FillRectangle(New SolidBrush(_BaseColor), BaseSize)
  1671.  
  1672.                     '-- ImageList
  1673.                     If ImageList IsNot Nothing Then
  1674.                         Try
  1675.                             If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
  1676.                                 '-- Image
  1677.                                 .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
  1678.                                 '-- Text
  1679.                                 .DrawString("      " & TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1680.                             Else
  1681.                                 '-- Text
  1682.                                 .DrawString(TabPages(i).Text, Font, New SolidBrush(active), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1683.                             End If
  1684.                         Catch ex As Exception
  1685.                             Throw New Exception(ex.Message)
  1686.                         End Try
  1687.                     Else
  1688.                         '-- Text
  1689.                         .DrawString(TabPages(i).Text, Font, New SolidBrush(active), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1690.  
  1691.  
  1692.                     End If
  1693.                 End If
  1694.             Next
  1695.         End With
  1696.  
  1697.         MyBase.OnPaint(e)
  1698.         G.Dispose()
  1699.         e.Graphics.InterpolationMode = 7
  1700.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1701.         B.Dispose()
  1702.     End Sub
  1703. End Class
  1704.  
  1705. Class MDAlertBox : Inherits Control
  1706.  
  1707.     ''' <summary>
  1708.     ''' How to use: FlatAlertBox.ShowControl(Kind, String, Interval)
  1709.     ''' </summary>
  1710.     ''' <remarks></remarks>
  1711.  
  1712. #Region " Variables"
  1713.  
  1714.     Private W, H As Integer
  1715.     Private K As _Kind
  1716.     Private _Text As String
  1717.     Private State As MouseState = MouseState.None
  1718.     Private X As Integer
  1719.     Private WithEvents T As Timer
  1720.  
  1721. #End Region
  1722.  
  1723. #Region " Properties"
  1724.  
  1725.     <Flags()> _
  1726.     Enum _Kind
  1727.         [Success]
  1728.         [Error]
  1729.         [Info]
  1730.     End Enum
  1731.  
  1732. #Region " Options"
  1733.  
  1734.     <Category("Options")> _
  1735.     Public Property kind As _Kind
  1736.         Get
  1737.             Return K
  1738.         End Get
  1739.         Set(value As _Kind)
  1740.             K = value
  1741.         End Set
  1742.     End Property
  1743.  
  1744.     <Category("Options")> _
  1745.     Overrides Property Text As String
  1746.         Get
  1747.             Return MyBase.Text
  1748.         End Get
  1749.         Set(ByVal value As String)
  1750.             MyBase.Text = value
  1751.             If _Text IsNot Nothing Then
  1752.                 _Text = value
  1753.             End If
  1754.         End Set
  1755.     End Property
  1756.  
  1757.     <Category("Options")> _
  1758.     Shadows Property Visible As Boolean
  1759.         Get
  1760.             Return MyBase.Visible = False
  1761.         End Get
  1762.         Set(value As Boolean)
  1763.             MyBase.Visible = value
  1764.         End Set
  1765.     End Property
  1766.  
  1767. #End Region
  1768.  
  1769.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  1770.         MyBase.OnTextChanged(e) : Invalidate()
  1771.     End Sub
  1772.  
  1773.     Protected Overrides Sub OnResize(e As EventArgs)
  1774.         MyBase.OnResize(e)
  1775.         Height = 42
  1776.     End Sub
  1777.  
  1778.     Public Sub ShowControl(Kind As _Kind, Str As String, Interval As Integer)
  1779.         K = Kind
  1780.         Text = Str
  1781.         Me.Visible = True
  1782.         T = New Timer
  1783.         T.Interval = Interval
  1784.         T.Enabled = True
  1785.     End Sub
  1786.  
  1787.     Private Sub T_Tick(sender As Object, e As EventArgs) Handles T.Tick
  1788.         Me.Visible = False
  1789.         T.Enabled = False
  1790.         T.Dispose()
  1791.     End Sub
  1792.  
  1793. #Region " Mouse States"
  1794.  
  1795.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  1796.         MyBase.OnMouseDown(e)
  1797.         State = MouseState.Down : Invalidate()
  1798.     End Sub
  1799.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  1800.         MyBase.OnMouseUp(e)
  1801.         State = MouseState.Over : Invalidate()
  1802.     End Sub
  1803.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  1804.         MyBase.OnMouseEnter(e)
  1805.         State = MouseState.Over : Invalidate()
  1806.     End Sub
  1807.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  1808.         MyBase.OnMouseLeave(e)
  1809.         State = MouseState.None : Invalidate()
  1810.     End Sub
  1811.  
  1812.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  1813.         MyBase.OnMouseMove(e)
  1814.         X = e.X : Invalidate()
  1815.     End Sub
  1816.  
  1817.     Protected Overrides Sub OnClick(e As EventArgs)
  1818.         MyBase.OnClick(e)
  1819.         Me.Visible = False
  1820.     End Sub
  1821.  
  1822. #End Region
  1823.  
  1824. #End Region
  1825.  
  1826. #Region " Colors"
  1827.  
  1828.     Private SuccessColor As Color = Color.FromArgb(60, 85, 79)
  1829.     Private SuccessText As Color = Color.FromArgb(35, 169, 110)
  1830.     Private ErrorColor As Color = Color.FromArgb(87, 71, 71)
  1831.     Private ErrorText As Color = Color.FromArgb(254, 142, 122)
  1832.     Private InfoColor As Color = Color.FromArgb(70, 91, 94)
  1833.     Private InfoText As Color = Color.FromArgb(97, 185, 186)
  1834.  
  1835. #End Region
  1836.  
  1837.     Sub New()
  1838.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  1839.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  1840.         DoubleBuffered = True
  1841.         BackColor = Color.FromArgb(60, 70, 73)
  1842.         Size = New Size(576, 42)
  1843.         Location = New Point(10, 61)
  1844.         Font = New Font("Segoe UI", 10)
  1845.         Cursor = Cursors.Hand
  1846.     End Sub
  1847.  
  1848.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1849.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  1850.         W = Width - 1 : H = Height - 1
  1851.  
  1852.         Dim Base As New Rectangle(0, 0, W, H)
  1853.  
  1854.         With G
  1855.             .SmoothingMode = 2
  1856.             .TextRenderingHint = 5
  1857.             .Clear(BackColor)
  1858.  
  1859.             Select Case K
  1860.                 Case _Kind.Success
  1861.                     '-- Base
  1862.                     .FillRectangle(New SolidBrush(SuccessColor), Base)
  1863.  
  1864.                     '-- Ellipse
  1865.                     .FillEllipse(New SolidBrush(SuccessText), New Rectangle(8, 9, 24, 24))
  1866.                     .FillEllipse(New SolidBrush(SuccessColor), New Rectangle(10, 11, 20, 20))
  1867.  
  1868.                     '-- Checked Sign
  1869.                     .DrawString("ü", New Font("Wingdings", 22), New SolidBrush(SuccessText), New Rectangle(7, 7, W, H), NearSF)
  1870.                     .DrawString(Text, Font, New SolidBrush(SuccessText), New Rectangle(48, 12, W, H), NearSF)
  1871.  
  1872.                     '-- X button
  1873.                     .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 30, H - 29, 17, 17))
  1874.                     .DrawString("r", New Font("Marlett", 8), New SolidBrush(SuccessColor), New Rectangle(W - 28, 16, W, H), NearSF)
  1875.  
  1876.                     Select Case State ' -- Mouse Over
  1877.                         Case MouseState.Over
  1878.                             .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 28, 16, W, H), NearSF)
  1879.                     End Select
  1880.  
  1881.                 Case _Kind.Error
  1882.                     '-- Base
  1883.                     .FillRectangle(New SolidBrush(ErrorColor), Base)
  1884.  
  1885.                     '-- Ellipse
  1886.                     .FillEllipse(New SolidBrush(ErrorText), New Rectangle(8, 9, 24, 24))
  1887.                     .FillEllipse(New SolidBrush(ErrorColor), New Rectangle(10, 11, 20, 20))
  1888.  
  1889.                     '-- X Sign
  1890.                     .DrawString("r", New Font("Marlett", 16), New SolidBrush(ErrorText), New Rectangle(6, 11, W, H), NearSF)
  1891.                     .DrawString(Text, Font, New SolidBrush(ErrorText), New Rectangle(48, 12, W, H), NearSF)
  1892.  
  1893.                     '-- X button
  1894.                     .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
  1895.                     .DrawString("r", New Font("Marlett", 8), New SolidBrush(ErrorColor), New Rectangle(W - 30, 17, W, H), NearSF)
  1896.  
  1897.                     Select Case State
  1898.                         Case MouseState.Over ' -- Mouse Over
  1899.                             .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 15, W, H), NearSF)
  1900.                     End Select
  1901.  
  1902.                 Case _Kind.Info
  1903.                     '-- Base
  1904.                     .FillRectangle(New SolidBrush(InfoColor), Base)
  1905.  
  1906.                     '-- Ellipse
  1907.                     .FillEllipse(New SolidBrush(InfoText), New Rectangle(8, 9, 24, 24))
  1908.                     .FillEllipse(New SolidBrush(InfoColor), New Rectangle(10, 11, 20, 20))
  1909.  
  1910.                     '-- Info Sign
  1911.                     .DrawString("¡", New Font("Segoe UI", 20, FontStyle.Bold), New SolidBrush(InfoText), New Rectangle(12, -4, W, H), NearSF)
  1912.                     .DrawString(Text, Font, New SolidBrush(InfoText), New Rectangle(48, 12, W, H), NearSF)
  1913.  
  1914.                     '-- X button
  1915.                     .FillEllipse(New SolidBrush(Color.FromArgb(35, Color.Black)), New Rectangle(W - 32, H - 29, 17, 17))
  1916.                     .DrawString("r", New Font("Marlett", 8), New SolidBrush(InfoColor), New Rectangle(W - 30, 17, W, H), NearSF)
  1917.  
  1918.                     Select Case State
  1919.                         Case MouseState.Over ' -- Mouse Over
  1920.                             .DrawString("r", New Font("Marlett", 8), New SolidBrush(Color.FromArgb(25, Color.White)), New Rectangle(W - 30, 17, W, H), NearSF)
  1921.                     End Select
  1922.             End Select
  1923.  
  1924.         End With
  1925.  
  1926.         MyBase.OnPaint(e)
  1927.         G.Dispose()
  1928.         e.Graphics.InterpolationMode = 7
  1929.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  1930.         B.Dispose()
  1931.     End Sub
  1932.  
  1933. End Class
  1934.  
  1935. Class MDProgressBar : Inherits Control
  1936.  
  1937. #Region " Variables"
  1938.  
  1939.     Private W, H As Integer
  1940.     Private _Value As Integer = 0
  1941.     Private _Maximum As Integer = 100
  1942.  
  1943. #End Region
  1944.  
  1945. #Region " Properties"
  1946.  
  1947. #Region " Control"
  1948.  
  1949.     <Category("Control")>
  1950.     Public Property Maximum() As Integer
  1951.         Get
  1952.             Return _Maximum
  1953.         End Get
  1954.         Set(V As Integer)
  1955.             Select Case V
  1956.                 Case Is < _Value
  1957.                     _Value = V
  1958.             End Select
  1959.             _Maximum = V
  1960.             Invalidate()
  1961.         End Set
  1962.     End Property
  1963.  
  1964.     <Category("Control")>
  1965.     Public Property Value() As Integer
  1966.         Get
  1967.             Select Case _Value
  1968.                 Case 0
  1969.                     Return 0
  1970.                     Invalidate()
  1971.                 Case Else
  1972.                     Return _Value
  1973.                     Invalidate()
  1974.             End Select
  1975.         End Get
  1976.         Set(V As Integer)
  1977.             Select Case V
  1978.                 Case Is > _Maximum
  1979.                     V = _Maximum
  1980.                     Invalidate()
  1981.             End Select
  1982.             _Value = V
  1983.             Invalidate()
  1984.         End Set
  1985.     End Property
  1986.  
  1987. #End Region
  1988.  
  1989. #Region " Colors"
  1990.  
  1991.     <Category("Colors")>
  1992.     Public Property ProgressColor As Color
  1993.         Get
  1994.             Return _ProgressColor
  1995.         End Get
  1996.         Set(value As Color)
  1997.             _ProgressColor = value
  1998.         End Set
  1999.     End Property
  2000.  
  2001.     <Category("Colors")>
  2002.     Public Property DarkerProgress As Color
  2003.         Get
  2004.             Return _DarkerProgress
  2005.         End Get
  2006.         Set(value As Color)
  2007.             _DarkerProgress = value
  2008.         End Set
  2009.     End Property
  2010.  
  2011. #End Region
  2012.  
  2013.     Protected Overrides Sub OnResize(e As EventArgs)
  2014.         MyBase.OnResize(e)
  2015.         Height = 42
  2016.     End Sub
  2017.  
  2018.     Protected Overrides Sub CreateHandle()
  2019.         MyBase.CreateHandle()
  2020.         Height = 42
  2021.     End Sub
  2022.  
  2023.     Public Sub Increment(ByVal Amount As Integer)
  2024.         Value += Amount
  2025.     End Sub
  2026.  
  2027. #End Region
  2028.  
  2029. #Region " Colors"
  2030.  
  2031.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  2032.     Private _ProgressColor As Color = _FlatColor
  2033.     Private _DarkerProgress As Color = Color.FromArgb(23, 148, 92)
  2034.  
  2035. #End Region
  2036.  
  2037.     Sub New()
  2038.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2039.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2040.         DoubleBuffered = True
  2041.         BackColor = Color.FromArgb(60, 70, 73)
  2042.         Height = 42
  2043.     End Sub
  2044.  
  2045.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2046.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2047.         W = Width - 1 : H = Height - 1
  2048.  
  2049.         Dim Base As New Rectangle(0, 24, W, H)
  2050.         Dim GP, GP2, GP3 As New GraphicsPath
  2051.  
  2052.         With G
  2053.             .SmoothingMode = 2
  2054.             .PixelOffsetMode = 2
  2055.             .TextRenderingHint = 5
  2056.             .Clear(BackColor)
  2057.  
  2058.             '-- Progress Value
  2059.             Dim iValue As Integer = CInt(_Value / _Maximum * Width)
  2060.  
  2061.             Select Case Value
  2062.                 Case 0
  2063.                     '-- Base
  2064.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  2065.                     '--Progress
  2066.                     .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
  2067.                 Case 100
  2068.                     '-- Base
  2069.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  2070.                     '--Progress
  2071.                     .FillRectangle(New SolidBrush(_ProgressColor), New Rectangle(0, 24, iValue - 1, H - 1))
  2072.                 Case Else
  2073.                     '-- Base
  2074.                     .FillRectangle(New SolidBrush(_BaseColor), Base)
  2075.  
  2076.                     '--Progress
  2077.                     GP.AddRectangle(New Rectangle(0, 24, iValue - 1, H - 1))
  2078.                     .FillPath(New SolidBrush(_ProgressColor), GP)
  2079.  
  2080.                     '-- Hatch Brush
  2081.                     'Dim HB As New HatchBrush(HatchStyle.Plaid, _DarkerProgress, _ProgressColor)
  2082.                     '.FillRectangle(HB, New Rectangle(0, 24, iValue - 1, H - 1))
  2083.  
  2084.                     '-- Balloon
  2085.                     'Dim Balloon As New Rectangle(iValue - 18, 25, 34, 16)
  2086.                     'GP2 = Helpers.RoundRec(Balloon, 4)
  2087.                     '.FillPath(New SolidBrush(_BaseColor), GP2)
  2088.  
  2089.                     '-- Arrow
  2090.                     ''GP3 = Helpers.DrawArrow(iValue - 9, 16, True)
  2091.                     ''.FillPath(New SolidBrush(_BaseColor), GP3)
  2092.  
  2093.                     '-- Value > You can add "%" > value & "%"
  2094.                     '.DrawString(Value, New Font("Segoe UI", 10), New SolidBrush(_ProgressColor), New Rectangle(iValue - 11, 25, W, H), NearSF)
  2095.             End Select
  2096.         End With
  2097.  
  2098.         MyBase.OnPaint(e)
  2099.         G.Dispose()
  2100.         e.Graphics.InterpolationMode = 7
  2101.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2102.         B.Dispose()
  2103.     End Sub
  2104.  
  2105. End Class
  2106.  
  2107. Class MDComboBox : Inherits Windows.Forms.ComboBox
  2108.  
  2109. #Region " Variables"
  2110.  
  2111.     Private W, H As Integer
  2112.     Private _StartIndex As Integer = 0
  2113.     Private x, y As Integer
  2114.     Private _LightTheme As Boolean
  2115.  
  2116. #End Region
  2117.  
  2118. #Region " Properties"
  2119.  
  2120. #Region " Mouse States"
  2121.  
  2122.     Private State As MouseState = MouseState.None
  2123.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2124.         MyBase.OnMouseDown(e)
  2125.         State = MouseState.Down : Invalidate()
  2126.     End Sub
  2127.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2128.         MyBase.OnMouseUp(e)
  2129.         State = MouseState.Over : Invalidate()
  2130.     End Sub
  2131.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  2132.         MyBase.OnMouseEnter(e)
  2133.         State = MouseState.Over : Invalidate()
  2134.     End Sub
  2135.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  2136.         MyBase.OnMouseLeave(e)
  2137.         State = MouseState.None : Invalidate()
  2138.     End Sub
  2139.  
  2140.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  2141.         MyBase.OnMouseMove(e)
  2142.         x = e.Location.X
  2143.         y = e.Location.Y
  2144.         Invalidate()
  2145.         If e.X < Width - 41 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
  2146.     End Sub
  2147.  
  2148.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  2149.         MyBase.OnDrawItem(e) : Invalidate()
  2150.         If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2151.             Invalidate()
  2152.         End If
  2153.     End Sub
  2154.  
  2155.     Protected Overrides Sub OnClick(e As EventArgs)
  2156.         MyBase.OnClick(e) : Invalidate()
  2157.     End Sub
  2158.  
  2159. #End Region
  2160.  
  2161. #Region " Colors"
  2162.  
  2163.     <Category("Colors")> _
  2164.     Public Property HoverColor As Color
  2165.         Get
  2166.             Return _HoverColor
  2167.         End Get
  2168.         Set(value As Color)
  2169.             _HoverColor = value
  2170.         End Set
  2171.     End Property
  2172.  
  2173. #End Region
  2174.  
  2175.     Public Property LightTheme As Boolean
  2176.         Get
  2177.             Return _LightTheme
  2178.         End Get
  2179.         Set(value As Boolean)
  2180.             _LightTheme = value
  2181.         End Set
  2182.     End Property
  2183.  
  2184.     Private Property StartIndex As Integer
  2185.         Get
  2186.             Return _StartIndex
  2187.         End Get
  2188.         Set(ByVal value As Integer)
  2189.             _StartIndex = value
  2190.             Try
  2191.                 MyBase.SelectedIndex = value
  2192.             Catch
  2193.             End Try
  2194.             Invalidate()
  2195.         End Set
  2196.     End Property
  2197.  
  2198.     Sub DrawItem_(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  2199.         If e.Index < 0 Then Exit Sub
  2200.         e.DrawBackground()
  2201.         e.DrawFocusRectangle()
  2202.  
  2203.         e.Graphics.SmoothingMode = 2
  2204.         e.Graphics.PixelOffsetMode = 2
  2205.         e.Graphics.TextRenderingHint = 5
  2206.         e.Graphics.InterpolationMode = 7
  2207.  
  2208.         If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  2209.             '-- Selected item
  2210.             e.Graphics.FillRectangle(New SolidBrush(_HoverColor), e.Bounds)
  2211.         Else
  2212.             '-- Not Selected
  2213.             e.Graphics.FillRectangle(New SolidBrush(_BaseColor), e.Bounds)
  2214.         End If
  2215.  
  2216.         '-- Text
  2217.         e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)), New Font("Segoe UI", 8), _
  2218.                      Brushes.White, New Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height))
  2219.  
  2220.  
  2221.         e.Graphics.Dispose()
  2222.     End Sub
  2223.  
  2224.     Protected Overrides Sub OnResize(e As EventArgs)
  2225.         MyBase.OnResize(e)
  2226.         Height = 18
  2227.     End Sub
  2228.  
  2229. #End Region
  2230.  
  2231. #Region " Colors"
  2232.  
  2233.     Private _BaseColor As Color = Color.FromArgb(25, 27, 29)
  2234.     Private _BGColor As Color = Color.FromArgb(45, 47, 49)
  2235.     Private _HoverColor As Color = Color.FromArgb(35, 168, 109)
  2236.  
  2237. #End Region
  2238.  
  2239.     Sub New()
  2240.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2241.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2242.         DoubleBuffered = True
  2243.  
  2244.         DrawMode = DrawMode.OwnerDrawFixed
  2245.         BackColor = Color.FromArgb(45, 45, 48)
  2246.         ForeColor = Color.White
  2247.         DropDownStyle = ComboBoxStyle.DropDownList
  2248.         Cursor = Cursors.Hand
  2249.         StartIndex = 0
  2250.         ItemHeight = 18
  2251.         Font = New Font("Segoe UI", 8, FontStyle.Regular)
  2252.     End Sub
  2253.  
  2254.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  2255.         If _LightTheme Then
  2256.             _BaseColor = Color.FromArgb(200, 200, 200)
  2257.             _BGColor = Color.FromArgb(250, 250, 250)
  2258.             _HoverColor = Color.FromArgb(150, 150, 150)
  2259.             ForeColor = Color.FromArgb(20, 20, 20)
  2260.         Else
  2261.             _BaseColor = Color.FromArgb(25, 25, 25)
  2262.             _BGColor = Color.FromArgb(40, 40, 40)
  2263.             _HoverColor = Color.FromArgb(80, 80, 80)
  2264.             ForeColor = Color.FromArgb(100, 100, 100)
  2265.         End If
  2266.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2267.         W = Width : H = Height
  2268.  
  2269.         Dim Base As New Rectangle(0, 0, W, H)
  2270.         Dim Button As New Rectangle(CInt(W - 40), 0, W, H)
  2271.         Dim GP, GP2 As New GraphicsPath
  2272.  
  2273.         With G
  2274.             .Clear(Color.FromArgb(45, 45, 48))
  2275.             .SmoothingMode = 2
  2276.             .PixelOffsetMode = 2
  2277.             .TextRenderingHint = 5
  2278.  
  2279.             '-- Base
  2280.             .FillRectangle(New SolidBrush(_BGColor), Base)
  2281.  
  2282.             '-- Button
  2283.             GP.Reset()
  2284.             GP.AddRectangle(Button)
  2285.             .SetClip(GP)
  2286.             .FillRectangle(New SolidBrush(_BaseColor), Button)
  2287.             .ResetClip()
  2288.  
  2289.             '-- Lines
  2290.             .DrawLine(Pens.White, W - 10, 6, W - 30, 6)
  2291.             .DrawLine(Pens.White, W - 10, 12, W - 30, 12)
  2292.             .DrawLine(Pens.White, W - 10, 18, W - 30, 18)
  2293.  
  2294.             '-- Text
  2295.             .DrawString(Text, Font, Brushes.White, New Point(4, 6), NearSF)
  2296.         End With
  2297.  
  2298.         G.Dispose()
  2299.         e.Graphics.InterpolationMode = 7
  2300.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2301.         B.Dispose()
  2302.     End Sub
  2303. End Class
  2304.  
  2305. Class MDStickyButton : Inherits Control
  2306.  
  2307. #Region " Variables"
  2308.  
  2309.     Private W, H As Integer
  2310.     Private State As MouseState = MouseState.None
  2311.     Private _Rounded As Boolean = False
  2312.  
  2313. #End Region
  2314.  
  2315. #Region " Properties"
  2316.  
  2317. #Region " MouseStates"
  2318.  
  2319.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2320.         MyBase.OnMouseDown(e)
  2321.         State = MouseState.Down : Invalidate()
  2322.     End Sub
  2323.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  2324.         MyBase.OnMouseUp(e)
  2325.         State = MouseState.Over : Invalidate()
  2326.     End Sub
  2327.     Protected Overrides Sub OnMouseEnter(e As EventArgs)
  2328.         MyBase.OnMouseEnter(e)
  2329.         State = MouseState.Over : Invalidate()
  2330.     End Sub
  2331.     Protected Overrides Sub OnMouseLeave(e As EventArgs)
  2332.         MyBase.OnMouseLeave(e)
  2333.         State = MouseState.None : Invalidate()
  2334.     End Sub
  2335.  
  2336. #End Region
  2337.  
  2338. #Region " Function"
  2339.  
  2340.     Private Function GetConnectedSides() As Boolean()
  2341.         Dim Bool = New Boolean(3) {False, False, False, False}
  2342.  
  2343.         For Each B As Control In Parent.Controls
  2344.  
  2345.         Next
  2346.  
  2347.         Return Bool
  2348.     End Function
  2349.  
  2350.     Private ReadOnly Property Rect() As Rectangle
  2351.         Get
  2352.             Return New Rectangle(Left, Top, Width, Height)
  2353.         End Get
  2354.     End Property
  2355.  
  2356. #End Region
  2357.  
  2358. #Region " Colors"
  2359.  
  2360.     <Category("Colors")> _
  2361.     Public Property BaseColor As Color
  2362.         Get
  2363.             Return _BaseColor
  2364.         End Get
  2365.         Set(value As Color)
  2366.             _BaseColor = value
  2367.         End Set
  2368.     End Property
  2369.  
  2370.     <Category("Colors")> _
  2371.     Public Property TextColor As Color
  2372.         Get
  2373.             Return _TextColor
  2374.         End Get
  2375.         Set(value As Color)
  2376.             _TextColor = value
  2377.         End Set
  2378.     End Property
  2379.  
  2380.     <Category("Options")> _
  2381.     Public Property Rounded As Boolean
  2382.         Get
  2383.             Return _Rounded
  2384.         End Get
  2385.         Set(value As Boolean)
  2386.             _Rounded = value
  2387.         End Set
  2388.     End Property
  2389.  
  2390. #End Region
  2391.  
  2392.     Protected Overrides Sub OnResize(e As EventArgs)
  2393.         MyBase.OnResize(e)
  2394.         'Height = 32
  2395.     End Sub
  2396.  
  2397.     Protected Overrides Sub OnCreateControl()
  2398.         MyBase.OnCreateControl()
  2399.         'Size = New Size(112, 32)
  2400.     End Sub
  2401.  
  2402. #End Region
  2403.  
  2404. #Region " Colors"
  2405.  
  2406.     Private _BaseColor As Color = _FlatColor
  2407.     Private _TextColor As Color = Color.FromArgb(243, 243, 243)
  2408.  
  2409. #End Region
  2410.  
  2411.     Sub New()
  2412.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2413.         ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  2414.         ControlStyles.SupportsTransparentBackColor, True)
  2415.         DoubleBuffered = True
  2416.         Size = New Size(106, 32)
  2417.         BackColor = Color.Transparent
  2418.         Font = New Font("Segoe UI", 12)
  2419.         Cursor = Cursors.Hand
  2420.     End Sub
  2421.  
  2422.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2423.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2424.         W = Width : H = Height
  2425.  
  2426.         Dim GP As New GraphicsPath
  2427.  
  2428.         Dim GCS = GetConnectedSides()
  2429.         Dim RoundedBase = Helpers.RoundRect(0, 0, W, H, , Not (GCS(2) Or GCS(1)), Not (GCS(1) Or GCS(0)), Not (GCS(3) Or GCS(0)), Not (GCS(3) Or GCS(2)))
  2430.         Dim Base As New Rectangle(0, 0, W, H)
  2431.  
  2432.         With G
  2433.             .SmoothingMode = 2
  2434.             .PixelOffsetMode = 2
  2435.             .TextRenderingHint = 5
  2436.             .Clear(BackColor)
  2437.  
  2438.             Select Case State
  2439.                 Case MouseState.None
  2440.                     If Rounded Then
  2441.                         '-- Base
  2442.                         GP = RoundedBase
  2443.                         .FillPath(New SolidBrush(_BaseColor), GP)
  2444.  
  2445.                         '-- Text
  2446.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2447.                     Else
  2448.                         '-- Base
  2449.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  2450.  
  2451.                         '-- Text
  2452.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2453.                     End If
  2454.                 Case MouseState.Over
  2455.                     If Rounded Then
  2456.                         '-- Base
  2457.                         GP = RoundedBase
  2458.                         .FillPath(New SolidBrush(_BaseColor), GP)
  2459.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.White)), GP)
  2460.  
  2461.                         '-- Text
  2462.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2463.                     Else
  2464.                         '-- Base
  2465.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  2466.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
  2467.  
  2468.                         '-- Text
  2469.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2470.                     End If
  2471.                 Case MouseState.Down
  2472.                     If Rounded Then
  2473.                         '-- Base
  2474.                         GP = RoundedBase
  2475.                         .FillPath(New SolidBrush(_BaseColor), GP)
  2476.                         .FillPath(New SolidBrush(Color.FromArgb(20, Color.Black)), GP)
  2477.  
  2478.                         '-- Text
  2479.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2480.                     Else
  2481.                         '-- Base
  2482.                         .FillRectangle(New SolidBrush(_BaseColor), Base)
  2483.                         .FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
  2484.  
  2485.                         '-- Text
  2486.                         .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
  2487.                     End If
  2488.             End Select
  2489.  
  2490.         End With
  2491.  
  2492.         MyBase.OnPaint(e)
  2493.         G.Dispose()
  2494.         e.Graphics.InterpolationMode = 7
  2495.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2496.         B.Dispose()
  2497.     End Sub
  2498.  
  2499. End Class
  2500.  
  2501. Class MDNumeric : Inherits Control
  2502.  
  2503. #Region " Variables"
  2504.  
  2505.     Private W, H As Integer
  2506.     Private State As MouseState = MouseState.None
  2507.     Private x, y As Integer
  2508.     Private _Value, _Min, _Max As Long
  2509.     Private Bool As Boolean
  2510.  
  2511. #End Region
  2512.  
  2513. #Region " Properties"
  2514.  
  2515.     Public Property Value As Long
  2516.         Get
  2517.             Return _Value
  2518.         End Get
  2519.         Set(value As Long)
  2520.             If value <= _Max And value >= _Min Then _Value = value
  2521.             Invalidate()
  2522.         End Set
  2523.     End Property
  2524.  
  2525.     Public Property Maximum As Long
  2526.         Get
  2527.             Return _Max
  2528.         End Get
  2529.         Set(value As Long)
  2530.             If value > _Min Then _Max = value
  2531.             If _Value > _Max Then _Value = _Max
  2532.             Invalidate()
  2533.         End Set
  2534.     End Property
  2535.  
  2536.     Public Property Minimum As Long
  2537.         Get
  2538.             Return _Min
  2539.         End Get
  2540.         Set(value As Long)
  2541.             If value < _Max Then _Min = value
  2542.             If _Value < _Min Then _Value = Minimum
  2543.             Invalidate()
  2544.         End Set
  2545.     End Property
  2546.  
  2547.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  2548.         MyBase.OnMouseMove(e)
  2549.         x = e.Location.X
  2550.         y = e.Location.Y
  2551.         Invalidate()
  2552.         If e.X < Width - 23 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
  2553.     End Sub
  2554.  
  2555.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  2556.         MyBase.OnMouseDown(e)
  2557.         If x > Width - 21 AndAlso x < Width - 3 Then
  2558.             If y < 15 Then
  2559.                 If (Value + 1) <= _Max Then _Value += 1
  2560.             Else
  2561.                 If (Value - 1) >= _Min Then _Value -= 1
  2562.             End If
  2563.         Else
  2564.             Bool = Not Bool
  2565.             Focus()
  2566.         End If
  2567.         Invalidate()
  2568.     End Sub
  2569.  
  2570.     Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
  2571.         MyBase.OnKeyPress(e)
  2572.         Try
  2573.             If Bool Then _Value = CStr(CStr(_Value) & e.KeyChar.ToString())
  2574.             If _Value > _Max Then _Value = _Max
  2575.             Invalidate()
  2576.         Catch : End Try
  2577.     End Sub
  2578.  
  2579.     Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
  2580.         MyBase.OnKeyDown(e)
  2581.         If e.KeyCode = Keys.Back Then
  2582.             Value = 0
  2583.         End If
  2584.     End Sub
  2585.  
  2586.     Protected Overrides Sub OnResize(e As EventArgs)
  2587.         MyBase.OnResize(e)
  2588.         Height = 30
  2589.     End Sub
  2590.  
  2591. #Region " Colors"
  2592.  
  2593.     <Category("Colors")> _
  2594.     Public Property BaseColor As Color
  2595.         Get
  2596.             Return _BaseColor
  2597.         End Get
  2598.         Set(value As Color)
  2599.             _BaseColor = value
  2600.         End Set
  2601.     End Property
  2602.  
  2603.     <Category("Colors")> _
  2604.     Public Property ButtonColor As Color
  2605.         Get
  2606.             Return _ButtonColor
  2607.         End Get
  2608.         Set(value As Color)
  2609.             _ButtonColor = value
  2610.         End Set
  2611.     End Property
  2612.  
  2613. #End Region
  2614.  
  2615. #End Region
  2616.  
  2617. #Region " Colors"
  2618.  
  2619.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  2620.     Private _ButtonColor As Color = _FlatColor
  2621.  
  2622. #End Region
  2623.  
  2624.     Sub New()
  2625.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2626.         ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
  2627.         ControlStyles.SupportsTransparentBackColor, True)
  2628.         DoubleBuffered = True
  2629.         Font = New Font("Segoe UI", 10)
  2630.         BackColor = Color.FromArgb(60, 70, 73)
  2631.         ForeColor = Color.White
  2632.         _Min = 0
  2633.         _Max = 9999999
  2634.     End Sub
  2635.  
  2636.  
  2637.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2638.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2639.         W = Width : H = Height
  2640.  
  2641.         Dim Base As New Rectangle(0, 0, W, H)
  2642.  
  2643.         With G
  2644.             .SmoothingMode = 2
  2645.             .PixelOffsetMode = 2
  2646.             .TextRenderingHint = 5
  2647.             .Clear(BackColor)
  2648.  
  2649.             '-- Base
  2650.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  2651.             .FillRectangle(New SolidBrush(_ButtonColor), New Rectangle(Width - 24, 0, 24, H))
  2652.  
  2653.             '-- Add
  2654.             .DrawString("+", New Font("Segoe UI", 12), Brushes.White, New Point(Width - 12, 8), CenterSF)
  2655.             '-- Subtract
  2656.             .DrawString("-", New Font("Segoe UI", 10, FontStyle.Bold), Brushes.White, New Point(Width - 12, 22), CenterSF)
  2657.  
  2658.             '-- Text
  2659.             .DrawString(Value, Font, Brushes.White, New Rectangle(5, 1, W, H), New StringFormat() With {.LineAlignment = StringAlignment.Center})
  2660.         End With
  2661.  
  2662.         MyBase.OnPaint(e)
  2663.         G.Dispose()
  2664.         e.Graphics.InterpolationMode = 7
  2665.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2666.         B.Dispose()
  2667.     End Sub
  2668.  
  2669. End Class
  2670.  
  2671. Class MDListBox : Inherits Control
  2672.  
  2673. #Region " Variables"
  2674.  
  2675.     Private WithEvents ListBx As New ListBox
  2676.     Private _items As String() = {""}
  2677.     Private _LightTheme As Boolean
  2678.  
  2679. #End Region
  2680.  
  2681. #Region " Poperties"
  2682.  
  2683.     Public Property LightTheme As Boolean
  2684.         Get
  2685.             Return _LightTheme
  2686.         End Get
  2687.         Set(value As Boolean)
  2688.             _LightTheme = value
  2689.         End Set
  2690.     End Property
  2691.  
  2692.     <Category("Options")> _
  2693.     Public Property items As String()
  2694.         Get
  2695.             Return _items
  2696.         End Get
  2697.         Set(value As String())
  2698.             _items = value
  2699.             ListBx.Items.Clear()
  2700.             ListBx.Items.AddRange(value)
  2701.             Invalidate()
  2702.         End Set
  2703.     End Property
  2704.  
  2705.     <Category("Colors")> _
  2706.     Public Property SelectedColor As Color
  2707.         Get
  2708.             Return _SelectedColor
  2709.         End Get
  2710.         Set(value As Color)
  2711.             _SelectedColor = value
  2712.         End Set
  2713.     End Property
  2714.  
  2715.     Public ReadOnly Property SelectedItem() As String
  2716.         Get
  2717.             Return ListBx.SelectedItem
  2718.         End Get
  2719.     End Property
  2720.  
  2721.     Public ReadOnly Property SelectedIndex() As Integer
  2722.         Get
  2723.             Return ListBx.SelectedIndex
  2724.             If ListBx.SelectedIndex < 0 Then Exit Property
  2725.         End Get
  2726.     End Property
  2727.  
  2728.     Public Sub Clear()
  2729.         ListBx.Items.Clear()
  2730.     End Sub
  2731.  
  2732.     Public Sub ClearSelected()
  2733.         For i As Integer = (ListBx.SelectedItems.Count - 1) To 0 Step -1
  2734.             ListBx.Items.Remove(ListBx.SelectedItems(i))
  2735.         Next
  2736.     End Sub
  2737.  
  2738.     Sub Drawitem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles ListBx.DrawItem
  2739.         If e.Index < 0 Then Exit Sub
  2740.         e.DrawBackground()
  2741.         e.DrawFocusRectangle()
  2742.  
  2743.         e.Graphics.SmoothingMode = 2
  2744.         e.Graphics.PixelOffsetMode = 2
  2745.         e.Graphics.InterpolationMode = 7
  2746.         e.Graphics.TextRenderingHint = 5
  2747.  
  2748.         If InStr(e.State.ToString, "Selected,") > 0 Then '-- if selected
  2749.             '-- Base
  2750.             e.Graphics.FillRectangle(New SolidBrush(_SelectedColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  2751.  
  2752.             '-- Text
  2753.             e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
  2754.         Else
  2755.             '-- Base
  2756.             e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(51, 53, 55)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  2757.  
  2758.             '-- Text
  2759.             e.Graphics.DrawString(" " & ListBx.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 2)
  2760.         End If
  2761.  
  2762.         e.Graphics.Dispose()
  2763.     End Sub
  2764.  
  2765.     Protected Overrides Sub OnCreateControl()
  2766.         MyBase.OnCreateControl()
  2767.         If Not Controls.Contains(ListBx) Then
  2768.             Controls.Add(ListBx)
  2769.         End If
  2770.     End Sub
  2771.  
  2772.     Sub AddRange(ByVal items As Object())
  2773.         ListBx.Items.Remove("")
  2774.         ListBx.Items.AddRange(items)
  2775.     End Sub
  2776.  
  2777.     Sub AddItem(ByVal item As Object)
  2778.         ListBx.Items.Remove("")
  2779.         ListBx.Items.Add(item)
  2780.     End Sub
  2781.  
  2782. #End Region
  2783.  
  2784. #Region " Colors"
  2785.  
  2786.     Private BaseColor As Color = Color.FromArgb(45, 47, 49)
  2787.     Private _SelectedColor As Color = _FlatColor
  2788.  
  2789. #End Region
  2790.  
  2791.     Sub New()
  2792.         If _LightTheme Then
  2793.             BaseColor = Color.FromArgb(255, 255, 255)
  2794.             ForeColor = Color.FromArgb(0, 0, 0)
  2795.             _SelectedColor = Color.FromArgb(200, 200, 200)
  2796.         Else
  2797.             BaseColor = Color.FromArgb(0, 0, 0)
  2798.             ForeColor = Color.FromArgb(255, 255, 255)
  2799.             _SelectedColor = Color.FromArgb(20, 20, 20)
  2800.         End If
  2801.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  2802.             ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  2803.         DoubleBuffered = True
  2804.  
  2805.         ListBx.DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  2806.         ListBx.ScrollAlwaysVisible = False
  2807.         ListBx.HorizontalScrollbar = False
  2808.         ListBx.BorderStyle = BorderStyle.None
  2809.         ListBx.BackColor = BaseColor
  2810.         'ListBx.ForeColor = Color.White
  2811.         ListBx.Location = New Point(3, 3)
  2812.         ListBx.Font = New Font("Segoe UI", 8)
  2813.         ListBx.ItemHeight = 20
  2814.         ListBx.Items.Clear()
  2815.         ListBx.IntegralHeight = False
  2816.  
  2817.         Size = New Size(131, 101)
  2818.         BackColor = BaseColor
  2819.     End Sub
  2820.  
  2821.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2822.         If _LightTheme Then
  2823.             BaseColor = Color.FromArgb(255, 255, 255)
  2824.             ForeColor = Color.FromArgb(0, 0, 0)
  2825.         Else
  2826.             BaseColor = Color.FromArgb(0, 0, 0)
  2827.             ForeColor = Color.FromArgb(255, 255, 255)
  2828.         End If
  2829.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  2830.  
  2831.         Dim Base As New Rectangle(0, 0, Width, Height)
  2832.  
  2833.         With G
  2834.             .SmoothingMode = 2
  2835.             .PixelOffsetMode = 2
  2836.             .TextRenderingHint = 5
  2837.             .Clear(BackColor)
  2838.  
  2839.             '-- Size
  2840.             ListBx.Size = New Size(Width - 6, Height - 2)
  2841.  
  2842.             '-- Base
  2843.             .FillRectangle(New SolidBrush(BaseColor), Base)
  2844.         End With
  2845.  
  2846.         MyBase.OnPaint(e)
  2847.         G.Dispose()
  2848.         e.Graphics.InterpolationMode = 7
  2849.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  2850.         B.Dispose()
  2851.     End Sub
  2852.  
  2853. End Class
  2854.  
  2855. Class MDContextMenuStrip : Inherits ContextMenuStrip
  2856.     Private _LightTheme As Boolean
  2857.     Public Property LightTheme As Boolean
  2858.         Get
  2859.             Return _LightTheme
  2860.         End Get
  2861.         Set(value As Boolean)
  2862.             _LightTheme = value
  2863.         End Set
  2864.     End Property
  2865.  
  2866.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  2867.         MyBase.OnTextChanged(e) : Invalidate()
  2868.     End Sub
  2869.  
  2870.     Sub New()
  2871.         MyBase.New()
  2872.         Renderer = New ToolStripProfessionalRenderer(New TColorTable())
  2873.         ShowImageMargin = False
  2874.         ForeColor = Color.White
  2875.         Font = New Font("Segoe UI", 8)
  2876.     End Sub
  2877.  
  2878.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  2879.         If _LightTheme Then
  2880.  
  2881.         End If
  2882.         MyBase.OnPaint(e)
  2883.         e.Graphics.TextRenderingHint = 5
  2884.     End Sub
  2885.  
  2886.     Class TColorTable : Inherits ProfessionalColorTable
  2887.  
  2888. #Region " Properties"
  2889.  
  2890. #Region " Colors"
  2891.  
  2892.         <Category("Colors")> _
  2893.         Public Property _BackColor As Color
  2894.             Get
  2895.                 Return BackColor
  2896.             End Get
  2897.             Set(value As Color)
  2898.                 BackColor = value
  2899.             End Set
  2900.         End Property
  2901.  
  2902.         <Category("Colors")> _
  2903.         Public Property _CheckedColor As Color
  2904.             Get
  2905.                 Return CheckedColor
  2906.             End Get
  2907.             Set(value As Color)
  2908.                 CheckedColor = value
  2909.             End Set
  2910.         End Property
  2911.  
  2912.         <Category("Colors")> _
  2913.         Public Property _BorderColor As Color
  2914.             Get
  2915.                 Return BorderColor
  2916.             End Get
  2917.             Set(value As Color)
  2918.                 BorderColor = value
  2919.             End Set
  2920.         End Property
  2921.  
  2922. #End Region
  2923.  
  2924. #End Region
  2925.  
  2926. #Region " Colors"
  2927.  
  2928.         Private BackColor As Color = Color.FromArgb(45, 47, 49)
  2929.         Private CheckedColor As Color = _FlatColor
  2930.         Private BorderColor As Color = Color.FromArgb(53, 58, 60)
  2931.  
  2932. #End Region
  2933.  
  2934. #Region " Overrides"
  2935.  
  2936.         Public Overrides ReadOnly Property ButtonSelectedBorder As Color
  2937.             Get
  2938.                 Return BackColor
  2939.             End Get
  2940.         End Property
  2941.         Public Overrides ReadOnly Property CheckBackground() As Color
  2942.             Get
  2943.                 Return CheckedColor
  2944.             End Get
  2945.         End Property
  2946.         Public Overrides ReadOnly Property CheckPressedBackground() As Color
  2947.             Get
  2948.                 Return CheckedColor
  2949.             End Get
  2950.         End Property
  2951.         Public Overrides ReadOnly Property CheckSelectedBackground() As Color
  2952.             Get
  2953.                 Return CheckedColor
  2954.             End Get
  2955.         End Property
  2956.         Public Overrides ReadOnly Property ImageMarginGradientBegin() As Color
  2957.             Get
  2958.                 Return CheckedColor
  2959.             End Get
  2960.         End Property
  2961.         Public Overrides ReadOnly Property ImageMarginGradientEnd() As Color
  2962.             Get
  2963.                 Return CheckedColor
  2964.             End Get
  2965.         End Property
  2966.         Public Overrides ReadOnly Property ImageMarginGradientMiddle() As Color
  2967.             Get
  2968.                 Return CheckedColor
  2969.             End Get
  2970.         End Property
  2971.         Public Overrides ReadOnly Property MenuBorder() As Color
  2972.             Get
  2973.                 Return BorderColor
  2974.             End Get
  2975.         End Property
  2976.         Public Overrides ReadOnly Property MenuItemBorder() As Color
  2977.             Get
  2978.                 Return BorderColor
  2979.             End Get
  2980.         End Property
  2981.         Public Overrides ReadOnly Property MenuItemSelected() As Color
  2982.             Get
  2983.                 Return CheckedColor
  2984.             End Get
  2985.         End Property
  2986.         Public Overrides ReadOnly Property SeparatorDark() As Color
  2987.             Get
  2988.                 Return BorderColor
  2989.             End Get
  2990.         End Property
  2991.         Public Overrides ReadOnly Property ToolStripDropDownBackground() As Color
  2992.             Get
  2993.                 Return BackColor
  2994.             End Get
  2995.         End Property
  2996.  
  2997. #End Region
  2998.  
  2999.     End Class
  3000.  
  3001. End Class
  3002.  
  3003. <DefaultEvent("Scroll")> Class MDTrackBar : Inherits Control
  3004.  
  3005. #Region " Variables"
  3006.  
  3007.     Private W, H As Integer
  3008.     Private Val As Integer
  3009.     Private Bool As Boolean
  3010.     Private Track As Rectangle
  3011.     Private Knob As Rectangle
  3012.     Private Style_ As _Style
  3013.     Private _LightTheme As Boolean
  3014.  
  3015. #End Region
  3016.  
  3017. #Region " Properties"
  3018.  
  3019. #Region " Mouse States"
  3020.  
  3021.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  3022.         MyBase.OnMouseDown(e)
  3023.         If e.Button = Windows.Forms.MouseButtons.Left Then
  3024.             Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
  3025.             Track = New Rectangle(Val, 0, 10, 20)
  3026.  
  3027.             Bool = Track.Contains(e.Location)
  3028.         End If
  3029.     End Sub
  3030.  
  3031.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  3032.         MyBase.OnMouseMove(e)
  3033.         If Bool AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
  3034.             Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
  3035.         End If
  3036.     End Sub
  3037.  
  3038.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  3039.         MyBase.OnMouseUp(e) : Bool = False
  3040.     End Sub
  3041.  
  3042. #End Region
  3043.  
  3044. #Region " Styles"
  3045.  
  3046.     <Flags> _
  3047.     Enum _Style
  3048.         Slider
  3049.         Knob
  3050.     End Enum
  3051.  
  3052.     Public Property Style As _Style
  3053.         Get
  3054.             Return Style_
  3055.         End Get
  3056.         Set(value As _Style)
  3057.             Style_ = value
  3058.         End Set
  3059.     End Property
  3060.  
  3061. #End Region
  3062.  
  3063. #Region " Colors"
  3064.  
  3065.     <Category("Colors")> _
  3066.     Public Property TrackColor As Color
  3067.         Get
  3068.             Return _TrackColor
  3069.         End Get
  3070.         Set(value As Color)
  3071.             _TrackColor = value
  3072.         End Set
  3073.     End Property
  3074.  
  3075.     <Category("Colors")> _
  3076.     Public Property HatchColor As Color
  3077.         Get
  3078.             Return _HatchColor
  3079.         End Get
  3080.         Set(value As Color)
  3081.             _HatchColor = value
  3082.         End Set
  3083.     End Property
  3084.  
  3085. #End Region
  3086.  
  3087.     Public Property LightTheme As Boolean
  3088.         Get
  3089.             Return _LightTheme
  3090.         End Get
  3091.         Set(value As Boolean)
  3092.             _LightTheme = value
  3093.         End Set
  3094.     End Property
  3095.  
  3096.     Event Scroll(ByVal sender As Object)
  3097.     Private _Minimum As Integer
  3098.     Public Property Minimum As Integer
  3099.         Get
  3100.             Return Minimum
  3101.         End Get
  3102.         Set(value As Integer)
  3103.             If value < 0 Then
  3104.             End If
  3105.  
  3106.             _Minimum = value
  3107.  
  3108.             If value > _Value Then _Value = value
  3109.             If value > _Maximum Then _Maximum = value
  3110.             Invalidate()
  3111.         End Set
  3112.     End Property
  3113.     Private _Maximum As Integer = 10
  3114.     Public Property Maximum As Integer
  3115.         Get
  3116.             Return _Maximum
  3117.         End Get
  3118.         Set(value As Integer)
  3119.             If value < 0 Then
  3120.             End If
  3121.  
  3122.             _Maximum = value
  3123.             If value < _Value Then _Value = value
  3124.             If value < _Minimum Then _Minimum = value
  3125.             Invalidate()
  3126.         End Set
  3127.     End Property
  3128.     Private _Value As Integer
  3129.     Public Property Value As Integer
  3130.         Get
  3131.             Return _Value
  3132.         End Get
  3133.         Set(value As Integer)
  3134.             If value = _Value Then Return
  3135.  
  3136.             If value > _Maximum OrElse value < _Minimum Then
  3137.             End If
  3138.  
  3139.             _Value = value
  3140.             Invalidate()
  3141.             RaiseEvent Scroll(Me)
  3142.         End Set
  3143.     End Property
  3144.     Private _ShowValue As Boolean = False
  3145.     Public Property ShowValue As Boolean
  3146.         Get
  3147.             Return _ShowValue
  3148.         End Get
  3149.         Set(value As Boolean)
  3150.             _ShowValue = value
  3151.         End Set
  3152.     End Property
  3153.  
  3154.     Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
  3155.         MyBase.OnKeyDown(e)
  3156.         If e.KeyCode = Keys.Subtract Then
  3157.             If Value = 0 Then Exit Sub
  3158.             Value -= 1
  3159.         ElseIf e.KeyCode = Keys.Add Then
  3160.             If Value = _Maximum Then Exit Sub
  3161.             Value += 1
  3162.         End If
  3163.     End Sub
  3164.  
  3165.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  3166.         MyBase.OnTextChanged(e) : Invalidate()
  3167.     End Sub
  3168.  
  3169.     Protected Overrides Sub OnResize(e As EventArgs)
  3170.         MyBase.OnResize(e)
  3171.         Height = 23
  3172.     End Sub
  3173.  
  3174. #End Region
  3175.  
  3176. #Region " Colors"
  3177.  
  3178.     Private BaseColor As Color = Color.FromArgb(45, 47, 49)
  3179.     Private _TrackColor As Color = _FlatColor
  3180.     Private SliderColor As Color = Color.FromArgb(25, 27, 29)
  3181.     Private _HatchColor As Color = Color.FromArgb(23, 148, 92)
  3182.  
  3183. #End Region
  3184.  
  3185.     Sub New()
  3186.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3187.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3188.         DoubleBuffered = True
  3189.         Height = 18
  3190.  
  3191.         BackColor = Color.FromArgb(60, 70, 73)
  3192.     End Sub
  3193.  
  3194.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3195.         If _LightTheme Then
  3196.             BaseColor = Color.FromArgb(0, 0, 0)
  3197.             _TrackColor = Color.FromArgb(200, 200, 200)
  3198.             SliderColor = Color.FromArgb(225, 225, 225)
  3199.             _HatchColor = Color.FromArgb(150, 150, 150)
  3200.         Else
  3201.             BaseColor = Color.FromArgb(250, 250, 250)
  3202.             _TrackColor = Color.FromArgb(100, 100, 100)
  3203.             SliderColor = Color.FromArgb(20, 20, 20)
  3204.             _HatchColor = Color.FromArgb(50, 50, 50)
  3205.         End If
  3206.  
  3207.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3208.         W = Width - 1 : H = Height - 1
  3209.  
  3210.         Dim Base As New Rectangle(1, 6, W - 2, 8)
  3211.         Dim GP, GP2 As New GraphicsPath
  3212.  
  3213.         With G
  3214.             .SmoothingMode = 2
  3215.             .PixelOffsetMode = 2
  3216.             .TextRenderingHint = 5
  3217.             .Clear(BackColor)
  3218.  
  3219.             '-- Value
  3220.             Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (W - 10))
  3221.             Track = New Rectangle(Val, 0, 10, 20)
  3222.             Knob = New Rectangle(Val, 4, 11, 14)
  3223.  
  3224.             '-- Base
  3225.             GP.AddRectangle(Base)
  3226.             .SetClip(GP)
  3227.             .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 7, W, 8))
  3228.             .FillRectangle(New SolidBrush(_TrackColor), New Rectangle(0, 7, Track.X + Track.Width, 8))
  3229.             .ResetClip()
  3230.  
  3231.             '-- Hatch Brush
  3232.             'Dim HB As New HatchBrush(HatchStyle.Plaid, HatchColor, _TrackColor)
  3233.             '.FillRectangle(HB, New Rectangle(-10, 7, Track.X + Track.Width, 8))
  3234.  
  3235.             '-- Slider/Knob
  3236.             Select Case Style
  3237.                 Case _Style.Slider
  3238.                     GP2.AddRectangle(Track)
  3239.                     .FillPath(New SolidBrush(SliderColor), GP2)
  3240.                 Case _Style.Knob
  3241.                     GP2.AddEllipse(Knob)
  3242.                     .FillPath(New SolidBrush(SliderColor), GP2)
  3243.             End Select
  3244.  
  3245.             '-- Show the value
  3246.             If ShowValue Then
  3247.                 .DrawString(Value, New Font("Segoe UI", 8), Brushes.White, New Rectangle(1, 6, W, H), New StringFormat() _
  3248.                             With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Far})
  3249.             End If
  3250.         End With
  3251.  
  3252.         MyBase.OnPaint(e)
  3253.         G.Dispose()
  3254.         e.Graphics.InterpolationMode = 7
  3255.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  3256.         B.Dispose()
  3257.     End Sub
  3258. End Class
  3259.  
  3260. Class MDStatusBar : Inherits Control
  3261.  
  3262. #Region " Variables"
  3263.  
  3264.     Private W, H As Integer
  3265.     Private _ShowTimeDate As Boolean = False
  3266.     Private _LightTheme As Boolean = False
  3267.  
  3268. #End Region
  3269.  
  3270. #Region " Properties"
  3271.  
  3272.     Protected Overrides Sub CreateHandle()
  3273.         MyBase.CreateHandle()
  3274.         Dock = DockStyle.Bottom
  3275.     End Sub
  3276.  
  3277.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  3278.         MyBase.OnTextChanged(e) : Invalidate()
  3279.     End Sub
  3280.  
  3281. #Region " Colors"
  3282.  
  3283.     <Category("Colors")> _
  3284.     Public Property BaseColor As Color
  3285.         Get
  3286.             Return _BaseColor
  3287.         End Get
  3288.         Set(value As Color)
  3289.             _BaseColor = value
  3290.         End Set
  3291.     End Property
  3292.  
  3293.     <Category("Colors")> _
  3294.     Public Property TextColor As Color
  3295.         Get
  3296.             Return _TextColor
  3297.         End Get
  3298.         Set(value As Color)
  3299.             _TextColor = value
  3300.         End Set
  3301.     End Property
  3302.  
  3303.     <Category("Colors")> _
  3304.     Public Property RectColor As Color
  3305.         Get
  3306.             Return _RectColor
  3307.         End Get
  3308.         Set(value As Color)
  3309.             _RectColor = value
  3310.         End Set
  3311.     End Property
  3312.  
  3313. #End Region
  3314.  
  3315.     Public Property ShowTimeDate As Boolean
  3316.         Get
  3317.             Return _ShowTimeDate
  3318.         End Get
  3319.         Set(value As Boolean)
  3320.             _ShowTimeDate = value
  3321.         End Set
  3322.     End Property
  3323.  
  3324.     Public Property LightTheme As Boolean
  3325.         Get
  3326.             Return _LightTheme
  3327.         End Get
  3328.         Set(value As Boolean)
  3329.             _LightTheme = value
  3330.         End Set
  3331.     End Property
  3332.  
  3333.     Function GetTimeDate() As String
  3334.         Return DateTime.Now.Date & " " & DateTime.Now.Hour & ":" & DateTime.Now.Minute
  3335.     End Function
  3336.  
  3337. #End Region
  3338.  
  3339. #Region " Colors"
  3340.  
  3341.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  3342.     Private _TextColor As Color = Color.White
  3343.     Private _RectColor As Color = _FlatColor
  3344.  
  3345. #End Region
  3346.  
  3347.     Sub New()
  3348.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3349.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3350.         DoubleBuffered = True
  3351.         Font = New Font("Segoe UI", 8)
  3352.         ForeColor = Color.White
  3353.         Size = New Size(Width, 20)
  3354.     End Sub
  3355.  
  3356.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3357.         If _LightTheme Then
  3358.             'light
  3359.             _BaseColor = Color.FromArgb(255, 255, 255)
  3360.             _TextColor = Color.FromArgb(0, 0, 0)
  3361.             ForeColor = Color.FromArgb(0, 0, 0)
  3362.         Else
  3363.             'dark
  3364.             _BaseColor = Color.FromArgb(0, 0, 0)
  3365.             _TextColor = Color.FromArgb(255, 255, 255)
  3366.             ForeColor = Color.FromArgb(255, 255, 255)
  3367.         End If
  3368.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3369.         W = Width : H = Height
  3370.  
  3371.         Dim Base As New Rectangle(2, 2, W - 10, H - 10)
  3372.  
  3373.         With G
  3374.             .SmoothingMode = 2
  3375.             .PixelOffsetMode = 2
  3376.             .TextRenderingHint = 5
  3377.             .Clear(BaseColor)
  3378.  
  3379.             '-- Base
  3380.             .FillRectangle(New SolidBrush(BaseColor), Base)
  3381.  
  3382.             '-- Text
  3383.             .DrawString(Text, Font, Brushes.White, New Rectangle(10, 4, W, H), NearSF)
  3384.  
  3385.             '-- Rectangle
  3386.             .FillRectangle(New SolidBrush(_RectColor), New Rectangle(4, 4, 4, 14))
  3387.  
  3388.             '-- TimeDate
  3389.             If ShowTimeDate Then
  3390.                 .DrawString(GetTimeDate, Font, New SolidBrush(_TextColor), New Rectangle(-4, 2, W, H), New StringFormat() _
  3391.                             With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
  3392.             End If
  3393.         End With
  3394.  
  3395.         MyBase.OnPaint(e)
  3396.         G.Dispose()
  3397.         e.Graphics.InterpolationMode = 7
  3398.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  3399.         B.Dispose()
  3400.     End Sub
  3401. End Class
  3402.  
  3403. Class MDLabel : Inherits Label
  3404.  
  3405.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  3406.         MyBase.OnTextChanged(e) : Invalidate()
  3407.     End Sub
  3408.  
  3409.     Sub New()
  3410.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  3411.         Font = New Font("Segoe UI", 8)
  3412.         ForeColor = Color.White
  3413.         BackColor = Color.Transparent
  3414.         Text = Text
  3415.     End Sub
  3416.  
  3417. End Class
  3418.  
  3419. Class MDTreeView : Inherits TreeView
  3420.  
  3421. #Region " Variables"
  3422.  
  3423.     Private State As TreeNodeStates
  3424.  
  3425. #End Region
  3426.  
  3427. #Region " Properties"
  3428.  
  3429.     Protected Overrides Sub OnDrawNode(e As DrawTreeNodeEventArgs)
  3430.         Try
  3431.             Dim Bounds As New Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y, e.Bounds.Width, e.Bounds.Height)
  3432.             'e.Node.Nodes.Item.
  3433.             Select Case State
  3434.                 Case TreeNodeStates.Default
  3435.                     e.Graphics.FillRectangle(Brushes.Red, Bounds)
  3436.                     e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.LimeGreen, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3437.                     Invalidate()
  3438.                 Case TreeNodeStates.Checked
  3439.                     e.Graphics.FillRectangle(Brushes.Green, Bounds)
  3440.                     e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3441.                     Invalidate()
  3442.                 Case TreeNodeStates.Selected
  3443.                     e.Graphics.FillRectangle(Brushes.Green, Bounds)
  3444.                     e.Graphics.DrawString(e.Node.Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3445.                     Invalidate()
  3446.             End Select
  3447.  
  3448.         Catch ex As Exception
  3449.             MsgBox(ex.Message)
  3450.         End Try
  3451.  
  3452.         MyBase.OnDrawNode(e)
  3453.     End Sub
  3454.  
  3455. #End Region
  3456.  
  3457. #Region " Colors"
  3458.  
  3459.     Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
  3460.     Private _LineColor As Color = Color.FromArgb(25, 27, 29)
  3461.  
  3462. #End Region
  3463.     Sub New()
  3464.  
  3465.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3466.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3467.         DoubleBuffered = True
  3468.  
  3469.         BackColor = _BaseColor
  3470.         ForeColor = Color.White
  3471.         LineColor = _LineColor
  3472.         DrawMode = TreeViewDrawMode.OwnerDrawAll
  3473.     End Sub
  3474.  
  3475.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3476.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3477.  
  3478.         Dim Base As New Rectangle(0, 0, Width, Height)
  3479.  
  3480.         With G
  3481.             .SmoothingMode = 2
  3482.             .PixelOffsetMode = 2
  3483.             .TextRenderingHint = 5
  3484.             .Clear(BackColor)
  3485.  
  3486.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  3487.             .DrawString(Text, New Font("Segoe UI", 8), Brushes.Black, New Rectangle(Bounds.X + 2, Bounds.Y + 2, Bounds.Width, Bounds.Height), NearSF)
  3488.  
  3489.         End With
  3490.  
  3491.         MyBase.OnPaint(e)
  3492.         G.Dispose()
  3493.         e.Graphics.InterpolationMode = 7
  3494.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  3495.         B.Dispose()
  3496.     End Sub
  3497.  
  3498. End Class
  3499.  
  3500. Class MDIcon : Inherits Windows.Forms.Button
  3501.  
  3502. #Region " Variables"
  3503.  
  3504.     Private _MDColor_border As Color
  3505.     Private _MDColor_click As Color
  3506.     Private _MDColor_hover As Color
  3507.  
  3508. #End Region
  3509.  
  3510. #Region " Properties"
  3511.     Public Property MDcolor_border As Color
  3512.         Get
  3513.             Return _MDColor_border
  3514.         End Get
  3515.         Set(value As Color)
  3516.             _MDColor_border = value
  3517.         End Set
  3518.     End Property
  3519.  
  3520.     Public Property MDcolor_click As Color
  3521.         Get
  3522.             Return _MDColor_click
  3523.         End Get
  3524.         Set(value As Color)
  3525.             _MDColor_click = value
  3526.         End Set
  3527.     End Property
  3528.  
  3529.     Public Property MDcolor_hover As Color
  3530.         Get
  3531.             Return _MDColor_hover
  3532.         End Get
  3533.         Set(value As Color)
  3534.             _MDColor_hover = value
  3535.         End Set
  3536.     End Property
  3537.  
  3538. #End Region
  3539.  
  3540.  
  3541.     Sub New()
  3542.         Me.Size = New System.Drawing.Point(33, 33)
  3543.         Me.Text = ""
  3544.         Me.FlatStyle = Windows.Forms.FlatStyle.Flat
  3545.         Me.BackColor = BackColor
  3546.         Me.Font = New System.Drawing.Font("Segoe UI", 8, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point, CType(0, Byte))
  3547.         Me.ForeColor = Drawing.Color.White
  3548.         Me.FlatAppearance.BorderColor = _MDColor_border
  3549.         Me.FlatAppearance.MouseDownBackColor = _MDColor_click
  3550.         Me.FlatAppearance.MouseOverBackColor = _MDColor_hover
  3551.         Me.FlatAppearance.BorderSize = 2
  3552.     End Sub
  3553.  
  3554.     Private Sub Metro_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  3555.         Me.BackColor = _MDColor_click
  3556.     End Sub
  3557.  
  3558.     Private Sub Metro_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
  3559.         Me.BackColor = _MDColor_hover
  3560.     End Sub
  3561.  
  3562.     Private Sub MDIcon_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover
  3563.         Me.BackColor = _MDColor_hover
  3564.     End Sub
  3565.  
  3566.     Private Sub Metro_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
  3567.         Me.BackColor = BackColor
  3568.     End Sub
  3569.  
  3570.     Private Sub Metro_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
  3571.         Me.BackColor = _MDColor_hover
  3572.     End Sub
  3573.  
  3574. End Class
  3575.  
  3576. Class MDlblButton : Inherits Windows.Forms.Label
  3577.  
  3578. #Region " Variables"
  3579.  
  3580.     Private _MDColor_normal As Color
  3581.     Private _MDColor_click As Color
  3582.     Private _MDColor_hover As Color
  3583.  
  3584. #End Region
  3585.  
  3586. #Region " Properties"
  3587.     Public Property MDcolor_normal As Color
  3588.         Get
  3589.             Return _MDColor_normal
  3590.         End Get
  3591.         Set(value As Color)
  3592.             _MDColor_normal = value
  3593.         End Set
  3594.     End Property
  3595.  
  3596.     Public Property MDcolor_click As Color
  3597.         Get
  3598.             Return _MDColor_click
  3599.         End Get
  3600.         Set(value As Color)
  3601.             _MDColor_click = value
  3602.         End Set
  3603.     End Property
  3604.  
  3605.     Public Property MDcolor_hover As Color
  3606.         Get
  3607.             Return _MDColor_hover
  3608.         End Get
  3609.         Set(value As Color)
  3610.             _MDColor_hover = value
  3611.         End Set
  3612.     End Property
  3613.  
  3614. #End Region
  3615.  
  3616.  
  3617.     Sub New()
  3618.         _MDColor_click = Color.DarkGray
  3619.         _MDColor_hover = Color.LightGray
  3620.         _MDColor_normal = Color.Silver
  3621.  
  3622.  
  3623.         Me.FlatStyle = Windows.Forms.FlatStyle.Flat
  3624.         Me.BackColor = Color.Transparent
  3625.         Me.Font = New System.Drawing.Font("Segoe UI", 8, Drawing.FontStyle.Regular, Drawing.GraphicsUnit.Point, CType(0, Byte))
  3626.         Me.ForeColor = _MDColor_normal
  3627.     End Sub
  3628.  
  3629.     Private Sub Metro_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
  3630.         Me.ForeColor = _MDColor_click
  3631.     End Sub
  3632.  
  3633.     Private Sub Metro_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
  3634.         Me.ForeColor = _MDColor_hover
  3635.     End Sub
  3636.  
  3637.     Private Sub MDIcon_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover
  3638.         Me.ForeColor = _MDColor_hover
  3639.     End Sub
  3640.  
  3641.     Private Sub Metro_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
  3642.         Me.ForeColor = _MDColor_normal
  3643.     End Sub
  3644.  
  3645.     Private Sub Metro_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
  3646.         Me.ForeColor = _MDColor_hover
  3647.     End Sub
  3648.  
  3649. End Class
  3650.  
  3651. Class DialogSkin : Inherits ContainerControl
  3652.  
  3653. #Region " Variables"
  3654.  
  3655.     Private W, H As Integer
  3656.     Private Cap As Boolean = False
  3657.     Private _HeaderMaximize As Boolean = False
  3658.     Private MousePoint As New Point(0, 0)
  3659.     Private MoveHeight = 50
  3660.     Private _MDcolor As Color
  3661.     Private _text As String = "MetroDisk by SilverMachine"
  3662.     Private _Font = New Font("tahoma", 7)
  3663.     Private __Font = New Font("Segoe UI", 18, FontStyle.Bold)
  3664. #End Region
  3665.  
  3666. #Region " Properties"
  3667.  
  3668. #Region " Colors"
  3669.  
  3670.     <Category("Colors")> _
  3671.     Public Property HeaderColor() As Color
  3672.         Get
  3673.             Return _HeaderColor
  3674.         End Get
  3675.         Set(value As Color)
  3676.             _HeaderColor = value
  3677.         End Set
  3678.     End Property
  3679.     <Category("Colors")> _
  3680.     Public Property BaseColor() As Color
  3681.         Get
  3682.             Return _BaseColor
  3683.         End Get
  3684.         Set(value As Color)
  3685.             _BaseColor = value
  3686.         End Set
  3687.     End Property
  3688.     <Category("Colors")> _
  3689.     Public Property BorderColor() As Color
  3690.         Get
  3691.             Return _BorderColor
  3692.         End Get
  3693.         Set(value As Color)
  3694.             _BorderColor = value
  3695.         End Set
  3696.     End Property
  3697.     <Category("Colors")> _
  3698.     Public Property FlatColor() As Color
  3699.         Get
  3700.             Return _FlatColor
  3701.         End Get
  3702.         Set(value As Color)
  3703.             _FlatColor = value
  3704.         End Set
  3705.     End Property
  3706.  
  3707. #End Region
  3708.  
  3709. #Region " Options"
  3710.  
  3711.     <Category("Options")> _
  3712.     Public Property HeaderMaximize As Boolean
  3713.         Get
  3714.             Return _HeaderMaximize
  3715.         End Get
  3716.         Set(value As Boolean)
  3717.             _HeaderMaximize = value
  3718.         End Set
  3719.     End Property
  3720.  
  3721. #End Region
  3722.  
  3723.     Public Property MDColor As Color
  3724.         Get
  3725.             Return _MDcolor
  3726.         End Get
  3727.         Set(value As Color)
  3728.             _MDcolor = value
  3729.         End Set
  3730.     End Property
  3731.  
  3732.     Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
  3733.         MyBase.OnMouseDown(e)
  3734.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  3735.             Cap = True
  3736.             MousePoint = e.Location
  3737.         End If
  3738.     End Sub
  3739.  
  3740.     Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
  3741.         If HeaderMaximize Then
  3742.             If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
  3743.                 If FindForm.WindowState = FormWindowState.Normal Then
  3744.                     FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
  3745.                 ElseIf FindForm.WindowState = FormWindowState.Maximized Then
  3746.                     FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
  3747.                 End If
  3748.             End If
  3749.         End If
  3750.     End Sub
  3751.  
  3752.     Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
  3753.         MyBase.OnMouseUp(e) : Cap = False
  3754.     End Sub
  3755.  
  3756.     Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
  3757.         MyBase.OnMouseMove(e)
  3758.         If Cap Then
  3759.             Parent.Location = MousePosition - MousePoint
  3760.         End If
  3761.     End Sub
  3762.  
  3763.     Protected Overrides Sub OnCreateControl()
  3764.         MyBase.OnCreateControl()
  3765.         ParentForm.FormBorderStyle = FormBorderStyle.None
  3766.         ParentForm.AllowTransparency = False
  3767.         ParentForm.TransparencyKey = Color.Fuchsia
  3768.         ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
  3769.         Dock = DockStyle.Fill
  3770.         Invalidate()
  3771.     End Sub
  3772.  
  3773. #End Region
  3774.  
  3775. #Region " Colors"
  3776.  
  3777. #Region " Dark Colors"
  3778.  
  3779.     Private _HeaderColor As Color = Color.FromArgb(60, 200, 80)
  3780.     Private _BaseColor As Color = Color.FromArgb(60, 70, 73)
  3781.     Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
  3782.     Private TextColor As Color = Color.FromArgb(234, 234, 234)
  3783.  
  3784. #End Region
  3785.  
  3786. #Region " Light Colors"
  3787.  
  3788.     Private _HeaderLight As Color = Color.FromArgb(171, 171, 172)
  3789.     Private _BaseLight As Color = Color.FromArgb(196, 199, 200)
  3790.     Public TextLight As Color = Color.FromArgb(45, 47, 49)
  3791.  
  3792. #End Region
  3793.  
  3794. #End Region
  3795.  
  3796.     Sub New()
  3797.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
  3798.                  ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
  3799.         _MDcolor = Color.FromArgb(45, 150, 45)
  3800.         DoubleBuffered = True
  3801.         BackColor = Color.White
  3802.         Font = New Font("Segoe UI", 12)
  3803.  
  3804.     End Sub
  3805.  
  3806.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  3807.             _HeaderColor = Color.FromArgb(255, 255, 255)
  3808.             _BaseColor = Color.FromArgb(255, 255, 255)
  3809.         _BorderColor = Color.FromArgb(245, 245, 245)
  3810.  
  3811.         B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
  3812.         W = Width : H = Height
  3813.         Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 40)
  3814.  
  3815.         With G
  3816.             .SmoothingMode = 2
  3817.             .PixelOffsetMode = 2
  3818.             .TextRenderingHint = 5
  3819.             .Clear(BackColor)
  3820.  
  3821.             '-- Base
  3822.             .FillRectangle(New SolidBrush(_BaseColor), Base)
  3823.  
  3824.             '-- Header
  3825.             .FillRectangle(New SolidBrush(_HeaderColor), Header)
  3826.  
  3827.             '-- Logo
  3828.             .DrawString(Text, __Font, New SolidBrush(Color.Black), New Rectangle(20, 20, W, H), NearSF)
  3829.             .DrawString(_text, _Font, New SolidBrush(Color.DimGray), New Rectangle(W - 120, H - 15, W, H), NearSF)
  3830.             .FillRectangle(New SolidBrush(_MDcolor), New Rectangle(20, 15, 150, 5))
  3831.  
  3832.             '-- Border
  3833.             .DrawRectangle(New Pen(_BorderColor), Base)
  3834.         End With
  3835.  
  3836.         MyBase.OnPaint(e)
  3837.         G.Dispose()
  3838.         e.Graphics.InterpolationMode = 7
  3839.         e.Graphics.DrawImageUnscaled(B, 0, 0)
  3840.         B.Dispose()
  3841.     End Sub
  3842. End Class
  3843.  
  3844. #Region "ThemeBase"
  3845.  
  3846.  
  3847. '------------------
  3848. 'Creator: aeonhack
  3849. 'Site: elitevs.net
  3850. 'Created: 08/02/2011
  3851. 'Changed: 12/06/2011
  3852. 'Version: 1.5.4
  3853. '------------------
  3854.  
  3855. MustInherit Class ThemeContainer154
  3856.     Inherits ContainerControl
  3857.  
  3858. #Region " Initialization "
  3859.  
  3860.     Protected G As Graphics, B As Bitmap
  3861.  
  3862.     Sub New()
  3863.         SetStyle(DirectCast(139270, ControlStyles), True)
  3864.  
  3865.         _ImageSize = Size.Empty
  3866.         Font = New Font("Verdana", 8S)
  3867.  
  3868.         MeasureBitmap = New Bitmap(1, 1)
  3869.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  3870.  
  3871.         DrawRadialPath = New GraphicsPath
  3872.  
  3873.         InvalidateCustimization()
  3874.     End Sub
  3875.  
  3876.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  3877.         If DoneCreation Then InitializeMessages()
  3878.  
  3879.         InvalidateCustimization()
  3880.         ColorHook()
  3881.  
  3882.         If Not _LockWidth = 0 Then Width = _LockWidth
  3883.         If Not _LockHeight = 0 Then Height = _LockHeight
  3884.         If Not _ControlMode Then MyBase.Dock = DockStyle.Fill
  3885.  
  3886.         Transparent = _Transparent
  3887.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  3888.  
  3889.         MyBase.OnHandleCreated(e)
  3890.     End Sub
  3891.  
  3892.     Private DoneCreation As Boolean
  3893.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  3894.         MyBase.OnParentChanged(e)
  3895.  
  3896.         If Parent Is Nothing Then Return
  3897.         _IsParentForm = TypeOf Parent Is Form
  3898.  
  3899.         If Not _ControlMode Then
  3900.             InitializeMessages()
  3901.  
  3902.             If _IsParentForm Then
  3903.                 ParentForm.FormBorderStyle = _BorderStyle
  3904.                 ParentForm.TransparencyKey = _TransparencyKey
  3905.  
  3906.                 If Not DesignMode Then
  3907.                     AddHandler ParentForm.Shown, AddressOf FormShown
  3908.                 End If
  3909.             End If
  3910.  
  3911.             Parent.BackColor = BackColor
  3912.         End If
  3913.  
  3914.         OnCreation()
  3915.         DoneCreation = True
  3916.         InvalidateTimer()
  3917.     End Sub
  3918.  
  3919. #End Region
  3920.  
  3921.     Private Sub DoAnimation(ByVal i As Boolean)
  3922.         OnAnimation()
  3923.         If i Then Invalidate()
  3924.     End Sub
  3925.  
  3926.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  3927.         If Width = 0 OrElse Height = 0 Then Return
  3928.  
  3929.         If _Transparent AndAlso _ControlMode Then
  3930.             PaintHook()
  3931.             e.Graphics.DrawImage(B, 0, 0)
  3932.         Else
  3933.             G = e.Graphics
  3934.             PaintHook()
  3935.         End If
  3936.     End Sub
  3937.  
  3938.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  3939.         RemoveAnimationCallback(AddressOf DoAnimation)
  3940.         MyBase.OnHandleDestroyed(e)
  3941.     End Sub
  3942.  
  3943.     Private HasShown As Boolean
  3944.     Private Sub FormShown(ByVal sender As Object, ByVal e As EventArgs)
  3945.         If _ControlMode OrElse HasShown Then Return
  3946.  
  3947.         If _StartPosition = FormStartPosition.CenterParent OrElse _StartPosition = FormStartPosition.CenterScreen Then
  3948.             Dim SB As Rectangle = Screen.PrimaryScreen.Bounds
  3949.             Dim CB As Rectangle = ParentForm.Bounds
  3950.             ParentForm.Location = New Point(SB.Width \ 2 - CB.Width \ 2, SB.Height \ 2 - CB.Width \ 2)
  3951.         End If
  3952.  
  3953.         HasShown = True
  3954.     End Sub
  3955.  
  3956.  
  3957. #Region " Size Handling "
  3958.  
  3959.     Private Frame As Rectangle
  3960.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  3961.         If _Movable AndAlso Not _ControlMode Then
  3962.             Frame = New Rectangle(7, 7, Width - 14, _Header - 7)
  3963.         End If
  3964.  
  3965.         InvalidateBitmap()
  3966.         Invalidate()
  3967.  
  3968.         MyBase.OnSizeChanged(e)
  3969.     End Sub
  3970.  
  3971.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  3972.         If Not _LockWidth = 0 Then width = _LockWidth
  3973.         If Not _LockHeight = 0 Then height = _LockHeight
  3974.         MyBase.SetBoundsCore(x, y, width, height, specified)
  3975.     End Sub
  3976.  
  3977. #End Region
  3978.  
  3979. #Region " State Handling "
  3980.  
  3981.     Protected State As MouseState
  3982.     Private Sub SetState(ByVal current As MouseState)
  3983.         State = current
  3984.         Invalidate()
  3985.     End Sub
  3986.  
  3987.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  3988.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized) Then
  3989.             If _Sizable AndAlso Not _ControlMode Then InvalidateMouse()
  3990.         End If
  3991.  
  3992.         MyBase.OnMouseMove(e)
  3993.     End Sub
  3994.  
  3995.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  3996.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  3997.         MyBase.OnEnabledChanged(e)
  3998.     End Sub
  3999.  
  4000.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  4001.         SetState(MouseState.Over)
  4002.         MyBase.OnMouseEnter(e)
  4003.     End Sub
  4004.  
  4005.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  4006.         SetState(MouseState.Over)
  4007.         MyBase.OnMouseUp(e)
  4008.     End Sub
  4009.  
  4010.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  4011.         SetState(MouseState.None)
  4012.  
  4013.         If GetChildAtPoint(PointToClient(MousePosition)) IsNot Nothing Then
  4014.             If _Sizable AndAlso Not _ControlMode Then
  4015.                 Cursor = Cursors.Default
  4016.                 Previous = 0
  4017.             End If
  4018.         End If
  4019.  
  4020.         MyBase.OnMouseLeave(e)
  4021.     End Sub
  4022.  
  4023.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  4024.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  4025.  
  4026.         If Not (_IsParentForm AndAlso ParentForm.WindowState = FormWindowState.Maximized OrElse _ControlMode) Then
  4027.             If _Movable AndAlso Frame.Contains(e.Location) Then
  4028.                 If Not New Rectangle(Width - 22, 5, 15, 15).Contains(e.Location) Then
  4029.                     Capture = False
  4030.                 End If
  4031.                 WM_LMBUTTONDOWN = True
  4032.                 DefWndProc(Messages(0))
  4033.             ElseIf _Sizable AndAlso Not Previous = 0 Then
  4034.                 Capture = False
  4035.                 WM_LMBUTTONDOWN = True
  4036.                 DefWndProc(Messages(Previous))
  4037.             End If
  4038.         End If
  4039.  
  4040.         MyBase.OnMouseDown(e)
  4041.     End Sub
  4042.  
  4043.     Private WM_LMBUTTONDOWN As Boolean
  4044.     Protected Overrides Sub WndProc(ByRef m As Message)
  4045.         MyBase.WndProc(m)
  4046.  
  4047.         If WM_LMBUTTONDOWN AndAlso m.Msg = 513 Then
  4048.             WM_LMBUTTONDOWN = False
  4049.  
  4050.             SetState(MouseState.Over)
  4051.             If Not _SmartBounds Then Return
  4052.  
  4053.             If IsParentMdi Then
  4054.                 CorrectBounds(New Rectangle(Point.Empty, Parent.Parent.Size))
  4055.             Else
  4056.                 CorrectBounds(Screen.FromControl(Parent).WorkingArea)
  4057.             End If
  4058.         End If
  4059.     End Sub
  4060.  
  4061.     Private GetIndexPoint As Point
  4062.     Private B1, B2, B3, B4 As Boolean
  4063.     Private Function GetIndex() As Integer
  4064.         GetIndexPoint = PointToClient(MousePosition)
  4065.         B1 = GetIndexPoint.X < 7
  4066.         B2 = GetIndexPoint.X > Width - 7
  4067.         B3 = GetIndexPoint.Y < 7
  4068.         B4 = GetIndexPoint.Y > Height - 7
  4069.  
  4070.         If B1 AndAlso B3 Then Return 4
  4071.         If B1 AndAlso B4 Then Return 7
  4072.         If B2 AndAlso B3 Then Return 5
  4073.         If B2 AndAlso B4 Then Return 8
  4074.         If B1 Then Return 1
  4075.         If B2 Then Return 2
  4076.         If B3 Then Return 3
  4077.         If B4 Then Return 6
  4078.         Return 0
  4079.     End Function
  4080.  
  4081.     Private Current, Previous As Integer
  4082.     Private Sub InvalidateMouse()
  4083.         Current = GetIndex()
  4084.         If Current = Previous Then Return
  4085.  
  4086.         Previous = Current
  4087.         Select Case Previous
  4088.             Case 0
  4089.                 Cursor = Cursors.Default
  4090.             Case 1, 2
  4091.                 Cursor = Cursors.SizeWE
  4092.             Case 3, 6
  4093.                 Cursor = Cursors.SizeNS
  4094.             Case 4, 8
  4095.                 Cursor = Cursors.SizeNWSE
  4096.             Case 5, 7
  4097.                 Cursor = Cursors.SizeNESW
  4098.         End Select
  4099.     End Sub
  4100.  
  4101.     Private Messages(8) As Message
  4102.     Private Sub InitializeMessages()
  4103.         Messages(0) = Message.Create(Parent.Handle, 161, New IntPtr(2), IntPtr.Zero)
  4104.         For I As Integer = 1 To 8
  4105.             Messages(I) = Message.Create(Parent.Handle, 161, New IntPtr(I + 9), IntPtr.Zero)
  4106.         Next
  4107.     End Sub
  4108.  
  4109.     Private Sub CorrectBounds(ByVal bounds As Rectangle)
  4110.         If Parent.Width > bounds.Width Then Parent.Width = bounds.Width
  4111.         If Parent.Height > bounds.Height Then Parent.Height = bounds.Height
  4112.  
  4113.         Dim X As Integer = Parent.Location.X
  4114.         Dim Y As Integer = Parent.Location.Y
  4115.  
  4116.         If X < bounds.X Then X = bounds.X
  4117.         If Y < bounds.Y Then Y = bounds.Y
  4118.  
  4119.         Dim Width As Integer = bounds.X + bounds.Width
  4120.         Dim Height As Integer = bounds.Y + bounds.Height
  4121.  
  4122.         If X + Parent.Width > Width Then X = Width - Parent.Width
  4123.         If Y + Parent.Height > Height Then Y = Height - Parent.Height
  4124.  
  4125.         Parent.Location = New Point(X, Y)
  4126.     End Sub
  4127.  
  4128. #End Region
  4129.  
  4130.  
  4131. #Region " Base Properties "
  4132.  
  4133.     Overrides Property Dock As DockStyle
  4134.         Get
  4135.             Return MyBase.Dock
  4136.         End Get
  4137.         Set(ByVal value As DockStyle)
  4138.             If Not _ControlMode Then Return
  4139.             MyBase.Dock = value
  4140.         End Set
  4141.     End Property
  4142.  
  4143.     Private _BackColor As Boolean
  4144.     <Category("Misc")> _
  4145.     Overrides Property BackColor() As Color
  4146.         Get
  4147.             Return MyBase.BackColor
  4148.         End Get
  4149.         Set(ByVal value As Color)
  4150.             If value = MyBase.BackColor Then Return
  4151.  
  4152.             If Not IsHandleCreated AndAlso _ControlMode AndAlso value = Color.Transparent Then
  4153.                 _BackColor = True
  4154.                 Return
  4155.             End If
  4156.  
  4157.             MyBase.BackColor = value
  4158.             If Parent IsNot Nothing Then
  4159.                 If Not _ControlMode Then Parent.BackColor = value
  4160.                 ColorHook()
  4161.             End If
  4162.         End Set
  4163.     End Property
  4164.  
  4165.     Overrides Property MinimumSize As Size
  4166.         Get
  4167.             Return MyBase.MinimumSize
  4168.         End Get
  4169.         Set(ByVal value As Size)
  4170.             MyBase.MinimumSize = value
  4171.             If Parent IsNot Nothing Then Parent.MinimumSize = value
  4172.         End Set
  4173.     End Property
  4174.  
  4175.     Overrides Property MaximumSize As Size
  4176.         Get
  4177.             Return MyBase.MaximumSize
  4178.         End Get
  4179.         Set(ByVal value As Size)
  4180.             MyBase.MaximumSize = value
  4181.             If Parent IsNot Nothing Then Parent.MaximumSize = value
  4182.         End Set
  4183.     End Property
  4184.  
  4185.     Overrides Property Text() As String
  4186.         Get
  4187.             Return MyBase.Text
  4188.         End Get
  4189.         Set(ByVal value As String)
  4190.             MyBase.Text = value
  4191.             Invalidate()
  4192.         End Set
  4193.     End Property
  4194.  
  4195.     Overrides Property Font() As Font
  4196.         Get
  4197.             Return MyBase.Font
  4198.         End Get
  4199.         Set(ByVal value As Font)
  4200.             MyBase.Font = value
  4201.             Invalidate()
  4202.         End Set
  4203.     End Property
  4204.  
  4205.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  4206.     Overrides Property ForeColor() As Color
  4207.         Get
  4208.             Return Color.Empty
  4209.         End Get
  4210.         Set(ByVal value As Color)
  4211.         End Set
  4212.     End Property
  4213.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  4214.     Overrides Property BackgroundImage() As Image
  4215.         Get
  4216.             Return Nothing
  4217.         End Get
  4218.         Set(ByVal value As Image)
  4219.         End Set
  4220.     End Property
  4221.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  4222.     Overrides Property BackgroundImageLayout() As ImageLayout
  4223.         Get
  4224.             Return ImageLayout.None
  4225.         End Get
  4226.         Set(ByVal value As ImageLayout)
  4227.         End Set
  4228.     End Property
  4229.  
  4230. #End Region
  4231.  
  4232. #Region " Public Properties "
  4233.  
  4234.     Private _SmartBounds As Boolean = True
  4235.     Property SmartBounds() As Boolean
  4236.         Get
  4237.             Return _SmartBounds
  4238.         End Get
  4239.         Set(ByVal value As Boolean)
  4240.             _SmartBounds = value
  4241.         End Set
  4242.     End Property
  4243.  
  4244.     Private _Movable As Boolean = True
  4245.     Property Movable() As Boolean
  4246.         Get
  4247.             Return _Movable
  4248.         End Get
  4249.         Set(ByVal value As Boolean)
  4250.             _Movable = value
  4251.         End Set
  4252.     End Property
  4253.  
  4254.     Private _Sizable As Boolean = True
  4255.     Property Sizable() As Boolean
  4256.         Get
  4257.             Return _Sizable
  4258.         End Get
  4259.         Set(ByVal value As Boolean)
  4260.             _Sizable = value
  4261.         End Set
  4262.     End Property
  4263.  
  4264.     Private _TransparencyKey As Color
  4265.     Property TransparencyKey() As Color
  4266.         Get
  4267.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.TransparencyKey Else Return _TransparencyKey
  4268.         End Get
  4269.         Set(ByVal value As Color)
  4270.             If value = _TransparencyKey Then Return
  4271.             _TransparencyKey = value
  4272.  
  4273.             If _IsParentForm AndAlso Not _ControlMode Then
  4274.                 ParentForm.TransparencyKey = value
  4275.                 ColorHook()
  4276.             End If
  4277.         End Set
  4278.     End Property
  4279.  
  4280.     Private _BorderStyle As FormBorderStyle
  4281.     Property BorderStyle() As FormBorderStyle
  4282.         Get
  4283.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.FormBorderStyle Else Return _BorderStyle
  4284.         End Get
  4285.         Set(ByVal value As FormBorderStyle)
  4286.             _BorderStyle = value
  4287.  
  4288.             If _IsParentForm AndAlso Not _ControlMode Then
  4289.                 ParentForm.FormBorderStyle = value
  4290.  
  4291.                 If Not value = FormBorderStyle.None Then
  4292.                     Movable = False
  4293.                     Sizable = False
  4294.                 End If
  4295.             End If
  4296.         End Set
  4297.     End Property
  4298.  
  4299.     Private _StartPosition As FormStartPosition
  4300.     Property StartPosition As FormStartPosition
  4301.         Get
  4302.             If _IsParentForm AndAlso Not _ControlMode Then Return ParentForm.StartPosition Else Return _StartPosition
  4303.         End Get
  4304.         Set(ByVal value As FormStartPosition)
  4305.             _StartPosition = value
  4306.  
  4307.             If _IsParentForm AndAlso Not _ControlMode Then
  4308.                 ParentForm.StartPosition = value
  4309.             End If
  4310.         End Set
  4311.     End Property
  4312.  
  4313.     Private _NoRounding As Boolean
  4314.     Property NoRounding() As Boolean
  4315.         Get
  4316.             Return _NoRounding
  4317.         End Get
  4318.         Set(ByVal v As Boolean)
  4319.             _NoRounding = v
  4320.             Invalidate()
  4321.         End Set
  4322.     End Property
  4323.  
  4324.     Private _Image As Image
  4325.     Property Image() As Image
  4326.         Get
  4327.             Return _Image
  4328.         End Get
  4329.         Set(ByVal value As Image)
  4330.             If value Is Nothing Then _ImageSize = Size.Empty Else _ImageSize = value.Size
  4331.  
  4332.             _Image = value
  4333.             Invalidate()
  4334.         End Set
  4335.     End Property
  4336.  
  4337.     Private Items As New Dictionary(Of String, Color)
  4338.     Property Colors() As Bloom()
  4339.         Get
  4340.             Dim T As New List(Of Bloom)
  4341.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  4342.  
  4343.             While E.MoveNext
  4344.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  4345.             End While
  4346.  
  4347.             Return T.ToArray
  4348.         End Get
  4349.         Set(ByVal value As Bloom())
  4350.             For Each B As Bloom In value
  4351.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  4352.             Next
  4353.  
  4354.             InvalidateCustimization()
  4355.             ColorHook()
  4356.             Invalidate()
  4357.         End Set
  4358.     End Property
  4359.  
  4360.     Private _Customization As String
  4361.     Property Customization() As String
  4362.         Get
  4363.             Return _Customization
  4364.         End Get
  4365.         Set(ByVal value As String)
  4366.             If value = _Customization Then Return
  4367.  
  4368.             Dim Data As Byte()
  4369.             Dim Items As Bloom() = Colors
  4370.  
  4371.             Try
  4372.                 Data = Convert.FromBase64String(value)
  4373.                 For I As Integer = 0 To Items.Length - 1
  4374.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  4375.                 Next
  4376.             Catch
  4377.                 Return
  4378.             End Try
  4379.  
  4380.             _Customization = value
  4381.  
  4382.             Colors = Items
  4383.             ColorHook()
  4384.             Invalidate()
  4385.         End Set
  4386.     End Property
  4387.  
  4388.     Private _Transparent As Boolean
  4389.     Property Transparent() As Boolean
  4390.         Get
  4391.             Return _Transparent
  4392.         End Get
  4393.         Set(ByVal value As Boolean)
  4394.             _Transparent = value
  4395.             If Not (IsHandleCreated OrElse _ControlMode) Then Return
  4396.  
  4397.             If Not value AndAlso Not BackColor.A = 255 Then
  4398.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  4399.             End If
  4400.  
  4401.             SetStyle(ControlStyles.Opaque, Not value)
  4402.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  4403.  
  4404.             InvalidateBitmap()
  4405.             Invalidate()
  4406.         End Set
  4407.     End Property
  4408.  
  4409. #End Region
  4410.  
  4411. #Region " Private Properties "
  4412.  
  4413.     Private _ImageSize As Size
  4414.     Protected ReadOnly Property ImageSize() As Size
  4415.         Get
  4416.             Return _ImageSize
  4417.         End Get
  4418.     End Property
  4419.  
  4420.     Private _IsParentForm As Boolean
  4421.     Protected ReadOnly Property IsParentForm As Boolean
  4422.         Get
  4423.             Return _IsParentForm
  4424.         End Get
  4425.     End Property
  4426.  
  4427.     Protected ReadOnly Property IsParentMdi As Boolean
  4428.         Get
  4429.             If Parent Is Nothing Then Return False
  4430.             Return Parent.Parent IsNot Nothing
  4431.         End Get
  4432.     End Property
  4433.  
  4434.     Private _LockWidth As Integer
  4435.     Protected Property LockWidth() As Integer
  4436.         Get
  4437.             Return _LockWidth
  4438.         End Get
  4439.         Set(ByVal value As Integer)
  4440.             _LockWidth = value
  4441.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  4442.         End Set
  4443.     End Property
  4444.  
  4445.     Private _LockHeight As Integer
  4446.     Protected Property LockHeight() As Integer
  4447.         Get
  4448.             Return _LockHeight
  4449.         End Get
  4450.         Set(ByVal value As Integer)
  4451.             _LockHeight = value
  4452.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  4453.         End Set
  4454.     End Property
  4455.  
  4456.     Private _Header As Integer = 24
  4457.     Protected Property Header() As Integer
  4458.         Get
  4459.             Return _Header
  4460.         End Get
  4461.         Set(ByVal v As Integer)
  4462.             _Header = v
  4463.  
  4464.             If Not _ControlMode Then
  4465.                 Frame = New Rectangle(7, 7, Width - 14, v - 7)
  4466.                 Invalidate()
  4467.             End If
  4468.         End Set
  4469.     End Property
  4470.  
  4471.     Private _ControlMode As Boolean
  4472.     Protected Property ControlMode() As Boolean
  4473.         Get
  4474.             Return _ControlMode
  4475.         End Get
  4476.         Set(ByVal v As Boolean)
  4477.             _ControlMode = v
  4478.  
  4479.             Transparent = _Transparent
  4480.             If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  4481.  
  4482.             InvalidateBitmap()
  4483.             Invalidate()
  4484.         End Set
  4485.     End Property
  4486.  
  4487.     Private _IsAnimated As Boolean
  4488.     Protected Property IsAnimated() As Boolean
  4489.         Get
  4490.             Return _IsAnimated
  4491.         End Get
  4492.         Set(ByVal value As Boolean)
  4493.             _IsAnimated = value
  4494.             InvalidateTimer()
  4495.         End Set
  4496.     End Property
  4497.  
  4498. #End Region
  4499.  
  4500.  
  4501. #Region " Property Helpers "
  4502.  
  4503.     Protected Function GetPen(ByVal name As String) As Pen
  4504.         Return New Pen(Items(name))
  4505.     End Function
  4506.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  4507.         Return New Pen(Items(name), width)
  4508.     End Function
  4509.  
  4510.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  4511.         Return New SolidBrush(Items(name))
  4512.     End Function
  4513.  
  4514.     Protected Function GetColor(ByVal name As String) As Color
  4515.         Return Items(name)
  4516.     End Function
  4517.  
  4518.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  4519.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  4520.     End Sub
  4521.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  4522.         SetColor(name, Color.FromArgb(r, g, b))
  4523.     End Sub
  4524.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  4525.         SetColor(name, Color.FromArgb(a, r, g, b))
  4526.     End Sub
  4527.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  4528.         SetColor(name, Color.FromArgb(a, value))
  4529.     End Sub
  4530.  
  4531.     Private Sub InvalidateBitmap()
  4532.         If _Transparent AndAlso _ControlMode Then
  4533.             If Width = 0 OrElse Height = 0 Then Return
  4534.             B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  4535.             G = Graphics.FromImage(B)
  4536.         Else
  4537.             G = Nothing
  4538.             B = Nothing
  4539.         End If
  4540.     End Sub
  4541.  
  4542.     Private Sub InvalidateCustimization()
  4543.         Dim M As New MemoryStream(Items.Count * 4)
  4544.  
  4545.         For Each B As Bloom In Colors
  4546.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  4547.         Next
  4548.  
  4549.         M.Close()
  4550.         _Customization = Convert.ToBase64String(M.ToArray)
  4551.     End Sub
  4552.  
  4553.     Private Sub InvalidateTimer()
  4554.         If DesignMode OrElse Not DoneCreation Then Return
  4555.  
  4556.         If _IsAnimated Then
  4557.             AddAnimationCallback(AddressOf DoAnimation)
  4558.         Else
  4559.             RemoveAnimationCallback(AddressOf DoAnimation)
  4560.         End If
  4561.     End Sub
  4562.  
  4563. #End Region
  4564.  
  4565.  
  4566. #Region " User Hooks "
  4567.  
  4568.     Protected MustOverride Sub ColorHook()
  4569.     Protected MustOverride Sub PaintHook()
  4570.  
  4571.     Protected Overridable Sub OnCreation()
  4572.     End Sub
  4573.  
  4574.     Protected Overridable Sub OnAnimation()
  4575.     End Sub
  4576.  
  4577. #End Region
  4578.  
  4579.  
  4580. #Region " Offset "
  4581.  
  4582.     Private OffsetReturnRectangle As Rectangle
  4583.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  4584.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  4585.         Return OffsetReturnRectangle
  4586.     End Function
  4587.  
  4588.     Private OffsetReturnSize As Size
  4589.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  4590.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  4591.         Return OffsetReturnSize
  4592.     End Function
  4593.  
  4594.     Private OffsetReturnPoint As Point
  4595.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  4596.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  4597.         Return OffsetReturnPoint
  4598.     End Function
  4599.  
  4600. #End Region
  4601.  
  4602. #Region " Center "
  4603.  
  4604.     Private CenterReturn As Point
  4605.  
  4606.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  4607.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  4608.         Return CenterReturn
  4609.     End Function
  4610.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  4611.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  4612.         Return CenterReturn
  4613.     End Function
  4614.  
  4615.     Protected Function Center(ByVal child As Rectangle) As Point
  4616.         Return Center(Width, Height, child.Width, child.Height)
  4617.     End Function
  4618.     Protected Function Center(ByVal child As Size) As Point
  4619.         Return Center(Width, Height, child.Width, child.Height)
  4620.     End Function
  4621.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  4622.         Return Center(Width, Height, childWidth, childHeight)
  4623.     End Function
  4624.  
  4625.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  4626.         Return Center(p.Width, p.Height, c.Width, c.Height)
  4627.     End Function
  4628.  
  4629.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  4630.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  4631.         Return CenterReturn
  4632.     End Function
  4633.  
  4634. #End Region
  4635.  
  4636. #Region " Measure "
  4637.  
  4638.     Private MeasureBitmap As Bitmap
  4639.     Private MeasureGraphics As Graphics
  4640.  
  4641.     Protected Function Measure() As Size
  4642.         SyncLock MeasureGraphics
  4643.             Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  4644.         End SyncLock
  4645.     End Function
  4646.     Protected Function Measure(ByVal text As String) As Size
  4647.         SyncLock MeasureGraphics
  4648.             Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  4649.         End SyncLock
  4650.     End Function
  4651.  
  4652. #End Region
  4653.  
  4654.  
  4655. #Region " DrawPixel "
  4656.  
  4657.     Private DrawPixelBrush As SolidBrush
  4658.  
  4659.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  4660.         If _Transparent Then
  4661.             B.SetPixel(x, y, c1)
  4662.         Else
  4663.             DrawPixelBrush = New SolidBrush(c1)
  4664.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  4665.         End If
  4666.     End Sub
  4667.  
  4668. #End Region
  4669.  
  4670. #Region " DrawCorners "
  4671.  
  4672.     Private DrawCornersBrush As SolidBrush
  4673.  
  4674.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  4675.         DrawCorners(c1, 0, 0, Width, Height, offset)
  4676.     End Sub
  4677.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  4678.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  4679.     End Sub
  4680.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  4681.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  4682.     End Sub
  4683.  
  4684.     Protected Sub DrawCorners(ByVal c1 As Color)
  4685.         DrawCorners(c1, 0, 0, Width, Height)
  4686.     End Sub
  4687.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  4688.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  4689.     End Sub
  4690.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4691.         If _NoRounding Then Return
  4692.  
  4693.         If _Transparent Then
  4694.             B.SetPixel(x, y, c1)
  4695.             B.SetPixel(x + (width - 1), y, c1)
  4696.             B.SetPixel(x, y + (height - 1), c1)
  4697.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  4698.         Else
  4699.             DrawCornersBrush = New SolidBrush(c1)
  4700.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  4701.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  4702.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  4703.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  4704.         End If
  4705.     End Sub
  4706.  
  4707. #End Region
  4708.  
  4709. #Region " DrawBorders "
  4710.  
  4711.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  4712.         DrawBorders(p1, 0, 0, Width, Height, offset)
  4713.     End Sub
  4714.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  4715.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  4716.     End Sub
  4717.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  4718.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  4719.     End Sub
  4720.  
  4721.     Protected Sub DrawBorders(ByVal p1 As Pen)
  4722.         DrawBorders(p1, 0, 0, Width, Height)
  4723.     End Sub
  4724.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  4725.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  4726.     End Sub
  4727.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4728.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  4729.     End Sub
  4730.  
  4731. #End Region
  4732.  
  4733. #Region " DrawText "
  4734.  
  4735.     Private DrawTextPoint As Point
  4736.     Private DrawTextSize As Size
  4737.  
  4738.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  4739.         DrawText(b1, Text, a, x, y)
  4740.     End Sub
  4741.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  4742.         If text.Length = 0 Then Return
  4743.  
  4744.         DrawTextSize = Measure(text)
  4745.         DrawTextPoint = New Point(Width \ 2 - DrawTextSize.Width \ 2, Header \ 2 - DrawTextSize.Height \ 2)
  4746.  
  4747.         Select Case a
  4748.             Case HorizontalAlignment.Left
  4749.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  4750.             Case HorizontalAlignment.Center
  4751.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  4752.             Case HorizontalAlignment.Right
  4753.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  4754.         End Select
  4755.     End Sub
  4756.  
  4757.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  4758.         If Text.Length = 0 Then Return
  4759.         G.DrawString(Text, Font, b1, p1)
  4760.     End Sub
  4761.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  4762.         If Text.Length = 0 Then Return
  4763.         G.DrawString(Text, Font, b1, x, y)
  4764.     End Sub
  4765.  
  4766. #End Region
  4767.  
  4768. #Region " DrawImage "
  4769.  
  4770.     Private DrawImagePoint As Point
  4771.  
  4772.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  4773.         DrawImage(_Image, a, x, y)
  4774.     End Sub
  4775.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  4776.         If image Is Nothing Then Return
  4777.         DrawImagePoint = New Point(Width \ 2 - image.Width \ 2, Header \ 2 - image.Height \ 2)
  4778.  
  4779.         Select Case a
  4780.             Case HorizontalAlignment.Left
  4781.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  4782.             Case HorizontalAlignment.Center
  4783.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  4784.             Case HorizontalAlignment.Right
  4785.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  4786.         End Select
  4787.     End Sub
  4788.  
  4789.     Protected Sub DrawImage(ByVal p1 As Point)
  4790.         DrawImage(_Image, p1.X, p1.Y)
  4791.     End Sub
  4792.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  4793.         DrawImage(_Image, x, y)
  4794.     End Sub
  4795.  
  4796.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  4797.         DrawImage(image, p1.X, p1.Y)
  4798.     End Sub
  4799.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  4800.         If image Is Nothing Then Return
  4801.         G.DrawImage(image, x, y, image.Width, image.Height)
  4802.     End Sub
  4803.  
  4804. #End Region
  4805.  
  4806. #Region " DrawGradient "
  4807.  
  4808.     Private DrawGradientBrush As LinearGradientBrush
  4809.     Private DrawGradientRectangle As Rectangle
  4810.  
  4811.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4812.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  4813.         DrawGradient(blend, DrawGradientRectangle)
  4814.     End Sub
  4815.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  4816.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  4817.         DrawGradient(blend, DrawGradientRectangle, angle)
  4818.     End Sub
  4819.  
  4820.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  4821.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  4822.         DrawGradientBrush.InterpolationColors = blend
  4823.         G.FillRectangle(DrawGradientBrush, r)
  4824.     End Sub
  4825.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  4826.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  4827.         DrawGradientBrush.InterpolationColors = blend
  4828.         G.FillRectangle(DrawGradientBrush, r)
  4829.     End Sub
  4830.  
  4831.  
  4832.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4833.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  4834.         DrawGradient(c1, c2, DrawGradientRectangle)
  4835.     End Sub
  4836.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  4837.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  4838.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  4839.     End Sub
  4840.  
  4841.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  4842.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  4843.         G.FillRectangle(DrawGradientBrush, r)
  4844.     End Sub
  4845.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  4846.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  4847.         G.FillRectangle(DrawGradientBrush, r)
  4848.     End Sub
  4849.  
  4850. #End Region
  4851.  
  4852. #Region " DrawRadial "
  4853.  
  4854.     Private DrawRadialPath As GraphicsPath
  4855.     Private DrawRadialBrush1 As PathGradientBrush
  4856.     Private DrawRadialBrush2 As LinearGradientBrush
  4857.     Private DrawRadialRectangle As Rectangle
  4858.  
  4859.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4860.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  4861.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  4862.     End Sub
  4863.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  4864.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  4865.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  4866.     End Sub
  4867.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  4868.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  4869.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  4870.     End Sub
  4871.  
  4872.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  4873.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  4874.     End Sub
  4875.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  4876.         DrawRadial(blend, r, center.X, center.Y)
  4877.     End Sub
  4878.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  4879.         DrawRadialPath.Reset()
  4880.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  4881.  
  4882.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  4883.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  4884.         DrawRadialBrush1.InterpolationColors = blend
  4885.  
  4886.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  4887.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  4888.         Else
  4889.             G.FillEllipse(DrawRadialBrush1, r)
  4890.         End If
  4891.     End Sub
  4892.  
  4893.  
  4894.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  4895.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  4896.         DrawRadial(c1, c2, DrawGradientRectangle)
  4897.     End Sub
  4898.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  4899.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  4900.         DrawRadial(c1, c2, DrawGradientRectangle, angle)
  4901.     End Sub
  4902.  
  4903.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  4904.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  4905.         G.FillRectangle(DrawGradientBrush, r)
  4906.     End Sub
  4907.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  4908.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  4909.         G.FillEllipse(DrawGradientBrush, r)
  4910.     End Sub
  4911.  
  4912. #End Region
  4913.  
  4914. #Region " CreateRound "
  4915.  
  4916.     Private CreateRoundPath As GraphicsPath
  4917.     Private CreateRoundRectangle As Rectangle
  4918.  
  4919.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  4920.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  4921.         Return CreateRound(CreateRoundRectangle, slope)
  4922.     End Function
  4923.  
  4924.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  4925.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  4926.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  4927.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  4928.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  4929.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  4930.         CreateRoundPath.CloseFigure()
  4931.         Return CreateRoundPath
  4932.     End Function
  4933.  
  4934. #End Region
  4935.  
  4936. End Class
  4937.  
  4938. MustInherit Class ThemeControl154
  4939.     Inherits Control
  4940.  
  4941.  
  4942. #Region " Initialization "
  4943.  
  4944.     Protected G As Graphics, B As Bitmap
  4945.  
  4946.     Sub New()
  4947.         SetStyle(DirectCast(139270, ControlStyles), True)
  4948.  
  4949.         _ImageSize = Size.Empty
  4950.         Font = New Font("Verdana", 8S)
  4951.  
  4952.         MeasureBitmap = New Bitmap(1, 1)
  4953.         MeasureGraphics = Graphics.FromImage(MeasureBitmap)
  4954.  
  4955.         DrawRadialPath = New GraphicsPath
  4956.  
  4957.         InvalidateCustimization() 'Remove?
  4958.     End Sub
  4959.  
  4960.     Protected NotOverridable Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  4961.         InvalidateCustimization()
  4962.         ColorHook()
  4963.  
  4964.         If Not _LockWidth = 0 Then Width = _LockWidth
  4965.         If Not _LockHeight = 0 Then Height = _LockHeight
  4966.  
  4967.         Transparent = _Transparent
  4968.         If _Transparent AndAlso _BackColor Then BackColor = Color.Transparent
  4969.  
  4970.         MyBase.OnHandleCreated(e)
  4971.     End Sub
  4972.  
  4973.     Private DoneCreation As Boolean
  4974.     Protected NotOverridable Overrides Sub OnParentChanged(ByVal e As EventArgs)
  4975.         If Parent IsNot Nothing Then
  4976.             OnCreation()
  4977.             DoneCreation = True
  4978.             InvalidateTimer()
  4979.         End If
  4980.  
  4981.         MyBase.OnParentChanged(e)
  4982.     End Sub
  4983.  
  4984. #End Region
  4985.  
  4986.     Private Sub DoAnimation(ByVal i As Boolean)
  4987.         OnAnimation()
  4988.         If i Then Invalidate()
  4989.     End Sub
  4990.  
  4991.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  4992.         If Width = 0 OrElse Height = 0 Then Return
  4993.  
  4994.         If _Transparent Then
  4995.             PaintHook()
  4996.             e.Graphics.DrawImage(B, 0, 0)
  4997.         Else
  4998.             G = e.Graphics
  4999.             PaintHook()
  5000.         End If
  5001.     End Sub
  5002.  
  5003.     Protected Overrides Sub OnHandleDestroyed(ByVal e As EventArgs)
  5004.         RemoveAnimationCallback(AddressOf DoAnimation)
  5005.         MyBase.OnHandleDestroyed(e)
  5006.     End Sub
  5007.  
  5008. #Region " Size Handling "
  5009.  
  5010.     Protected NotOverridable Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  5011.         If _Transparent Then
  5012.             InvalidateBitmap()
  5013.         End If
  5014.  
  5015.         Invalidate()
  5016.         MyBase.OnSizeChanged(e)
  5017.     End Sub
  5018.  
  5019.     Protected Overrides Sub SetBoundsCore(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal specified As BoundsSpecified)
  5020.         If Not _LockWidth = 0 Then width = _LockWidth
  5021.         If Not _LockHeight = 0 Then height = _LockHeight
  5022.         MyBase.SetBoundsCore(x, y, width, height, specified)
  5023.     End Sub
  5024.  
  5025. #End Region
  5026.  
  5027. #Region " State Handling "
  5028.  
  5029.     Private InPosition As Boolean
  5030.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  5031.         InPosition = True
  5032.         SetState(MouseState.Over)
  5033.         MyBase.OnMouseEnter(e)
  5034.     End Sub
  5035.  
  5036.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  5037.         If InPosition Then SetState(MouseState.Over)
  5038.         MyBase.OnMouseUp(e)
  5039.     End Sub
  5040.  
  5041.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  5042.         If e.Button = Windows.Forms.MouseButtons.Left Then SetState(MouseState.Down)
  5043.         MyBase.OnMouseDown(e)
  5044.     End Sub
  5045.  
  5046.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  5047.         InPosition = False
  5048.         SetState(MouseState.None)
  5049.         MyBase.OnMouseLeave(e)
  5050.     End Sub
  5051.  
  5052.     Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
  5053.         If Enabled Then SetState(MouseState.None) Else SetState(MouseState.Block)
  5054.         MyBase.OnEnabledChanged(e)
  5055.     End Sub
  5056.  
  5057.     Protected State As MouseState
  5058.     Private Sub SetState(ByVal current As MouseState)
  5059.         State = current
  5060.         Invalidate()
  5061.     End Sub
  5062.  
  5063. #End Region
  5064.  
  5065.  
  5066. #Region " Base Properties "
  5067.  
  5068.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  5069.     Overrides Property ForeColor() As Color
  5070.         Get
  5071.             Return Color.Empty
  5072.         End Get
  5073.         Set(ByVal value As Color)
  5074.         End Set
  5075.     End Property
  5076.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  5077.     Overrides Property BackgroundImage() As Image
  5078.         Get
  5079.             Return Nothing
  5080.         End Get
  5081.         Set(ByVal value As Image)
  5082.         End Set
  5083.     End Property
  5084.     <Browsable(False), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
  5085.     Overrides Property BackgroundImageLayout() As ImageLayout
  5086.         Get
  5087.             Return ImageLayout.None
  5088.         End Get
  5089.         Set(ByVal value As ImageLayout)
  5090.         End Set
  5091.     End Property
  5092.  
  5093.     Overrides Property Text() As String
  5094.         Get
  5095.             Return MyBase.Text
  5096.         End Get
  5097.         Set(ByVal value As String)
  5098.             MyBase.Text = value
  5099.             Invalidate()
  5100.         End Set
  5101.     End Property
  5102.     Overrides Property Font() As Font
  5103.         Get
  5104.             Return MyBase.Font
  5105.         End Get
  5106.         Set(ByVal value As Font)
  5107.             MyBase.Font = value
  5108.             Invalidate()
  5109.         End Set
  5110.     End Property
  5111.  
  5112.     Private _BackColor As Boolean
  5113.     <Category("Misc")> _
  5114.     Overrides Property BackColor() As Color
  5115.         Get
  5116.             Return MyBase.BackColor
  5117.         End Get
  5118.         Set(ByVal value As Color)
  5119.             If Not IsHandleCreated AndAlso value = Color.Transparent Then
  5120.                 _BackColor = True
  5121.                 Return
  5122.             End If
  5123.  
  5124.             MyBase.BackColor = value
  5125.             If Parent IsNot Nothing Then ColorHook()
  5126.         End Set
  5127.     End Property
  5128.  
  5129. #End Region
  5130.  
  5131. #Region " Public Properties "
  5132.  
  5133.     Private _NoRounding As Boolean
  5134.     Property NoRounding() As Boolean
  5135.         Get
  5136.             Return _NoRounding
  5137.         End Get
  5138.         Set(ByVal v As Boolean)
  5139.             _NoRounding = v
  5140.             Invalidate()
  5141.         End Set
  5142.     End Property
  5143.  
  5144.     Private _Image As Image
  5145.     Property Image() As Image
  5146.         Get
  5147.             Return _Image
  5148.         End Get
  5149.         Set(ByVal value As Image)
  5150.             If value Is Nothing Then
  5151.                 _ImageSize = Size.Empty
  5152.             Else
  5153.                 _ImageSize = value.Size
  5154.             End If
  5155.  
  5156.             _Image = value
  5157.             Invalidate()
  5158.         End Set
  5159.     End Property
  5160.  
  5161.     Private _Transparent As Boolean
  5162.     Property Transparent() As Boolean
  5163.         Get
  5164.             Return _Transparent
  5165.         End Get
  5166.         Set(ByVal value As Boolean)
  5167.             _Transparent = value
  5168.             If Not IsHandleCreated Then Return
  5169.  
  5170.             If Not value AndAlso Not BackColor.A = 255 Then
  5171.                 Throw New Exception("Unable to change value to false while a transparent BackColor is in use.")
  5172.             End If
  5173.  
  5174.             SetStyle(ControlStyles.Opaque, Not value)
  5175.             SetStyle(ControlStyles.SupportsTransparentBackColor, value)
  5176.  
  5177.             If value Then InvalidateBitmap() Else B = Nothing
  5178.             Invalidate()
  5179.         End Set
  5180.     End Property
  5181.  
  5182.     Private Items As New Dictionary(Of String, Color)
  5183.     Property Colors() As Bloom()
  5184.         Get
  5185.             Dim T As New List(Of Bloom)
  5186.             Dim E As Dictionary(Of String, Color).Enumerator = Items.GetEnumerator
  5187.  
  5188.             While E.MoveNext
  5189.                 T.Add(New Bloom(E.Current.Key, E.Current.Value))
  5190.             End While
  5191.  
  5192.             Return T.ToArray
  5193.         End Get
  5194.         Set(ByVal value As Bloom())
  5195.             For Each B As Bloom In value
  5196.                 If Items.ContainsKey(B.Name) Then Items(B.Name) = B.Value
  5197.             Next
  5198.  
  5199.             InvalidateCustimization()
  5200.             ColorHook()
  5201.             Invalidate()
  5202.         End Set
  5203.     End Property
  5204.  
  5205.     Private _Customization As String
  5206.     Property Customization() As String
  5207.         Get
  5208.             Return _Customization
  5209.         End Get
  5210.         Set(ByVal value As String)
  5211.             If value = _Customization Then Return
  5212.  
  5213.             Dim Data As Byte()
  5214.             Dim Items As Bloom() = Colors
  5215.  
  5216.             Try
  5217.                 Data = Convert.FromBase64String(value)
  5218.                 For I As Integer = 0 To Items.Length - 1
  5219.                     Items(I).Value = Color.FromArgb(BitConverter.ToInt32(Data, I * 4))
  5220.                 Next
  5221.             Catch
  5222.                 Return
  5223.             End Try
  5224.  
  5225.             _Customization = value
  5226.  
  5227.             Colors = Items
  5228.             ColorHook()
  5229.             Invalidate()
  5230.         End Set
  5231.     End Property
  5232.  
  5233. #End Region
  5234.  
  5235. #Region " Private Properties "
  5236.  
  5237.     Private _ImageSize As Size
  5238.     Protected ReadOnly Property ImageSize() As Size
  5239.         Get
  5240.             Return _ImageSize
  5241.         End Get
  5242.     End Property
  5243.  
  5244.     Private _LockWidth As Integer
  5245.     Protected Property LockWidth() As Integer
  5246.         Get
  5247.             Return _LockWidth
  5248.         End Get
  5249.         Set(ByVal value As Integer)
  5250.             _LockWidth = value
  5251.             If Not LockWidth = 0 AndAlso IsHandleCreated Then Width = LockWidth
  5252.         End Set
  5253.     End Property
  5254.  
  5255.     Private _LockHeight As Integer
  5256.     Protected Property LockHeight() As Integer
  5257.         Get
  5258.             Return _LockHeight
  5259.         End Get
  5260.         Set(ByVal value As Integer)
  5261.             _LockHeight = value
  5262.             If Not LockHeight = 0 AndAlso IsHandleCreated Then Height = LockHeight
  5263.         End Set
  5264.     End Property
  5265.  
  5266.     Private _IsAnimated As Boolean
  5267.     Protected Property IsAnimated() As Boolean
  5268.         Get
  5269.             Return _IsAnimated
  5270.         End Get
  5271.         Set(ByVal value As Boolean)
  5272.             _IsAnimated = value
  5273.             InvalidateTimer()
  5274.         End Set
  5275.     End Property
  5276.  
  5277. #End Region
  5278.  
  5279.  
  5280. #Region " Property Helpers "
  5281.  
  5282.     Protected Function GetPen(ByVal name As String) As Pen
  5283.         Return New Pen(Items(name))
  5284.     End Function
  5285.     Protected Function GetPen(ByVal name As String, ByVal width As Single) As Pen
  5286.         Return New Pen(Items(name), width)
  5287.     End Function
  5288.  
  5289.     Protected Function GetBrush(ByVal name As String) As SolidBrush
  5290.         Return New SolidBrush(Items(name))
  5291.     End Function
  5292.  
  5293.     Protected Function GetColor(ByVal name As String) As Color
  5294.         Return Items(name)
  5295.     End Function
  5296.  
  5297.     Protected Sub SetColor(ByVal name As String, ByVal value As Color)
  5298.         If Items.ContainsKey(name) Then Items(name) = value Else Items.Add(name, value)
  5299.     End Sub
  5300.     Protected Sub SetColor(ByVal name As String, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  5301.         SetColor(name, Color.FromArgb(r, g, b))
  5302.     End Sub
  5303.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal r As Byte, ByVal g As Byte, ByVal b As Byte)
  5304.         SetColor(name, Color.FromArgb(a, r, g, b))
  5305.     End Sub
  5306.     Protected Sub SetColor(ByVal name As String, ByVal a As Byte, ByVal value As Color)
  5307.         SetColor(name, Color.FromArgb(a, value))
  5308.     End Sub
  5309.  
  5310.     Private Sub InvalidateBitmap()
  5311.         If Width = 0 OrElse Height = 0 Then Return
  5312.         B = New Bitmap(Width, Height, PixelFormat.Format32bppPArgb)
  5313.         G = Graphics.FromImage(B)
  5314.     End Sub
  5315.  
  5316.     Private Sub InvalidateCustimization()
  5317.         Dim M As New MemoryStream(Items.Count * 4)
  5318.  
  5319.         For Each B As Bloom In Colors
  5320.             M.Write(BitConverter.GetBytes(B.Value.ToArgb), 0, 4)
  5321.         Next
  5322.  
  5323.         M.Close()
  5324.         _Customization = Convert.ToBase64String(M.ToArray)
  5325.     End Sub
  5326.  
  5327.     Private Sub InvalidateTimer()
  5328.         If DesignMode OrElse Not DoneCreation Then Return
  5329.  
  5330.         If _IsAnimated Then
  5331.             AddAnimationCallback(AddressOf DoAnimation)
  5332.         Else
  5333.             RemoveAnimationCallback(AddressOf DoAnimation)
  5334.         End If
  5335.     End Sub
  5336. #End Region
  5337.  
  5338.  
  5339. #Region " User Hooks "
  5340.  
  5341.     Protected MustOverride Sub ColorHook()
  5342.     Protected MustOverride Sub PaintHook()
  5343.  
  5344.     Protected Overridable Sub OnCreation()
  5345.     End Sub
  5346.  
  5347.     Protected Overridable Sub OnAnimation()
  5348.     End Sub
  5349.  
  5350. #End Region
  5351.  
  5352.  
  5353. #Region " Offset "
  5354.  
  5355.     Private OffsetReturnRectangle As Rectangle
  5356.     Protected Function Offset(ByVal r As Rectangle, ByVal amount As Integer) As Rectangle
  5357.         OffsetReturnRectangle = New Rectangle(r.X + amount, r.Y + amount, r.Width - (amount * 2), r.Height - (amount * 2))
  5358.         Return OffsetReturnRectangle
  5359.     End Function
  5360.  
  5361.     Private OffsetReturnSize As Size
  5362.     Protected Function Offset(ByVal s As Size, ByVal amount As Integer) As Size
  5363.         OffsetReturnSize = New Size(s.Width + amount, s.Height + amount)
  5364.         Return OffsetReturnSize
  5365.     End Function
  5366.  
  5367.     Private OffsetReturnPoint As Point
  5368.     Protected Function Offset(ByVal p As Point, ByVal amount As Integer) As Point
  5369.         OffsetReturnPoint = New Point(p.X + amount, p.Y + amount)
  5370.         Return OffsetReturnPoint
  5371.     End Function
  5372.  
  5373. #End Region
  5374.  
  5375. #Region " Center "
  5376.  
  5377.     Private CenterReturn As Point
  5378.  
  5379.     Protected Function Center(ByVal p As Rectangle, ByVal c As Rectangle) As Point
  5380.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X + c.X, (p.Height \ 2 - c.Height \ 2) + p.Y + c.Y)
  5381.         Return CenterReturn
  5382.     End Function
  5383.     Protected Function Center(ByVal p As Rectangle, ByVal c As Size) As Point
  5384.         CenterReturn = New Point((p.Width \ 2 - c.Width \ 2) + p.X, (p.Height \ 2 - c.Height \ 2) + p.Y)
  5385.         Return CenterReturn
  5386.     End Function
  5387.  
  5388.     Protected Function Center(ByVal child As Rectangle) As Point
  5389.         Return Center(Width, Height, child.Width, child.Height)
  5390.     End Function
  5391.     Protected Function Center(ByVal child As Size) As Point
  5392.         Return Center(Width, Height, child.Width, child.Height)
  5393.     End Function
  5394.     Protected Function Center(ByVal childWidth As Integer, ByVal childHeight As Integer) As Point
  5395.         Return Center(Width, Height, childWidth, childHeight)
  5396.     End Function
  5397.  
  5398.     Protected Function Center(ByVal p As Size, ByVal c As Size) As Point
  5399.         Return Center(p.Width, p.Height, c.Width, c.Height)
  5400.     End Function
  5401.  
  5402.     Protected Function Center(ByVal pWidth As Integer, ByVal pHeight As Integer, ByVal cWidth As Integer, ByVal cHeight As Integer) As Point
  5403.         CenterReturn = New Point(pWidth \ 2 - cWidth \ 2, pHeight \ 2 - cHeight \ 2)
  5404.         Return CenterReturn
  5405.     End Function
  5406.  
  5407. #End Region
  5408.  
  5409. #Region " Measure "
  5410.  
  5411.     Private MeasureBitmap As Bitmap
  5412.     Private MeasureGraphics As Graphics 'TODO: Potential issues during multi-threading.
  5413.  
  5414.     Protected Function Measure() As Size
  5415.         Return MeasureGraphics.MeasureString(Text, Font, Width).ToSize
  5416.     End Function
  5417.     Protected Function Measure(ByVal text As String) As Size
  5418.         Return MeasureGraphics.MeasureString(text, Font, Width).ToSize
  5419.     End Function
  5420.  
  5421. #End Region
  5422.  
  5423.  
  5424. #Region " DrawPixel "
  5425.  
  5426.     Private DrawPixelBrush As SolidBrush
  5427.  
  5428.     Protected Sub DrawPixel(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer)
  5429.         If _Transparent Then
  5430.             B.SetPixel(x, y, c1)
  5431.         Else
  5432.             DrawPixelBrush = New SolidBrush(c1)
  5433.             G.FillRectangle(DrawPixelBrush, x, y, 1, 1)
  5434.         End If
  5435.     End Sub
  5436.  
  5437. #End Region
  5438.  
  5439. #Region " DrawCorners "
  5440.  
  5441.     Private DrawCornersBrush As SolidBrush
  5442.  
  5443.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal offset As Integer)
  5444.         DrawCorners(c1, 0, 0, Width, Height, offset)
  5445.     End Sub
  5446.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle, ByVal offset As Integer)
  5447.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height, offset)
  5448.     End Sub
  5449.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  5450.         DrawCorners(c1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  5451.     End Sub
  5452.  
  5453.     Protected Sub DrawCorners(ByVal c1 As Color)
  5454.         DrawCorners(c1, 0, 0, Width, Height)
  5455.     End Sub
  5456.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal r1 As Rectangle)
  5457.         DrawCorners(c1, r1.X, r1.Y, r1.Width, r1.Height)
  5458.     End Sub
  5459.     Protected Sub DrawCorners(ByVal c1 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5460.         If _NoRounding Then Return
  5461.  
  5462.         If _Transparent Then
  5463.             B.SetPixel(x, y, c1)
  5464.             B.SetPixel(x + (width - 1), y, c1)
  5465.             B.SetPixel(x, y + (height - 1), c1)
  5466.             B.SetPixel(x + (width - 1), y + (height - 1), c1)
  5467.         Else
  5468.             DrawCornersBrush = New SolidBrush(c1)
  5469.             G.FillRectangle(DrawCornersBrush, x, y, 1, 1)
  5470.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y, 1, 1)
  5471.             G.FillRectangle(DrawCornersBrush, x, y + (height - 1), 1, 1)
  5472.             G.FillRectangle(DrawCornersBrush, x + (width - 1), y + (height - 1), 1, 1)
  5473.         End If
  5474.     End Sub
  5475.  
  5476. #End Region
  5477.  
  5478. #Region " DrawBorders "
  5479.  
  5480.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal offset As Integer)
  5481.         DrawBorders(p1, 0, 0, Width, Height, offset)
  5482.     End Sub
  5483.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle, ByVal offset As Integer)
  5484.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height, offset)
  5485.     End Sub
  5486.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal offset As Integer)
  5487.         DrawBorders(p1, x + offset, y + offset, width - (offset * 2), height - (offset * 2))
  5488.     End Sub
  5489.  
  5490.     Protected Sub DrawBorders(ByVal p1 As Pen)
  5491.         DrawBorders(p1, 0, 0, Width, Height)
  5492.     End Sub
  5493.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal r As Rectangle)
  5494.         DrawBorders(p1, r.X, r.Y, r.Width, r.Height)
  5495.     End Sub
  5496.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5497.         G.DrawRectangle(p1, x, y, width - 1, height - 1)
  5498.     End Sub
  5499.  
  5500. #End Region
  5501.  
  5502. #Region " DrawText "
  5503.  
  5504.     Private DrawTextPoint As Point
  5505.     Private DrawTextSize As Size
  5506.  
  5507.     Protected Sub DrawText(ByVal b1 As Brush, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  5508.         DrawText(b1, Text, a, x, y)
  5509.     End Sub
  5510.     Protected Sub DrawText(ByVal b1 As Brush, ByVal text As String, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  5511.         If text.Length = 0 Then Return
  5512.  
  5513.         DrawTextSize = Measure(text)
  5514.         DrawTextPoint = Center(DrawTextSize)
  5515.  
  5516.         Select Case a
  5517.             Case HorizontalAlignment.Left
  5518.                 G.DrawString(text, Font, b1, x, DrawTextPoint.Y + y)
  5519.             Case HorizontalAlignment.Center
  5520.                 G.DrawString(text, Font, b1, DrawTextPoint.X + x, DrawTextPoint.Y + y)
  5521.             Case HorizontalAlignment.Right
  5522.                 G.DrawString(text, Font, b1, Width - DrawTextSize.Width - x, DrawTextPoint.Y + y)
  5523.         End Select
  5524.     End Sub
  5525.  
  5526.     Protected Sub DrawText(ByVal b1 As Brush, ByVal p1 As Point)
  5527.         If Text.Length = 0 Then Return
  5528.         G.DrawString(Text, Font, b1, p1)
  5529.     End Sub
  5530.     Protected Sub DrawText(ByVal b1 As Brush, ByVal x As Integer, ByVal y As Integer)
  5531.         If Text.Length = 0 Then Return
  5532.         G.DrawString(Text, Font, b1, x, y)
  5533.     End Sub
  5534.  
  5535. #End Region
  5536.  
  5537. #Region " DrawImage "
  5538.  
  5539.     Private DrawImagePoint As Point
  5540.  
  5541.     Protected Sub DrawImage(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  5542.         DrawImage(_Image, a, x, y)
  5543.     End Sub
  5544.     Protected Sub DrawImage(ByVal image As Image, ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  5545.         If image Is Nothing Then Return
  5546.         DrawImagePoint = Center(image.Size)
  5547.  
  5548.         Select Case a
  5549.             Case HorizontalAlignment.Left
  5550.                 G.DrawImage(image, x, DrawImagePoint.Y + y, image.Width, image.Height)
  5551.             Case HorizontalAlignment.Center
  5552.                 G.DrawImage(image, DrawImagePoint.X + x, DrawImagePoint.Y + y, image.Width, image.Height)
  5553.             Case HorizontalAlignment.Right
  5554.                 G.DrawImage(image, Width - image.Width - x, DrawImagePoint.Y + y, image.Width, image.Height)
  5555.         End Select
  5556.     End Sub
  5557.  
  5558.     Protected Sub DrawImage(ByVal p1 As Point)
  5559.         DrawImage(_Image, p1.X, p1.Y)
  5560.     End Sub
  5561.     Protected Sub DrawImage(ByVal x As Integer, ByVal y As Integer)
  5562.         DrawImage(_Image, x, y)
  5563.     End Sub
  5564.  
  5565.     Protected Sub DrawImage(ByVal image As Image, ByVal p1 As Point)
  5566.         DrawImage(image, p1.X, p1.Y)
  5567.     End Sub
  5568.     Protected Sub DrawImage(ByVal image As Image, ByVal x As Integer, ByVal y As Integer)
  5569.         If image Is Nothing Then Return
  5570.         G.DrawImage(image, x, y, image.Width, image.Height)
  5571.     End Sub
  5572.  
  5573. #End Region
  5574.  
  5575. #Region " DrawGradient "
  5576.  
  5577.     Private DrawGradientBrush As LinearGradientBrush
  5578.     Private DrawGradientRectangle As Rectangle
  5579.  
  5580.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5581.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  5582.         DrawGradient(blend, DrawGradientRectangle)
  5583.     End Sub
  5584.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  5585.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  5586.         DrawGradient(blend, DrawGradientRectangle, angle)
  5587.     End Sub
  5588.  
  5589.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle)
  5590.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, 90.0F)
  5591.         DrawGradientBrush.InterpolationColors = blend
  5592.         G.FillRectangle(DrawGradientBrush, r)
  5593.     End Sub
  5594.     Protected Sub DrawGradient(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal angle As Single)
  5595.         DrawGradientBrush = New LinearGradientBrush(r, Color.Empty, Color.Empty, angle)
  5596.         DrawGradientBrush.InterpolationColors = blend
  5597.         G.FillRectangle(DrawGradientBrush, r)
  5598.     End Sub
  5599.  
  5600.  
  5601.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5602.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  5603.         DrawGradient(c1, c2, DrawGradientRectangle)
  5604.     End Sub
  5605.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  5606.         DrawGradientRectangle = New Rectangle(x, y, width, height)
  5607.         DrawGradient(c1, c2, DrawGradientRectangle, angle)
  5608.     End Sub
  5609.  
  5610.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  5611.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, 90.0F)
  5612.         G.FillRectangle(DrawGradientBrush, r)
  5613.     End Sub
  5614.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  5615.         DrawGradientBrush = New LinearGradientBrush(r, c1, c2, angle)
  5616.         G.FillRectangle(DrawGradientBrush, r)
  5617.     End Sub
  5618.  
  5619. #End Region
  5620.  
  5621. #Region " DrawRadial "
  5622.  
  5623.     Private DrawRadialPath As GraphicsPath
  5624.     Private DrawRadialBrush1 As PathGradientBrush
  5625.     Private DrawRadialBrush2 As LinearGradientBrush
  5626.     Private DrawRadialRectangle As Rectangle
  5627.  
  5628.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5629.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  5630.         DrawRadial(blend, DrawRadialRectangle, width \ 2, height \ 2)
  5631.     End Sub
  5632.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal center As Point)
  5633.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  5634.         DrawRadial(blend, DrawRadialRectangle, center.X, center.Y)
  5635.     End Sub
  5636.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cx As Integer, ByVal cy As Integer)
  5637.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  5638.         DrawRadial(blend, DrawRadialRectangle, cx, cy)
  5639.     End Sub
  5640.  
  5641.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle)
  5642.         DrawRadial(blend, r, r.Width \ 2, r.Height \ 2)
  5643.     End Sub
  5644.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal center As Point)
  5645.         DrawRadial(blend, r, center.X, center.Y)
  5646.     End Sub
  5647.     Sub DrawRadial(ByVal blend As ColorBlend, ByVal r As Rectangle, ByVal cx As Integer, ByVal cy As Integer)
  5648.         DrawRadialPath.Reset()
  5649.         DrawRadialPath.AddEllipse(r.X, r.Y, r.Width - 1, r.Height - 1)
  5650.  
  5651.         DrawRadialBrush1 = New PathGradientBrush(DrawRadialPath)
  5652.         DrawRadialBrush1.CenterPoint = New Point(r.X + cx, r.Y + cy)
  5653.         DrawRadialBrush1.InterpolationColors = blend
  5654.  
  5655.         If G.SmoothingMode = SmoothingMode.AntiAlias Then
  5656.             G.FillEllipse(DrawRadialBrush1, r.X + 1, r.Y + 1, r.Width - 3, r.Height - 3)
  5657.         Else
  5658.             G.FillEllipse(DrawRadialBrush1, r)
  5659.         End If
  5660.     End Sub
  5661.  
  5662.  
  5663.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  5664.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  5665.         DrawRadial(c1, c2, DrawRadialRectangle)
  5666.     End Sub
  5667.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  5668.         DrawRadialRectangle = New Rectangle(x, y, width, height)
  5669.         DrawRadial(c1, c2, DrawRadialRectangle, angle)
  5670.     End Sub
  5671.  
  5672.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  5673.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, 90.0F)
  5674.         G.FillEllipse(DrawRadialBrush2, r)
  5675.     End Sub
  5676.     Protected Sub DrawRadial(ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle, ByVal angle As Single)
  5677.         DrawRadialBrush2 = New LinearGradientBrush(r, c1, c2, angle)
  5678.         G.FillEllipse(DrawRadialBrush2, r)
  5679.     End Sub
  5680.  
  5681. #End Region
  5682.  
  5683. #Region " CreateRound "
  5684.  
  5685.     Private CreateRoundPath As GraphicsPath
  5686.     Private CreateRoundRectangle As Rectangle
  5687.  
  5688.     Function CreateRound(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal slope As Integer) As GraphicsPath
  5689.         CreateRoundRectangle = New Rectangle(x, y, width, height)
  5690.         Return CreateRound(CreateRoundRectangle, slope)
  5691.     End Function
  5692.  
  5693.     Function CreateRound(ByVal r As Rectangle, ByVal slope As Integer) As GraphicsPath
  5694.         CreateRoundPath = New GraphicsPath(FillMode.Winding)
  5695.         CreateRoundPath.AddArc(r.X, r.Y, slope, slope, 180.0F, 90.0F)
  5696.         CreateRoundPath.AddArc(r.Right - slope, r.Y, slope, slope, 270.0F, 90.0F)
  5697.         CreateRoundPath.AddArc(r.Right - slope, r.Bottom - slope, slope, slope, 0.0F, 90.0F)
  5698.         CreateRoundPath.AddArc(r.X, r.Bottom - slope, slope, slope, 90.0F, 90.0F)
  5699.         CreateRoundPath.CloseFigure()
  5700.         Return CreateRoundPath
  5701.     End Function
  5702.  
  5703. #End Region
  5704.  
  5705. End Class
  5706.  
  5707. Module ThemeShare
  5708.  
  5709. #Region " Animation "
  5710.  
  5711.     Private Frames As Integer
  5712.     Private Invalidate As Boolean
  5713.     Public ThemeTimer As New PrecisionTimer
  5714.  
  5715.     Private Const FPS As Integer = 50 '1000 / 50 = 20 FPS
  5716.     Private Const Rate As Integer = 10
  5717.  
  5718.     Public Delegate Sub AnimationDelegate(ByVal invalidate As Boolean)
  5719.  
  5720.     Private Callbacks As New List(Of AnimationDelegate)
  5721.  
  5722.     Private Sub HandleCallbacks(ByVal state As IntPtr, ByVal reserve As Boolean)
  5723.         Invalidate = (Frames >= FPS)
  5724.         If Invalidate Then Frames = 0
  5725.  
  5726.         SyncLock Callbacks
  5727.             For I As Integer = 0 To Callbacks.Count - 1
  5728.                 Callbacks(I).Invoke(Invalidate)
  5729.             Next
  5730.         End SyncLock
  5731.  
  5732.         Frames += Rate
  5733.     End Sub
  5734.  
  5735.     Private Sub InvalidateThemeTimer()
  5736.         If Callbacks.Count = 0 Then
  5737.             ThemeTimer.Delete()
  5738.         Else
  5739.             ThemeTimer.Create(0, Rate, AddressOf HandleCallbacks)
  5740.         End If
  5741.     End Sub
  5742.  
  5743.     Sub AddAnimationCallback(ByVal callback As AnimationDelegate)
  5744.         SyncLock Callbacks
  5745.             If Callbacks.Contains(callback) Then Return
  5746.  
  5747.             Callbacks.Add(callback)
  5748.             InvalidateThemeTimer()
  5749.         End SyncLock
  5750.     End Sub
  5751.  
  5752.     Sub RemoveAnimationCallback(ByVal callback As AnimationDelegate)
  5753.         SyncLock Callbacks
  5754.             If Not Callbacks.Contains(callback) Then Return
  5755.  
  5756.             Callbacks.Remove(callback)
  5757.             InvalidateThemeTimer()
  5758.         End SyncLock
  5759.     End Sub
  5760.  
  5761. #End Region
  5762.  
  5763. End Module
  5764.  
  5765.  
  5766. Structure Bloom
  5767.  
  5768.     Public _Name As String
  5769.     ReadOnly Property Name() As String
  5770.         Get
  5771.             Return _Name
  5772.         End Get
  5773.     End Property
  5774.  
  5775.     Private _Value As Color
  5776.     Property Value() As Color
  5777.         Get
  5778.             Return _Value
  5779.         End Get
  5780.         Set(ByVal value As Color)
  5781.             _Value = value
  5782.         End Set
  5783.     End Property
  5784.  
  5785.     Property ValueHex() As String
  5786.         Get
  5787.             Return String.Concat("#", _
  5788.             _Value.R.ToString("X2", Nothing), _
  5789.             _Value.G.ToString("X2", Nothing), _
  5790.             _Value.B.ToString("X2", Nothing))
  5791.         End Get
  5792.         Set(ByVal value As String)
  5793.             Try
  5794.                 _Value = ColorTranslator.FromHtml(value)
  5795.             Catch
  5796.                 Return
  5797.             End Try
  5798.         End Set
  5799.     End Property
  5800.  
  5801.  
  5802.     Sub New(ByVal name As String, ByVal value As Color)
  5803.         _Name = name
  5804.         _Value = value
  5805.     End Sub
  5806. End Structure
  5807.  
  5808. '------------------
  5809. 'Creator: aeonhack
  5810. 'Site: elitevs.net
  5811. 'Created: 11/30/2011
  5812. 'Changed: 11/30/2011
  5813. 'Version: 1.0.0
  5814. '------------------
  5815. Class PrecisionTimer
  5816.     Implements IDisposable
  5817.  
  5818.     Private _Enabled As Boolean
  5819.     ReadOnly Property Enabled() As Boolean
  5820.         Get
  5821.             Return _Enabled
  5822.         End Get
  5823.     End Property
  5824.  
  5825.     Private Handle As IntPtr
  5826.     Private TimerCallback As TimerDelegate
  5827.  
  5828.     <DllImport("kernel32.dll", EntryPoint:="CreateTimerQueueTimer")> _
  5829.     Private Shared Function CreateTimerQueueTimer( _
  5830.     ByRef handle As IntPtr, _
  5831.     ByVal queue As IntPtr, _
  5832.     ByVal callback As TimerDelegate, _
  5833.     ByVal state As IntPtr, _
  5834.     ByVal dueTime As UInteger, _
  5835.     ByVal period As UInteger, _
  5836.     ByVal flags As UInteger) As Boolean
  5837.     End Function
  5838.  
  5839.     <DllImport("kernel32.dll", EntryPoint:="DeleteTimerQueueTimer")> _
  5840.     Private Shared Function DeleteTimerQueueTimer( _
  5841.     ByVal queue As IntPtr, _
  5842.     ByVal handle As IntPtr, _
  5843.     ByVal callback As IntPtr) As Boolean
  5844.     End Function
  5845.  
  5846.     Delegate Sub TimerDelegate(ByVal r1 As IntPtr, ByVal r2 As Boolean)
  5847.  
  5848.     Sub Create(ByVal dueTime As UInteger, ByVal period As UInteger, ByVal callback As TimerDelegate)
  5849.         If _Enabled Then Return
  5850.  
  5851.         TimerCallback = callback
  5852.         Dim Success As Boolean = CreateTimerQueueTimer(Handle, IntPtr.Zero, TimerCallback, IntPtr.Zero, dueTime, period, 0)
  5853.  
  5854.         If Not Success Then ThrowNewException("CreateTimerQueueTimer")
  5855.         _Enabled = Success
  5856.     End Sub
  5857.  
  5858.     Sub Delete()
  5859.         If Not _Enabled Then Return
  5860.         Dim Success As Boolean = DeleteTimerQueueTimer(IntPtr.Zero, Handle, IntPtr.Zero)
  5861.  
  5862.         If Not Success AndAlso Not Marshal.GetLastWin32Error = 997 Then
  5863.             ThrowNewException("DeleteTimerQueueTimer")
  5864.         End If
  5865.  
  5866.         _Enabled = Not Success
  5867.     End Sub
  5868.  
  5869.     Private Sub ThrowNewException(ByVal name As String)
  5870.         Throw New Exception(String.Format("{0} failed. Win32Error: {1}", name, Marshal.GetLastWin32Error))
  5871.     End Sub
  5872.  
  5873.     Public Sub Dispose() Implements IDisposable.Dispose
  5874.         Delete()
  5875.     End Sub
  5876. End Class
  5877. #End Region
  5878.  
  5879. Class MDSimpleButton
  5880.     Inherits ThemeControl154
  5881.  
  5882.     Sub New()
  5883.         Font = New Font("Segoe UI", 9)
  5884.         SetColor("Gradient top normal", 237, 237, 237)
  5885.         SetColor("Gradient top over", 242, 242, 242)
  5886.         SetColor("Gradient top down", 235, 235, 235)
  5887.         SetColor("Gradient bottom normal", 230, 230, 230)
  5888.         SetColor("Gradient bottom over", 235, 235, 235)
  5889.         SetColor("Gradient bottom down", 223, 223, 223)
  5890.         SetColor("Border", 167, 167, 167)
  5891.         SetColor("Text normal", 60, 60, 60)
  5892.         SetColor("Text down/over", 20, 20, 20)
  5893.         SetColor("Text disabled", Color.Gray)
  5894.     End Sub
  5895.  
  5896.     Dim GTN, GTO, GTD, GBN, GBO, GBD, Bo, TN, TD, TDO As Color
  5897.     Protected Overrides Sub ColorHook()
  5898.         GTN = GetColor("Gradient top normal")
  5899.         GTO = GetColor("Gradient top over")
  5900.         GTD = GetColor("Gradient top down")
  5901.         GBN = GetColor("Gradient bottom normal")
  5902.         GBO = GetColor("Gradient bottom over")
  5903.         GBD = GetColor("Gradient bottom down")
  5904.         Bo = GetColor("Border")
  5905.         TN = GetColor("Text normal")
  5906.         TDO = GetColor("Text down/over")
  5907.         TD = GetColor("Text disabled")
  5908.     End Sub
  5909.  
  5910.     Protected Overrides Sub PaintHook()
  5911.         G.Clear(BackColor)
  5912.         Dim LGB As LinearGradientBrush
  5913.         G.SmoothingMode = SmoothingMode.HighQuality
  5914.  
  5915.  
  5916.         Select Case State
  5917.             Case MouseState.None
  5918.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), GTN, GBN, 90.0F)
  5919.             Case MouseState.Over
  5920.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), GTO, GBO, 90.0F)
  5921.             Case Else
  5922.                 LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), GTD, GBD, 90.0F)
  5923.         End Select
  5924.  
  5925.         If Not Enabled Then
  5926.             LGB = New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height - 1), GTN, GBN, 90.0F)
  5927.         End If
  5928.  
  5929.         Dim buttonpath As GraphicsPath = CreateRound(Rectangle.Round(LGB.Rectangle), 3)
  5930.         G.FillPath(LGB, CreateRound(Rectangle.Round(LGB.Rectangle), 3))
  5931.         If Not Enabled Then G.FillPath(New SolidBrush(Color.FromArgb(50, Color.White)), CreateRound(Rectangle.Round(LGB.Rectangle), 3))
  5932.         G.SetClip(buttonpath)
  5933.         LGB = New LinearGradientBrush(New Rectangle(0, 0, Width, Height / 6), Color.FromArgb(80, Color.White), Color.Transparent, 90.0F)
  5934.         G.FillRectangle(LGB, Rectangle.Round(LGB.Rectangle))
  5935.  
  5936.  
  5937.  
  5938.         G.ResetClip()
  5939.         G.DrawPath(New Pen(Bo), buttonpath)
  5940.  
  5941.         If Enabled Then
  5942.             Select Case State
  5943.                 Case MouseState.None
  5944.                     DrawText(New SolidBrush(TN), HorizontalAlignment.Center, 1, 0)
  5945.                 Case Else
  5946.                     DrawText(New SolidBrush(TDO), HorizontalAlignment.Center, 1, 0)
  5947.             End Select
  5948.         Else
  5949.             DrawText(New SolidBrush(TD), HorizontalAlignment.Center, 1, 0)
  5950.         End If
  5951.     End Sub
  5952. End Class
  5953.  
  5954. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement