Advertisement
ThePrinCe

[ VB.Net ] Sharp-Theme (01) [ GDI ]

Dec 15th, 2012
8,336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.ComponentModel, System.Drawing, System.Drawing.Drawing2D
  2. Enum MouseState As Byte
  3.     None = 0
  4.     Over = 1
  5.     Down = 2
  6.     Block = 3
  7. End Enum
  8.  
  9. Class SharpButton
  10.  
  11.     Inherits Control
  12.    
  13. #Region " Control Help - MouseState & Flicker Control"
  14.     Private State As MouseState = MouseState.None
  15.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  16.         MyBase.OnMouseEnter(e)
  17.         State = MouseState.Over
  18.         Invalidate()
  19.     End Sub
  20.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  21.         MyBase.OnMouseDown(e)
  22.         State = MouseState.Down
  23.         Invalidate()
  24.     End Sub
  25.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  26.         MyBase.OnMouseLeave(e)
  27.         State = MouseState.None
  28.         Invalidate()
  29.     End Sub
  30.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  31.         MyBase.OnMouseUp(e)
  32.         State = MouseState.Over
  33.         Invalidate()
  34.     End Sub
  35.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  36.         MyBase.OnTextChanged(e)
  37.         Invalidate()
  38.     End Sub
  39.  
  40. #End Region
  41.     Public Property Color2() As Boolean
  42.         Get
  43.             Return _Color2
  44.         End Get
  45.         Set(ByVal value As Boolean)
  46.             _Color2 = value
  47.             Me.Refresh()
  48.         End Set
  49.     End Property
  50.     Private _Color2 As Boolean = False
  51.     Sub New()
  52.         MyBase.New()
  53.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  54.         ForeColor = Color.FromArgb(210, 220, 230)
  55.         DoubleBuffered = True
  56.         Font = New Font("Verdana", 8.5F, FontStyle.Regular)
  57.     End Sub
  58.  
  59.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  60.         Dim bmp As New Bitmap(Width, Height)
  61.         Dim G As Graphics = Graphics.FromImage(bmp)
  62.         MyBase.OnPaint(e)
  63.  
  64.         Select Case State
  65.             Case MouseState.None
  66.                 If _Color2 Then
  67.                     G.Clear(Color.FromArgb(43, 53, 63))
  68.                     Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(37, 47, 57), Color.FromArgb(140, 149, 155), 180)
  69.                     G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  70.                     Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(140, 149, 155), Color.FromArgb(37, 47, 57), 180)
  71.                     G.FillRectangle(BTNLGB1, New Rectangle(1, 1, Width / 2, Height / 2 - 2))
  72.  
  73.                     G.SmoothingMode = SmoothingMode.HighQuality
  74.  
  75.                     '----- Borders -----
  76.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(23, 33, 43))), New Rectangle(0, 0, Width - 1, Height - 1))
  77.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(113, 123, 133), Color.FromArgb(50, 50, 50), 90)
  78.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  79.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(63, 73, 83))), 2, Height - 2, Width - 2, Height - 2)
  80.                     G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, -1, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  81.                 Else
  82.                     G.Clear(Color.FromArgb(43, 53, 63))
  83.                     Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(37, 47, 57), Color.FromArgb(140, 149, 155), LinearGradientMode.Horizontal)
  84.                     G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  85.                     Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(140, 149, 155), Color.FromArgb(37, 47, 57), LinearGradientMode.Horizontal)
  86.                     G.FillRectangle(BTNLGB1, New Rectangle(1, 1, Width / 2, Height / 2 - 2))
  87.  
  88.                     G.SmoothingMode = SmoothingMode.HighQuality
  89.  
  90.                     '----- Borders -----
  91.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectangle(0, 0, Width - 1, Height - 1))
  92.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(153, 163, 173), Color.FromArgb(50, 50, 50), 90)
  93.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  94.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(73, 83, 93))), 1, Height - 2, Width - 2, Height - 2)
  95.                     G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, -1, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  96.                 End If
  97.             Case MouseState.Over
  98.                 If _Color2 Then
  99.                     G.Clear(Color.FromArgb(47, 57, 67))
  100.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(43, 53, 63), Color.FromArgb(157, 166, 172), 180)
  101.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  102.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(157, 166, 172), Color.FromArgb(43, 53, 63), 180)
  103.                     G.FillRectangle(LGBOver1, New Rectangle(1, 1, Width / 2, Height / 2 - 2))
  104.  
  105.                     G.SmoothingMode = SmoothingMode.HighQuality
  106.  
  107.                     '----- Borders -----
  108.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(29, 39, 49))), New Rectangle(0, 0, Width - 1, Height - 1))
  109.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(153, 163, 173), Color.FromArgb(50, 50, 50), 90S)
  110.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  111.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(73, 83, 93))), 1, Height - 2, Width - 2, Height - 2)
  112.                     G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(200, 210, 220)), New Rectangle(0, -1, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  113.                 Else
  114.                     G.Clear(Color.FromArgb(51, 61, 71))
  115.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(43, 53, 63), Color.FromArgb(154, 163, 169), LinearGradientMode.Horizontal)
  116.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  117.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(154, 163, 169), Color.FromArgb(43, 53, 63), LinearGradientMode.Horizontal)
  118.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  119.  
  120.                     G.SmoothingMode = SmoothingMode.HighQuality
  121.  
  122.                     '----- Borders -----
  123.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(43, 53, 63))), New Rectangle(0, 0, Width - 1, Height - 1))
  124.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(163, 173, 183), Color.FromArgb(60, 60, 60), 90)
  125.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  126.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(83, 93, 103))), 1, Height - 2, Width - 2, Height - 2)
  127.                     G.DrawString(Text, Font, New SolidBrush(Color.FromArgb(200, 210, 220)), New Rectangle(0, -1, Width - 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  128.                 End If
  129.             Case MouseState.Down
  130.                 If _Color2 Then
  131.                     G.Clear(Color.FromArgb(37, 47, 57))
  132.                     Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(35, 45, 55), Color.FromArgb(132, 141, 147), 180)
  133.                     G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  134.                     Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(132, 141, 147), Color.FromArgb(35, 45, 55), 180)
  135.                     G.FillRectangle(BTNLGB1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  136.  
  137.                     G.SmoothingMode = SmoothingMode.HighQuality
  138.  
  139.                     '----- Borders -----
  140.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectangle(0, 0, Width - 1, Height - 1))
  141.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(93, 103, 113), Color.FromArgb(45, 45, 45), 90)
  142.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  143.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(53, 63, 73))), 1, Height - 2, Width - 2, Height - 2)
  144.                     G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(1, -1, Width - 1, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  145.                 Else
  146.                     G.Clear(Color.FromArgb(43, 53, 63))
  147.                     Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(27, 37, 47), Color.FromArgb(130, 139, 145), LinearGradientMode.Horizontal)
  148.                     G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  149.                     Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(130, 139, 145), Color.FromArgb(27, 37, 47), LinearGradientMode.Horizontal)
  150.                     G.FillRectangle(BTNLGB1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  151.  
  152.                     G.SmoothingMode = SmoothingMode.HighQuality
  153.  
  154.                     '----- Borders -----
  155.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectangle(0, 0, Width - 1, Height - 1))
  156.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(123, 133, 143), Color.FromArgb(55, 55, 55), 90)
  157.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  158.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(73, 83, 93))), 2, Height - 2, Width - 2, Height - 2)
  159.                     G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(1, -1, Width - 1, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  160.                 End If
  161.         End Select
  162.  
  163.         e.Graphics.DrawImage(bmp, 0, 0)
  164.         G.Dispose()
  165.         bmp.Dispose()
  166.  
  167.     End Sub
  168. End Class
  169.  
  170. Class SharpForm
  171.     Inherits ContainerControl
  172.     Private Header As Integer
  173.     Private Cap As Boolean
  174.     Private MouseP As Point = New Point(0, 0)
  175.     Private path As GraphicsPath
  176.     Protected G As Graphics, bmp As Bitmap
  177.     Private Function RoundRect(ByVal r As RectangleF, ByVal r1 As Single, ByVal r2 As Single, ByVal r3 As Single, ByVal r4 As Single) As GraphicsPath
  178.         Dim x As Single = r.X, y As Single = r.Y, w As Single = r.Width, h As Single = r.Height
  179.         Dim rr5 As GraphicsPath = New GraphicsPath
  180.         rr5.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y)
  181.         rr5.AddLine(x + r1, y, x + w - r2, y)
  182.         rr5.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2)
  183.         rr5.AddLine(x + w, y + r2, x + w, y + h - r3)
  184.         rr5.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h)
  185.         rr5.AddLine(x + w - r3, y + h, x + r4, y + h)
  186.         rr5.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4)
  187.         rr5.AddLine(x, y + h - r4, x, y + r1)
  188.         Return rr5
  189.     End Function
  190. #Region " Control Help - Movement & Flicker Control "
  191.     Protected Overrides Sub OnInvalidated(ByVal e As System.Windows.Forms.InvalidateEventArgs)
  192.         MyBase.OnInvalidated(e)
  193.         ParentForm.FindForm.Text = Text
  194.     End Sub
  195.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  196.         MyBase.OnTextChanged(e)
  197.         Invalidate()
  198.     End Sub
  199.     Protected Overrides Sub OnCreateControl()
  200.         MyBase.OnCreateControl()
  201.         Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  202.         Me.ParentForm.TransparencyKey = Color.Fuchsia
  203.     End Sub
  204.     Protected Overrides Sub CreateHandle()
  205.         MyBase.CreateHandle()
  206.     End Sub
  207.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  208.         MyBase.OnMouseDown(e)
  209.         If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, Header).Contains(e.Location) Then
  210.             Cap = True : MouseP = e.Location
  211.         End If
  212.     End Sub
  213.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  214.         MyBase.OnMouseUp(e) : Cap = False
  215.     End Sub
  216.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  217.         MyBase.OnMouseMove(e)
  218.         If Cap Then
  219.             Parent.Location = MousePosition - MouseP
  220.         End If
  221.     End Sub
  222.     Private Sub minimBtnClick() Handles minimBtn.Click
  223.         ParentForm.FindForm.WindowState = FormWindowState.Minimized
  224.     End Sub
  225.     Private Sub closeBtnClick() Handles closeBtn.Click
  226.         If CloseButtonExitsApp Then
  227.             System.Environment.Exit(0)
  228.         Else
  229.             ParentForm.FindForm.Close()
  230.         End If
  231.     End Sub
  232.     Private _closesEnv As Boolean = False
  233.     Public Property CloseButtonExitsApp() As Boolean
  234.         Get
  235.             Return _closesEnv
  236.         End Get
  237.         Set(ByVal v As Boolean)
  238.             _closesEnv = v
  239.             Invalidate()
  240.         End Set
  241.     End Property
  242.  
  243.     Private _minimBool As Boolean = True
  244.     Public Property MinimizeButton() As Boolean
  245.         Get
  246.             Return _minimBool
  247.         End Get
  248.         Set(ByVal v As Boolean)
  249.             _minimBool = v
  250.             Invalidate()
  251.         End Set
  252.     End Property
  253. #End Region
  254.  
  255.  
  256.     Dim WithEvents minimBtn As New SharpTopButton With {.TopButtonTXT = SharpTopButton.TxtState.Minim, .Location = New Point(Width - 60, 0)}
  257.     Dim WithEvents closeBtn As New SharpTopButton With {.TopButtonTXT = SharpTopButton.TxtState.Close, .Location = New Point(Width - 40, 0)}
  258.  
  259.  
  260.     Public Property Color2() As Boolean
  261.         Get
  262.             Return _Color2
  263.         End Get
  264.         Set(ByVal value As Boolean)
  265.             _Color2 = value
  266.             Me.Refresh()
  267.         End Set
  268.     End Property
  269.     Private _Color2 As Boolean = True
  270.  
  271.  
  272.     Sub New()
  273.         MyBase.new()
  274.         Header = 25
  275.         Dock = DockStyle.Fill
  276.         DoubleBuffered = True
  277.  
  278.         Controls.Add(closeBtn)
  279.  
  280.         closeBtn.Refresh() : minimBtn.Refresh()
  281.     End Sub
  282.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  283.         bmp = New Bitmap(Width, Height)
  284.         G = Graphics.FromImage(bmp)
  285.         Dim TransparencyKey As Color = Me.ParentForm.TransparencyKey
  286.  
  287.  
  288.         MyBase.OnPaint(e)
  289.  
  290.         If _minimBool Then
  291.             Controls.Add(minimBtn)
  292.         Else
  293.             Controls.Remove(minimBtn)
  294.         End If
  295.  
  296.         minimBtn.Location = New Point(Width - 60, 0)
  297.         closeBtn.Location = New Point(Width - 40, 0)
  298.  
  299.  
  300.         G.Clear(Color.FromArgb(43, 53, 63))
  301.         '---- Sides--
  302.        Dim LGBunderGrdrect As Rectangle = New Rectangle(1, Header, Width, 130)
  303.         Dim LGBunderGrd As New LinearGradientBrush(LGBunderGrdrect, Color.FromArgb(43, 53, 63), Color.FromArgb(70, 79, 85), 90)
  304.         G.FillRectangle(LGBunderGrd, LGBunderGrdrect)
  305.  
  306.  
  307.         If _Color2 Then
  308.             Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Header / 2), Color.FromArgb(20, 30, 40), Color.FromArgb(135, Color.White), 360)
  309.             G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Header / 2))
  310.             Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(-1, 1, Width, Header / 2), Color.FromArgb(100, Color.White), Color.FromArgb(20, 30, 40), 360)
  311.             G.FillRectangle(BTNLGB1, New Rectangle(-1, 1, Width / 2, Header / 2))
  312.             Dim txtbrushCL2 As Brush = New SolidBrush(Color.FromArgb(250, 250, 250))
  313.             G.DrawString(Text, Font, txtbrushCL2, New Rectangle(16, 6, Width - 1, 22), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  314.         Else
  315.             Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Header / 2), Color.FromArgb(35, 45, 55), Color.FromArgb(155, Color.White), 180)
  316.             G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Header / 2))
  317.             Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(-1, 1, Width, Header / 2), Color.FromArgb(120, Color.White), Color.FromArgb(35, 45, 55), 180)
  318.             G.FillRectangle(BTNLGB1, New Rectangle(-1, 1, Width / 2, Header / 2))
  319.             Dim txtbrush As Brush = New SolidBrush(Color.FromArgb(210, 220, 230))
  320.             G.DrawString(Text, Font, txtbrush, New Rectangle(16, 7, Width - 1, 22), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  321.         End If
  322.  
  323.  
  324.  
  325.  
  326.  
  327.         Dim InerRecLGB As Rectangle = New Rectangle(11, 28, Width - 22, Height - 37)
  328.         Dim InnerRecLGB As New LinearGradientBrush(InerRecLGB, Color.FromArgb(57, 67, 77), Color.FromArgb(60, 69, 75), 90)
  329.         G.FillRectangle(InnerRecLGB, InerRecLGB)
  330.  
  331.         '----- InnerRect
  332.        Dim P1 As Pen = New Pen(New SolidBrush(Color.FromArgb(23, 33, 43)))
  333.         G.DrawRectangle(P1, 12, 29, Width - 25, Height - 40)
  334.         Dim P2 As Pen = New Pen(New SolidBrush(Color.FromArgb(93, 103, 113)))
  335.         G.DrawRectangle(P2, 11, 28, Width - 23, Height - 38)
  336.  
  337.  
  338.  
  339.         Dim LGBunderGrd3 As New LinearGradientBrush(New Rectangle(0, Height - 9, Width \ 2, 50), Color.FromArgb(40, 50, 60), Color.FromArgb(50, Color.White), 360)
  340.         G.FillRectangle(LGBunderGrd3, 0, Height - 9, Width \ 2, 50)
  341.         Dim LGBunderGrd2 As New LinearGradientBrush(New Rectangle(Width \ 2, Height - 9, Width \ 2, Height), Color.FromArgb(40, 50, 60), Color.FromArgb(50, Color.White), 180)
  342.         G.FillRectangle(LGBunderGrd2, Width \ 2, Height - 9, Width \ 2, Height)
  343.         G.DrawLine(New Pen(Color.FromArgb(90, 90, 90)), Width \ 2, Height - 9, Width \ 2, Height)
  344.  
  345.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(137, 147, 157))), 1, 1, Width - 3, Height - 3)
  346.  
  347.         Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
  348.         G.DrawPath(Pens.Black, RoundRect(ClientRectangle, 0, 0, 0, 0))
  349.  
  350.         G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(163, 173, 183))), 2, 1, Width - 3, 1)
  351.         e.Graphics.DrawImage(bmp.Clone, 0, 0)
  352.         bmp.Dispose()
  353.         G.Dispose()
  354.  
  355.     End Sub
  356.  
  357. End Class
  358.  
  359. Class SharpTopButton
  360.     Inherits Control
  361. #Region " Control Help - MouseState & Flicker Control"
  362.     Enum MouseState As Byte
  363.         None = 0
  364.         Over = 1
  365.         Down = 2
  366.         Block = 3
  367.     End Enum
  368.     Private State As MouseState
  369.     Dim X As Integer
  370.  
  371.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  372.         MyBase.OnMouseEnter(e)
  373.         State = MouseState.Over
  374.         Invalidate()
  375.     End Sub
  376.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  377.         MyBase.OnMouseDown(e)
  378.         State = MouseState.Down
  379.         Invalidate()
  380.     End Sub
  381.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  382.         MyBase.OnMouseLeave(e)
  383.         State = MouseState.None
  384.         Invalidate()
  385.     End Sub
  386.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  387.         MyBase.OnMouseUp(e)
  388.         State = MouseState.Over
  389.         Invalidate()
  390.     End Sub
  391.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  392.     End Sub
  393.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  394.         MyBase.OnTextChanged(e)
  395.         Invalidate()
  396.     End Sub
  397.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  398.         MyBase.OnMouseMove(e)
  399.         X = e.X
  400.         Invalidate()
  401.     End Sub
  402.  
  403. #End Region
  404.     Enum TxtState As Byte
  405.         Close = 1
  406.         Minim = 2
  407.     End Enum
  408.     Private BtnTxt As TxtState
  409.     Public Property TopButtonTXT() As TxtState
  410.         Get
  411.             Return BtnTxt
  412.         End Get
  413.         Set(ByVal v As TxtState)
  414.             BtnTxt = v
  415.             Invalidate()
  416.         End Set
  417.     End Property
  418.     Sub New()
  419.         MyBase.New()
  420.         BackColor = Color.FromArgb(38, 38, 38)
  421.         Font = New Font("Verdana", 8.25F)
  422.         Size = New Size(30, 20)
  423.  
  424.         DoubleBuffered = True
  425.         Focus()
  426.     End Sub
  427.  
  428.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  429.         Dim bmp As New Bitmap(Width, Height)
  430.         Dim G As Graphics = Graphics.FromImage(bmp)
  431.         MyBase.OnPaint(e)
  432.  
  433.  
  434.         Select Case State
  435.             Case MouseState.Over
  436.  
  437.                 If BtnTxt = TxtState.Close Then
  438.                     G.Clear(Color.FromArgb(170, 18, 32))
  439.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(170, 18, 32), Color.FromArgb(147, 156, 162), 360)
  440.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  441.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(147, 156, 162), Color.FromArgb(170, 18, 32), 360)
  442.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  443.  
  444.                     G.SmoothingMode = SmoothingMode.HighQuality
  445.  
  446.                     '----- Borders -----
  447.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(39, 49, 59))), New Rectangle(0, 0, Width - 1, Height - 1))
  448.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(159, 169, 179), Color.FromArgb(90, 90, 90), 90)
  449.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  450.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(123, 133, 143))), 1, Height - 2, Width - 2, Height - 2)
  451.  
  452.                 ElseIf BtnTxt = TxtState.Minim Then
  453.                     G.Clear(Color.FromArgb(0, 102, 175))
  454.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(0, 102, 175), Color.FromArgb(157, 166, 172), 360)
  455.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  456.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(157, 166, 172), Color.FromArgb(0, 102, 175), 360)
  457.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  458.  
  459.                     G.SmoothingMode = SmoothingMode.HighQuality
  460.  
  461.                     '----- Borders -----
  462.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(39, 49, 59))), New Rectangle(0, 0, Width - 1, Height - 1))
  463.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(159, 169, 179), Color.FromArgb(90, 90, 90), 90)
  464.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  465.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(123, 133, 143))), 1, Height - 2, Width - 2, Height - 2)
  466.  
  467.                 End If
  468.             Case MouseState.None
  469.  
  470.                 If BtnTxt = TxtState.Close Then
  471.                     G.Clear(Color.FromArgb(140, 18, 32))
  472.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(140, 18, 32), Color.FromArgb(117, 126, 132), 360)
  473.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  474.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(117, 126, 132), Color.FromArgb(140, 18, 32), 360)
  475.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  476.  
  477.                     G.SmoothingMode = SmoothingMode.HighQuality
  478.  
  479.                     '----- Borders -----
  480.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectangle(0, 0, Width - 1, Height - 1))
  481.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(153, 163, 173), Color.FromArgb(85, 85, 85), 90)
  482.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  483.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(103, 113, 123))), 1, Height - 2, Width - 2, Height - 2)
  484.  
  485.                 ElseIf BtnTxt = TxtState.Minim Then
  486.                     G.Clear(Color.FromArgb(0, 102, 156))
  487.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(0, 102, 156), Color.FromArgb(117, 126, 132), 360)
  488.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  489.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(117, 126, 132), Color.FromArgb(0, 102, 156), 360)
  490.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  491.  
  492.                     G.SmoothingMode = SmoothingMode.HighQuality
  493.  
  494.                     '----- Borders -----
  495.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectangle(0, 0, Width - 1, Height - 1))
  496.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(153, 163, 173), Color.FromArgb(85, 85, 85), 90)
  497.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  498.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(103, 113, 123))), 1, Height - 2, Width - 2, Height - 2)
  499.  
  500.                 End If
  501.             Case MouseState.Down
  502.                 If BtnTxt = TxtState.Close Then
  503.                     G.Clear(Color.FromArgb(130, 18, 32))
  504.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(130, 18, 32), Color.FromArgb(117, 126, 132), 360)
  505.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  506.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(117, 126, 132), Color.FromArgb(130, 18, 32), 360)
  507.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  508.  
  509.                     G.SmoothingMode = SmoothingMode.HighQuality
  510.                     '----- Borders -----
  511.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 40, 50))), New Rectangle(0, 0, Width - 1, Height - 1))
  512.                     Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 2), Color.FromArgb(151, 161, 171), Color.FromArgb(83, 83, 83), 90)
  513.                     G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
  514.                     G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(97, 107, 117))), 1, Height - 2, Width - 2, Height - 2)
  515.  
  516.                 ElseIf BtnTxt = TxtState.Minim Then
  517.                     G.Clear(Color.FromArgb(0, 102, 146))
  518.                     Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2 - 2), Color.FromArgb(0, 102, 154), Color.FromArgb(132, 141, 147), 360)
  519.                     G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
  520.                     Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2 - 2), Color.FromArgb(132, 141, 147), Color.FromArgb(0, 102, 154), 360)
  521.                     G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
  522.  
  523.                     G.SmoothingMode = SmoothingMode.HighQuality
  524.  
  525.                     '----- Borders -----
  526.                    G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(37, 47, 57))), New Rectangle(0, 0, Width - 1, Height - 1))
  527.                     Dim InnerRect1 As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height - 3), Color.FromArgb(150, 150, 150), Color.FromArgb(127, 137, 147), 90S)
  528.                     G.DrawRectangle(New Pen(InnerRect1), New Rectangle(1, 1, Width - 3, Height - 3))
  529.                 End If
  530.  
  531.         End Select
  532.         Select Case BtnTxt
  533.             Case TxtState.Close
  534.                 Size = New Size(30, 20)
  535.                 G.DrawString("r", New Font("Marlett", 8.75), New SolidBrush(Color.FromArgb(220, Color.White)), New Rectangle(0, 1, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  536.             Case TxtState.Minim
  537.                 Size = New Size(25, 20)
  538.                 G.DrawString("0", New Font("Marlett", 12), New SolidBrush(Color.FromArgb(220, Color.White)), New Rectangle(1, -1, Width - 1, Height - 1), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center})
  539.         End Select
  540.  
  541.         '  G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(40, 40, 40))), 0, 0, 29, 19)
  542.  
  543.         e.Graphics.DrawImage(bmp.Clone(), 0, 0)
  544.         G.Dispose() : bmp.Dispose()
  545.     End Sub
  546.  
  547. End Class
  548.  
  549. Class SharpGroupBOx
  550.     Inherits ContainerControl
  551. #Region " Control Help - Properties & Flicker Control"
  552.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  553.         MyBase.OnTextChanged(e)
  554.         Invalidate()
  555.     End Sub
  556. #End Region
  557.     Sub New()
  558.         MyBase.New()
  559.         Size = New Size(200, 100)
  560.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  561.         'BackColor = Color.Transparent
  562.        DoubleBuffered = True
  563.         ForeColor = Color.FromArgb(210, 220, 230)
  564.     End Sub
  565.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  566.         Dim bmp As New Bitmap(Width, Height)
  567.         Dim G As Graphics = Graphics.FromImage(bmp)
  568.  
  569.         MyBase.OnPaint(e)
  570.         G.SmoothingMode = SmoothingMode.HighQuality
  571.  
  572.         G.Clear(Color.FromArgb(43, 53, 63))
  573.  
  574.         Dim s2 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 25), Color.FromArgb(35, 45, 55), Color.FromArgb(50, Color.White), 90S)
  575.         G.FillRectangle(s2, New Rectangle(1, 14, Width - 3, 13))
  576.         Dim s1 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 25), Color.FromArgb(90, Color.White), Color.FromArgb(35, 45, 55), 90S)
  577.         G.FillRectangle(s1, New Rectangle(1, 1, Width - 3, 13))
  578.  
  579.  
  580.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 40, 50))), 0, 0, Width - 1, 28)
  581.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(111, 121, 131))), 1, 1, Width - 3, 26)
  582.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 40, 50))), 0, 30, Width - 1, Height - 31)
  583.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(60, 70, 80))), 1, 31, Width - 3, Height - 33)
  584.  
  585.         G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 30, 30))), New Rectangle(0, 0, Width - 1, Height - 1))
  586.         G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(20, 30, 40))), 1, 29, Width - 2, 29)
  587.  
  588.         G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(1, 4, Width, 20), New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
  589.  
  590.         e.Graphics.DrawImage(bmp.Clone(), 0, 0)
  591.         G.Dispose() : bmp.Dispose()
  592.     End Sub
  593. End Class
  594.  
  595. Class SharpProgreSsBar
  596.     Inherits Control
  597.     Private GlowAnimation As Timer = New Timer
  598.     'Private _GlowColor As Color = Color.FromArgb(55, 65, 75)
  599.    Private _GlowColor As Color = Color.FromArgb(50, 255, 255, 255)
  600.     Private _Animate As Boolean = True
  601.     Private _Value As Int32 = 0
  602.     Private _HighlightColor As Color = Color.Silver
  603.     Private _BackgroundColor As Color = Color.FromArgb(150, 150, 150)
  604.     Private _StartColor As Color = Color.FromArgb(110, 110, 110)
  605. #Region "Properties"
  606.     Public Property Color() As Color
  607.         Get
  608.             Return _StartColor
  609.         End Get
  610.         Set(ByVal value As Color)
  611.             _StartColor = value
  612.             Me.Invalidate()
  613.         End Set
  614.     End Property
  615.     Public Property Animate() As Boolean
  616.         Get
  617.             Return _Animate
  618.         End Get
  619.         Set(ByVal value As Boolean)
  620.             _Animate = value
  621.             If value = True Then
  622.                 GlowAnimation.Start()
  623.             Else
  624.                 GlowAnimation.Stop()
  625.             End If
  626.             Me.Invalidate()
  627.         End Set
  628.     End Property
  629.     Public Property GlowColor() As Color
  630.         Get
  631.             Return _GlowColor
  632.         End Get
  633.         Set(ByVal value As Color)
  634.             _GlowColor = value
  635.             Me.Invalidate()
  636.         End Set
  637.     End Property
  638.     Public Property Value() As Int32
  639.         Get
  640.             Return _Value
  641.         End Get
  642.         Set(ByVal value As Int32)
  643.             If value < 0 Then Return
  644.             _Value = value
  645.             If value < 100 Then GlowAnimation.Start()
  646.  
  647.             Me.Invalidate()
  648.         End Set
  649.     End Property
  650.     Public Property BackgroundColor() As Color
  651.         Get
  652.             Return _BackgroundColor
  653.         End Get
  654.         Set(ByVal value As Color)
  655.             _BackgroundColor = value
  656.             Me.Invalidate()
  657.         End Set
  658.     End Property
  659.     Public Property HighlightColor() As Color
  660.         Get
  661.             Return _HighlightColor
  662.         End Get
  663.         Set(ByVal value As Color)
  664.             _HighlightColor = value
  665.             Me.Invalidate()
  666.         End Set
  667.     End Property
  668.  
  669. #End Region
  670.     Private Function InDesignMode() As Boolean
  671.         Return (LicenseManager.UsageMode = LicenseUsageMode.Designtime)
  672.     End Function
  673.     Sub New()
  674.         MyBase.New()
  675.         DoubleBuffered = True
  676.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  677.  
  678.         If Not InDesignMode() Then
  679.             GlowAnimation.Interval = 15
  680.             If Value < 100 Then GlowAnimation.Start()
  681.  
  682.             AddHandler GlowAnimation.Tick, AddressOf GlowAnimation_Tick
  683.         End If
  684.     End Sub
  685.     Private _mGlowPosition As Integer = -100
  686.  
  687.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  688.         Dim B As New Bitmap(Width, Height)
  689.         Dim G As Graphics = Graphics.FromImage(B)
  690.         G.SmoothingMode = SmoothingMode.HighQuality
  691.  
  692.         G.Clear(Color.FromArgb(43, 53, 63))
  693.         '   -------------------Draw Background for the MBProgressBar--------------------
  694.  
  695.         Dim s2 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 50), Color.FromArgb(35, 45, 55), Color.FromArgb(50, Color.White), 90S)
  696.  
  697.         Dim s1 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 50), Color.FromArgb(75, Color.White), Color.FromArgb(35, 45, 55), 90)
  698.  
  699.         Dim BackRectangle As Rectangle = Me.ClientRectangle
  700.         BackRectangle.Width = BackRectangle.Width - 1
  701.         BackRectangle.Height = BackRectangle.Height - 1
  702.         Dim GrafP As GraphicsPath = RoundRect(BackRectangle, 2, 2, 2, 2)
  703.         G.FillPath(s1, GrafP)
  704.  
  705.  
  706.         '--------------------Draw Background Shadows for MBProgrssBar------------------
  707.        Dim BGSH As Rectangle = New Rectangle(2, 2, 10, Me.Height - 5)
  708.         Dim LGBS As LinearGradientBrush = New LinearGradientBrush(BGSH, Color.FromArgb(70, 80, 90), Color.FromArgb(95, 105, 115), LinearGradientMode.Horizontal)
  709.         G.FillRectangle(LGBS, BGSH)
  710.         Dim BGSRectangle As Rectangle = New Rectangle(Me.Width - 12, 2, 10, Me.Height - 5)
  711.         Dim LG As LinearGradientBrush = New LinearGradientBrush(BGSRectangle, Color.FromArgb(80, 90, 100), Color.FromArgb(75, 85, 95), LinearGradientMode.Horizontal)
  712.         G.FillRectangle(LG, BGSRectangle)
  713.  
  714.  
  715.         '----------------------Draw MBProgressBar--------------------  
  716.        Dim ProgressRect As Rectangle = New Rectangle(1, 2, Me.Width - 3, Me.Height - 3)
  717.         ProgressRect.Width = CInt((Value * 1.0F / (100) * Me.Width))
  718.         G.FillRectangle(s2, ProgressRect)
  719.  
  720.  
  721.         '----------------------Draw Shadows for MBProgressBar------------------
  722.        Dim SHRect As Rectangle = New Rectangle(1, 2, 15, Me.Height - 3)
  723.         Dim LGSHP As LinearGradientBrush = New LinearGradientBrush(SHRect, Color.Black, Color.Black, LinearGradientMode.Horizontal)
  724.  
  725.         Dim BColor As ColorBlend = New ColorBlend(3)
  726.         BColor.Colors = New Color() {Color.Gray, Color.FromArgb(40, 0, 0, 0), Color.Transparent}
  727.         BColor.Positions = New Single() {0.0F, 0.2F, 1.0F}
  728.         LGSHP.InterpolationColors = BColor
  729.  
  730.         SHRect.X = SHRect.X - 1
  731.         G.FillRectangle(LGSHP, SHRect)
  732.  
  733.         Dim Rect1 As Rectangle = New Rectangle(Me.Width - 3, 2, 15, Me.Height - 3)
  734.         Rect1.X = CInt((Value * 1.0F / (100) * Me.Width) - 14)
  735.         Dim LGSH1 As LinearGradientBrush = New LinearGradientBrush(Rect1, Color.Black, Color.Black, LinearGradientMode.Horizontal)
  736.  
  737.         Dim BColor1 As ColorBlend = New ColorBlend(3)
  738.         BColor1.Colors = New Color() {Color.Transparent, Color.FromArgb(70, 0, 0, 0), Color.Transparent}
  739.         BColor1.Positions = New Single() {0.0F, 0.8F, 1.0F}
  740.         LGSH1.InterpolationColors = BColor1
  741.  
  742.         G.FillRectangle(LGSH1, Rect1)
  743.  
  744.  
  745.         '-------------------------Draw Highlight for MBProgressBar-----------------
  746.        Dim HLRect As Rectangle = New Rectangle(1, 1, Me.Width - 1, 6)
  747.         Dim HLGPa As GraphicsPath = RoundRect(HLRect, 2, 2, 0, 0)
  748.         'G.SetClip(HLGPa)
  749.        Dim HLGBS As LinearGradientBrush = New LinearGradientBrush(HLRect, Color.FromArgb(190, 190, 190), Color.FromArgb(150, 150, 150), LinearGradientMode.Vertical)
  750.         G.FillPath(HLGBS, HLGPa)
  751.         G.ResetClip()
  752.         Dim HLrect2 As Rectangle = New Rectangle(1, Me.Height - 8, Me.Width - 1, 6)
  753.         Dim bp1 As GraphicsPath = RoundRect(HLrect2, 0, 0, 2, 2)
  754.         ' G.SetClip(bp1)
  755.        Dim bg1 As LinearGradientBrush = New LinearGradientBrush(HLrect2, Color.Transparent, Color.FromArgb(150, Me.HighlightColor), LinearGradientMode.Vertical)
  756.         G.FillPath(bg1, bp1)
  757.         G.ResetClip()
  758.  
  759.  
  760.         '--------------------Draw Inner Sroke for MBProgressBar--------------
  761.        Dim Rect20 As Rectangle = Me.ClientRectangle
  762.         Rect20.X = Rect20.X + 1
  763.         Rect20.Y = Rect20.Y + 1
  764.         Rect20.Width -= 3
  765.         Rect20.Height -= 3
  766.         Dim Rect15 As GraphicsPath = RoundRect(Rect20, 2, 2, 2, 2)
  767.         G.DrawPath(New Pen(Color.FromArgb(55, 65, 75)), Rect15)
  768.  
  769.         '-----------------------Draw Outer Stroke on the Control----------------------------
  770.        Dim StrokeRect As Rectangle = Me.ClientRectangle
  771.         StrokeRect.Width = StrokeRect.Width - 1
  772.         StrokeRect.Height = StrokeRect.Height - 1
  773.         Dim GGH As GraphicsPath = RoundRect(StrokeRect, 2, 2, 2, 2)
  774.         G.DrawPath(New Pen(Color.FromArgb(122, 122, 122)), GGH)
  775.  
  776.         '------------------------Draw Glow for MBProgressBar-----------------------
  777.        Dim GlowRect As Rectangle = New Rectangle(_mGlowPosition, 6, 60, 60)
  778.         Dim GlowLGBS As LinearGradientBrush = New LinearGradientBrush(GlowRect, Color.FromArgb(127, 137, 147), Color.FromArgb(75, 85, 95), LinearGradientMode.Horizontal)
  779.         Dim BColor3 As ColorBlend = New ColorBlend(4)
  780.         BColor3.Colors = New Color() {Color.Transparent, Me.GlowColor, Me.GlowColor, Color.Transparent}
  781.         BColor3.Positions = New Single() {0.0F, 0.5F, 0.6F, 1.0F}
  782.         GlowLGBS.InterpolationColors = BColor3
  783.         Dim clip As Rectangle = New Rectangle(1, 2, Me.Width - 3, Me.Height - 3)
  784.         clip.Width = CInt((Value * 1.0F / (100) * Me.Width))
  785.         G.SetClip(clip)
  786.         G.FillRectangle(GlowLGBS, GlowRect)
  787.         G.ResetClip()
  788.  
  789.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  790.         G.Dispose() : B.Dispose()
  791.     End Sub
  792.  
  793.     Private Function RoundRect(ByVal r As RectangleF, ByVal r1 As Single, ByVal r2 As Single, ByVal r3 As Single, ByVal r4 As Single) As GraphicsPath
  794.         Dim x As Single = r.X, y As Single = r.Y, w As Single = r.Width, h As Single = r.Height
  795.         Dim rr5 As GraphicsPath = New GraphicsPath
  796.         rr5.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y)
  797.         rr5.AddLine(x + r1, y, x + w - r2, y)
  798.         rr5.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2)
  799.         rr5.AddLine(x + w, y + r2, x + w, y + h - r3)
  800.         rr5.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w - r3, y + h)
  801.         rr5.AddLine(x + w - r3, y + h, x + r4, y + h)
  802.         rr5.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4)
  803.         rr5.AddLine(x, y + h - r4, x, y + r1)
  804.         Return rr5
  805.     End Function
  806.     Private Sub GlowAnimation_Tick(ByVal sender As Object, ByVal e As EventArgs)
  807.         If Me.Animate Then
  808.             _mGlowPosition += 4
  809.             If _mGlowPosition > Me.Width Then
  810.                 _mGlowPosition = -10
  811.                 Me.Invalidate()
  812.             End If
  813.  
  814.         Else
  815.  
  816.             GlowAnimation.Stop()
  817.  
  818.             _mGlowPosition = -50
  819.         End If
  820.     End Sub
  821.  
  822. End Class
  823.  
  824. Class SharpTextBox : Inherits Control
  825.     Dim WithEvents txtbox As New TextBox
  826.  
  827. #Region " Control Help - Properties & Flicker Control "
  828.     Private _passmask As Boolean = False
  829.     Public Shadows Property UseSystemPasswordChar() As Boolean
  830.         Get
  831.             Return _passmask
  832.         End Get
  833.         Set(ByVal v As Boolean)
  834.             txtbox.UseSystemPasswordChar = UseSystemPasswordChar
  835.             _passmask = v
  836.             Invalidate()
  837.         End Set
  838.     End Property
  839.     Private _maxchars As Integer = 32767
  840.     Public Shadows Property MaxLength() As Integer
  841.         Get
  842.             Return _maxchars
  843.         End Get
  844.         Set(ByVal v As Integer)
  845.             _maxchars = v
  846.             txtbox.MaxLength = MaxLength
  847.             Invalidate()
  848.         End Set
  849.     End Property
  850.     Private _align As HorizontalAlignment
  851.     Public Shadows Property TextAlignment() As HorizontalAlignment
  852.         Get
  853.             Return _align
  854.         End Get
  855.         Set(ByVal v As HorizontalAlignment)
  856.             _align = v
  857.             Invalidate()
  858.         End Set
  859.     End Property
  860.  
  861.     Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
  862.     End Sub
  863.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  864.         MyBase.OnTextChanged(e)
  865.         Invalidate()
  866.     End Sub
  867.     Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
  868.         MyBase.OnBackColorChanged(e)
  869.         txtbox.BackColor = BackColor
  870.         Invalidate()
  871.     End Sub
  872.     Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
  873.         MyBase.OnForeColorChanged(e)
  874.         txtbox.ForeColor = ForeColor
  875.         Invalidate()
  876.     End Sub
  877.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  878.         MyBase.OnFontChanged(e)
  879.         txtbox.Font = Font
  880.     End Sub
  881.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  882.         MyBase.OnGotFocus(e)
  883.         txtbox.Focus()
  884.     End Sub
  885.     Sub TextChngTxtBox() Handles txtbox.TextChanged
  886.         Text = txtbox.Text
  887.     End Sub
  888.     Sub TextChng() Handles MyBase.TextChanged
  889.         txtbox.Text = Text
  890.     End Sub
  891.     Sub NewTextBox()
  892.         With txtbox
  893.             .Multiline = False
  894.             .BackColor = Color.FromArgb(43, 43, 43)
  895.             .ForeColor = ForeColor
  896.             .Text = String.Empty
  897.             .TextAlign = HorizontalAlignment.Center
  898.             .BorderStyle = BorderStyle.None
  899.             .Location = New Point(5, 5)
  900.             .Font = New Font("Verdana", 8)
  901.             .Size = New Size(Width - 10, Height - 11)
  902.             .UseSystemPasswordChar = UseSystemPasswordChar
  903.         End With
  904.  
  905.     End Sub
  906. #End Region
  907.  
  908.     Sub New()
  909.         MyBase.New()
  910.         NewTextBox()
  911.         Controls.Add(txtbox)
  912.         Text = ""
  913.         BackColor = Color.FromArgb(35, 45, 55)
  914.         ForeColor = Color.FromArgb(162, 172, 182)
  915.         Size = New Size(135, 35)
  916.         DoubleBuffered = True
  917.     End Sub
  918.  
  919.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  920.         Dim B As New Bitmap(Width, Height)
  921.         Dim G As Graphics = Graphics.FromImage(B)
  922.         G.SmoothingMode = SmoothingMode.HighQuality
  923.         MyBase.OnPaint(e)
  924.  
  925.         Height = txtbox.Height + 11
  926.         With txtbox
  927.             .Width = Width - 10
  928.             .TextAlign = TextAlignment
  929.             .UseSystemPasswordChar = UseSystemPasswordChar
  930.         End With
  931.  
  932.         G.Clear(Color.FromArgb(35, 45, 55))
  933.         Dim txtRect As New Rectangle(0, 0, Width - 1, Height - 1)
  934.         Dim InnerRect As New LinearGradientBrush(txtRect, Color.FromArgb(74, 84, 94), Color.FromArgb(94, 104, 114), 90S)
  935.  
  936.         G.DrawRectangle(New Pen(Color.FromArgb(12, 22, 32), 2), txtRect)
  937.         G.DrawLine(New Pen(InnerRect), Width - 1, 0, Width - 1, Height)
  938.         G.DrawLine(New Pen(InnerRect), 0, Height - 1, Width - 1, Height - 1)
  939.  
  940.  
  941.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  942.         G.Dispose() : B.Dispose()
  943.     End Sub
  944.  
  945. End Class
  946.  
  947. Class SharpCheckBox : Inherits Control
  948.    
  949. #Region " Control Help - MouseState & Flicker Control"
  950.     Private State As MouseState = MouseState.None
  951.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  952.         MyBase.OnMouseEnter(e)
  953.         State = MouseState.Over
  954.         Invalidate()
  955.     End Sub
  956.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  957.         MyBase.OnMouseDown(e)
  958.         State = MouseState.Down
  959.         Invalidate()
  960.     End Sub
  961.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  962.         MyBase.OnMouseLeave(e)
  963.         State = MouseState.None
  964.         Invalidate()
  965.     End Sub
  966.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  967.         MyBase.OnMouseUp(e)
  968.         State = MouseState.Over
  969.         Invalidate()
  970.     End Sub
  971.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  972.         MyBase.OnTextChanged(e)
  973.         Invalidate()
  974.     End Sub
  975.     Private _Checked As Boolean
  976.     Property Checked() As Boolean
  977.         Get
  978.             Return _Checked
  979.         End Get
  980.         Set(ByVal value As Boolean)
  981.             _Checked = value
  982.             Invalidate()
  983.         End Set
  984.     End Property
  985.  
  986.     Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
  987.         _Checked = Not _Checked
  988.         RaiseEvent CheckedChanged(Me)
  989.         MyBase.OnClick(e)
  990.     End Sub
  991.     Event CheckedChanged(ByVal sender As Object)
  992.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  993.         MyBase.OnResize(e)
  994.         Height = 18
  995.     End Sub
  996. #End Region
  997.  
  998.     Sub New()
  999.         MyBase.New()
  1000.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1001.         BackColor = Color.Transparent
  1002.         Size = New Size(145, 16)
  1003.         ForeColor = Color.FromArgb(210, 210, 222)
  1004.         DoubleBuffered = True
  1005.         Font = New Font("Verdana", 8)
  1006.     End Sub
  1007.  
  1008.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1009.         Dim B As New Bitmap(Width, Height)
  1010.         Dim G As Graphics = Graphics.FromImage(B)
  1011.  
  1012.         MyBase.OnPaint(e)
  1013.         G.SmoothingMode = SmoothingMode.HighQuality
  1014.         G.Clear(BackColor)
  1015.         If Checked = False Then
  1016.             Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(3, 3, 12, 11), Color.FromArgb(37, 47, 57), Color.FromArgb(62, 68, 74), 90)
  1017.             G.FillRectangle(BTNLGBOver, New Rectangle(3, 3, 12, 11))
  1018.  
  1019.  
  1020.         Else
  1021.  
  1022.             Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(3, 3, 12, 11), Color.FromArgb(73, 83, 93), Color.FromArgb(40, 50, 60), 90)
  1023.             G.FillRectangle(BTNLGBOver, New Rectangle(3, 3, 12, 11))
  1024.  
  1025.             Dim chkRec12 As New Rectangle(3, 2, Height - 5, Height - 6)
  1026.             Dim chkPoly As Rectangle = New Rectangle(chkRec12.X + chkRec12.Width / 4, chkRec12.Y + chkRec12.Height / 4, chkRec12.Width \ 2, chkRec12.Height \ 2)
  1027.             Dim Poly() As Point = {New Point(chkPoly.X, chkPoly.Y + chkPoly.Height \ 2), _
  1028.                            New Point(chkPoly.X + chkPoly.Width \ 2, chkPoly.Y + chkPoly.Height), _
  1029.                            New Point(chkPoly.X + chkPoly.Width, chkPoly.Y)}
  1030.  
  1031.             Dim P1 As Pen = New Pen((Color.White), 2)
  1032.  
  1033.             For i = 0 To Poly.Length - 2
  1034.                 G.DrawLine(P1, Poly(i), Poly(i + 1))
  1035.             Next
  1036.  
  1037.  
  1038.         End If
  1039.         G.DrawRectangle(New Pen(Color.FromArgb(93, 103, 113)), 1, 1, 16, 15)
  1040.         G.DrawRectangle(New Pen(Color.FromArgb(13, 23, 33)), 2, 2, 14, 13)
  1041.         G.DrawRectangle(New Pen(Color.FromArgb(113, 123, 133)), 3, 3, 12, 11)
  1042.         Dim txtbrush As Brush = New SolidBrush(Color.FromArgb(210, 220, 230))
  1043.         G.DrawString(Text, Font, txtbrush, New Point(18, 2), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  1044.  
  1045.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  1046.         G.Dispose() : B.Dispose()
  1047.     End Sub
  1048. End Class
  1049.  
  1050. Class SharpRadioButton : Inherits Control
  1051. #Region " Control Help - MouseState & Flicker Control"
  1052.  
  1053.     Enum MouseState As Byte
  1054.         None = 0
  1055.         Over = 1
  1056.         Down = 2
  1057.         Block = 3
  1058.     End Enum
  1059.     Private State As MouseState = MouseState.None
  1060.     Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
  1061.         MyBase.OnMouseEnter(e)
  1062.         State = MouseState.Over
  1063.         Invalidate()
  1064.     End Sub
  1065.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  1066.         MyBase.OnMouseDown(e)
  1067.         State = MouseState.Down
  1068.         Invalidate()
  1069.     End Sub
  1070.     Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
  1071.         MyBase.OnMouseLeave(e)
  1072.         State = MouseState.None
  1073.         Invalidate()
  1074.     End Sub
  1075.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  1076.         MyBase.OnMouseUp(e)
  1077.         State = MouseState.Over
  1078.         Invalidate()
  1079.     End Sub
  1080.     Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
  1081.         MyBase.OnResize(e)
  1082.         Height = 16
  1083.     End Sub
  1084.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  1085.         MyBase.OnTextChanged(e)
  1086.         Invalidate()
  1087.     End Sub
  1088.     Private _Checked As Boolean
  1089.     Property Checked() As Boolean
  1090.         Get
  1091.             Return _Checked
  1092.         End Get
  1093.         Set(ByVal value As Boolean)
  1094.             _Checked = value
  1095.             InvalidateControls()
  1096.             RaiseEvent CheckedChanged(Me)
  1097.             Invalidate()
  1098.         End Set
  1099.     End Property
  1100.     Protected Overrides Sub OnClick(ByVal e As EventArgs)
  1101.         If Not _Checked Then Checked = True
  1102.         MyBase.OnClick(e)
  1103.     End Sub
  1104.     Event CheckedChanged(ByVal sender As Object)
  1105.     Protected Overrides Sub OnCreateControl()
  1106.         MyBase.OnCreateControl()
  1107.         InvalidateControls()
  1108.     End Sub
  1109.     Private Sub InvalidateControls()
  1110.         If Not IsHandleCreated OrElse Not _Checked Then Return
  1111.  
  1112.         For Each C As Control In Parent.Controls
  1113.             If C IsNot Me AndAlso TypeOf C Is SharpRadioButton Then
  1114.                 DirectCast(C, SharpRadioButton).Checked = False
  1115.             End If
  1116.         Next
  1117.     End Sub
  1118. #End Region
  1119.     Sub New()
  1120.         MyBase.New()
  1121.         SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
  1122.         BackColor = Color.Transparent
  1123.         Size = New Size(150, 16)
  1124.         ForeColor = Color.FromArgb(210, 210, 222)
  1125.         DoubleBuffered = True
  1126.         Font = New Font("Verdana", 8)
  1127.     End Sub
  1128.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1129.         Dim B As New Bitmap(Width, Height)
  1130.         Dim G As Graphics = Graphics.FromImage(B)
  1131.  
  1132.         G.SmoothingMode = SmoothingMode.HighQuality
  1133.  
  1134.         MyBase.OnPaint(e)
  1135.  
  1136.         G.Clear(BackColor)
  1137.  
  1138.  
  1139.         If Checked = False Then
  1140.             Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(3, 3, 12, 11), Color.FromArgb(37, 47, 57), Color.FromArgb(62, 68, 74), 90)
  1141.             G.FillEllipse(BTNLGBOver, New Rectangle(3, 3, 12, 11))
  1142.             G.DrawEllipse(New Pen(Color.FromArgb(0, 0, 0)), 2, 2, 14, 13)
  1143.         Else
  1144.  
  1145.             Dim CKelGrd As New LinearGradientBrush(New Rectangle(3, 3, 12, 11), Color.FromArgb(65, 71, 77), Color.FromArgb(0, 0, 0), 90)
  1146.             G.FillEllipse(CKelGrd, New Rectangle(3, 3, 12, 11))
  1147.             G.DrawEllipse(New Pen(Color.FromArgb(13, 23, 33)), 2, 2, 14, 13)
  1148.         End If
  1149.  
  1150.  
  1151.  
  1152.         G.DrawEllipse(New Pen(Color.FromArgb(93, 103, 113)), 1, 1, 15, 14)
  1153.  
  1154.         G.DrawEllipse(New Pen(Color.FromArgb(113, 123, 133)), 3, 3, 11, 10)
  1155.         Dim txtbrush As Brush = New SolidBrush(Color.FromArgb(210, 220, 230))
  1156.         G.DrawString(Text, Font, txtbrush, New Point(18, 2), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
  1157.  
  1158.  
  1159.         e.Graphics.DrawImage(B.Clone(), 0, 0)
  1160.         G.Dispose() : B.Dispose()
  1161.  
  1162.     End Sub
  1163.  
  1164. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement