Advertisement
benito

Untitled

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