Advertisement
imaking31

Metrodisk 1.0.6

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