Advertisement
Guest User

Untitled

a guest
May 21st, 2014
1,073
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Region "Comments"
  2. 'Classes Theme, ThemeControl, and ThemeContainerControl were created by AeonHack
  3. '   Creator: Aeonhack
  4. '   Date: 4/23/2011
  5. '   Site: www.elitevs.net
  6. '   Version: 1.4
  7. '
  8. 'SimplyGray theme created by Hydrogen
  9. 'http://www.hackforums.net/member.php?action=profile&uid=441774
  10. 'Please include my name in the credits if you use this theme in a project
  11. #End Region
  12.  
  13. Imports System.Drawing.Drawing2D
  14. Imports System.ComponentModel
  15. Imports System.Runtime.InteropServices
  16.  
  17. MustInherit Class Theme
  18.     Inherits ContainerControl
  19.  
  20. #Region " Initialization "
  21.  
  22.     Protected G As Graphics
  23.     Sub New()
  24.         SetStyle(DirectCast(139270, ControlStyles), True)
  25.     End Sub
  26.  
  27.     Private ParentIsForm As Boolean
  28.     Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  29.         Dock = DockStyle.Fill
  30.         ParentIsForm = TypeOf Parent Is Form
  31.         If ParentIsForm Then
  32.             If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey
  33.             ParentForm.FormBorderStyle = FormBorderStyle.None
  34.         End If
  35.         MyBase.OnHandleCreated(e)
  36.     End Sub
  37.  
  38.     Overrides Property Text As String
  39.         Get
  40.             Return MyBase.Text
  41.         End Get
  42.         Set(ByVal v As String)
  43.             MyBase.Text = v
  44.             Invalidate()
  45.         End Set
  46.     End Property
  47. #End Region
  48.  
  49. #Region " Sizing and Movement "
  50.  
  51.     Private _Resizable As Boolean = True
  52.     Property Resizable() As Boolean
  53.         Get
  54.             Return _Resizable
  55.         End Get
  56.         Set(ByVal value As Boolean)
  57.             _Resizable = value
  58.         End Set
  59.     End Property
  60.  
  61.     Private _MoveHeight As Integer = 24
  62.     Property MoveHeight() As Integer
  63.         Get
  64.             Return _MoveHeight
  65.         End Get
  66.         Set(ByVal v As Integer)
  67.             _MoveHeight = v
  68.             Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  69.         End Set
  70.     End Property
  71.  
  72.     Private Flag As IntPtr
  73.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  74.         If Not e.Button = MouseButtons.Left Then Return
  75.         If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return
  76.  
  77.         If Header.Contains(e.Location) Then
  78.             Flag = New IntPtr(2)
  79.         ElseIf Current.Position = 0 Or Not _Resizable Then
  80.             Return
  81.         Else
  82.             Flag = New IntPtr(Current.Position)
  83.         End If
  84.  
  85.         Capture = False
  86.         DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))
  87.  
  88.         MyBase.OnMouseDown(e)
  89.     End Sub
  90.  
  91.     Private Structure Pointer
  92.         ReadOnly Cursor As Cursor, Position As Byte
  93.         Sub New(ByVal c As Cursor, ByVal p As Byte)
  94.             Cursor = c
  95.             Position = p
  96.         End Sub
  97.     End Structure
  98.  
  99.     Private F1, F2, F3, F4 As Boolean, PTC As Point
  100.     Private Function GetPointer() As Pointer
  101.         PTC = PointToClient(MousePosition)
  102.         F1 = PTC.X < 7
  103.         F2 = PTC.X > Width - 7
  104.         F3 = PTC.Y < 7
  105.         F4 = PTC.Y > Height - 7
  106.  
  107.         If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)
  108.         If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)
  109.         If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)
  110.         If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)
  111.         If F1 Then Return New Pointer(Cursors.SizeWE, 10)
  112.         If F2 Then Return New Pointer(Cursors.SizeWE, 11)
  113.         If F3 Then Return New Pointer(Cursors.SizeNS, 12)
  114.         If F4 Then Return New Pointer(Cursors.SizeNS, 15)
  115.         Return New Pointer(Cursors.Default, 0)
  116.     End Function
  117.  
  118.     Private Current, Pending As Pointer
  119.     Private Sub SetCurrent()
  120.         Pending = GetPointer()
  121.         If Current.Position = Pending.Position Then Return
  122.         Current = GetPointer()
  123.         Cursor = Current.Cursor
  124.     End Sub
  125.  
  126.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  127.         If _Resizable Then SetCurrent()
  128.         MyBase.OnMouseMove(e)
  129.     End Sub
  130.  
  131.     Protected Header As Rectangle
  132.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  133.         If Width = 0 OrElse Height = 0 Then Return
  134.         Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  135.         Invalidate()
  136.         MyBase.OnSizeChanged(e)
  137.     End Sub
  138.  
  139. #End Region
  140.  
  141. #Region " Convienence "
  142.  
  143.     MustOverride Sub PaintHook()
  144.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  145.         If Width = 0 OrElse Height = 0 Then Return
  146.         G = e.Graphics
  147.         PaintHook()
  148.     End Sub
  149.  
  150.     Private _TransparencyKey As Color
  151.     Property TransparencyKey() As Color
  152.         Get
  153.             Return _TransparencyKey
  154.         End Get
  155.         Set(ByVal v As Color)
  156.             _TransparencyKey = v
  157.             Invalidate()
  158.         End Set
  159.     End Property
  160.  
  161.     Private _Image As Image
  162.     Property Image() As Image
  163.         Get
  164.             Return _Image
  165.         End Get
  166.         Set(ByVal value As Image)
  167.             _Image = value
  168.             Invalidate()
  169.         End Set
  170.     End Property
  171.     ReadOnly Property ImageWidth() As Integer
  172.         Get
  173.             If _Image Is Nothing Then Return 0
  174.             Return _Image.Width
  175.         End Get
  176.     End Property
  177.  
  178.     Private _Size As Size
  179.     Private _Rectangle As Rectangle
  180.     Private _Gradient As LinearGradientBrush
  181.     Private _Brush As SolidBrush
  182.  
  183.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  184.         _Brush = New SolidBrush(c)
  185.         G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)
  186.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)
  187.         G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)
  188.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)
  189.     End Sub
  190.  
  191.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  192.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  193.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  194.     End Sub
  195.  
  196.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  197.         DrawText(a, c, x, 0)
  198.     End Sub
  199.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  200.         If String.IsNullOrEmpty(Text) Then Return
  201.         _Size = G.MeasureString(Text, Font).ToSize
  202.         _Brush = New SolidBrush(c)
  203.  
  204.         Select Case a
  205.             Case HorizontalAlignment.Left
  206.                 G.DrawString(Text, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  207.             Case HorizontalAlignment.Right
  208.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  209.             Case HorizontalAlignment.Center
  210.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  211.         End Select
  212.     End Sub
  213.  
  214.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  215.         DrawIcon(a, x, 0)
  216.     End Sub
  217.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  218.         If _Image Is Nothing Then Return
  219.         Select Case a
  220.             Case HorizontalAlignment.Left
  221.                 G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  222.             Case HorizontalAlignment.Right
  223.                 G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  224.             Case HorizontalAlignment.Center
  225.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  226.         End Select
  227.     End Sub
  228.  
  229.     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)
  230.         _Rectangle = New Rectangle(x, y, width, height)
  231.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  232.         G.FillRectangle(_Gradient, _Rectangle)
  233.     End Sub
  234.  
  235. #End Region
  236.  
  237. End Class
  238. MustInherit Class ThemeControl
  239.     Inherits Control
  240.  
  241. #Region " Initialization "
  242.  
  243.     Protected G As Graphics, B As Bitmap
  244.     Sub New()
  245.         SetStyle(DirectCast(139270, ControlStyles), True)
  246.         B = New Bitmap(1, 1)
  247.         G = Graphics.FromImage(B)
  248.     End Sub
  249.  
  250.     Sub AllowTransparent()
  251.         SetStyle(ControlStyles.Opaque, False)
  252.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  253.     End Sub
  254.  
  255.     Overrides Property Text As String
  256.         Get
  257.             Return MyBase.Text
  258.         End Get
  259.         Set(ByVal v As String)
  260.             MyBase.Text = v
  261.             Invalidate()
  262.         End Set
  263.     End Property
  264. #End Region
  265.  
  266. #Region " Mouse Handling "
  267.  
  268.     Protected Enum State As Byte
  269.         MouseNone = 0
  270.         MouseOver = 1
  271.         MouseDown = 2
  272.     End Enum
  273.  
  274.     Protected MouseState As State
  275.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  276.         ChangeMouseState(State.MouseNone)
  277.         MyBase.OnMouseLeave(e)
  278.     End Sub
  279.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  280.         ChangeMouseState(State.MouseOver)
  281.         MyBase.OnMouseEnter(e)
  282.     End Sub
  283.     Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  284.         ChangeMouseState(State.MouseOver)
  285.         MyBase.OnMouseUp(e)
  286.     End Sub
  287.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  288.         If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  289.         MyBase.OnMouseDown(e)
  290.     End Sub
  291.  
  292.     Private Sub ChangeMouseState(ByVal e As State)
  293.         MouseState = e
  294.         Invalidate()
  295.     End Sub
  296.  
  297. #End Region
  298.  
  299. #Region " Convienence "
  300.  
  301.     MustOverride Sub PaintHook()
  302.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  303.         If Width = 0 OrElse Height = 0 Then Return
  304.         PaintHook()
  305.         e.Graphics.DrawImage(B, 0, 0)
  306.     End Sub
  307.  
  308.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  309.         If Not Width = 0 AndAlso Not Height = 0 Then
  310.             B = New Bitmap(Width, Height)
  311.             G = Graphics.FromImage(B)
  312.             Invalidate()
  313.         End If
  314.         MyBase.OnSizeChanged(e)
  315.     End Sub
  316.  
  317.     Private _NoRounding As Boolean
  318.     Property NoRounding() As Boolean
  319.         Get
  320.             Return _NoRounding
  321.         End Get
  322.         Set(ByVal v As Boolean)
  323.             _NoRounding = v
  324.             Invalidate()
  325.         End Set
  326.     End Property
  327.  
  328.     Private _Image As Image
  329.     Property Image() As Image
  330.         Get
  331.             Return _Image
  332.         End Get
  333.         Set(ByVal value As Image)
  334.             _Image = value
  335.             Invalidate()
  336.         End Set
  337.     End Property
  338.     ReadOnly Property ImageWidth() As Integer
  339.         Get
  340.             If _Image Is Nothing Then Return 0
  341.             Return _Image.Width
  342.         End Get
  343.     End Property
  344.     ReadOnly Property ImageTop() As Integer
  345.         Get
  346.             If _Image Is Nothing Then Return 0
  347.             Return Height \ 2 - _Image.Height \ 2
  348.         End Get
  349.     End Property
  350.  
  351.     Private _Size As Size
  352.     Private _Rectangle As Rectangle
  353.     Private _Gradient As LinearGradientBrush
  354.     Private _Brush As SolidBrush
  355.  
  356.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  357.         If _NoRounding Then Return
  358.  
  359.         B.SetPixel(rect.X, rect.Y, c)
  360.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  361.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  362.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  363.     End Sub
  364.  
  365.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  366.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  367.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  368.     End Sub
  369.  
  370.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  371.         DrawText(a, c, x, 0)
  372.     End Sub
  373.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  374.         If String.IsNullOrEmpty(Text) Then Return
  375.         _Size = G.MeasureString(Text, Font).ToSize
  376.         _Brush = New SolidBrush(c)
  377.  
  378.         Select Case a
  379.             Case HorizontalAlignment.Left
  380.                 G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  381.             Case HorizontalAlignment.Right
  382.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  383.             Case HorizontalAlignment.Center
  384.                 G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  385.         End Select
  386.     End Sub
  387.  
  388.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  389.         DrawIcon(a, x, 0)
  390.     End Sub
  391.     Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  392.         If _Image Is Nothing Then Return
  393.         Select Case a
  394.             Case HorizontalAlignment.Left
  395.                 G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  396.             Case HorizontalAlignment.Right
  397.                 G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  398.             Case HorizontalAlignment.Center
  399.                 G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  400.         End Select
  401.     End Sub
  402.  
  403.     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)
  404.         _Rectangle = New Rectangle(x, y, width, height)
  405.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  406.         G.FillRectangle(_Gradient, _Rectangle)
  407.     End Sub
  408. #End Region
  409.  
  410. End Class
  411. MustInherit Class ThemeContainerControl
  412.     Inherits ContainerControl
  413.  
  414. #Region " Initialization "
  415.  
  416.     Protected G As Graphics, B As Bitmap
  417.     Sub New()
  418.         SetStyle(DirectCast(139270, ControlStyles), True)
  419.         B = New Bitmap(1, 1)
  420.         G = Graphics.FromImage(B)
  421.     End Sub
  422.  
  423.     Sub AllowTransparent()
  424.         SetStyle(ControlStyles.Opaque, False)
  425.         SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  426.     End Sub
  427.  
  428. #End Region
  429.  
  430. #Region " Convienence "
  431.  
  432.     MustOverride Sub PaintHook()
  433.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  434.         If Width = 0 OrElse Height = 0 Then Return
  435.         PaintHook()
  436.         e.Graphics.DrawImage(B, 0, 0)
  437.     End Sub
  438.  
  439.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  440.         If Not Width = 0 AndAlso Not Height = 0 Then
  441.             B = New Bitmap(Width, Height)
  442.             G = Graphics.FromImage(B)
  443.             Invalidate()
  444.         End If
  445.         MyBase.OnSizeChanged(e)
  446.     End Sub
  447.  
  448.     Private _NoRounding As Boolean
  449.     Property NoRounding() As Boolean
  450.         Get
  451.             Return _NoRounding
  452.         End Get
  453.         Set(ByVal v As Boolean)
  454.             _NoRounding = v
  455.             Invalidate()
  456.         End Set
  457.     End Property
  458.  
  459.     Private _Rectangle As Rectangle
  460.     Private _Gradient As LinearGradientBrush
  461.  
  462.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  463.         If _NoRounding Then Return
  464.         B.SetPixel(rect.X, rect.Y, c)
  465.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  466.         B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  467.         B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  468.     End Sub
  469.  
  470.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  471.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  472.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  473.     End Sub
  474.  
  475.     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)
  476.         _Rectangle = New Rectangle(x, y, width, height)
  477.         _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  478.         G.FillRectangle(_Gradient, _Rectangle)
  479.     End Sub
  480. #End Region
  481.  
  482. End Class
  483.  
  484. Class SimplyGrayTheme
  485.     Inherits Theme
  486.  
  487.     Public Shared _BorderColor1 As Pen = Pens.DarkGray
  488.     Public Shared _BorderColor2 As Pen = Pens.Black
  489.     Private _SubText As String = "Subtext"
  490.  
  491.     Public Property InnerBorderColor() As Color
  492.         Get
  493.             Return _BorderColor1.Color
  494.         End Get
  495.         Set(ByVal value As Color)
  496.             _BorderColor1 = New Pen(value)
  497.             Invalidate()
  498.         End Set
  499.     End Property
  500.  
  501.     Public Property OuterBorderColor() As Color
  502.         Get
  503.             Return _BorderColor2.Color
  504.         End Get
  505.         Set(ByVal value As Color)
  506.             _BorderColor2 = New Pen(value)
  507.             Invalidate()
  508.         End Set
  509.     End Property
  510.  
  511.     Public Property SubText() As String
  512.         Get
  513.             Return _SubText
  514.         End Get
  515.         Set(ByVal value As String)
  516.             _SubText = value
  517.             Invalidate()
  518.         End Set
  519.     End Property
  520.  
  521.     Sub New()
  522.         MoveHeight = 19
  523.         TransparencyKey = Color.Fuchsia
  524.         BackColor = Color.Gray
  525.         ForeColor = Color.White
  526.     End Sub
  527.  
  528.     Dim F As New System.Drawing.Font("Verdana", 8)
  529.     Dim B As New SolidBrush(Color.DimGray)
  530.     Dim Gr As Color = Color.Gray : Dim LG As Color = Color.LightGray : Dim Fc As Color = Color.Fuchsia : Dim TextColor As Color = Color.FromArgb(60, 60, 60)
  531.  
  532.     Overrides Sub PaintHook()
  533.         G.Clear(Color.Gray)
  534.         DrawGradient(LG, Gr, 0, 0, Width, 20, 90S)
  535.  
  536.         DrawBorders(_BorderColor2, _BorderColor1, ClientRectangle)
  537.         DrawCorners(Fc, ClientRectangle)
  538.  
  539.         DrawText(HorizontalAlignment.Left, TextColor, 3, 0)
  540.         G.DrawString(_SubText, F, B, 4, 19)
  541.     End Sub
  542. End Class
  543.  
  544. Class SimplyGrayButton
  545.     Inherits ThemeControl
  546.  
  547.     Dim Gr As Color = Color.Gray : Dim LG As Color = Color.LightGray : Dim O As Color = Color.FromArgb(244, 244, 244) : Dim D As Color = Color.FromArgb(183, 183, 183)
  548.     Dim P As Pen = Pens.DarkGray : Dim PG As Pen = Pens.Gray
  549.  
  550.     Sub New()
  551.         ForeColor = Color.Black
  552.     End Sub
  553.  
  554.  
  555.     Overrides Sub PaintHook()
  556.         G.Clear(Color.DarkGray)
  557.  
  558.         If MouseState = State.MouseNone Then
  559.             DrawGradient(LG, Gr, 0, 0, Width, Height, 90)
  560.         ElseIf MouseState = State.MouseOver Then
  561.             DrawGradient(O, Gr, 0, 0, Width, Height, 90)
  562.         ElseIf MouseState = State.MouseDown Then
  563.             DrawGradient(D, Gr, 0, 0, Width, Height, 90)
  564.         End If
  565.  
  566.         DrawText(HorizontalAlignment.Center, ForeColor, 0)
  567.  
  568.         DrawBorders(P, PG, ClientRectangle)
  569.         DrawCorners(BackColor, ClientRectangle)
  570.     End Sub
  571. End Class
  572.  
  573.  
  574. Class SimplyGrayLightProgressBar
  575.     Inherits ThemeControl
  576.  
  577.  
  578.     Private _Maximum As Integer = 100
  579.     Property Maximum() As Integer
  580.         Get
  581.             Return _Maximum
  582.         End Get
  583.         Set(ByVal v As Integer)
  584.             If v < 1 Then v = 1
  585.             If v < _Value Then _Value = v
  586.  
  587.             _Maximum = v
  588.             Invalidate()
  589.         End Set
  590.     End Property
  591.  
  592.  
  593.     Private _Value As Integer
  594.     Property Value() As Integer
  595.         Get
  596.             Return _Value
  597.         End Get
  598.         Set(ByVal v As Integer)
  599.             If v > _Maximum Then v = _Maximum
  600.  
  601.             _Value = v
  602.             Invalidate()
  603.         End Set
  604.     End Property
  605.  
  606.     Sub New()
  607.         AllowTransparent()
  608.     End Sub
  609.  
  610.     Dim Gr As Color = Color.Gray : Dim P As Pen = Pens.DarkGray : Dim Br As Brush = Brushes.DarkGray : Dim T As Color = Color.Transparent
  611.  
  612.  
  613.     Overrides Sub PaintHook()
  614.         G.Clear(Gr)
  615.  
  616.         G.DrawRectangle(P, 0, 0, Width - 1, Height - 1)
  617.         G.FillRectangle(Br, 0, 0, CInt((_Value / _Maximum) * Width), Height)
  618.  
  619.         DrawCorners(T, ClientRectangle)
  620.     End Sub
  621. End Class
  622.  
  623. Class SimplyGrayProgressBar
  624.     Inherits ThemeControl
  625.  
  626.  
  627.     Private _Maximum As Integer = 100
  628.     Property Maximum() As Integer
  629.         Get
  630.             Return _Maximum
  631.         End Get
  632.         Set(ByVal v As Integer)
  633.             If v < 1 Then v = 1
  634.             If v < _Value Then _Value = v
  635.  
  636.             _Maximum = v
  637.             Invalidate()
  638.         End Set
  639.     End Property
  640.  
  641.  
  642.     Private _Value As Integer
  643.     Property Value() As Integer
  644.         Get
  645.             Return _Value
  646.         End Get
  647.         Set(ByVal v As Integer)
  648.             If v > _Maximum Then v = _Maximum
  649.  
  650.             _Value = v
  651.             Invalidate()
  652.         End Set
  653.     End Property
  654.  
  655.     Sub New()
  656.         AllowTransparent()
  657.     End Sub
  658.  
  659.     Dim Gr As Color = Color.Gray : Dim P As New Pen(Color.FromArgb(60, 60, 60)) : Dim Br As Brush = Brushes.DarkGray : Dim T As Color = Color.Transparent
  660.  
  661.     Overrides Sub PaintHook()
  662.         G.Clear(Gr)
  663.  
  664.         G.FillRectangle(Br, 1, 1, CInt((_Value / _Maximum) * Width), Height - 2)
  665.         G.DrawRectangle(P, 0, 0, Width - 1, Height - 1)
  666.  
  667.         DrawCorners(T, ClientRectangle)
  668.     End Sub
  669. End Class
  670.  
  671. Class SimplyGray3DBarLight
  672.     Inherits ThemeControl
  673.  
  674.     Private _Maximum As Integer = 100
  675.     Property Maximum() As Integer
  676.         Get
  677.             Return _Maximum
  678.         End Get
  679.         Set(ByVal v As Integer)
  680.             If v < 1 Then v = 1
  681.             If v < _Value Then _Value = v
  682.  
  683.             _Maximum = v
  684.             Invalidate()
  685.         End Set
  686.     End Property
  687.  
  688.  
  689.     Private _Value As Integer
  690.     Property Value() As Integer
  691.         Get
  692.             Return _Value
  693.         End Get
  694.         Set(ByVal v As Integer)
  695.             If v > _Maximum Then v = _Maximum
  696.  
  697.             _Value = v
  698.             Invalidate()
  699.         End Set
  700.     End Property
  701.  
  702.     Sub New()
  703.         AllowTransparent()
  704.         ForeColor = Color.White
  705.     End Sub
  706.  
  707.     Dim Gr As Color = Color.Gray : Dim SBr As Brush = Brushes.Silver : Dim P As Pen = Pens.DarkGray : Dim Br As Brush = Brushes.DarkGray : Dim T As Color = Color.Transparent
  708.  
  709.  
  710.     Overrides Sub PaintHook()
  711.         G.Clear(Gr)
  712.  
  713.         G.DrawRectangle(P, 0, 0, Width - 1, Height - 1)
  714.         G.FillRectangle(Br, 0, 0, CInt((_Value / _Maximum) * Width), Height)
  715.         G.FillRectangle(SBr, 0, 0, CInt((_Value / _Maximum) * Width), Height \ 2)
  716.  
  717.         DrawText(HorizontalAlignment.Center, ForeColor, 0)
  718.  
  719.         DrawCorners(T, ClientRectangle)
  720.     End Sub
  721. End Class
  722.  
  723. Class SimplyGray3DBar
  724.     Inherits ThemeControl
  725.  
  726.  
  727.     Private _Maximum As Integer = 100
  728.     Property Maximum() As Integer
  729.         Get
  730.             Return _Maximum
  731.         End Get
  732.         Set(ByVal v As Integer)
  733.             If v < 1 Then v = 1
  734.             If v < _Value Then _Value = v
  735.  
  736.             _Maximum = v
  737.             Invalidate()
  738.         End Set
  739.     End Property
  740.  
  741.  
  742.     Private _Value As Integer
  743.     Property Value() As Integer
  744.         Get
  745.             Return _Value
  746.         End Get
  747.         Set(ByVal v As Integer)
  748.             If v > _Maximum Then v = _Maximum
  749.  
  750.             _Value = v
  751.             Invalidate()
  752.         End Set
  753.     End Property
  754.  
  755.     Sub New()
  756.         AllowTransparent()
  757.         ForeColor = Color.White
  758.     End Sub
  759.  
  760.     Dim Gr As Color = Color.Gray : Dim SBr As Brush = Brushes.Silver : Dim P As New Pen(Color.FromArgb(60, 60, 60)) : Dim Br As Brush = Brushes.DarkGray : Dim T As Color = Color.Transparent
  761.  
  762.     Overrides Sub PaintHook()
  763.         G.Clear(Gr)
  764.  
  765.         G.FillRectangle(Br, 1, 1, CInt((_Value / _Maximum) * Width), Height - 2)
  766.         G.FillRectangle(SBr, 1, 1, CInt((_Value / _Maximum) * Width), (Height - 2) \ 2)
  767.         G.DrawRectangle(P, 0, 0, Width - 1, Height - 1)
  768.  
  769.         DrawText(HorizontalAlignment.Center, ForeColor, 0)
  770.  
  771.         DrawCorners(T, ClientRectangle)
  772.     End Sub
  773. End Class
  774.  
  775. Class SimplyGraySeperator
  776.     Inherits ThemeControl
  777.  
  778.     Private _Color1 As Color = Color.DarkGray
  779.     Public Property Color1() As Color
  780.         Get
  781.             Return _Color1
  782.         End Get
  783.         Set(ByVal value As Color)
  784.             _Color1 = value
  785.         End Set
  786.     End Property
  787.  
  788.     Private _Color2 As Color = Color.FromArgb(50, 50, 50)
  789.     Public Property Color2() As Color
  790.         Get
  791.             Return _Color2
  792.         End Get
  793.         Set(ByVal value As Color)
  794.             _Color2 = value
  795.         End Set
  796.     End Property
  797.  
  798.     Sub New()
  799.         AllowTransparent()
  800.         BackColor = Color.Transparent
  801.         Dim S As New Size(150, 10) : Size = S
  802.     End Sub
  803.  
  804.     Dim Gr As Color = Color.Gray : Dim DGr As Color = Color.DarkGray : Dim T As Color = Color.Transparent : Dim PDGr As Pen = Pens.DarkGray
  805.  
  806.     Overrides Sub PaintHook()
  807.         G.Clear(Gr)
  808.  
  809.         G.DrawLine(New Pen(_Color1), 0, Height \ 2, Width, Height \ 2)
  810.         G.DrawLine(New Pen(_Color2), 0, Height \ 2 + 1, Width, Height \ 2 + 1)
  811.     End Sub
  812. End Class
  813.  
  814. Class SimplyGrayMenuButton
  815.     Inherits ThemeControl
  816.  
  817.     Sub New()
  818.         AllowTransparent()
  819.         ForeColor = Color.White
  820.         Dim S As New Size(15, 20) : Size = S
  821.     End Sub
  822.  
  823.     Dim T As Color = Color.Transparent : Dim LG As Color = Color.LightGray : Dim Gr As Color = Color.Gray
  824.     Dim P As Pen = Pens.DarkGray : Dim Pb As Pen = Pens.Black
  825.  
  826.     Overrides Sub PaintHook()
  827.         G.Clear(Color.DarkGray)
  828.  
  829.         DrawGradient(LG, Gr, 0, 0, Width, Height, 90)
  830.  
  831.         G.DrawLine(Pb, 0, 0, Width, 0)
  832.         G.DrawLine(P, 0, 1, Width, 1)
  833.  
  834.         DrawText(HorizontalAlignment.Center, ForeColor, 0)
  835.     End Sub
  836. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement