SaketSaket

Unique Theme HF

Aug 4th, 2014
2,518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 46.53 KB | None | 0 0
  1. Option Strict On
  2.  
  3. Imports System.Drawing.Drawing2D
  4.  
  5. '<info>
  6. ' --------------------Unique Theme--------------------
  7. ' Creator - SaketSaket (HF)
  8. ' UID - 1869668
  9. ' Inspiration & Credits to all Theme creaters of HF
  10. ' Version - 1.0
  11. ' Date Created - 1st August 2014
  12. ' Date Modified - 4th August 2014
  13. '
  14. '
  15. 'Special Thanks to Aeonhack for RoundRect Functions...
  16. 'Theme container inspiration taken from Mephobia's Perplex Theme
  17. '
  18. '
  19. ' For bugs & Constructive Criticism contact me on HF
  20. ' If you like it & want to donate then pm me on HF
  21. ' --------------------Unique Theme--------------------
  22. '<info>
  23.  
  24. 'Please Leave Credits in Source, Do not redistribute
  25.  
  26. Enum MouseState As Byte
  27.     None = 0
  28.     Over = 1
  29.     Down = 2
  30. End Enum
  31.  
  32. Module Draw
  33.     'Special Thanks to Aeonhack for RoundRect Functions... ;)
  34.     Public Function RoundRect(ByVal rectangle As Rectangle, ByVal curve As Integer) As GraphicsPath
  35.         Dim p As GraphicsPath = New GraphicsPath()
  36.         Dim arcRectangleWidth As Integer = curve * 2
  37.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  38.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  39.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  40.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  41.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  42.         Return p
  43.     End Function
  44.     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
  45.         Dim rectangle As Rectangle = New Rectangle(x, y, width, height)
  46.         Dim p As GraphicsPath = New GraphicsPath()
  47.         Dim arcRectangleWidth As Integer = curve * 2
  48.         p.AddArc(New Rectangle(rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -180, 90)
  49.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Y, arcRectangleWidth, arcRectangleWidth), -90, 90)
  50.         p.AddArc(New Rectangle(rectangle.Width - arcRectangleWidth + rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 0, 90)
  51.         p.AddArc(New Rectangle(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y, arcRectangleWidth, arcRectangleWidth), 90, 90)
  52.         p.AddLine(New Point(rectangle.X, rectangle.Height - arcRectangleWidth + rectangle.Y), New Point(rectangle.X, curve + rectangle.Y))
  53.         Return p
  54.     End Function
  55. End Module
  56.  
  57. Public Class UniqueTheme : Inherits ContainerControl
  58.     Dim WithEvents _mytimer As Windows.Forms.Timer
  59.     Dim _myval As Integer = 0
  60.     Private _mousepos As Point = New Point(0, 0)
  61.     Private _drag As Boolean = False
  62.     Private _icon As Icon
  63.     Public Property Icon() As Icon
  64.         Get
  65.             Return _icon
  66.         End Get
  67.         Set(ByVal value As Icon)
  68.             _icon = value
  69.             Invalidate()
  70.         End Set
  71.     End Property
  72.  
  73.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  74.         MyBase.OnMouseDown(e)
  75.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(55, 1, Width - 180, 35).Contains(e.Location) Then
  76.             _drag = True : _mousepos = e.Location
  77.         End If
  78.     End Sub
  79.  
  80.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  81.         MyBase.OnMouseUp(e)
  82.         _drag = False
  83.     End Sub
  84.  
  85.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  86.         MyBase.OnMouseMove(e)
  87.         If _drag Then
  88.             Parent.Location = New Point(MousePosition.X - _mousepos.X, MousePosition.Y - _mousepos.Y)
  89.         End If
  90.     End Sub
  91.  
  92.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  93.         MyBase.OnResize(e)
  94.         Invalidate()
  95.     End Sub
  96.  
  97.     Sub New()
  98.         MyBase.New()
  99.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  100.         BackColor = Color.FromArgb(32, 32, 32)
  101.         DoubleBuffered = True
  102.         _mytimer = New Timer()
  103.         _mytimer.Interval = 1000
  104.     End Sub
  105.  
  106.     Protected Overrides Sub OnCreateControl()
  107.         MyBase.OnCreateControl()
  108.         ParentForm.FormBorderStyle = FormBorderStyle.None
  109.         ParentForm.TransparencyKey = Color.Fuchsia
  110.         Dock = DockStyle.Fill
  111.     End Sub
  112.  
  113.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  114.         Dim b As Bitmap = New Bitmap(Width, Height)
  115.         Dim g As Graphics = Graphics.FromImage(b)
  116.         Dim outerrect As Rectangle = New Rectangle(7, 18, Width - 15, Height - 19)
  117.         Dim innerrect As Rectangle = New Rectangle(11, 22, Width - 23, Height - 27)
  118.         Dim headleftrecct As Rectangle = New Rectangle(1, 1, 35, 35)
  119.         Dim headcenterrect As Rectangle = New Rectangle(55, 1, Width - 180, 35)
  120.         Dim headrightrecct As Rectangle = New Rectangle(Width - 105, 1, 100, 35)
  121.         MyBase.OnPaint(e)
  122.         g.Clear(Color.Fuchsia)
  123.         g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  124.         g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  125.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  126.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  127.         Dim leftheader As New LinearGradientBrush(headleftrecct, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  128.         g.FillPath(leftheader, RoundRect(headleftrecct, 4))
  129.         g.DrawPath(New Pen(Brushes.Black), RoundRect(headleftrecct, 4))
  130.         Dim centerheader As New LinearGradientBrush(headcenterrect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  131.         g.FillPath(centerheader, RoundRect(headcenterrect, 4))
  132.         g.DrawPath(New Pen(Brushes.Black), RoundRect(headcenterrect, 4))
  133.         Dim rightheader As New LinearGradientBrush(headcenterrect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  134.         g.FillPath(rightheader, RoundRect(headrightrecct, 4))
  135.         g.DrawPath(New Pen(Brushes.Black), RoundRect(headrightrecct, 4))
  136.         Try
  137.             g.DrawIcon(_icon, New Rectangle(6, 6, 26, 26))
  138.         Catch : End Try
  139.         If _myval = 0 Then
  140.             g.DrawString(Text, New Font("Verdana", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(180, 180, 180)), headcenterrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  141.         ElseIf _myval = 1 Then
  142.             g.DrawString(Text, New Font("Verdana", 11, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), headcenterrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  143.         End If
  144.         If Not DesignMode Then _mytimer.Start()
  145.         e.Graphics.DrawImage(b, New Point(0, 0))
  146.         g.Dispose() : b.Dispose()
  147.     End Sub
  148.  
  149.     Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  150.         If _myval = 0 Then
  151.             _myval = 1
  152.         Else
  153.             _myval = 0
  154.         End If
  155.         Invalidate()
  156.     End Sub
  157. End Class
  158.  
  159. Public Class UniqueControlBox : Inherits Control
  160.     Dim _state As MouseState = MouseState.None
  161.     Dim _x As Integer
  162.     ReadOnly _minrect As New Rectangle(5, 2, 24, 24)
  163.     ReadOnly _maxrect As New Rectangle(32, 2, 24, 24)
  164.     ReadOnly _closerect As New Rectangle(59, 2, 24, 24)
  165.     Private _minDisable As Boolean = False
  166.     Public Property MinimumDisable As Boolean
  167.         Get
  168.             Return _minDisable
  169.         End Get
  170.         Set(value As Boolean)
  171.             _minDisable = value
  172.             Invalidate()
  173.         End Set
  174.     End Property
  175.  
  176.     Private _maxDisable As Boolean = False
  177.     Public Property MaximumDisable As Boolean
  178.         Get
  179.             Return _maxDisable
  180.         End Get
  181.         Set(value As Boolean)
  182.             _maxDisable = value
  183.             Invalidate()
  184.         End Set
  185.     End Property
  186.  
  187.     Protected Overrides Sub OnMouseDown(ByVal e As Windows.Forms.MouseEventArgs)
  188.         MyBase.OnMouseDown(e)
  189.         If _x > 5 AndAlso _x < 29 Then
  190.             If MinimumDisable = False Then
  191.                 FindForm.WindowState = FormWindowState.Minimized
  192.             End If
  193.         ElseIf _x > 32 AndAlso _x < 56 Then
  194.             If MaximumDisable = False Then
  195.                 If FindForm.WindowState = FormWindowState.Maximized Then
  196.                     FindForm.WindowState = FormWindowState.Minimized
  197.                     FindForm.WindowState = FormWindowState.Normal
  198.                 Else
  199.                     FindForm.WindowState = FormWindowState.Minimized
  200.                     FindForm.WindowState = FormWindowState.Maximized
  201.                 End If
  202.             End If
  203.         ElseIf _x > 59 AndAlso _x < 83 Then
  204.             FindForm.Close()
  205.         End If
  206.         _state = MouseState.Down : Invalidate()
  207.     End Sub
  208.  
  209.     Protected Overrides Sub OnMouseUp(ByVal e As Windows.Forms.MouseEventArgs)
  210.         MyBase.OnMouseUp(e)
  211.         _state = MouseState.Over : Invalidate()
  212.     End Sub
  213.  
  214.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  215.         MyBase.OnMouseEnter(e)
  216.         _state = MouseState.Over : Invalidate()
  217.     End Sub
  218.  
  219.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  220.         MyBase.OnMouseLeave(e)
  221.         _state = MouseState.None : Invalidate()
  222.     End Sub
  223.  
  224.     Protected Overrides Sub OnMouseMove(ByVal e As Windows.Forms.MouseEventArgs)
  225.         MyBase.OnMouseMove(e)
  226.         _x = e.Location.X
  227.         Invalidate()
  228.     End Sub
  229.  
  230.     Sub New()
  231.         MyBase.New()
  232.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  233.         DoubleBuffered = True
  234.         BackColor = Color.Transparent
  235.         Width = 85
  236.         Height = 30
  237.         Anchor = AnchorStyles.Top Or AnchorStyles.Right
  238.     End Sub
  239.  
  240.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  241.         Dim g As Graphics = e.Graphics
  242.         MyBase.OnPaint(e)
  243.         g.SmoothingMode = SmoothingMode.HighQuality
  244.         Dim minrdefault As New LinearGradientBrush(_minrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  245.         g.FillEllipse(minrdefault, _minrect)
  246.         g.DrawEllipse(Pens.DimGray, _minrect)
  247.         Dim maxrdefault As New LinearGradientBrush(_maxrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  248.         g.FillEllipse(maxrdefault, _maxrect)
  249.         g.DrawEllipse(Pens.DimGray, _maxrect)
  250.         Dim crdefault As New LinearGradientBrush(_closerect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  251.         g.FillEllipse(crdefault, _closerect)
  252.         g.DrawEllipse(Pens.DimGray, _closerect)
  253.         Select Case _state
  254.             Case MouseState.None
  255.                 Dim minrnone As New LinearGradientBrush(_minrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  256.                 g.FillEllipse(minrnone, _minrect)
  257.                 g.DrawEllipse(Pens.DimGray, _minrect)
  258.                 Dim maxrnone As New LinearGradientBrush(_maxrect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  259.                 g.FillEllipse(maxrnone, _maxrect)
  260.                 g.DrawEllipse(Pens.DimGray, _maxrect)
  261.                 Dim crnone As New LinearGradientBrush(_closerect, Color.FromArgb(89, 87, 85), Color.FromArgb(52, 52, 52), 90S)
  262.                 g.FillEllipse(crnone, _closerect)
  263.                 g.DrawEllipse(Pens.DimGray, _closerect)
  264.             Case MouseState.Over
  265.                 If _x > 5 AndAlso _x < 29 Then
  266.                     If MinimumDisable = False Then
  267.                         Dim minrover As New LinearGradientBrush(_minrect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  268.                         g.FillEllipse(minrover, _minrect)
  269.                         g.DrawEllipse(Pens.DimGray, _minrect)
  270.                     End If
  271.                 ElseIf _x > 32 AndAlso _x < 56 Then
  272.                     If MaximumDisable = False Then
  273.                         Dim maxrover As New LinearGradientBrush(_maxrect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  274.                         g.FillEllipse(maxrover, _maxrect)
  275.                         g.DrawEllipse(Pens.DimGray, _maxrect)
  276.                     End If
  277.                 ElseIf _x > 59 AndAlso _x < 83 Then
  278.                     Dim crover As New LinearGradientBrush(_closerect, Color.FromArgb(109, 107, 105), Color.FromArgb(72, 72, 72), 90S)
  279.                     g.FillEllipse(crover, _closerect)
  280.                     g.DrawEllipse(Pens.DimGray, _closerect)
  281.                 End If
  282.             Case Else
  283.                 If MinimumDisable = False Then
  284.                     Dim minrelse As New LinearGradientBrush(_minrect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  285.                     g.FillEllipse(minrelse, _minrect)
  286.                     g.DrawEllipse(Pens.DimGray, _minrect)
  287.                 End If
  288.                 If MaximumDisable = False Then
  289.                     Dim maxrelse As New LinearGradientBrush(_maxrect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  290.                     g.FillEllipse(maxrelse, _maxrect)
  291.                     g.DrawEllipse(Pens.DimGray, _maxrect)
  292.                 End If
  293.                 Dim crelse As New LinearGradientBrush(_closerect, Color.FromArgb(129, 127, 125), Color.FromArgb(92, 92, 92), 90S)
  294.                 g.FillEllipse(crelse, _closerect)
  295.                 g.DrawEllipse(Pens.DimGray, _closerect)
  296.         End Select
  297.     End Sub
  298. End Class
  299.  
  300. Public Class UniqueRadioButton : Inherits Control
  301.     Private _check As Boolean
  302.     Public Property Checked As Boolean
  303.         Get
  304.             Return _check
  305.         End Get
  306.         Set(value As Boolean)
  307.             _check = value
  308.             Invalidate()
  309.         End Set
  310.     End Property
  311.  
  312.     Sub New()
  313.         MyBase.New()
  314.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  315.         BackColor = Color.Transparent
  316.         DoubleBuffered = True
  317.         Size = New Size(180, 25)
  318.     End Sub
  319.  
  320.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  321.         MyBase.OnTextChanged(e)
  322.         Invalidate()
  323.     End Sub
  324.  
  325.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  326.         MyBase.OnClick(e)
  327.         If Not Checked Then Checked = True
  328.         For Each ctrl As UniqueRadioButton In From ctrl1 In Parent.Controls.OfType(Of UniqueRadioButton)() Where ctrl1.Handle <> Handle Where ctrl1.Enabled
  329.             ctrl.Checked = False
  330.         Next
  331.     End Sub
  332.  
  333.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  334.         Dim b As Bitmap = New Bitmap(Width, Height)
  335.         Dim g As Graphics = Graphics.FromImage(b)
  336.         MyBase.OnPaint(e)
  337.         g.SmoothingMode = SmoothingMode.HighQuality
  338.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  339.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  340.         g.Clear(BackColor)
  341.         g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  342.         Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
  343.         g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152), 2), selectionrect)
  344.         If Checked Then
  345.             selectionrect.Inflate(-4, -4)
  346.             g.DrawEllipse(New Pen(Color.FromArgb(182, 182, 182), 2), selectionrect)
  347.         Else
  348.             g.DrawEllipse(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
  349.         End If
  350.         e.Graphics.DrawImage(b, New Point(0, 0))
  351.         g.Dispose() : b.Dispose()
  352.     End Sub
  353. End Class
  354.  
  355. Public Class UniqueCheckBox : Inherits Control
  356.     Private _check As Boolean
  357.     Public Property Checked As Boolean
  358.         Get
  359.             Return _check
  360.         End Get
  361.         Set(value As Boolean)
  362.             _check = value
  363.             Invalidate()
  364.         End Set
  365.     End Property
  366.  
  367.     Sub New()
  368.         MyBase.New()
  369.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  370.         BackColor = Color.Transparent
  371.         DoubleBuffered = True
  372.         Size = New Size(180, 25)
  373.     End Sub
  374.  
  375.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  376.         MyBase.OnTextChanged(e)
  377.         Invalidate()
  378.     End Sub
  379.  
  380.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  381.         MyBase.OnClick(e)
  382.         If Not Checked Then Checked = True Else Checked = False
  383.     End Sub
  384.  
  385.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  386.         Dim b As Bitmap = New Bitmap(Width, Height)
  387.         Dim g As Graphics = Graphics.FromImage(b)
  388.         MyBase.OnPaint(e)
  389.         g.SmoothingMode = SmoothingMode.HighQuality
  390.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  391.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  392.         g.Clear(BackColor)
  393.         g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(12, 4, Width, 16), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  394.         Dim selectionrect As Rectangle = New Rectangle(3, 3, 17, 17)
  395.         g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152), 2), selectionrect)
  396.         If Checked Then
  397.             selectionrect.Inflate(-4, -4)
  398.             g.DrawRectangle(New Pen(Color.FromArgb(182, 182, 182), 2), selectionrect)
  399.         Else
  400.             g.DrawRectangle(New Pen(Color.FromArgb(152, 152, 152)), selectionrect)
  401.         End If
  402.         e.Graphics.DrawImage(b, New Point(0, 0))
  403.         g.Dispose() : b.Dispose()
  404.     End Sub
  405. End Class
  406.  
  407. Public Class UniqueProgressBar : Inherits Control
  408.     Dim WithEvents _mytimer As Windows.Forms.Timer
  409.     Dim _myval As Integer = 0
  410.     Private _val As Integer
  411.     Public Property Value() As Integer
  412.         Get
  413.             Return _val
  414.         End Get
  415.         Set(ByVal v As Integer)
  416.             If v > _max Then
  417.                 _val = _max
  418.             ElseIf v < 0 Then
  419.                 _val = 0
  420.             Else
  421.                 _val = v
  422.             End If
  423.             Invalidate()
  424.         End Set
  425.     End Property
  426.  
  427.     Private _max As Integer
  428.     Public Property Maximum() As Integer
  429.         Get
  430.             Return _max
  431.         End Get
  432.         Set(ByVal v As Integer)
  433.             If v < 1 Then
  434.                 _max = 1
  435.             Else
  436.                 _max = v
  437.             End If
  438.             If v < _val Then
  439.                 _val = _max
  440.             End If
  441.             Invalidate()
  442.         End Set
  443.     End Property
  444.  
  445.     Private _showPercentage As Boolean = False
  446.     Public Property ShowPercentage() As Boolean
  447.         Get
  448.             Return _showPercentage
  449.         End Get
  450.         Set(ByVal v As Boolean)
  451.             _showPercentage = v
  452.             Invalidate()
  453.         End Set
  454.     End Property
  455.  
  456.     Sub New()
  457.         MyBase.New()
  458.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  459.         BackColor = Color.Transparent
  460.         Size = New Size(200, 20)
  461.         DoubleBuffered = True
  462.         _max = 100
  463.         _mytimer = New Timer()
  464.         _mytimer.Interval = 500
  465.     End Sub
  466.  
  467.     Protected Overrides Sub OnPaint(e As Windows.Forms.PaintEventArgs)
  468.         Dim b As Bitmap = New Bitmap(Width, Height)
  469.         Dim g As Graphics = Graphics.FromImage(b)
  470.         Dim percent As Integer = CInt((Width - 1) * (_val / _max))
  471.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  472.         Dim innerrect As Rectangle = New Rectangle(1, 1, percent - 3, Height - 3)
  473.         MyBase.OnPaint(e)
  474.         g.Clear(BackColor)
  475.         g.SmoothingMode = SmoothingMode.HighQuality
  476.         g.FillPath(New SolidBrush(Color.FromArgb(129, 127, 125)), RoundRect(outerrect, 3))
  477.         If percent <> 0 Then
  478.             Try
  479.                 If _myval = 0 Then
  480.                     g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(innerrect, 3))
  481.                 ElseIf _myval = 1 Then
  482.                     g.FillPath(New SolidBrush(Color.FromArgb(62, 62, 62)), RoundRect(innerrect, 3))
  483.                 End If
  484.             Catch : End Try
  485.         End If
  486.         If Not DesignMode Then _mytimer.Start()
  487.         If _showPercentage Then
  488.             g.DrawString(String.Format("{0}%", _val), New Font("Verdana", 10, FontStyle.Regular), Brushes.White, New Rectangle(10, 1, Width - 1, Height - 1), New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  489.         End If
  490.         e.Graphics.DrawImage(b, New Point(0, 0))
  491.         g.Dispose() : b.Dispose()
  492.     End Sub
  493.  
  494.     Private Sub MyTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles _mytimer.Tick
  495.         If _myval = 0 Then
  496.             _myval = 1
  497.         Else
  498.             _myval = 0
  499.         End If
  500.         Invalidate()
  501.     End Sub
  502. End Class
  503.  
  504. Public Class UniquePanel : Inherits ContainerControl
  505.  
  506.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  507.         MyBase.OnResize(e)
  508.         Invalidate()
  509.     End Sub
  510.  
  511.     Sub New()
  512.         MyBase.New()
  513.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  514.         BackColor = Color.Transparent
  515.         DoubleBuffered = True
  516.         Size = New Size(240, 160)
  517.     End Sub
  518.  
  519.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  520.         Dim b As Bitmap = New Bitmap(Width, Height)
  521.         Dim g As Graphics = Graphics.FromImage(b)
  522.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  523.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  524.         MyBase.OnPaint(e)
  525.         g.SmoothingMode = SmoothingMode.HighQuality
  526.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  527.         g.Clear(BackColor)
  528.         g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  529.         g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  530.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  531.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  532.         e.Graphics.DrawImage(b, New Point(0, 0))
  533.         g.Dispose() : b.Dispose()
  534.     End Sub
  535. End Class
  536.  
  537. Public Class UniqueGroupBox : Inherits ContainerControl
  538.  
  539.     Protected Overrides Sub OnResize(ByVal e As EventArgs)
  540.         MyBase.OnResize(e)
  541.         Invalidate()
  542.     End Sub
  543.  
  544.     Sub New()
  545.         MyBase.New()
  546.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  547.         BackColor = Color.Transparent
  548.         DoubleBuffered = True
  549.         Size = New Size(240, 160)
  550.     End Sub
  551.  
  552.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  553.         Dim b As Bitmap = New Bitmap(Width, Height)
  554.         Dim g As Graphics = Graphics.FromImage(b)
  555.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  556.         Dim innerrect As Rectangle = New Rectangle(3, 3, Width - 7, Height - 7)
  557.         Dim underlinepen As New Pen(Color.FromArgb(255, 255, 255), 2)
  558.         MyBase.OnPaint(e)
  559.         g.SmoothingMode = SmoothingMode.HighQuality
  560.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  561.         g.Clear(BackColor)
  562.         g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  563.         g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  564.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  565.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  566.         g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 0, Width - 1, 30), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  567.         g.DrawLine(underlinepen, 20, 28, Width - 21, 28)
  568.         e.Graphics.DrawImage(b, New Point(0, 0))
  569.         g.Dispose() : b.Dispose()
  570.     End Sub
  571. End Class
  572.  
  573. Public Class UniqueButton : Inherits Control
  574.     Dim _state As MouseState
  575.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  576.         MyBase.OnMouseDown(e)
  577.         _state = MouseState.Down
  578.         Invalidate()
  579.     End Sub
  580.  
  581.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  582.         MyBase.OnMouseUp(e)
  583.         _state = MouseState.Over
  584.         Invalidate()
  585.     End Sub
  586.  
  587.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  588.         MyBase.OnMouseEnter(e)
  589.         _state = MouseState.Over
  590.         Invalidate()
  591.     End Sub
  592.  
  593.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  594.         MyBase.OnMouseLeave(e)
  595.         _state = MouseState.None
  596.         Invalidate()
  597.     End Sub
  598.  
  599.     Sub New()
  600.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  601.         BackColor = Color.Transparent
  602.         DoubleBuffered = True
  603.         Size = New Size(150, 30)
  604.         _state = MouseState.None
  605.     End Sub
  606.  
  607.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  608.         Dim b As Bitmap = New Bitmap(Width, Height)
  609.         Dim g As Graphics = Graphics.FromImage(b)
  610.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  611.         Dim btnfont As New Font("Verdana", 10, FontStyle.Regular)
  612.         MyBase.OnPaint(e)
  613.         g.SmoothingMode = SmoothingMode.HighQuality
  614.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  615.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  616.         g.Clear(BackColor)
  617.         Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  618.         g.FillPath(buttonrect, RoundRect(rect, 3))
  619.         g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  620.         Select Case _state
  621.             Case MouseState.None
  622.                 Dim buttonrectnone As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), LinearGradientMode.Vertical)
  623.                 g.FillPath(buttonrectnone, RoundRect(rect, 3))
  624.                 g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  625.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  626.             Case MouseState.Down
  627.                 Dim buttonrectdown As New LinearGradientBrush(rect, Color.FromArgb(76, 88, 105), Color.FromArgb(61, 62, 66), LinearGradientMode.Vertical)
  628.                 g.FillPath(buttonrectdown, RoundRect(rect, 3))
  629.                 g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  630.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  631.             Case MouseState.Over
  632.                 Dim buttonrectover As New LinearGradientBrush(rect, Color.FromArgb(66, 78, 95), Color.FromArgb(51, 52, 56), LinearGradientMode.Vertical)
  633.                 g.FillPath(buttonrectover, RoundRect(rect, 3))
  634.                 g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  635.                 g.DrawString(Text, btnfont, Brushes.White, New Rectangle(0, 0, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  636.         End Select
  637.         e.Graphics.DrawImage(b, New Point(0, 0))
  638.         g.Dispose() : b.Dispose()
  639.     End Sub
  640. End Class
  641.  
  642. Public Class UniqueTextBox : Inherits Control
  643.     Dim WithEvents _tb As New TextBox
  644.  
  645.     Private _allowpassword As Boolean = False
  646.     Public Shadows Property UseSystemPasswordChar() As Boolean
  647.         Get
  648.             Return _allowpassword
  649.         End Get
  650.         Set(ByVal value As Boolean)
  651.             _tb.UseSystemPasswordChar = UseSystemPasswordChar
  652.             _allowpassword = value
  653.             Invalidate()
  654.         End Set
  655.     End Property
  656.  
  657.     Private _maxChars As Integer = 32767
  658.     Public Shadows Property MaxLength() As Integer
  659.         Get
  660.             Return _maxChars
  661.         End Get
  662.         Set(ByVal value As Integer)
  663.             _maxChars = value
  664.             _tb.MaxLength = MaxLength
  665.             Invalidate()
  666.         End Set
  667.     End Property
  668.  
  669.     Private _textAlignment As HorizontalAlignment
  670.     Public Shadows Property TextAlign() As HorizontalAlignment
  671.         Get
  672.             Return _textAlignment
  673.         End Get
  674.         Set(ByVal value As HorizontalAlignment)
  675.             _textAlignment = value
  676.             Invalidate()
  677.         End Set
  678.     End Property
  679.  
  680.     Private _multiLine As Boolean = False
  681.     Public Shadows Property MultiLine() As Boolean
  682.         Get
  683.             Return _multiLine
  684.         End Get
  685.         Set(ByVal value As Boolean)
  686.             _multiLine = value
  687.             _tb.Multiline = value
  688.             OnResize(EventArgs.Empty)
  689.             Invalidate()
  690.         End Set
  691.     End Property
  692.  
  693.     Private _readOnly As Boolean = False
  694.     Public Shadows Property [ReadOnly]() As Boolean
  695.         Get
  696.             Return _readOnly
  697.         End Get
  698.         Set(ByVal value As Boolean)
  699.             _readOnly = value
  700.             If _tb IsNot Nothing Then
  701.                 _tb.ReadOnly = value
  702.             End If
  703.         End Set
  704.     End Property
  705.  
  706.     Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
  707.         MyBase.OnTextChanged(e)
  708.         Invalidate()
  709.     End Sub
  710.  
  711.     Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
  712.         MyBase.OnBackColorChanged(e)
  713.         Invalidate()
  714.     End Sub
  715.  
  716.     Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
  717.         MyBase.OnForeColorChanged(e)
  718.         _tb.ForeColor = ForeColor
  719.         Invalidate()
  720.     End Sub
  721.  
  722.     Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
  723.         MyBase.OnFontChanged(e)
  724.         _tb.Font = Font
  725.     End Sub
  726.  
  727.     Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
  728.         MyBase.OnGotFocus(e)
  729.         _tb.Focus()
  730.     End Sub
  731.  
  732.     Private Sub TextChangeTb() Handles _tb.TextChanged
  733.         Text = _tb.Text
  734.     End Sub
  735.  
  736.     Private Sub TextChng() Handles MyBase.TextChanged
  737.         _tb.Text = Text
  738.     End Sub
  739.  
  740.     Public Sub NewTextBox()
  741.         With _tb
  742.             .Text = String.Empty
  743.             .BackColor = Color.FromArgb(52, 52, 52)
  744.             .ForeColor = ForeColor
  745.             .TextAlign = HorizontalAlignment.Center
  746.             .BorderStyle = BorderStyle.None
  747.             .Location = New Point(3, 3)
  748.             .Font = New Font("Verdana", 10, FontStyle.Regular)
  749.             .Size = New Size(Width - 3, Height - 3)
  750.             .UseSystemPasswordChar = UseSystemPasswordChar
  751.         End With
  752.     End Sub
  753.  
  754.     Sub New()
  755.         MyBase.New()
  756.         NewTextBox()
  757.         Controls.Add(_tb)
  758.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  759.         DoubleBuffered = True
  760.         BackColor = Color.FromArgb(52, 52, 52)
  761.         ForeColor = Color.FromArgb(255, 255, 255)
  762.         Font = New Font("Verdana", 10, FontStyle.Regular)
  763.         Size = New Size(150, 30)
  764.     End Sub
  765.  
  766.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  767.         Dim b As Bitmap = New Bitmap(Width, Height)
  768.         Dim g As Graphics = Graphics.FromImage(b)
  769.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  770.         MyBase.OnPaint(e)
  771.         g.SmoothingMode = SmoothingMode.HighQuality
  772.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  773.         g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
  774.         With _tb
  775.             .TextAlign = TextAlign
  776.             .UseSystemPasswordChar = UseSystemPasswordChar
  777.         End With
  778.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  779.         g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  780.         e.Graphics.DrawImage(b, New Point(0, 0))
  781.         g.Dispose() : b.Dispose()
  782.     End Sub
  783.  
  784.     Protected Overrides Sub OnResize(e As EventArgs)
  785.         MyBase.OnResize(e)
  786.         If Not MultiLine Then
  787.             Dim tbheight As Integer = _tb.Height
  788.             _tb.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 1), Integer))
  789.             _tb.Size = New Size(Width - 20, tbheight)
  790.         Else
  791.             _tb.Location = New Point(10, 10)
  792.             _tb.Size = New Size(Width - 20, Height - 20)
  793.         End If
  794.     End Sub
  795. End Class
  796.  
  797. Public Class UniqueLabel : Inherits Control
  798.     Private _border As Boolean = True
  799.     Public Property Border As Boolean
  800.         Get
  801.             Return _border
  802.         End Get
  803.         Set(value As Boolean)
  804.             _border = value
  805.             Invalidate()
  806.         End Set
  807.     End Property
  808.  
  809.     Sub New()
  810.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  811.         BackColor = Color.Transparent
  812.         DoubleBuffered = True
  813.         Size = New Size(150, 30)
  814.     End Sub
  815.  
  816.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  817.         Dim b As Bitmap = New Bitmap(Width, Height)
  818.         Dim g As Graphics = Graphics.FromImage(b)
  819.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  820.         MyBase.OnPaint(e)
  821.         g.Clear(BackColor)
  822.         g.SmoothingMode = SmoothingMode.HighQuality
  823.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  824.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  825.         If Border = True Then
  826.             g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  827.         End If
  828.         g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), rect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  829.         e.Graphics.DrawImage(b, New Point(0, 0))
  830.         g.Dispose() : b.Dispose()
  831.     End Sub
  832. End Class
  833.  
  834. Public Class UniqueTabControl : Inherits TabControl
  835.  
  836.     Sub New()
  837.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  838.         BackColor = Color.Transparent
  839.         DoubleBuffered = True
  840.         ItemSize = New Size(80, 35)
  841.     End Sub
  842.  
  843.     Protected Overrides Sub OnPaint(ByVal e As Windows.Forms.PaintEventArgs)
  844.         Dim b As Bitmap = New Bitmap(Width, Height)
  845.         Dim g As Graphics = Graphics.FromImage(b)
  846.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  847.         Try : SelectedTab.BackColor = Color.FromArgb(72, 72, 72) : Catch : End Try
  848.         MyBase.OnPaint(e)
  849.         g.Clear(BackColor)
  850.         g.FillRectangle(New SolidBrush(Color.FromArgb(52, 52, 52)), rect)
  851.         g.DrawRectangle(New Pen(Brushes.Black), rect)
  852.         For i = 0 To TabCount - 1
  853.             Dim textRectangle As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 5, GetTabRect(i).Location.Y + 1), New Size(GetTabRect(i).Width, GetTabRect(i).Height - 5))
  854.             If i = SelectedIndex Then
  855.                 Dim tabrect As Rectangle = New Rectangle(New Point(GetTabRect(i).Location.X + 3, GetTabRect(i).Location.Y + 3), New Size(GetTabRect(i).Width - 6, GetTabRect(i).Height - 9))
  856.                 Dim buttonrect As New LinearGradientBrush(rect, Color.FromArgb(56, 68, 85), Color.FromArgb(41, 42, 46), 90S)
  857.                 g.FillPath(buttonrect, RoundRect(tabrect, 3))
  858.                 g.DrawPath(New Pen(Brushes.Black), RoundRect(tabrect, 3))
  859.                 g.DrawString(TabPages(i).Text, New Font("Verdana", 8, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  860.             Else
  861.                 g.DrawString(TabPages(i).Text, New Font("Verdana", 8, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), textRectangle, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Near})
  862.             End If
  863.         Next
  864.         e.Graphics.DrawImage(b, New Point(0, 0))
  865.         g.Dispose() : b.Dispose()
  866.     End Sub
  867. End Class
  868.  
  869. Public Class UniqueToggle : Inherits Control
  870.  
  871.     Private _check As Boolean
  872.     Public Property Checked As Boolean
  873.         Get
  874.             Return _check
  875.         End Get
  876.         Set(value As Boolean)
  877.             _check = value
  878.             Invalidate()
  879.         End Set
  880.     End Property
  881.  
  882.     Sub New()
  883.         MyBase.New()
  884.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  885.         DoubleBuffered = True
  886.         BackColor = Color.Transparent
  887.         Size = New Size(80, 25)
  888.     End Sub
  889.  
  890.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  891.         MyBase.OnClick(e)
  892.         If Not Checked Then Checked = True Else Checked = False
  893.     End Sub
  894.  
  895.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  896.         Dim b As Bitmap = New Bitmap(Width, Height)
  897.         Dim g As Graphics = Graphics.FromImage(b)
  898.         Dim rect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  899.         MyBase.OnPaint(e)
  900.         g.Clear(BackColor)
  901.         g.SmoothingMode = SmoothingMode.HighQuality
  902.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  903.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(rect, 3))
  904.         g.DrawPath(New Pen(Brushes.Black), RoundRect(rect, 3))
  905.         If Checked Then
  906.             g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(CInt((Width / 2) - 2), 2, CInt((Width / 2) - 1), Height - 5), 3))
  907.             g.DrawString("ON", New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 5, CInt((Width / 2)), 15), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  908.             g.DrawLine(New Pen(Color.Black), 56, 5, 56, Height - 7)
  909.             g.DrawLine(New Pen(Color.Black), 58, 3, 58, Height - 5)
  910.             g.DrawLine(New Pen(Color.Black), 60, 5, 60, Height - 7)
  911.         Else
  912.             g.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(2, 2, CInt((Width / 2) - 1), Height - 5), 3))
  913.             g.DrawString("OFF", New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(CInt((Width / 2)), 5, CInt((Width / 2)), 15), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  914.             g.DrawLine(New Pen(Color.Black), 20, 5, 20, Height - 7)
  915.             g.DrawLine(New Pen(Color.Black), 22, 3, 22, Height - 5)
  916.             g.DrawLine(New Pen(Color.Black), 24, 5, 24, Height - 7)
  917.         End If
  918.         e.Graphics.DrawImage(b, New Point(0, 0))
  919.         g.Dispose() : b.Dispose()
  920.     End Sub
  921. End Class
  922.  
  923. Public Class UniqueSeperator : Inherits Control
  924.  
  925.     Enum Style
  926.         Horizontal
  927.         Verticle
  928.     End Enum
  929.  
  930.     Private _alignment As Style = Style.Horizontal
  931.     Public Property Alignment As Style
  932.         Get
  933.             Return _alignment
  934.         End Get
  935.         Set(ByVal value As Style)
  936.             _alignment = value
  937.         End Set
  938.     End Property
  939.  
  940.     Private _showInfo As Boolean = False
  941.     Public Property ShowInfo As Boolean
  942.         Get
  943.             Return _showInfo
  944.         End Get
  945.         Set(ByVal value As Boolean)
  946.             _showInfo = value
  947.             Invalidate()
  948.         End Set
  949.     End Property
  950.  
  951.     Sub New()
  952.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  953.         DoubleBuffered = True
  954.         BackColor = Color.Transparent
  955.         Size = New Size(40, 40)
  956.     End Sub
  957.  
  958.     Protected Overrides Sub OnPaint(e As PaintEventArgs)
  959.         Dim b As Bitmap = New Bitmap(Width, Height)
  960.         Dim g As Graphics = Graphics.FromImage(b)
  961.         MyBase.OnPaint(e)
  962.         g.Clear(BackColor)
  963.         g.SmoothingMode = SmoothingMode.HighQuality
  964.         g.InterpolationMode = InterpolationMode.HighQualityBicubic
  965.         Select Case _alignment
  966.             Case Style.Horizontal
  967.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(20, CType((Height / 2), Integer) - 2), New Point(Width - 20, CType((Height / 2), Integer) - 2))
  968.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(10, CType((Height / 2), Integer) - 1), New Point(Width - 10, CType((Height / 2), Integer) - 1))
  969.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(0, CType((Height / 2), Integer)), New Point(Width, CType((Height / 2), Integer)))
  970.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(10, CType((Height / 2), Integer) + 1), New Point(Width - 10, CType((Height / 2), Integer) + 1))
  971.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(20, CType((Height / 2), Integer) + 2), New Point(Width - 20, CType((Height / 2), Integer) + 2))
  972.                 If ShowInfo = True Then
  973.                     g.DrawString(Text, New Font("Verdana", 10, FontStyle.Regular), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(0, 0, Width - 1, CType((Height / 2), Integer)), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  974.                 End If
  975.             Case Style.Verticle
  976.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) - 2, 20), New Point(CType((Width / 2), Integer) - 2, Height - 20))
  977.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) - 1, 10), New Point(CType((Width / 2), Integer) - 1, Height - 10))
  978.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer), 0), New Point(CType((Width / 2), Integer), Height))
  979.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) + 1, 10), New Point(CType((Width / 2), Integer) + 1, Height - 10))
  980.                 g.DrawLine(New Pen(Color.FromArgb(89, 87, 85)), New Point(CType((Width / 2), Integer) + 2, 20), New Point(CType((Width / 2), Integer) + 2, Height - 20))
  981.         End Select
  982.         e.Graphics.DrawImage(b, New Point(0, 0))
  983.         g.Dispose() : b.Dispose()
  984.     End Sub
  985. End Class
  986.  
  987. Public Class UniqueComboBox : Inherits ComboBox
  988.     Private _startIndex As Integer = 0
  989.     Private Property StartIndex As Integer
  990.         Get
  991.             Return _startIndex
  992.         End Get
  993.         Set(ByVal value As Integer)
  994.             _startIndex = value
  995.             Try
  996.                 SelectedIndex = value
  997.             Catch
  998.             End Try
  999.             Invalidate()
  1000.         End Set
  1001.     End Property
  1002.  
  1003.     Sub ReplaceItem(ByVal sender As System.Object, ByVal e As Windows.Forms.DrawItemEventArgs) Handles Me.DrawItem
  1004.         e.DrawBackground()
  1005.         Try
  1006.             If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
  1007.                 e.Graphics.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  1008.                 e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  1009.             Else
  1010.                 e.Graphics.FillPath(New SolidBrush(Color.FromArgb(72, 72, 72)), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  1011.                 e.Graphics.DrawPath(New Pen(Brushes.Black), RoundRect(New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height), 3))
  1012.             End If
  1013.             e.Graphics.DrawString(GetItemText(Items(e.Index)), e.Font, New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  1014.         Catch
  1015.         End Try
  1016.     End Sub
  1017.  
  1018.     Sub New()
  1019.         MyBase.New()
  1020.         SetStyle(ControlStyles.UserPaint Or ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True)
  1021.         DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
  1022.         BackColor = Color.Transparent
  1023.         DropDownStyle = ComboBoxStyle.DropDownList
  1024.         StartIndex = 0
  1025.         ItemHeight = 25
  1026.         DoubleBuffered = True
  1027.         Width = 200
  1028.     End Sub
  1029.  
  1030.     Protected Overrides Sub OnResize(e As EventArgs)
  1031.         MyBase.OnResize(e)
  1032.         Height = 20
  1033.     End Sub
  1034.  
  1035.     Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  1036.         Dim b As Bitmap = New Bitmap(Width, Height)
  1037.         Dim g As Graphics = Graphics.FromImage(b)
  1038.         Dim outerrect As Rectangle = New Rectangle(0, 0, Width - 1, Height - 1)
  1039.         Dim innerrect As Rectangle = New Rectangle(2, 2, Width - 5, Height - 5)
  1040.         MyBase.OnPaint(e)
  1041.         g.Clear(BackColor)
  1042.         g.FillPath(New SolidBrush(Color.FromArgb(89, 87, 85)), RoundRect(outerrect, 3))
  1043.         g.DrawPath(New Pen(Brushes.Black), RoundRect(outerrect, 3))
  1044.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  1045.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  1046.         g.SetClip(RoundRect(innerrect, 3))
  1047.         g.FillPath(New SolidBrush(Color.FromArgb(52, 52, 52)), RoundRect(innerrect, 3))
  1048.         g.DrawPath(New Pen(Brushes.Black), RoundRect(innerrect, 3))
  1049.         g.ResetClip()
  1050.         g.DrawLine(Pens.White, Width - 9, 10, Width - 22, 10)
  1051.         g.DrawLine(Pens.White, Width - 9, 11, Width - 22, 11)
  1052.         g.DrawLine(Pens.White, Width - 9, 15, Width - 22, 15)
  1053.         g.DrawLine(Pens.White, Width - 9, 16, Width - 22, 16)
  1054.         g.DrawLine(Pens.White, Width - 9, 20, Width - 22, 20)
  1055.         g.DrawLine(Pens.White, Width - 9, 21, Width - 22, 21)
  1056.         g.DrawLine(New Pen(Color.FromArgb(255, 255, 255)), New Point(Width - 29, 7), New Point(Width - 29, Height - 7))
  1057.         g.DrawLine(New Pen(Color.FromArgb(255, 255, 255)), New Point(Width - 30, 7), New Point(Width - 30, Height - 7))
  1058.         Try
  1059.             g.DrawString(Text, New Font("Verdana", 10, FontStyle.Bold), New SolidBrush(Color.FromArgb(255, 255, 255)), innerrect, New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  1060.         Catch : End Try
  1061.         e.Graphics.DrawImage(b, New Point(0, 0))
  1062.         g.Dispose() : b.Dispose()
  1063.     End Sub
  1064. End Class
Advertisement
Add Comment
Please, Sign In to add comment