sproductions

SecureTheme

Aug 27th, 2011
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 19.06 KB | None | 0 0
  1. '       ######################################
  2. '       #       Autor: SoulZeh               #
  3. '       #       Date:24/08/11                #
  4. '       #       Name: SecureTheme            #
  5. '       #       Credits: Ap.                 #
  6. '       ######################################
  7.  
  8. Imports System.Drawing.Drawing2D
  9. Imports System.ComponentModel
  10. Imports System.Runtime.InteropServices
  11. MustInherit Class Theme
  12.     Inherits ContainerControl
  13.  
  14. #Region " Initialization "
  15.  
  16.     Protected G As Graphics
  17.     Sub New()
  18.         SetStyle(DirectCast(139270, ControlStyles), True)
  19.     End Sub
  20.  
  21.     Private ParentIsForm As Boolean
  22.     Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  23.         Dock = DockStyle.Fill
  24.         ParentIsForm = TypeOf Parent Is Form
  25.         If ParentIsForm Then
  26.             If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey
  27.             ParentForm.FormBorderStyle = FormBorderStyle.None
  28.         End If
  29.         MyBase.OnHandleCreated(e)
  30.     End Sub
  31.  
  32.     Overrides Property Text As String
  33.         Get
  34.             Return MyBase.Text
  35.         End Get
  36.         Set(ByVal v As String)
  37.             MyBase.Text = v
  38.             Invalidate()
  39.         End Set
  40.     End Property
  41. #End Region
  42.  
  43. #Region " Sizing and Movement "
  44.  
  45.     Private _Resizable As Boolean = True
  46.     Property Resizable() As Boolean
  47.         Get
  48.             Return _Resizable
  49.         End Get
  50.         Set(ByVal value As Boolean)
  51.             _Resizable = value
  52.         End Set
  53.     End Property
  54.  
  55.     Private _MoveHeight As Integer = 24
  56.     Property MoveHeight() As Integer
  57.         Get
  58.             Return _MoveHeight
  59.         End Get
  60.         Set(ByVal v As Integer)
  61.             _MoveHeight = v
  62.             Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  63.         End Set
  64.     End Property
  65.  
  66.     Private Flag As IntPtr
  67.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  68.         If Not e.Button = MouseButtons.Left Then Return
  69.         If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return
  70.  
  71.         If Header.Contains(e.Location) Then
  72.             Flag = New IntPtr(2)
  73.         ElseIf Current.Position = 0 Or Not _Resizable Then
  74.             Return
  75.         Else
  76.             Flag = New IntPtr(Current.Position)
  77.         End If
  78.  
  79.         Capture = False
  80.         DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))
  81.  
  82.         MyBase.OnMouseDown(e)
  83.     End Sub
  84.  
  85.     Private Structure Pointer
  86.         ReadOnly Cursor As Cursor, Position As Byte
  87.         Sub New(ByVal c As Cursor, ByVal p As Byte)
  88.             Cursor = c
  89.             Position = p
  90.         End Sub
  91.     End Structure
  92.  
  93.     Private F1, F2, F3, F4 As Boolean, PTC As Point
  94.     Private Function GetPointer() As Pointer
  95.         PTC = PointToClient(MousePosition)
  96.         F1 = PTC.X < 7
  97.         F2 = PTC.X > Width - 7
  98.         F3 = PTC.Y < 7
  99.         F4 = PTC.Y > Height - 7
  100.  
  101.         If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)
  102.         If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)
  103.         If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)
  104.         If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)
  105.         If F1 Then Return New Pointer(Cursors.SizeWE, 10)
  106.         If F2 Then Return New Pointer(Cursors.SizeWE, 11)
  107.         If F3 Then Return New Pointer(Cursors.SizeNS, 12)
  108.         If F4 Then Return New Pointer(Cursors.SizeNS, 15)
  109.         Return New Pointer(Cursors.Default, 0)
  110.     End Function
  111.  
  112.     Private Current, Pending As Pointer
  113.     Private Sub SetCurrent()
  114.         Pending = GetPointer()
  115.         If Current.Position = Pending.Position Then Return
  116.         Current = GetPointer()
  117.         Cursor = Current.Cursor
  118.     End Sub
  119.  
  120.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  121.         If _Resizable Then SetCurrent()
  122.         MyBase.OnMouseMove(e)
  123.     End Sub
  124.  
  125.     Protected Header As Rectangle
  126.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  127.         If Width = 0 OrElse Height = 0 Then Return
  128.         Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  129.         Invalidate()
  130.         MyBase.OnSizeChanged(e)
  131.     End Sub
  132.  
  133. #End Region
  134.  
  135. #Region " Convienence "
  136.  
  137.     MustOverride Sub PaintHook()
  138.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  139.         If Width = 0 OrElse Height = 0 Then Return
  140.         G = e.Graphics
  141.         PaintHook()
  142.     End Sub
  143.  
  144.     Private _TransparencyKey As Color
  145.     Property TransparencyKey() As Color
  146.         Get
  147.             Return _TransparencyKey
  148.         End Get
  149.         Set(ByVal v As Color)
  150.             _TransparencyKey = v
  151.             Invalidate()
  152.         End Set
  153.     End Property
  154.  
  155.     Private _Image As Image
  156.     Property Image() As Image
  157.         Get
  158.             Return _Image
  159.         End Get
  160.         Set(ByVal value As Image)
  161.             _Image = value
  162.             Invalidate()
  163.         End Set
  164.     End Property
  165.     ReadOnly Property ImageWidth() As Integer
  166.         Get
  167.             If _Image Is Nothing Then Return 0
  168.             Return _Image.Width
  169.         End Get
  170.     End Property
  171.  
  172.     Private _Size As Size
  173.     Private _Rectangle As Rectangle
  174.     Private _Gradient As LinearGradientBrush
  175.     Private _Brush As SolidBrush
  176.  
  177.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  178.         _Brush = New SolidBrush(c)
  179.         G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)
  180.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)
  181.         G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)
  182.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)
  183.     End Sub
  184.  
  185.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  186.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  187.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  188.     End Sub
  189.  
  190.     Protected Sub DrawBG(ByVal c As Color, ByVal rect As Rectangle)
  191.         DrawGradient(Color.FromArgb(43, 255, 255, 255), Color.PowderBlue, 0, 0, Me.Width / 2, Me.Height / 2, 45)
  192.         DrawGradient(Color.FromArgb(43, 255, 255, 255), Color.PowderBlue, Me.Width / 2, 0, Me.Width / 2, Me.Height / 2, 135)
  193.         DrawGradient(Color.FromArgb(43, 255, 255, 255), Color.PowderBlue, 0, Me.Height / 2, Me.Width / 2, Me.Height / 2, 315)
  194.         DrawGradient(Color.FromArgb(43, 255, 255, 255), Color.PowderBlue, Me.Width / 2, Me.Height / 2, Me.Width / 2, Me.Height / 2, 225)
  195.     End Sub
  196.  
  197.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  198.         DrawText(a, c, x, 0)
  199.     End Sub
  200.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  201.         If String.IsNullOrEmpty(Text) Then Return
  202.         _Size = G.MeasureString(Text, Font).ToSize
  203.         _Brush = New SolidBrush(c)
  204.  
  205.         Select Case a
  206.             Case HorizontalAlignment.Left
  207.                 G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  208.             Case HorizontalAlignment.Right
  209.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  210.             Case HorizontalAlignment.Center
  211.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  212.         End Select
  213.     End Sub
  214.  
  215.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  216.         DrawIcon(a, x, 0)
  217.     End Sub
  218.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  219.         If _Image Is Nothing Then Return
  220.         Select Case a
  221.             Case HorizontalAlignment.Left
  222.                 G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  223.             Case HorizontalAlignment.Right
  224.                 G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  225.             Case HorizontalAlignment.Center
  226.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  227.         End Select
  228.     End Sub
  229.  
  230.     Protected Sub DrawGradient(ByVal PowderBlue As Color, ByVal SlateGray As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  231.         _Rectangle = New Rectangle(x, y, width, height)
  232.         _Gradient = New LinearGradientBrush(_Rectangle, PowderBlue, Color.SlateGray, angle)
  233.         G.FillRectangle(_Gradient, _Rectangle)
  234.     End Sub
  235.  
  236. #End Region
  237.  
  238. End Class
  239. MustInherit Class ThemeControl
  240.     Inherits Control
  241.  
  242. #Region " Initialization "
  243.  
  244.     Protected G As Graphics, B As Bitmap
  245.     Sub New()
  246.         SetStyle(DirectCast(139270, ControlStyles), True)
  247.         B = New Bitmap(1, 1)
  248.         G = Graphics.FromImage(B)
  249.     End Sub
  250.  
  251.     Sub AllowTransparent()
  252.         SetStyle(ControlStyles.Opaque, False)
  253.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  254.     End Sub
  255.  
  256.     Overrides Property Text As String
  257.         Get
  258.             Return MyBase.Text
  259.         End Get
  260.         Set(ByVal v As String)
  261.             MyBase.Text = v
  262.             Invalidate()
  263.         End Set
  264.     End Property
  265. #End Region
  266.  
  267. #Region " Mouse Handling "
  268.  
  269.     Protected Enum State As Byte
  270.         MouseNone = 0
  271.         MouseOver = 1
  272.         MouseDown = 2
  273.     End Enum
  274.  
  275.     Protected MouseState As State
  276.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  277.         ChangeMouseState(State.MouseNone)
  278.         MyBase.OnMouseLeave(e)
  279.     End Sub
  280.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  281.         ChangeMouseState(State.MouseOver)
  282.         MyBase.OnMouseEnter(e)
  283.     End Sub
  284.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  285.         ChangeMouseState(State.MouseOver)
  286.         MyBase.OnMouseUp(e)
  287.     End Sub
  288.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  289.         If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  290.         MyBase.OnMouseDown(e)
  291.     End Sub
  292.  
  293.     Private Sub ChangeMouseState(ByVal e As State)
  294.         MouseState = e
  295.         Invalidate()
  296.     End Sub
  297.  
  298. #End Region
  299.  
  300. #Region " Convienence "
  301.  
  302.     MustOverride Sub PaintHook()
  303.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  304.         If Width = 0 OrElse Height = 0 Then Return
  305.         PaintHook()
  306.         e.Graphics.DrawImage(B, 0, 0)
  307.     End Sub
  308.  
  309.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  310.         If Not Width = 0 AndAlso Not Height = 0 Then
  311.             B = New Bitmap(Width, Height)
  312.             G = Graphics.FromImage(B)
  313.             Invalidate()
  314.         End If
  315.         MyBase.OnSizeChanged(e)
  316.     End Sub
  317.  
  318.     Private _NoRounding As Boolean
  319.     Property NoRounding() As Boolean
  320.         Get
  321.             Return _NoRounding
  322.         End Get
  323.         Set(ByVal v As Boolean)
  324.             _NoRounding = v
  325.             Invalidate()
  326.         End Set
  327.     End Property
  328.  
  329.     Private _Image As Image
  330.     Property Image() As Image
  331.         Get
  332.             Return _Image
  333.         End Get
  334.         Set(ByVal value As Image)
  335.             _Image = value
  336.             Invalidate()
  337.         End Set
  338.     End Property
  339.     ReadOnly Property ImageWidth() As Integer
  340.         Get
  341.             If _Image Is Nothing Then Return 0
  342.             Return _Image.Width
  343.         End Get
  344.     End Property
  345.     ReadOnly Property ImageTop() As Integer
  346.         Get
  347.             If _Image Is Nothing Then Return 0
  348.             Return Height \ 2 - _Image.Height \ 2
  349.         End Get
  350.     End Property
  351.  
  352.     Private _Size As Size
  353.     Private _Rectangle As Rectangle
  354.     Private _Gradient As LinearGradientBrush
  355.     Private _Brush As SolidBrush
  356.  
  357.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  358.         If _NoRounding Then Return
  359.  
  360.         B.SetPixel(rect.X, rect.Y, c)
  361.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  362.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  363.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  364.     End Sub
  365.  
  366.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  367.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  368.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  369.     End Sub
  370.  
  371.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  372.         DrawText(a, c, x, 0)
  373.     End Sub
  374.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  375.         If String.IsNullOrEmpty(Text) Then Return
  376.         _Size = G.MeasureString(Text, Font).ToSize
  377.         _Brush = New SolidBrush(c)
  378.  
  379.         Select Case a
  380.             Case HorizontalAlignment.Left
  381.                 G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  382.             Case HorizontalAlignment.Right
  383.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  384.             Case HorizontalAlignment.Center
  385.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  386.         End Select
  387.     End Sub
  388.  
  389.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  390.         DrawIcon(a, x, 0)
  391.     End Sub
  392.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  393.         If _Image Is Nothing Then Return
  394.         Select Case a
  395.             Case HorizontalAlignment.Left
  396.                 G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  397.             Case HorizontalAlignment.Right
  398.                 G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  399.             Case HorizontalAlignment.Center
  400.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  401.         End Select
  402.     End Sub
  403.  
  404.     Protected Sub DrawGradient(ByVal PowderBlue As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  405.         _Rectangle = New Rectangle(x, y, width, height)
  406.         _Gradient = New LinearGradientBrush(_Rectangle, PowderBlue, Color.DarkSlateGray, angle)
  407.         G.FillRectangle(_Gradient, _Rectangle)
  408.     End Sub
  409. #End Region
  410.  
  411. End Class
  412. MustInherit Class ThemeContainerControl
  413.     Inherits ContainerControl
  414.  
  415. #Region " Initialization "
  416.  
  417.     Protected G As Graphics, B As Bitmap
  418.     Sub New()
  419.         SetStyle(DirectCast(139270, ControlStyles), True)
  420.         B = New Bitmap(1, 1)
  421.         G = Graphics.FromImage(B)
  422.     End Sub
  423.  
  424.     Sub AllowTransparent()
  425.         SetStyle(ControlStyles.Opaque, False)
  426.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  427.     End Sub
  428.  
  429. #End Region
  430.  
  431. #Region " Convienence "
  432.  
  433.     MustOverride Sub PaintHook()
  434.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  435.         If Width = 0 OrElse Height = 0 Then Return
  436.         PaintHook()
  437.         e.Graphics.DrawImage(B, 0, 0)
  438.     End Sub
  439.  
  440.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  441.         If Not Width = 0 AndAlso Not Height = 0 Then
  442.             B = New Bitmap(Width, Height)
  443.             G = Graphics.FromImage(B)
  444.             Invalidate()
  445.         End If
  446.         MyBase.OnSizeChanged(e)
  447.     End Sub
  448.  
  449.     Private _NoRounding As Boolean
  450.     Property NoRounding() As Boolean
  451.         Get
  452.             Return _NoRounding
  453.         End Get
  454.         Set(ByVal v As Boolean)
  455.             _NoRounding = v
  456.             Invalidate()
  457.         End Set
  458.     End Property
  459.  
  460.     Private _Rectangle As Rectangle
  461.     Private _Gradient As LinearGradientBrush
  462.  
  463.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  464.         If _NoRounding Then Return
  465.         B.SetPixel(rect.X, rect.Y, c)
  466.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  467.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  468.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  469.     End Sub
  470.  
  471.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  472.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  473.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  474.     End Sub
  475.  
  476.     Protected Sub DrawGradient(ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal angle As Single)
  477.         _Rectangle = New Rectangle(x, y, width, height)
  478.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  479.         G.FillRectangle(_Gradient, _Rectangle)
  480.     End Sub
  481. #End Region
  482.  
  483. End Class
  484.  
  485. Class SecureTheme
  486.     Inherits Theme
  487.     Sub New()
  488.         Resizable = False
  489.         Font = New Font("Verdana", 8.25!)
  490.         ForeColor = Color.Black
  491.         BackColor = Color.White
  492.         TransparencyKey = Color.Fuchsia
  493.         MoveHeight = 20
  494.     End Sub
  495.     Overrides Sub PaintHook()
  496.         G.Clear(Color.Black)
  497.         DrawBG(Color.DimGray, ClientRectangle)
  498.         DrawGradient(Color.DimGray, Color.Black, 0, 0, Width, 20, 90S)
  499.         DrawCorners(Color.Fuchsia, ClientRectangle)
  500.         DrawText(HorizontalAlignment.Center, Color.White, ImageWidth)
  501.         DrawBorders(Pens.Transparent, Pens.LightGray, ClientRectangle)
  502.  
  503.     End Sub
  504. End Class
  505. Class SecureButton
  506.     Inherits ThemeControl
  507.  
  508.     Public Overrides Sub PaintHook()
  509.         If MouseState = State.MouseDown Then
  510.             DrawGradient(Color.PowderBlue, Color.DarkSlateGray, 0, 0, Width, Height, 90S)
  511.         ElseIf MouseState = State.MouseOver Then
  512.             DrawGradient(Color.PowderBlue, Color.DarkSlateGray, 0, 0, Width, Height, 90S)
  513.         Else
  514.             DrawGradient(Color.DimGray, Color.DarkGray, 0, 0, Width, Height, 90S)
  515.         End If
  516.         DrawText(HorizontalAlignment.Center, ForeColor, 0)
  517.         DrawBorders(Pens.Transparent, Pens.Black, ClientRectangle)
  518.     End Sub
  519. End Class
  520.  
  521. Class SecureProgressBar
  522.     Inherits ThemeControl
  523.  
  524.     Private _Maximum As Integer = 100
  525.     Public Property Maximum() As Integer
  526.         Get
  527.             Return _Maximum
  528.         End Get
  529.         Set(ByVal value As Integer)
  530.             If value < 1 Then value = 1
  531.             If value < _Value Then _Value = value
  532.             _Maximum = value
  533.             Invalidate()
  534.         End Set
  535.     End Property
  536.  
  537.     Private _Value As Integer = 50
  538.     Public Property Value() As Integer
  539.         Get
  540.             Return _Value
  541.         End Get
  542.         Set(ByVal value As Integer)
  543.             If value > _Maximum Then value = _Maximum
  544.             If value < 1 Then value = 1
  545.             _Value = value
  546.             Invalidate()
  547.         End Set
  548.     End Property
  549.  
  550.     Overrides Sub PaintHook()
  551.         G.Clear(Color.Gray)
  552.         If (_Value > 0) Then
  553.             DrawGradient(Color.DarkSlateGray, Color.PowderBlue, 0, 0, CInt((_Value / _Maximum) * Width), Height, 90S)
  554.         End If
  555.         G.DrawRectangle(Pens.LightGray, 0, 0, Width - 1, Height - 1)
  556.         DrawBorders(Pens.White, Pens.Transparent, ClientRectangle)
  557.     End Sub
  558. End Class
Add Comment
Please, Sign In to add comment