SaketSaket

Butterscotch Theme HF

Aug 16th, 2014
4,710
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 64.96 KB | None | 0 0
  1. Option Strict On
  2.  
  3. Imports System.Drawing.Drawing2D
  4. Imports System.Drawing.Text
  5.  
  6. '<info>
  7. ' --------------------Butterscotch Theme--------------------
  8. ' Creator - SaketSaket (HF)
  9. ' UID - 1869668
  10. ' Inspiration & Credits to all Theme creators of HF
  11. ' Version - 1.0
  12. ' Date Created - 14st August 2014
  13. ' Date Modified - 17th August 2014
  14. '
  15. '
  16. 'Special Thanks to Aeonhack for RoundRect Functions...
  17. 'Special Thanks to Mephobia's for NoiseBrush Functions...
  18. 'AlertBox Control idea taken from iSynthesis' Flat UI theme
  19. '
  20. '
  21. ' For bugs & Constructive Criticism contact me on HF
  22. ' If you like it & want to DONATE then pm me on HF
  23. ' --------------------Butterscotch Theme--------------------
  24. '<info>
  25.  
  26. 'Please Leave Credits in Source, Do not redistribute
  27.  
  28. Enum MouseState As Byte
  29.     None = 0
  30.     Over = 1
  31.     Down = 2
  32. End Enum
  33.  
  34. Module Draw
  35.     'Special Thanks to Aeonhack for RoundRect Functions... ;)
  36.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  37.         Dim p As GraphicsPath = New GraphicsPath()
  38.         Dim arcRectangleWidth As Integer = curve * 2
  39.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  40.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  41.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  42.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  43.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  44.         Return p
  45.     End Function
  46.     Public Function RoundRect(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal curve As Integer) As GraphicsPath
  47.         Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  48.         Dim p As GraphicsPath = New GraphicsPath()
  49.         Dim arcRectangleWidth As Integer = curve * 2
  50.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  51.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  52.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  53.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  54.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  55.         Return p
  56.     End Function
  57.  
  58.     'Special Thanks to Mephobia's for NoiseBrush Functions...
  59.     Function NoiseBrush(colors As Color()) As TextureBrush
  60.         Dim b As New Bitmap(128, 128)
  61.         Dim r As New Random(128)
  62.         For x As Integer = 0 To b.Width - 1
  63.             For y As Integer = 0 To b.Height - 1
  64.                 b.SetPixel(x, y, colors(r.Next(colors.Length)))
  65.             Next
  66.         Next
  67.         Dim T As New TextureBrush(b)
  68.         b.Dispose()
  69.         Return T
  70.     End Function
  71. End Module
  72.  
  73. Public Class ButterscotchTheme : Inherits ContainerControl
  74.     Dim WithEvents _mytimer As Windows.Forms.Timer
  75.     Dim _myval As Integer = 0
  76.     Private _mousepos As Point = New Point(0, 0)
  77.     Private _drag As Boolean = False
  78.     Private _icon As Icon
  79.  
  80.     Public Property Icon() As Icon
  81.         Get
  82.             Return _icon
  83.         End Get
  84.         Set(ByVal value As Icon)
  85.             _icon = value
  86.             Invalidate()
  87.         End Set
  88.     End Property
  89.  
  90.     Private _border As Boolean = True
  91.     Public Property Border As Boolean
  92.         Get
  93.             Return _border
  94.         End Get
  95.         Set(value As Boolean)
  96.             _border = value
  97.             Invalidate()
  98.         End Set
  99.     End Property
  100.  
  101.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  102.         MyBase.OnMouseDown(e)
  103.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(60, 7, Width - 141, 37).Contains(e.Location) Then
  104.             _drag = True : _mousepos = e.Location
  105.         End If
  106.     End Sub
  107.  
  108.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  109.         MyBase.OnMouseUp(e)
  110.         _drag = False
  111.     End Sub
  112.  
  113.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  114.         MyBase.OnMouseMove(e)
  115.         If _drag Then
  116.             Parent.Location = New Point(MousePosition.X - _mousepos.X, MousePosition.Y - _mousepos.Y)
  117.         End If
  118.     End Sub
  119.  
  120.     Sub New()
  121.         MyBase.New()
  122.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  123.         DoubleBuffered = True
  124.         _mytimer = New Timer()
  125.         _mytimer.Interval = 2000
  126.     End Sub
  127.  
  128.     Protected Overrides Sub OnCreateControl()
  129.         MyBase.OnCreateControl()
  130.         ParentForm.FormBorderStyle = FormBorderStyle.None
  131.         ParentForm.TransparencyKey = Color.Fuchsia
  132.         Dock = DockStyle.Fill
  133.     End Sub
  134.  
  135.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  136.         Dim b As Bitmap = New Bitmap(Width, Height)
  137.         Dim g As Graphics = Graphics.FromImage(b)
  138.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  139.         Dim headrect As Rectangle = New Rectangle(60, 7, Width - 141, 37)
  140.         MyBase.OnPaint(e)
  141.         g.Clear(Color.Fuchsia)
  142.         Dim bodygb As TextureBrush = NoiseBrush({Color.FromArgb(34, 29, 23), Color.FromArgb(50, 45, 39)})
  143.         g.FillPath(bodygb, RoundRect(rect, 3))
  144.         Try
  145.             g.DrawIcon(_icon, New Rectangle(8, 8, 38, 38))
  146.         Catch : End Try
  147.         If _myval = 0 Then
  148.             g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(206, 209, 208)), headrect, New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  149.         ElseIf _myval = 1 Then
  150.             g.DrawString(Text, New Font("Segoe UI", 12, FontStyle.Bold), New SolidBrush(Color.FromArgb(128, 128, 128)), headrect, New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
  151.         End If
  152.         If Border = True Then
  153.             g.DrawPath(New Pen(Color.FromArgb(212, 212, 212), 3), RoundRect(rect, 3))
  154.         End If
  155.         If Not DesignMode Then _mytimer.Start()
  156.         e.Graphics.DrawImage(b, New Point(0, 0))
  157.         g.Dispose() : b.Dispose()
  158.     End Sub
  159.  
  160.     Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  161.         If _myval = 0 Then
  162.             _myval = 1
  163.         ElseIf _myval = 1 Then
  164.             _myval = 0
  165.         End If
  166.         Invalidate()
  167.     End Sub
  168. End Class
  169.  
  170. Public Class ButterscotchControlBox : Inherits Control
  171.     Dim _state As MouseState = MouseState.None
  172.     Dim _x As Integer
  173.     ReadOnly _minrect As New Rectangle(5, 2, 24, 24)
  174.     ReadOnly _maxrect As New Rectangle(32, 2, 24, 24)
  175.     ReadOnly _closerect As New Rectangle(59, 2, 24, 24)
  176.     Private _minDisable As Boolean = False
  177.     Public Property MinimumDisable As Boolean
  178.         Get
  179.             Return _minDisable
  180.         End Get
  181.         Set(value As Boolean)
  182.             _minDisable = value
  183.             Invalidate()
  184.         End Set
  185.     End Property
  186.  
  187.     Private _maxDisable As Boolean = False
  188.     Public Property MaximumDisable As Boolean
  189.         Get
  190.             Return _maxDisable
  191.         End Get
  192.         Set(value As Boolean)
  193.             _maxDisable = value
  194.             Invalidate()
  195.         End Set
  196.     End Property
  197.  
  198.     Protected Overrides Sub OnMouseDown(ByVal e As Windows.Forms.MouseEventArgs)
  199.         MyBase.OnMouseDown(e)
  200.         If _x > 5 AndAlso _x < 29 Then
  201.             If MinimumDisable = False Then
  202.                 FindForm.WindowState = FormWindowState.Minimized
  203.             End If
  204.         ElseIf _x > 32 AndAlso _x < 56 Then
  205.             If MaximumDisable = False Then
  206.                 If FindForm.WindowState = FormWindowState.Maximized Then
  207.                     FindForm.WindowState = FormWindowState.Minimized
  208.                     FindForm.WindowState = FormWindowState.Normal
  209.                 Else
  210.                     FindForm.WindowState = FormWindowState.Minimized
  211.                     FindForm.WindowState = FormWindowState.Maximized
  212.                 End If
  213.             End If
  214.         ElseIf _x > 59 AndAlso _x < 83 Then
  215.             FindForm.Close()
  216.         End If
  217.         _state = MouseState.Down : Invalidate()
  218.     End Sub
  219.  
  220.     Protected Overrides Sub OnMouseUp(ByVal e As Windows.Forms.MouseEventArgs)
  221.         MyBase.OnMouseUp(e)
  222.         _state = MouseState.Over : Invalidate()
  223.     End Sub
  224.  
  225.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  226.         MyBase.OnMouseEnter(e)
  227.         _state = MouseState.Over : Invalidate()
  228.     End Sub
  229.  
  230.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  231.         MyBase.OnMouseLeave(e)
  232.         _state = MouseState.None : Invalidate()
  233.     End Sub
  234.  
  235.     Protected Overrides Sub OnMouseMove(ByVal e As Windows.Forms.MouseEventArgs)
  236.         MyBase.OnMouseMove(e)
  237.         _x = e.Location.X
  238.         Invalidate()
  239.     End Sub
  240.  
  241.     Sub New()
  242.         MyBase.New()
  243.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  244.         DoubleBuffered = True
  245.         BackColor = Color.Transparent
  246.         Width = 85
  247.         Height = 30
  248.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  249.     End Sub
  250.  
  251.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  252.         Dim g As Graphics = e.Graphics
  253.         MyBase.OnPaint(e)
  254.         g.SmoothingMode = SmoothingMode.HighQuality
  255.         Dim minrdefault As New LinearGradientBrush(_minrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  256.         g.FillRectangle(minrdefault, _minrect)
  257.         g.DrawRectangle(Pens.Black, _minrect)
  258.         Dim maxrdefault As New LinearGradientBrush(_maxrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  259.         g.FillRectangle(maxrdefault, _maxrect)
  260.         g.DrawRectangle(Pens.Black, _maxrect)
  261.         Dim crdefault As New LinearGradientBrush(_closerect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  262.         g.FillRectangle(crdefault, _closerect)
  263.         g.DrawRectangle(Pens.Black, _closerect)
  264.         Select Case _state
  265.             Case MouseState.None
  266.                 Dim minrnone As New LinearGradientBrush(_minrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  267.                 g.FillRectangle(minrnone, _minrect)
  268.                 g.DrawRectangle(Pens.Black, _minrect)
  269.                 Dim maxrnone As New LinearGradientBrush(_maxrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  270.                 g.FillRectangle(maxrnone, _maxrect)
  271.                 g.DrawRectangle(Pens.Black, _maxrect)
  272.                 Dim crnone As New LinearGradientBrush(_closerect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  273.                 g.FillRectangle(crnone, _closerect)
  274.                 g.DrawRectangle(Pens.Black, _closerect)
  275.             Case MouseState.Over
  276.                 If _x > 5 AndAlso _x < 29 Then
  277.                     If MinimumDisable = False Then
  278.                         Dim minrover As New LinearGradientBrush(_minrect, Color.FromArgb(25, 23, 22), Color.FromArgb(100, 90, 80), 90S)
  279.                         g.FillRectangle(minrover, _minrect)
  280.                         g.DrawRectangle(Pens.DimGray, _minrect)
  281.                     End If
  282.                 ElseIf _x > 32 AndAlso _x < 56 Then
  283.                     If MaximumDisable = False Then
  284.                         Dim maxrover As New LinearGradientBrush(_maxrect, Color.FromArgb(25, 23, 22), Color.FromArgb(100, 90, 80), 90S)
  285.                         g.FillRectangle(maxrover, _maxrect)
  286.                         g.DrawRectangle(Pens.DimGray, _maxrect)
  287.                     End If
  288.                 ElseIf _x > 59 AndAlso _x < 83 Then
  289.                     Dim crover As New LinearGradientBrush(_closerect, Color.FromArgb(25, 23, 22), Color.FromArgb(100, 90, 80), 90S)
  290.                     g.FillRectangle(crover, _closerect)
  291.                     g.DrawRectangle(Pens.DimGray, _closerect)
  292.                 End If
  293.             Case Else
  294.                 If MinimumDisable = False Then
  295.                     Dim minrelse As New LinearGradientBrush(_minrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  296.                     g.FillRectangle(minrelse, _minrect)
  297.                     g.DrawRectangle(Pens.Silver, _minrect)
  298.                 End If
  299.                 If MaximumDisable = False Then
  300.                     Dim maxrelse As New LinearGradientBrush(_maxrect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  301.                     g.FillRectangle(maxrelse, _maxrect)
  302.                     g.DrawRectangle(Pens.Silver, _maxrect)
  303.                 End If
  304.                 Dim crelse As New LinearGradientBrush(_closerect, Color.FromArgb(100, 90, 80), Color.FromArgb(25, 23, 22), 90S)
  305.                 g.FillRectangle(crelse, _closerect)
  306.                 g.DrawRectangle(Pens.Silver, _closerect)
  307.         End Select
  308.     End Sub
  309. End Class
  310.  
  311. Public Class ButterscotchRadioButton : Inherits Control
  312.     Private _check As Boolean
  313.     Public Property Checked As Boolean
  314.         Get
  315.             Return _check
  316.         End Get
  317.         Set(value As Boolean)
  318.             _check = value
  319.             Invalidate()
  320.         End Set
  321.     End Property
  322.  
  323.     Sub New()
  324.         MyBase.New()
  325.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  326.         BackColor = Color.Transparent
  327.         DoubleBuffered = True
  328.         Size = New Size(180, 25)
  329.     End Sub
  330.  
  331.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  332.         MyBase.OnTextChanged(e)
  333.         Invalidate()
  334.     End Sub
  335.  
  336.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  337.         MyBase.OnClick(e)
  338.         If Not Checked Then Checked = True
  339.         For Each ctrl As ButterscotchRadioButton In From ctrl1 In Parent.Controls.OfType(Of ButterscotchRadioButton)() Where ctrl1.Handle <> Handle Where ctrl1.Enabled
  340.             ctrl.Checked = False
  341.         Next
  342.     End Sub
  343.  
  344.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  345.         Dim b As Bitmap = New Bitmap(Width, Height)
  346.         Dim g As Graphics = Graphics.FromImage(b)
  347.         Dim selectionrect As Rectangle = New Rectangle(3, 3, 18, 18)
  348.         Dim innerselectionrect As Rectangle = New Rectangle(4, 4, 17, 17)
  349.         Dim selectrect As Rectangle = New Rectangle(8, 8, 8, 8)
  350.         MyBase.OnPaint(e)
  351.         g.SmoothingMode = SmoothingMode.HighQuality
  352.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  353.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  354.         g.Clear(BackColor)
  355.         g.DrawString(Text, New Font("Segoe UI", 11, FontStyle.Regular), New SolidBrush(Color.FromArgb(245, 245, 245)), New Rectangle(25, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  356.         If Checked Then
  357.             g.FillEllipse(New SolidBrush(Color.FromArgb(0, 0, 0)), selectionrect)
  358.             g.FillEllipse(New SolidBrush(Color.FromArgb(40, 37, 33)), innerselectionrect)
  359.             g.FillEllipse(New SolidBrush(Color.FromArgb(246, 180, 12)), selectrect)
  360.         Else
  361.             g.FillEllipse(New SolidBrush(Color.FromArgb(0, 0, 0)), selectionrect)
  362.             g.FillEllipse(New SolidBrush(Color.FromArgb(40, 37, 33)), innerselectionrect)
  363.             g.FillEllipse(New SolidBrush(Color.FromArgb(20, 18, 17)), selectrect)
  364.         End If
  365.         e.Graphics.DrawImage(b, New Point(0, 0))
  366.         g.Dispose() : b.Dispose()
  367.     End Sub
  368. End Class
  369.  
  370. Public Class ButterscotchCheckBox : Inherits Control
  371.     Private _check As Boolean
  372.     Public Property Checked As Boolean
  373.         Get
  374.             Return _check
  375.         End Get
  376.         Set(value As Boolean)
  377.             _check = value
  378.             Invalidate()
  379.         End Set
  380.     End Property
  381.  
  382.     Sub New()
  383.         MyBase.New()
  384.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  385.         BackColor = Color.Transparent
  386.         DoubleBuffered = True
  387.         Size = New Size(180, 25)
  388.     End Sub
  389.  
  390.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  391.         MyBase.OnTextChanged(e)
  392.         Invalidate()
  393.     End Sub
  394.  
  395.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  396.         MyBase.OnClick(e)
  397.         If Not Checked Then Checked = True Else Checked = False
  398.     End Sub
  399.  
  400.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  401.         Dim b As Bitmap = New Bitmap(Width, Height)
  402.         Dim g As Graphics = Graphics.FromImage(b)
  403.         Dim selectionrect As Rectangle = New Rectangle(3, 3, 18, 18)
  404.         Dim innerselectionrect As Rectangle = New Rectangle(4, 4, 17, 17)
  405.         Dim selectrect As Rectangle = New Rectangle(6, 6, 16, 16)
  406.         MyBase.OnPaint(e)
  407.         g.SmoothingMode = SmoothingMode.HighQuality
  408.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  409.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  410.         g.Clear(BackColor)
  411.         g.DrawString(Text, New Font("Segoe UI", 11, FontStyle.Regular), New SolidBrush(Color.FromArgb(245, 245, 245)), New Rectangle(20, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  412.         If Checked Then
  413.             g.FillRectangle(New SolidBrush(Color.FromArgb(0, 0, 0)), selectionrect)
  414.             g.FillRectangle(New SolidBrush(Color.FromArgb(40, 37, 33)), innerselectionrect)
  415.             g.DrawString("b", New Font("Marlett", 15, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), selectrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  416.         Else
  417.             g.FillRectangle(New SolidBrush(Color.FromArgb(0, 0, 0)), selectionrect)
  418.             g.FillRectangle(New SolidBrush(Color.FromArgb(40, 37, 33)), innerselectionrect)
  419.             g.DrawString("b", New Font("Marlett", 15, FontStyle.Bold), New SolidBrush(Color.FromArgb(20, 18, 17)), selectrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  420.         End If
  421.         e.Graphics.DrawImage(b, New Point(0, 0))
  422.         g.Dispose() : b.Dispose()
  423.     End Sub
  424. End Class
  425.  
  426. Public Class ButterscotchButton : Inherits Control
  427.     Dim _state As MouseState
  428.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  429.         MyBase.OnMouseDown(e)
  430.         _state = MouseState.Down
  431.         Invalidate()
  432.     End Sub
  433.  
  434.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  435.         MyBase.OnMouseUp(e)
  436.         _state = MouseState.Over
  437.         Invalidate()
  438.     End Sub
  439.  
  440.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  441.         MyBase.OnMouseEnter(e)
  442.         _state = MouseState.Over
  443.         Invalidate()
  444.     End Sub
  445.  
  446.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  447.         MyBase.OnMouseLeave(e)
  448.         _state = MouseState.None
  449.         Invalidate()
  450.     End Sub
  451.  
  452.     Sub New()
  453.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  454.         BackColor = Color.Transparent
  455.         DoubleBuffered = True
  456.         Size = New Size(160, 35)
  457.         _state = MouseState.None
  458.     End Sub
  459.  
  460.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  461.         Dim b As Bitmap = New Bitmap(Width, Height)
  462.         Dim g As Graphics = Graphics.FromImage(b)
  463.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  464.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  465.         Dim btnfont As New Font("Verdana", 10, FontStyle.Regular)
  466.         MyBase.OnPaint(e)
  467.         g.SmoothingMode = SmoothingMode.HighQuality
  468.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  469.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  470.         g.Clear(BackColor)
  471.         Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), LinearGradientMode.Vertical)
  472.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  473.         g.FillPath(buttonrect, RoundRect(innerrect, 3))
  474.         Select Case _state
  475.             Case MouseState.None
  476.                 Dim buttonrectnone As New LinearGradientBrush(innerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), LinearGradientMode.Vertical)
  477.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  478.                 g.FillPath(buttonrectnone, RoundRect(innerrect, 3))
  479.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  480.             Case MouseState.Down
  481.                 Dim buttonrectdown As New LinearGradientBrush(innerrect, Color.FromArgb(48, 43, 39), Color.FromArgb(100, 90, 80), LinearGradientMode.Vertical)
  482.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  483.                 g.FillPath(buttonrectdown, RoundRect(innerrect, 3))
  484.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  485.             Case MouseState.Over
  486.                 Dim buttonrectover As New LinearGradientBrush(innerrect, Color.FromArgb(48, 43, 39), Color.FromArgb(100, 90, 80), LinearGradientMode.Vertical)
  487.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  488.                 g.FillPath(buttonrectover, RoundRect(innerrect, 3))
  489.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  490.         End Select
  491.         e.Graphics.DrawImage(b, New Point(0, 0))
  492.         g.Dispose() : b.Dispose()
  493.     End Sub
  494. End Class
  495.  
  496. Public Class ButterscotchPanel : Inherits ContainerControl
  497.  
  498.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  499.         MyBase.OnResize(e)
  500.         Invalidate()
  501.     End Sub
  502.  
  503.     Sub New()
  504.         MyBase.New()
  505.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  506.         BackColor = Color.Transparent
  507.         DoubleBuffered = True
  508.         Size = New Size(240, 160)
  509.     End Sub
  510.  
  511.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  512.         Dim b As Bitmap = New Bitmap(Width, Height)
  513.         Dim g As Graphics = Graphics.FromImage(b)
  514.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  515.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  516.         MyBase.OnPaint(e)
  517.         g.SmoothingMode = SmoothingMode.HighQuality
  518.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  519.         g.Clear(BackColor)
  520.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(outerrect, 3))
  521.         Dim panelgb As New LinearGradientBrush(innerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  522.         g.FillPath(panelgb, RoundRect(innerrect, 3))
  523.         e.Graphics.DrawImage(b, New Point(0, 0))
  524.         g.Dispose() : b.Dispose()
  525.     End Sub
  526. End Class
  527.  
  528. Public Class ButterscotchGroupBox : Inherits ContainerControl
  529.  
  530.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  531.         MyBase.OnResize(e)
  532.         Invalidate()
  533.     End Sub
  534.  
  535.     Sub New()
  536.         MyBase.New()
  537.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  538.         BackColor = Color.Transparent
  539.         DoubleBuffered = True
  540.         Size = New Size(240, 160)
  541.     End Sub
  542.  
  543.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  544.         Dim b As Bitmap = New Bitmap(Width, Height)
  545.         Dim g As Graphics = Graphics.FromImage(b)
  546.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  547.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  548.         Dim underlinepen As New Pen(Color.FromArgb(255, 255, 255), 2)
  549.         MyBase.OnPaint(e)
  550.         g.SmoothingMode = SmoothingMode.HighQuality
  551.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  552.         g.Clear(BackColor)
  553.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(outerrect, 3))
  554.         Dim panelgb As New LinearGradientBrush(innerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  555.         g.FillPath(panelgb, RoundRect(innerrect, 3))
  556.         g.DrawString(Text, New Font("Segoe UI", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 3, Width - 1, 30), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  557.         g.DrawLine(underlinepen, 20, 30, Width - 21, 30)
  558.         e.Graphics.DrawImage(b, New Point(0, 0))
  559.         g.Dispose() : b.Dispose()
  560.     End Sub
  561. End Class
  562.  
  563. Public Class ButterscotchProgressBar : Inherits Control
  564.     Private _val As Integer
  565.     Public Property Value() As Integer
  566.         Get
  567.             Return _val
  568.         End Get
  569.         Set(ByVal v As Integer)
  570.             If v > _max Then
  571.                 _val = _max
  572.             ElseIf v < 0 Then
  573.                 _val = 0
  574.             Else
  575.                 _val = v
  576.             End If
  577.             Invalidate()
  578.         End Set
  579.     End Property
  580.  
  581.     Private _max As Integer
  582.     Public Property Maximum() As Integer
  583.         Get
  584.             Return _max
  585.         End Get
  586.         Set(ByVal v As Integer)
  587.             If v < 1 Then
  588.                 _max = 1
  589.             Else
  590.                 _max = v
  591.             End If
  592.             If v < _val Then
  593.                 _val = _max
  594.             End If
  595.             Invalidate()
  596.         End Set
  597.     End Property
  598.  
  599.     Private _showPercentage As Boolean = False
  600.     Public Property ShowPercentage() As Boolean
  601.         Get
  602.             Return _showPercentage
  603.         End Get
  604.         Set(ByVal v As Boolean)
  605.             _showPercentage = v
  606.             Invalidate()
  607.         End Set
  608.     End Property
  609.  
  610.     Sub New()
  611.         MyBase.New()
  612.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  613.         BackColor = Color.Transparent
  614.         Size = New Size(250, 20)
  615.         DoubleBuffered = True
  616.         _max = 100
  617.     End Sub
  618.  
  619.     Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
  620.         Dim b As Bitmap = New Bitmap(Width, Height)
  621.         Dim g As Graphics = Graphics.FromImage(b)
  622.         Dim percent As Integer = CInt((Width - 1) * (_val / _max))
  623.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  624.         Dim maininnerrect As Rectangle = New Rectangle(7, 7, Width - 15, Height - 15)
  625.         Dim innerrect As Rectangle = New Rectangle(4, 4, percent - 9, Height - 9)
  626.         MyBase.OnPaint(e)
  627.         g.Clear(BackColor)
  628.         g.SmoothingMode = SmoothingMode.HighQuality
  629.         g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(outerrect, 5))
  630.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(outerrect, 5))
  631.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(maininnerrect, 3))
  632.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(maininnerrect, 3))
  633.         If percent <> 0 Then
  634.             Dim progressgb As New LinearGradientBrush(innerrect, Color.FromArgb(91, 82, 73), Color.FromArgb(57, 52, 46), 90S)
  635.             g.FillPath(progressgb, RoundRect(innerrect, 7))
  636.         End If
  637.         If _showPercentage Then
  638.             g.DrawString(String.Format("{0}%", _val), New Font("Segoe UI", 11, FontStyle.Regular), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(10, 1, Width - 1, Height - 1), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  639.         End If
  640.         e.Graphics.DrawImage(b, New Point(0, 0))
  641.         g.Dispose() : b.Dispose()
  642.     End Sub
  643. End Class
  644.  
  645. Public Class ButterscotchLabel : Inherits Control
  646.     Private _border As Boolean = True
  647.     Public Property Border As Boolean
  648.         Get
  649.             Return _border
  650.         End Get
  651.         Set(value As Boolean)
  652.             _border = value
  653.             Invalidate()
  654.         End Set
  655.     End Property
  656.  
  657.     Sub New()
  658.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  659.         BackColor = Color.Transparent
  660.         DoubleBuffered = True
  661.         Size = New Size(150, 30)
  662.     End Sub
  663.  
  664.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  665.         Dim b As Bitmap = New Bitmap(Width, Height)
  666.         Dim g As Graphics = Graphics.FromImage(b)
  667.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  668.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  669.         MyBase.OnPaint(e)
  670.         g.Clear(BackColor)
  671.         g.SmoothingMode = SmoothingMode.HighQuality
  672.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  673.         g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(rect, 3))
  674.         If Border = True Then
  675.             g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  676.             g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(innerrect, 3))
  677.         End If
  678.         g.DrawString(Text, New Font("Segoe UI", 11, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  679.         e.Graphics.DrawImage(b, New Point(0, 0))
  680.         g.Dispose() : b.Dispose()
  681.     End Sub
  682. End Class
  683.  
  684. Public Class ButterscotchTabControl : Inherits TabControl
  685.  
  686.     Sub New()
  687.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  688.         BackColor = Color.Transparent
  689.         DoubleBuffered = True
  690.         ItemSize = New Size(100, 35)
  691.     End Sub
  692.  
  693.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  694.         Dim b As Bitmap = New Bitmap(Width, Height)
  695.         Dim g As Graphics = Graphics.FromImage(b)
  696.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  697.         Try : SelectedTab.BackColor = Color.FromArgb(100, 90, 80) : Catch : End Try
  698.         MyBase.OnPaint(e)
  699.         g.Clear(BackColor)
  700.         g.FillRectangle(New SolidBrush(Color.FromArgb(40, 37, 33)), rect)
  701.         g.DrawRectangle(New Pen(Brushes.Black), rect)
  702.         For i = 0 To TabCount - 1
  703.             Dim textRectangle As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 3, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width - 7, GetTabRect(i).Height))
  704.             If i = SelectedIndex Then
  705.                 Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 1, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width - 2, GetTabRect(i).Height))
  706.                 Dim buttonrect As New LinearGradientBrush(tabrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  707.                 g.FillPath(buttonrect, RoundRect(tabrect, 5))
  708.                 g.DrawString(TabPages(i).Text, New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(25, 23, 22)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  709.             Else
  710.                 Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 1, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width - 2, GetTabRect(i).Height))
  711.                 Dim buttonrect As New LinearGradientBrush(tabrect, Color.FromArgb(57, 52, 46), Color.FromArgb(92, 83, 74), 90S)
  712.  
  713.                 g.FillPath(buttonrect, RoundRect(tabrect, 5))
  714.                 g.DrawString(TabPages(i).Text, New Font("Segoe UI", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  715.             End If
  716.         Next
  717.         e.Graphics.DrawImage(b, New Point(0, 0))
  718.         g.Dispose() : b.Dispose()
  719.     End Sub
  720. End Class
  721.  
  722. Public Class ButterscotchVerticalTabControl : Inherits TabControl
  723.  
  724.     Sub New()
  725.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  726.         BackColor = Color.Transparent
  727.         DoubleBuffered = True
  728.         SizeMode = TabSizeMode.Fixed
  729.         Alignment = TabAlignment.Left
  730.         ItemSize = New Size(35, 100)
  731.     End Sub
  732.  
  733.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  734.         Dim b As Bitmap = New Bitmap(Width, Height)
  735.         Dim g As Graphics = Graphics.FromImage(b)
  736.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  737.         Try : SelectedTab.BackColor = Color.FromArgb(100, 90, 80) : Catch : End Try
  738.         MyBase.OnPaint(e)
  739.         g.Clear(BackColor)
  740.         g.FillRectangle(New SolidBrush(Color.FromArgb(40, 37, 33)), rect)
  741.         g.DrawRectangle(New Pen(Brushes.Black), rect)
  742.         For i = 0 To TabCount - 1
  743.             Dim textRectangle As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 7, GetTabRect(i).Location.Y + 2), New Size(GetTabRect(i).Width - 15, GetTabRect(i).Height - 5))
  744.             If i = SelectedIndex Then
  745.                 Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y + 1), New Size(GetTabRect(i).Width - 2, GetTabRect(i).Height - 3))
  746.                 Dim buttonrect As New LinearGradientBrush(tabrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  747.                 g.FillPath(buttonrect, RoundRect(tabrect, 5))
  748.                 g.DrawString(TabPages(i).Text, New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(25, 23, 22)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  749.             Else
  750.                 Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y + 1), New Size(GetTabRect(i).Width - 2, GetTabRect(i).Height - 3))
  751.                 Dim buttonrect As New LinearGradientBrush(tabrect, Color.FromArgb(57, 52, 46), Color.FromArgb(92, 83, 74), 90S)
  752.                 g.FillPath(buttonrect, RoundRect(tabrect, 5))
  753.                 g.DrawString(TabPages(i).Text, New Font("Segoe UI", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  754.             End If
  755.         Next
  756.         e.Graphics.DrawImage(b, New Point(0, 0))
  757.         g.Dispose() : b.Dispose()
  758.     End Sub
  759. End Class
  760.  
  761. Public Class ButterscotchToggle : Inherits Control
  762.  
  763.     Private _check As Boolean
  764.     Public Property Checked As Boolean
  765.         Get
  766.             Return _check
  767.         End Get
  768.         Set(value As Boolean)
  769.             _check = value
  770.             Invalidate()
  771.         End Set
  772.     End Property
  773.  
  774.     Sub New()
  775.         MyBase.New()
  776.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  777.         DoubleBuffered = True
  778.         BackColor = Color.Transparent
  779.         Size = New Size(80, 25)
  780.     End Sub
  781.  
  782.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  783.         MyBase.OnClick(e)
  784.         If Not Checked Then Checked = True Else Checked = False
  785.     End Sub
  786.  
  787.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  788.         Dim b As Bitmap = New Bitmap(Width, Height)
  789.         Dim g As Graphics = Graphics.FromImage(b)
  790.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  791.         Dim maininnerrect As Rectangle = New Rectangle(7, 7, Width - 15, Height - 15)
  792.         Dim buttonrect As New LinearGradientBrush(outerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  793.         MyBase.OnPaint(e)
  794.         g.Clear(BackColor)
  795.         g.SmoothingMode = SmoothingMode.HighQuality
  796.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  797.         g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(outerrect, 5))
  798.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(outerrect, 5))
  799.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(maininnerrect, 3))
  800.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(maininnerrect, 3))
  801.         If Checked Then
  802.             g.FillPath(buttonrect, RoundRect(New Rectangle(3, 3, CInt((Width / 2) - 3), Height - 7), 7))
  803.             g.DrawString("ON", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  804.         Else
  805.             g.FillPath(buttonrect, RoundRect(New Rectangle(CInt((Width / 2) - 3), 3, CInt((Width / 2) - 3), Height - 7), 7))
  806.             g.DrawString("OFF", New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  807.         End If
  808.         e.Graphics.DrawImage(b, New Point(0, 0))
  809.         g.Dispose() : b.Dispose()
  810.     End Sub
  811. End Class
  812.  
  813. Public Class ButterscotchComboBox : Inherits ComboBox
  814.     Private _startIndex As Integer = 0
  815.     Private Property StartIndex As Integer
  816.         Get
  817.             Return _startIndex
  818.         End Get
  819.         Set(ByVal value As Integer)
  820.             _startIndex = value
  821.             Try
  822.                 SelectedIndex = value
  823.             Catch
  824.             End Try
  825.             Invalidate()
  826.         End Set
  827.     End Property
  828.  
  829.     Sub ReplaceItem(ByVal sender As System.Object, ByVal e As Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  830.         e.DrawBackground()
  831.         Dim sitemrect As New LinearGradientBrush(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  832.         Dim itemrect As New LinearGradientBrush(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), Color.FromArgb(57, 52, 46), Color.FromArgb(92, 83, 74), 90S)
  833.         Try
  834.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  835.                 e.Graphics.FillPath(sitemrect, RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  836.                 e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  837.             Else
  838.                 e.Graphics.FillPath(itemrect, RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  839.                 e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  840.             End If
  841.             e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, New SolidBrush(Color.FromArgb(212, 212, 212)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  842.         Catch : End Try
  843.     End Sub
  844.  
  845.     Sub New()
  846.         MyBase.New()
  847.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  848.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  849.         BackColor = Color.Transparent
  850.         DropDownStyle = ComboBoxStyle.DropDownList
  851.         StartIndex = 0
  852.         ItemHeight = 25
  853.         DoubleBuffered = True
  854.         Width = 200
  855.     End Sub
  856.  
  857.     Protected Overrides Sub OnResize(e As EventArgs)
  858.         MyBase.OnResize(e)
  859.         Height = 20
  860.     End Sub
  861.  
  862.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  863.         Dim b As Bitmap = New Bitmap(Width, Height)
  864.         Dim g As Graphics = Graphics.FromImage(b)
  865.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  866.         Dim innerrect As Rectangle = New Rectangle(2, 2, Width - 5, Height - 5)
  867.         MyBase.OnPaint(e)
  868.         g.Clear(BackColor)
  869.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(outerrect, 3))
  870.         g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  871.         Dim rectgb As New LinearGradientBrush(innerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  872.         g.FillPath(rectgb, RoundRect(innerrect, 3))
  873.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  874.         g.SetClip(RoundRect(innerrect, 3))
  875.         g.FillPath(rectgb, RoundRect(innerrect, 3))
  876.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  877.         g.ResetClip()
  878.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 10, Width - 22, 10)
  879.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 11, Width - 22, 11)
  880.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 15, Width - 22, 15)
  881.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 16, Width - 22, 16)
  882.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 20, Width - 22, 20)
  883.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), Width - 9, 21, Width - 22, 21)
  884.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), New Point(Width - 29, 7), New Point(Width - 29, Height - 7))
  885.         g.DrawLine(New Pen(Color.FromArgb(246, 180, 12)), New Point(Width - 30, 7), New Point(Width - 30, Height - 7))
  886.         Try
  887.             g.DrawString(Text, New Font("Segoe UI", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(212, 212, 212)), innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  888.         Catch : End Try
  889.         e.Graphics.DrawImage(b, New Point(0, 0))
  890.         g.Dispose() : b.Dispose()
  891.     End Sub
  892. End Class
  893.  
  894. Public Class ButterscotchTextBox : Inherits Control
  895.     Dim WithEvents _tb As New TextBox
  896.     Private _allowpassword As Boolean = False
  897.     Public Shadows Property UseSystemPasswordChar() As Boolean
  898.         Get
  899.             Return _allowpassword
  900.         End Get
  901.         Set(ByVal value As Boolean)
  902.             _tb.UseSystemPasswordChar = UseSystemPasswordChar
  903.             _allowpassword = value
  904.             Invalidate()
  905.         End Set
  906.     End Property
  907.  
  908.     Private _maxChars As Integer = 32767
  909.     Public Shadows Property MaxLength() As Integer
  910.         Get
  911.             Return _maxChars
  912.         End Get
  913.         Set(ByVal value As Integer)
  914.             _maxChars = value
  915.             _tb.MaxLength = MaxLength
  916.             Invalidate()
  917.         End Set
  918.     End Property
  919.  
  920.     Private _textAlignment As HorizontalAlignment
  921.     Public Shadows Property TextAlign() As HorizontalAlignment
  922.         Get
  923.             Return _textAlignment
  924.         End Get
  925.         Set(ByVal value As HorizontalAlignment)
  926.             _textAlignment = value
  927.             Invalidate()
  928.         End Set
  929.     End Property
  930.  
  931.     Private _multiLine As Boolean = False
  932.     Public Shadows Property MultiLine() As Boolean
  933.         Get
  934.             Return _multiLine
  935.         End Get
  936.         Set(ByVal value As Boolean)
  937.             _multiLine = value
  938.             _tb.Multiline = value
  939.             OnResize(EventArgs.Empty)
  940.             Invalidate()
  941.         End Set
  942.     End Property
  943.  
  944.     Private _readOnly As Boolean = False
  945.     Public Shadows Property [ReadOnly]() As Boolean
  946.         Get
  947.             Return _readOnly
  948.         End Get
  949.         Set(ByVal value As Boolean)
  950.             _readOnly = value
  951.             If _tb IsNot Nothing Then
  952.                 _tb.ReadOnly = value
  953.             End If
  954.         End Set
  955.     End Property
  956.  
  957.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  958.         MyBase.OnTextChanged(e)
  959.         Invalidate()
  960.     End Sub
  961.  
  962.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  963.         MyBase.OnBackColorChanged(e)
  964.         Invalidate()
  965.     End Sub
  966.  
  967.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  968.         MyBase.OnForeColorChanged(e)
  969.         _tb.ForeColor = ForeColor
  970.         Invalidate()
  971.     End Sub
  972.  
  973.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  974.         MyBase.OnFontChanged(e)
  975.         _tb.Font = Font
  976.     End Sub
  977.  
  978.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  979.         MyBase.OnGotFocus(e)
  980.         _tb.Focus()
  981.     End Sub
  982.  
  983.     Private Sub TextChangeTb() Handles _tb.TextChanged
  984.         Text = _tb.Text
  985.     End Sub
  986.  
  987.     Private Sub TextChng() Handles MyBase.TextChanged
  988.         _tb.Text = Text
  989.     End Sub
  990.  
  991.     Public Sub NewTextBox()
  992.         With _tb
  993.             .Text = String.Empty
  994.             .BackColor = Color.FromArgb(48, 43, 39)
  995.             .ForeColor = ForeColor
  996.             .TextAlign = HorizontalAlignment.Center
  997.             .BorderStyle = BorderStyle.None
  998.             .Location = New Point(3, 3)
  999.             .Font = New Font("Segoe UI", 11, FontStyle.Regular)
  1000.             .Size = New Size(Width - 3, Height - 3)
  1001.             .UseSystemPasswordChar = UseSystemPasswordChar
  1002.         End With
  1003.     End Sub
  1004.  
  1005.     Sub New()
  1006.         MyBase.New()
  1007.         NewTextBox()
  1008.         Controls.Add(_tb)
  1009.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1010.         DoubleBuffered = True
  1011.         BackColor = Color.FromArgb(48, 43, 39)
  1012.         ForeColor = Color.FromArgb(255, 255, 255)
  1013.         Font = New Font("Segoe UI", 11, FontStyle.Regular)
  1014.         Size = New Size(200, 30)
  1015.     End Sub
  1016.  
  1017.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  1018.         Dim b As Bitmap = New Bitmap(Width, Height)
  1019.         Dim g As Graphics = Graphics.FromImage(b)
  1020.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1021.         MyBase.OnPaint(e)
  1022.         g.SmoothingMode = SmoothingMode.HighQuality
  1023.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1024.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  1025.         With _tb
  1026.             .TextAlign = TextAlign
  1027.             .UseSystemPasswordChar = UseSystemPasswordChar
  1028.         End With
  1029.         g.FillPath(New SolidBrush(Color.FromArgb(48, 43, 39)), RoundRect(rect, 1))
  1030.         g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 1))
  1031.         e.Graphics.DrawImage(b, New Point(0, 0))
  1032.         g.Dispose() : b.Dispose()
  1033.     End Sub
  1034.  
  1035.     Protected Overrides Sub OnResize(e As EventArgs)
  1036.         MyBase.OnResize(e)
  1037.         If Not MultiLine Then
  1038.             Dim tbheight As Integer = _tb.Height
  1039.             _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 1), Integer))
  1040.             _tb.Size = New Size(Width - 20, tbheight)
  1041.         Else
  1042.             _tb.Location = New Point(10, 10)
  1043.             _tb.Size = New Size(Width - 20, Height - 20)
  1044.         End If
  1045.     End Sub
  1046. End Class
  1047.  
  1048. Public Class ButterscotchVerticalProgressBar : Inherits Control
  1049.     Private _val As Integer
  1050.     Public Property Value() As Integer
  1051.         Get
  1052.             Return _val
  1053.         End Get
  1054.         Set(ByVal v As Integer)
  1055.             If v > _max Then
  1056.                 _val = _max
  1057.             ElseIf v < 0 Then
  1058.                 _val = 0
  1059.             Else
  1060.                 _val = v
  1061.             End If
  1062.             Invalidate()
  1063.         End Set
  1064.     End Property
  1065.  
  1066.     Private _max As Integer
  1067.     Public Property Maximum() As Integer
  1068.         Get
  1069.             Return _max
  1070.         End Get
  1071.         Set(ByVal v As Integer)
  1072.             If v < 1 Then
  1073.                 _max = 1
  1074.             Else
  1075.                 _max = v
  1076.             End If
  1077.             If v < _val Then
  1078.                 _val = _max
  1079.             End If
  1080.             Invalidate()
  1081.         End Set
  1082.     End Property
  1083.  
  1084.     Private _showPercentage As Boolean = False
  1085.     Public Property ShowPercentage() As Boolean
  1086.         Get
  1087.             Return _showPercentage
  1088.         End Get
  1089.         Set(ByVal v As Boolean)
  1090.             _showPercentage = v
  1091.             Invalidate()
  1092.         End Set
  1093.     End Property
  1094.  
  1095.     Sub New()
  1096.         MyBase.New()
  1097.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1098.         BackColor = Color.Transparent
  1099.         Size = New Size(20, 250)
  1100.         DoubleBuffered = True
  1101.         _max = 100
  1102.     End Sub
  1103.  
  1104.     Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
  1105.         Dim b As Bitmap = New Bitmap(Width, Height)
  1106.         Dim g As Graphics = Graphics.FromImage(b)
  1107.         Dim percent As Integer = CInt((Height - 1) * (_val / _max))
  1108.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1109.         Dim maininnerrect As Rectangle = New Rectangle(7, 7, Width - 15, Height - 15)
  1110.         Dim innerrect As Rectangle = New Rectangle(4, (Height - percent) + 4, Width - 9, percent - 9)
  1111.         MyBase.OnPaint(e)
  1112.         g.Clear(BackColor)
  1113.         g.SmoothingMode = SmoothingMode.HighQuality
  1114.         g.FillPath(New SolidBrush(Color.FromArgb(40, 37, 33)), RoundRect(outerrect, 5))
  1115.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(outerrect, 5))
  1116.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(maininnerrect, 3))
  1117.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(maininnerrect, 3))
  1118.         If percent <> 0 Then
  1119.             Try
  1120.                 Dim progressgb As New LinearGradientBrush(innerrect, Color.FromArgb(91, 82, 73), Color.FromArgb(57, 52, 46), 90S)
  1121.                 g.FillPath(progressgb, RoundRect(innerrect, 7))
  1122.             Catch : End Try
  1123.         End If
  1124.         If _showPercentage Then
  1125.             g.DrawString(String.Format("{0}%", _val), New Font("Segoe UI", 8, FontStyle.Bold), New SolidBrush(Color.FromArgb(246, 180, 12)), outerrect, New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1126.         End If
  1127.         e.Graphics.DrawImage(b, New Point(0, 0))
  1128.         g.Dispose() : b.Dispose()
  1129.     End Sub
  1130. End Class
  1131.  
  1132. Public Class ButterscotchHorizontalSeperator : Inherits Control
  1133.  
  1134.     Sub New()
  1135.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1136.         DoubleBuffered = True
  1137.         BackColor = Color.Transparent
  1138.         Size = New Size(200, 3)
  1139.     End Sub
  1140.  
  1141.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1142.         MyBase.OnResize(e)
  1143.         Height = 3
  1144.     End Sub
  1145.  
  1146.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1147.         Dim b As Bitmap = New Bitmap(Width, Height)
  1148.         Dim g As Graphics = Graphics.FromImage(b)
  1149.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1150.         MyBase.OnPaint(e)
  1151.         g.Clear(BackColor)
  1152.         g.SmoothingMode = SmoothingMode.HighQuality
  1153.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1154.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 2))
  1155.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(rect, 2))
  1156.         e.Graphics.DrawImage(b, New Point(0, 0))
  1157.         g.Dispose() : b.Dispose()
  1158.     End Sub
  1159. End Class
  1160.  
  1161. Public Class ButterscotchVerticalSeperator : Inherits Control
  1162.  
  1163.     Sub New()
  1164.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1165.         DoubleBuffered = True
  1166.         BackColor = Color.Transparent
  1167.         Size = New Size(3, 200)
  1168.     End Sub
  1169.  
  1170.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  1171.         MyBase.OnResize(e)
  1172.         Width = 3
  1173.     End Sub
  1174.  
  1175.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1176.         Dim b As Bitmap = New Bitmap(Width, Height)
  1177.         Dim g As Graphics = Graphics.FromImage(b)
  1178.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1179.         MyBase.OnPaint(e)
  1180.         g.Clear(BackColor)
  1181.         g.SmoothingMode = SmoothingMode.HighQuality
  1182.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1183.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 2))
  1184.         g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(rect, 2))
  1185.         e.Graphics.DrawImage(b, New Point(0, 0))
  1186.         g.Dispose() : b.Dispose()
  1187.     End Sub
  1188. End Class
  1189.  
  1190. Public Class ButterscotchListBox : Inherits ListBox
  1191.     Sub New()
  1192.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
  1193.                  ControlStyles.SupportsTransparentBackColor, True)
  1194.         BackColor = Color.Transparent
  1195.         DoubleBuffered = True
  1196.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  1197.         ForeColor = Color.White
  1198.         BackColor = Color.FromArgb(100, 90, 80)
  1199.         BorderStyle = Windows.Forms.BorderStyle.None
  1200.         ItemHeight = 20
  1201.     End Sub
  1202.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1203.         Dim b As Bitmap = New Bitmap(Width, Height)
  1204.         Dim g As Graphics = Graphics.FromImage(b)
  1205.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1206.         MyBase.OnPaint(e)
  1207.         g.Clear(Color.Transparent)
  1208.         g.FillPath(New SolidBrush(Color.FromArgb(100, 90, 80)), RoundRect(rect, 3))
  1209.         g.DrawPath(New Pen(Color.FromArgb(26, 25, 21)), RoundRect(rect, 1))
  1210.         e.Graphics.DrawImage(b, New Point(0, 0))
  1211.         g.Dispose() : b.Dispose()
  1212.     End Sub
  1213.     Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
  1214.         Dim b As Bitmap = New Bitmap(Width, Height)
  1215.         Dim g As Graphics = Graphics.FromImage(b)
  1216.         g.TextRenderingHint = TextRenderingHint.AntiAlias
  1217.         g.SmoothingMode = SmoothingMode.HighQuality
  1218.         g.SetClip(RoundRect(New Rectangle(0, 0, Width, Height), 3))
  1219.         g.Clear(Color.Transparent)
  1220.         g.FillRectangle(New SolidBrush(BackColor), New Rectangle(e.Bounds.X, e.Bounds.Y - 1, e.Bounds.Width, e.Bounds.Height + 3))
  1221.         If e.State.ToString().Contains("Selected,") Then
  1222.             Dim selectgb As New LinearGradientBrush(New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height), Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), 90S)
  1223.             g.FillRectangle(selectgb, New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height))
  1224.             g.DrawRectangle(New Pen(Color.FromArgb(212, 212, 212)), New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height))
  1225.         Else
  1226.             Dim nonselectgb As New LinearGradientBrush(New Rectangle(e.Bounds.X, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height), Color.FromArgb(48, 43, 39), Color.FromArgb(100, 90, 80), 90S)
  1227.             g.FillRectangle(nonselectgb, e.Bounds)
  1228.         End If
  1229.         Try
  1230.             g.DrawString(Items(e.Index).ToString(), New Font("Segoe UI", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(e.Bounds.X + 3, e.Bounds.Y + 1, e.Bounds.Width, e.Bounds.Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  1231.         Catch : End Try
  1232.         g.DrawPath(New Pen(Color.FromArgb(26, 25, 21), 2), RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 1))
  1233.         e.Graphics.DrawImage(b, New Point(0, 0))
  1234.         g.Dispose() : b.Dispose()
  1235.     End Sub
  1236. End Class
  1237.  
  1238. Public Class ButterscotchProgressButton : Inherits Control
  1239.     Dim _state As MouseState
  1240.     Private _val As Integer
  1241.     Public Property Value() As Integer
  1242.         Get
  1243.             Return _val
  1244.         End Get
  1245.         Set(ByVal v As Integer)
  1246.             If v > _max Then
  1247.                 _val = _max
  1248.             ElseIf v < 0 Then
  1249.                 _val = 0
  1250.             Else
  1251.                 _val = v
  1252.             End If
  1253.             Invalidate()
  1254.         End Set
  1255.     End Property
  1256.  
  1257.     Private _max As Integer
  1258.     Public Property Maximum() As Integer
  1259.         Get
  1260.             Return _max
  1261.         End Get
  1262.         Set(ByVal v As Integer)
  1263.             If v < 1 Then
  1264.                 _max = 1
  1265.             Else
  1266.                 _max = v
  1267.             End If
  1268.             If v < _val Then
  1269.                 _val = _max
  1270.             End If
  1271.             Invalidate()
  1272.         End Set
  1273.     End Property
  1274.  
  1275.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  1276.         MyBase.OnMouseDown(e)
  1277.         _state = MouseState.Down
  1278.         Invalidate()
  1279.     End Sub
  1280.  
  1281.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  1282.         MyBase.OnMouseUp(e)
  1283.         _state = MouseState.Over
  1284.         Invalidate()
  1285.     End Sub
  1286.  
  1287.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  1288.         MyBase.OnMouseEnter(e)
  1289.         _state = MouseState.Over
  1290.         Invalidate()
  1291.     End Sub
  1292.  
  1293.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  1294.         MyBase.OnMouseLeave(e)
  1295.         _state = MouseState.None
  1296.         Invalidate()
  1297.     End Sub
  1298.     Sub New()
  1299.         MyBase.New()
  1300.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1301.         BackColor = Color.Transparent
  1302.         Size = New Size(160, 50)
  1303.         DoubleBuffered = True
  1304.         _max = 100
  1305.     End Sub
  1306.  
  1307.     Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
  1308.         Dim b As Bitmap = New Bitmap(Width, Height)
  1309.         Dim g As Graphics = Graphics.FromImage(b)
  1310.         Dim percent As Integer = CInt((Width - 1) * (_val / _max))
  1311.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1312.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  1313.         Dim progressinnerrect As Rectangle = New Rectangle(4, 4, percent - 9, Height - 9)
  1314.         Dim btnfont As New Font("Segoe UI", 10, FontStyle.Regular)
  1315.         MyBase.OnPaint(e)
  1316.         g.SmoothingMode = SmoothingMode.HighQuality
  1317.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  1318.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  1319.         g.Clear(BackColor)
  1320.         Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), LinearGradientMode.Vertical)
  1321.         g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  1322.         g.FillPath(buttonrect, RoundRect(innerrect, 3))
  1323.         Select Case _state
  1324.             Case MouseState.None
  1325.                 Dim buttonrectnone As New LinearGradientBrush(innerrect, Color.FromArgb(100, 90, 80), Color.FromArgb(48, 43, 39), LinearGradientMode.Vertical)
  1326.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  1327.                 g.FillPath(buttonrectnone, RoundRect(innerrect, 3))
  1328.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1329.             Case MouseState.Down
  1330.                 Dim buttonrectdown As New LinearGradientBrush(innerrect, Color.FromArgb(48, 43, 39), Color.FromArgb(100, 90, 80), LinearGradientMode.Vertical)
  1331.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  1332.                 g.FillPath(buttonrectdown, RoundRect(innerrect, 3))
  1333.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1334.             Case MouseState.Over
  1335.                 Dim buttonrectover As New LinearGradientBrush(innerrect, Color.FromArgb(48, 43, 39), Color.FromArgb(100, 90, 80), LinearGradientMode.Vertical)
  1336.                 g.FillPath(New SolidBrush(Color.FromArgb(26, 25, 21)), RoundRect(rect, 3))
  1337.                 g.FillPath(buttonrectover, RoundRect(innerrect, 3))
  1338.                 g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1339.         End Select
  1340.         If percent <> 0 Then
  1341.             Dim progressgb As New LinearGradientBrush(progressinnerrect, Color.FromArgb(91, 82, 73), Color.FromArgb(57, 52, 46), 180S)
  1342.             g.FillPath(progressgb, RoundRect(progressinnerrect, 3))
  1343.             g.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), RoundRect(progressinnerrect, 3))
  1344.             g.DrawString(Text, btnfont, Brushes.White, innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1345.         End If
  1346.         e.Graphics.DrawImage(b, New Point(0, 0))
  1347.         g.Dispose() : b.Dispose()
  1348.     End Sub
  1349. End Class
  1350.  
  1351. Public Class ButterscotchAlertBox : Inherits Control
  1352.     Dim WithEvents _mytimer As Windows.Forms.Timer
  1353.  
  1354.     Enum AlertStyle
  1355.         [Info]
  1356.         [Success]
  1357.         [Error]
  1358.     End Enum
  1359.  
  1360.     Private _style As AlertStyle
  1361.     Public Property Style As AlertStyle
  1362.         Get
  1363.             Return _style
  1364.         End Get
  1365.         Set(value As AlertStyle)
  1366.             _style = value
  1367.         End Set
  1368.     End Property
  1369.  
  1370.     Private _text As String
  1371.     Overrides Property Text As String
  1372.         Get
  1373.             Return MyBase.Text
  1374.         End Get
  1375.         Set(ByVal value As String)
  1376.             MyBase.Text = value
  1377.             If _text IsNot Nothing Then
  1378.                 _text = value
  1379.             End If
  1380.         End Set
  1381.     End Property
  1382.  
  1383.     Shadows Property Visible As Boolean
  1384.         Get
  1385.             Return MyBase.Visible = False
  1386.         End Get
  1387.         Set(value As Boolean)
  1388.             MyBase.Visible = value
  1389.         End Set
  1390.     End Property
  1391.  
  1392.     Protected Overrides Sub OnTextChanged(e As EventArgs)
  1393.         MyBase.OnTextChanged(e) : Invalidate()
  1394.     End Sub
  1395.  
  1396.     Public Sub ShowAlertBox(mystyle As AlertStyle, str As String, interval As Integer)
  1397.         _style = mystyle
  1398.         Text = str
  1399.         Visible = True
  1400.         _mytimer.Interval = interval
  1401.         _mytimer.Enabled = True
  1402.     End Sub
  1403.  
  1404.     Sub New()
  1405.         MyBase.New()
  1406.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1407.         BackColor = Color.Transparent
  1408.         Size = New Size(450, 30)
  1409.         DoubleBuffered = True
  1410.         _mytimer = New Timer()
  1411.     End Sub
  1412.  
  1413.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  1414.         Dim b As Bitmap = New Bitmap(Width, Height)
  1415.         Dim g As Graphics = Graphics.FromImage(b)
  1416.         Dim rect As New Rectangle(0, 0, Width - 1, Height - 1)
  1417.         Dim textrect As New Rectangle(20, 10, Width - 21, Height - 21)
  1418.         Dim logorect As New Rectangle(7, 7, 20, 20)
  1419.         Dim logocirclerect As New Rectangle(5, 5, 20, 20)
  1420.         g.TextRenderingHint = TextRenderingHint.AntiAlias
  1421.         g.SmoothingMode = SmoothingMode.HighQuality
  1422.         g.Clear(Color.Transparent)
  1423.         MyBase.OnPaint(e)
  1424.         Select Case _style
  1425.             Case AlertStyle.Success
  1426.                 g.FillRectangle(New SolidBrush(Color.FromArgb(40, 0, 255, 0)), rect)
  1427.                 g.DrawRectangle(New Pen(Color.FromArgb(0, 0, 0)), rect)
  1428.                 g.DrawString(Text, New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), textrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1429.                 g.DrawString("ü", New Font("Wingdings", 14), New SolidBrush(Color.FromArgb(255, 255, 255)), logorect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1430.             Case AlertStyle.Error
  1431.                 g.FillRectangle(New SolidBrush(Color.FromArgb(40, 255, 0, 0)), rect)
  1432.                 g.DrawRectangle(New Pen(Color.FromArgb(0, 0, 0)), rect)
  1433.                 g.DrawString(Text, New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), textrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1434.                 g.DrawString("r", New Font("Marlett", 10), New SolidBrush(Color.FromArgb(255, 255, 255)), logorect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1435.             Case AlertStyle.Info
  1436.                 g.FillRectangle(New SolidBrush(Color.FromArgb(40, 0, 0, 255)), rect)
  1437.                 g.DrawRectangle(New Pen(Color.FromArgb(0, 0, 0)), rect)
  1438.                 g.DrawString(Text, New Font("Segoe UI", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), textrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1439.                 g.DrawString("i", New Font("Segoe UI", 12), New SolidBrush(Color.FromArgb(255, 255, 255)), logorect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1440.         End Select
  1441.         g.DrawEllipse(New Pen(Color.FromArgb(255, 255, 255)), logocirclerect)
  1442.         e.Graphics.DrawImage(b, New Point(0, 0))
  1443.         g.Dispose() : b.Dispose()
  1444.     End Sub
  1445.  
  1446.     Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  1447.         Visible = False
  1448.         _mytimer.Enabled = False
  1449.     End Sub
  1450. End Class
Advertisement
Add Comment
Please, Sign In to add comment