ImaFoSho

[VB] Hero Theme

Nov 17th, 2012
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 20.72 KB | None | 0 0
  1. 'Hero Theme
  2. 'By: FoSho
  3. 'Theme Base: AeonHack
  4. 'Version: 1.0.0.0
  5.  
  6.  
  7. Imports System.Drawing.Drawing2D
  8. Imports System.ComponentModel
  9. Imports System.Runtime.InteropServices
  10.  
  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 DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  191.         DrawText(a, c, x, 0)
  192.     End Sub
  193.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  194.         If String.IsNullOrEmpty(Text) Then Return
  195.         _Size = G.MeasureString(Text, Font).ToSize
  196.         _Brush = New SolidBrush(c)
  197.  
  198.         Select Case a
  199.             Case HorizontalAlignment.Left
  200.                 G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  201.             Case HorizontalAlignment.Right
  202.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  203.             Case HorizontalAlignment.Center
  204.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  205.         End Select
  206.     End Sub
  207.  
  208.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  209.         DrawIcon(a, x, 0)
  210.     End Sub
  211.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  212.         If _Image Is Nothing Then Return
  213.         Select Case a
  214.             Case HorizontalAlignment.Left
  215.                 G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  216.             Case HorizontalAlignment.Right
  217.                 G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  218.             Case HorizontalAlignment.Center
  219.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  220.         End Select
  221.     End Sub
  222.  
  223.     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)
  224.         _Rectangle = New Rectangle(x, y, width, height)
  225.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  226.         G.FillRectangle(_Gradient, _Rectangle)
  227.     End Sub
  228.  
  229. #End Region
  230.  
  231. End Class
  232. MustInherit Class ThemeControl
  233.     Inherits Control
  234.  
  235. #Region " Initialization "
  236.  
  237.     Protected G As Graphics, B As Bitmap
  238.     Sub New()
  239.         SetStyle(DirectCast(139270, ControlStyles), True)
  240.         B = New Bitmap(1, 1)
  241.         G = Graphics.FromImage(B)
  242.     End Sub
  243.  
  244.     Sub AllowTransparent()
  245.         SetStyle(ControlStyles.Opaque, False)
  246.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  247.     End Sub
  248.  
  249.     Overrides Property Text As String
  250.         Get
  251.             Return MyBase.Text
  252.         End Get
  253.         Set(ByVal v As String)
  254.             MyBase.Text = v
  255.             Invalidate()
  256.         End Set
  257.     End Property
  258. #End Region
  259.  
  260. #Region " Mouse Handling "
  261.  
  262.     Protected Enum State As Byte
  263.         MouseNone = 0
  264.         MouseOver = 1
  265.         MouseDown = 2
  266.     End Enum
  267.  
  268.     Protected MouseState As State
  269.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  270.         ChangeMouseState(State.MouseNone)
  271.         MyBase.OnMouseLeave(e)
  272.     End Sub
  273.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  274.         ChangeMouseState(State.MouseOver)
  275.         MyBase.OnMouseEnter(e)
  276.     End Sub
  277.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  278.         ChangeMouseState(State.MouseOver)
  279.         MyBase.OnMouseUp(e)
  280.     End Sub
  281.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  282.         If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  283.         MyBase.OnMouseDown(e)
  284.     End Sub
  285.  
  286.     Private Sub ChangeMouseState(ByVal e As State)
  287.         MouseState = e
  288.         Invalidate()
  289.     End Sub
  290.  
  291. #End Region
  292.  
  293. #Region " Convienence "
  294.  
  295.     MustOverride Sub PaintHook()
  296.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  297.         If Width = 0 OrElse Height = 0 Then Return
  298.         PaintHook()
  299.         e.Graphics.DrawImage(B, 0, 0)
  300.     End Sub
  301.  
  302.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  303.         If Not Width = 0 AndAlso Not Height = 0 Then
  304.             B = New Bitmap(Width, Height)
  305.             G = Graphics.FromImage(B)
  306.             Invalidate()
  307.         End If
  308.         MyBase.OnSizeChanged(e)
  309.     End Sub
  310.  
  311.     Private _NoRounding As Boolean
  312.     Property NoRounding() As Boolean
  313.         Get
  314.             Return _NoRounding
  315.         End Get
  316.         Set(ByVal v As Boolean)
  317.             _NoRounding = v
  318.             Invalidate()
  319.         End Set
  320.     End Property
  321.  
  322.     Private _Image As Image
  323.     Property Image() As Image
  324.         Get
  325.             Return _Image
  326.         End Get
  327.         Set(ByVal value As Image)
  328.             _Image = value
  329.             Invalidate()
  330.         End Set
  331.     End Property
  332.     ReadOnly Property ImageWidth() As Integer
  333.         Get
  334.             If _Image Is Nothing Then Return 0
  335.             Return _Image.Width
  336.         End Get
  337.     End Property
  338.     ReadOnly Property ImageTop() As Integer
  339.         Get
  340.             If _Image Is Nothing Then Return 0
  341.             Return Height \ 2 - _Image.Height \ 2
  342.         End Get
  343.     End Property
  344.  
  345.     Private _Size As Size
  346.     Private _Rectangle As Rectangle
  347.     Private _Gradient As LinearGradientBrush
  348.     Private _Brush As SolidBrush
  349.  
  350.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  351.         If _NoRounding Then Return
  352.  
  353.         B.SetPixel(rect.X, rect.Y, c)
  354.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  355.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  356.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  357.     End Sub
  358.  
  359.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  360.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  361.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  362.     End Sub
  363.  
  364.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  365.         DrawText(a, c, x, 0)
  366.     End Sub
  367.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  368.         If String.IsNullOrEmpty(Text) Then Return
  369.         _Size = G.MeasureString(Text, Font).ToSize
  370.         _Brush = New SolidBrush(c)
  371.  
  372.         Select Case a
  373.             Case HorizontalAlignment.Left
  374.                 G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  375.             Case HorizontalAlignment.Right
  376.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  377.             Case HorizontalAlignment.Center
  378.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  379.         End Select
  380.     End Sub
  381.  
  382.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  383.         DrawIcon(a, x, 0)
  384.     End Sub
  385.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  386.         If _Image Is Nothing Then Return
  387.         Select Case a
  388.             Case HorizontalAlignment.Left
  389.                 G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  390.             Case HorizontalAlignment.Right
  391.                 G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  392.             Case HorizontalAlignment.Center
  393.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  394.         End Select
  395.     End Sub
  396.  
  397.     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)
  398.         _Rectangle = New Rectangle(x, y, width, height)
  399.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  400.         G.FillRectangle(_Gradient, _Rectangle)
  401.     End Sub
  402. #End Region
  403.  
  404. End Class
  405. MustInherit Class ThemeContainerControl
  406.     Inherits ContainerControl
  407.  
  408. #Region " Initialization "
  409.  
  410.     Protected G As Graphics, B As Bitmap
  411.     Sub New()
  412.         SetStyle(DirectCast(139270, ControlStyles), True)
  413.         B = New Bitmap(1, 1)
  414.         G = Graphics.FromImage(B)
  415.     End Sub
  416.  
  417.     Sub AllowTransparent()
  418.         SetStyle(ControlStyles.Opaque, False)
  419.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  420.     End Sub
  421.  
  422. #End Region
  423.  
  424. #Region " Convienence "
  425.  
  426.     MustOverride Sub PaintHook()
  427.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  428.         If Width = 0 OrElse Height = 0 Then Return
  429.         PaintHook()
  430.         e.Graphics.DrawImage(B, 0, 0)
  431.     End Sub
  432.  
  433.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  434.         If Not Width = 0 AndAlso Not Height = 0 Then
  435.             B = New Bitmap(Width, Height)
  436.             G = Graphics.FromImage(B)
  437.             Invalidate()
  438.         End If
  439.         MyBase.OnSizeChanged(e)
  440.     End Sub
  441.  
  442.     Private _NoRounding As Boolean
  443.     Property NoRounding() As Boolean
  444.         Get
  445.             Return _NoRounding
  446.         End Get
  447.         Set(ByVal v As Boolean)
  448.             _NoRounding = v
  449.             Invalidate()
  450.         End Set
  451.     End Property
  452.  
  453.     Private _Rectangle As Rectangle
  454.     Private _Gradient As LinearGradientBrush
  455.  
  456.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  457.         If _NoRounding Then Return
  458.         B.SetPixel(rect.X, rect.Y, c)
  459.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  460.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  461.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  462.     End Sub
  463.  
  464.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  465.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  466.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  467.     End Sub
  468.  
  469.     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)
  470.         _Rectangle = New Rectangle(x, y, width, height)
  471.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  472.         G.FillRectangle(_Gradient, _Rectangle)
  473.     End Sub
  474. #End Region
  475.  
  476. End Class
  477.  
  478. Class HeroTheme
  479.     Inherits Theme
  480.  
  481.     Sub New()
  482.         Resizable = False
  483.         BackColor = Color.FromArgb(211, 211, 211)
  484.         MoveHeight = 25
  485.         TransparencyKey = Color.Fuchsia
  486.     End Sub
  487.  
  488.     Public Overrides Sub PaintHook()
  489.         G.Clear(BackColor)
  490.  
  491.  
  492.         G.Clear(Color.FromArgb(211, 211, 211))
  493.         DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(40, 40, 40), 0, 0, Width, 25, 90S)
  494.  
  495.         G.DrawLine(Pens.Black, 0, 25, Width, 25)
  496.  
  497.         DrawCorners(Color.Fuchsia, ClientRectangle)
  498.         DrawBorders(Pens.Black, Pens.DimGray, ClientRectangle)
  499.  
  500.         DrawText(HorizontalAlignment.Left, Color.FromArgb(211, 211, 211), 7, 1)
  501.     End Sub
  502. End Class
  503. Class HeroButton
  504.     Inherits ThemeControl
  505.  
  506.     Overrides Sub PaintHook()
  507.         Select Case MouseState
  508.             Case State.MouseNone
  509.                 G.Clear(Color.FromArgb(50, 50, 50))
  510.                 DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(40, 40, 40), 0, 0, Width, Height, 90S)
  511.             Case State.MouseOver
  512.                 G.Clear(Color.Gray)
  513.                 DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(40, 40, 40), 0, 0, Width, Height, 90S)
  514.             Case State.MouseDown
  515.                 G.Clear(Color.FromArgb(211, 211, 211))
  516.                 DrawGradient(Color.FromArgb(38, 38, 38), Color.FromArgb(40, 40, 40), 0, 0, Width, Height, 90S)
  517.         End Select
  518.  
  519.         DrawCorners(Color.Black, ClientRectangle)
  520.         DrawText(HorizontalAlignment.Center, Color.FromArgb(211, 211, 211), 0)
  521.     End Sub
  522. End Class
  523. Class HeroLabel
  524.     Inherits ThemeControl
  525.     Overrides Sub PaintHook()
  526.         G.Clear(BackColor)
  527.         DrawText(HorizontalAlignment.Center, Color.FromArgb(40, 40, 40), 0)
  528.     End Sub
  529. End Class
  530. Class HeroSeperater
  531. Inherits ThemeControl
  532. Overrides Sub PaintHook()
  533.     G.Clear(BackColor)
  534.     G.DrawLine(Pens.Gray, 0, CInt(ClientRectangle.Y \ 2), Width, 0)
  535. End Sub
  536. End Class
  537. Class HeroGroupBox
  538.     Inherits ThemeContainerControl
  539.     Sub New()
  540.         AllowTransparent()
  541.     End Sub
  542.  
  543.     Overrides Sub PaintHook()
  544.         G.Clear(BackColor)
  545.         DrawBorders(Pens.Black, Pens.DimGray, ClientRectangle)
  546.         DrawCorners(Color.Fuchsia, ClientRectangle)
  547.     End Sub
  548. End Class
  549. Class HeroProgressBar
  550.     Inherits ThemeControl
  551.  
  552.     Private _Maximum As Integer = 100
  553.     Public Property Maximum() As Integer
  554.         Get
  555.             Return _Maximum
  556.         End Get
  557.         Set(ByVal value As Integer)
  558.             If value < 1 Then value = 1
  559.             If value < _Value Then _Value = value
  560.             _Maximum = value
  561.             Invalidate()
  562.         End Set
  563.     End Property
  564.  
  565.     Private _Value As Integer = 50
  566.     Public Property Value() As Integer
  567.         Get
  568.             Return _Value
  569.         End Get
  570.         Set(ByVal value As Integer)
  571.             If value > _Maximum Then value = _Maximum
  572.             If value < 1 Then value = 1
  573.             _Value = value
  574.             Invalidate()
  575.         End Set
  576.     End Property
  577.  
  578.     Overrides Sub PaintHook()
  579.         G.Clear(Color.FromArgb(50, 50, 50))
  580.         If (_Value > 0) Then
  581.             DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(40, 40, 40), 0, 0, CInt((_Value / _Maximum) * Width), Height, 90S)
  582.         End If
  583.         G.DrawRectangle(Pens.LightGray, 0, 0, Width - 1, Height - 1)
  584.         DrawBorders(Pens.Black, Pens.DimGray, ClientRectangle)
  585.     End Sub
  586. End Class
  587. Class HeroCheckBox
  588.     Inherits ThemeControl
  589.  
  590. #Region " Properties "
  591.     Private _CheckedState As Boolean
  592.     Public Property CheckedState() As Boolean
  593.         Get
  594.             Return _CheckedState
  595.         End Get
  596.         Set(ByVal v As Boolean)
  597.             _CheckedState = v
  598.             Invalidate()
  599.         End Set
  600.     End Property
  601. #End Region
  602.  
  603.     Sub New()
  604.         'Default properties
  605.         Size = New Size(90, 15)
  606.         MinimumSize = New Size(16, 16)
  607.         MaximumSize = New Size(600, 16)
  608.         CheckedState = False
  609.     End Sub
  610.  
  611.     Public Overrides Sub PaintHook()
  612.         G.Clear(BackColor)
  613.  
  614.         Select Case CheckedState
  615.             Case True
  616.  
  617.                 DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, 15, 15, 90S)
  618.                 DrawGradient(Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 3, 3, 9, 9, 90S)
  619.                 DrawGradient(Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 4, 4, 7, 7, 90S)
  620.             Case False
  621.                 DrawGradient(Color.FromArgb(211, 211, 211), Color.FromArgb(200, 200, 200), 0, 0, 15, 15, 90S)
  622.         End Select
  623.  
  624.  
  625.         DrawBorders(Pens.Black, Pens.DimGray, New Rectangle(0, 0, 15, 15))
  626.         DrawText(HorizontalAlignment.Left, Color.FromArgb(30, 30, 30), 17, 0)
  627.     End Sub
  628.  
  629.     Sub changeCheck() Handles Me.Click
  630.         Select Case CheckedState
  631.             Case True
  632.                 CheckedState = False
  633.             Case False
  634.                 CheckedState = True
  635.         End Select
  636.     End Sub
  637. End Class
Advertisement
Add Comment
Please, Sign In to add comment