SaketSaket

SimpleBlue Theme for HF

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