Advertisement
Guest User

V Theme

a guest
Aug 18th, 2015
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 21.24 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.FixedSingle
  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.   Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer, ByVal f As Font)
  202.   If String.IsNullOrEmpty(Text) Then Return
  203.   _Size = G.MeasureString(Text, Font).ToSize
  204.   _Brush = New SolidBrush(c)
  205.  
  206.   Select Case a
  207.   Case HorizontalAlignment.Left
  208.   G.DrawString(Text, f, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  209.   Case HorizontalAlignment.Right
  210.   G.DrawString(Text, f, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  211.   Case HorizontalAlignment.Center
  212.   G.DrawString(Text, f, _Brush, Width \ 2 - _Size.Width \ 2 + x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  213.   End Select
  214.   End Sub
  215.  
  216.   Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  217.   DrawIcon(a, x, 0)
  218.   End Sub
  219.   Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  220.   If _Image Is Nothing Then Return
  221.   Select Case a
  222.   Case HorizontalAlignment.Left
  223.   G.DrawImage(_Image, x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  224.   Case HorizontalAlignment.Right
  225.   G.DrawImage(_Image, Width - _Image.Width - x, _MoveHeight \ 2 - _Image.Height \ 2 + y)
  226.   Case HorizontalAlignment.Center
  227.   G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, _MoveHeight \ 2 - _Image.Height \ 2)
  228.   End Select
  229.   End Sub
  230.  
  231.   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)
  232.   _Rectangle = New Rectangle(x, y, width, height)
  233.   _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  234.   G.FillRectangle(_Gradient, _Rectangle)
  235.   End Sub
  236.  
  237. #End Region
  238.  
  239. End Class
  240. MustInherit Class ThemeControl
  241.   Inherits Control
  242.  
  243. #Region " Initialization "
  244.  
  245.   Protected G As Graphics, B As Bitmap
  246.   Sub New()
  247.   SetStyle(DirectCast(139270, ControlStyles), True)
  248.   B = New Bitmap(1, 1)
  249.   G = Graphics.FromImage(B)
  250.   End Sub
  251.  
  252.   Sub AllowTransparent()
  253.   SetStyle(ControlStyles.Opaque, False)
  254.   SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  255.   End Sub
  256.  
  257.   Overrides Property Text As String
  258.   Get
  259.   Return MyBase.Text
  260.   End Get
  261.   Set(ByVal v As String)
  262.   MyBase.Text = v
  263.   Invalidate()
  264.   End Set
  265.   End Property
  266. #End Region
  267.  
  268. #Region " Mouse Handling "
  269.  
  270.   Protected Enum State As Byte
  271.   MouseNone = 0
  272.   MouseOver = 1
  273.   MouseDown = 2
  274.   End Enum
  275.  
  276.   Protected MouseState As State
  277.   Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  278.   ChangeMouseState(State.MouseNone)
  279.   MyBase.OnMouseLeave(e)
  280.   End Sub
  281.   Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  282.   ChangeMouseState(State.MouseOver)
  283.   MyBase.OnMouseEnter(e)
  284.   End Sub
  285.   Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
  286.   ChangeMouseState(State.MouseOver)
  287.   MyBase.OnMouseUp(e)
  288.   End Sub
  289.   Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  290.   If e.Button = MouseButtons.Left Then ChangeMouseState(State.MouseDown)
  291.   MyBase.OnMouseDown(e)
  292.   End Sub
  293.  
  294.   Private Sub ChangeMouseState(ByVal e As State)
  295.   MouseState = e
  296.   Invalidate()
  297.   End Sub
  298.  
  299. #End Region
  300.  
  301. #Region " Convienence "
  302.  
  303.   MustOverride Sub PaintHook()
  304.   Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  305.   If Width = 0 OrElse Height = 0 Then Return
  306.   PaintHook()
  307.   e.Graphics.DrawImage(B, 0, 0)
  308.   End Sub
  309.  
  310.   Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  311.   If Not Width = 0 AndAlso Not Height = 0 Then
  312.   B = New Bitmap(Width, Height)
  313.   G = Graphics.FromImage(B)
  314.   Invalidate()
  315.   End If
  316.   MyBase.OnSizeChanged(e)
  317.   End Sub
  318.  
  319.   Private _NoRounding As Boolean
  320.   Property NoRounding() As Boolean
  321.   Get
  322.   Return _NoRounding
  323.   End Get
  324.   Set(ByVal v As Boolean)
  325.   _NoRounding = v
  326.   Invalidate()
  327.   End Set
  328.   End Property
  329.  
  330.   Private _Image As Image
  331.   Property Image() As Image
  332.   Get
  333.   Return _Image
  334.   End Get
  335.   Set(ByVal value As Image)
  336.   _Image = value
  337.   Invalidate()
  338.   End Set
  339.   End Property
  340.   ReadOnly Property ImageWidth() As Integer
  341.   Get
  342.   If _Image Is Nothing Then Return 0
  343.   Return _Image.Width
  344.   End Get
  345.   End Property
  346.   ReadOnly Property ImageTop() As Integer
  347.   Get
  348.   If _Image Is Nothing Then Return 0
  349.   Return Height \ 2 - _Image.Height \ 2
  350.   End Get
  351.   End Property
  352.  
  353.   Private _Size As Size
  354.   Private _Rectangle As Rectangle
  355.   Private _Gradient As LinearGradientBrush
  356.   Private _Brush As SolidBrush
  357.  
  358.   Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  359.   If _NoRounding Then Return
  360.  
  361.   B.SetPixel(rect.X, rect.Y, c)
  362.   B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  363.   B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  364.   B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  365.   End Sub
  366.  
  367.   Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  368.   G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  369.   G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  370.   End Sub
  371.  
  372.   Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  373.   DrawText(a, c, x, 0)
  374.   End Sub
  375.   Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  376.   If String.IsNullOrEmpty(Text) Then Return
  377.   _Size = G.MeasureString(Text, Font).ToSize
  378.   _Brush = New SolidBrush(c)
  379.  
  380.   Select Case a
  381.   Case HorizontalAlignment.Left
  382.   G.DrawString(Text, Font, _Brush, x, Height \ 2 - _Size.Height \ 2 + y)
  383.   Case HorizontalAlignment.Right
  384.   G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, Height \ 2 - _Size.Height \ 2 + y)
  385.   Case HorizontalAlignment.Center
  386.   G.DrawString(Text, Font, _Brush, Width \ 2 - _Size.Width \ 2 + x, Height \ 2 - _Size.Height \ 2 + y)
  387.   End Select
  388.   End Sub
  389.  
  390.   Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer)
  391.   DrawIcon(a, x, 0)
  392.   End Sub
  393.   Protected Sub DrawIcon(ByVal a As HorizontalAlignment, ByVal x As Integer, ByVal y As Integer)
  394.   If _Image Is Nothing Then Return
  395.   Select Case a
  396.   Case HorizontalAlignment.Left
  397.   G.DrawImage(_Image, x, Height \ 2 - _Image.Height \ 2 + y)
  398.   Case HorizontalAlignment.Right
  399.   G.DrawImage(_Image, Width - _Image.Width - x, Height \ 2 - _Image.Height \ 2 + y)
  400.   Case HorizontalAlignment.Center
  401.   G.DrawImage(_Image, Width \ 2 - _Image.Width \ 2, Height \ 2 - _Image.Height \ 2)
  402.   End Select
  403.   End Sub
  404.  
  405.   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)
  406.   _Rectangle = New Rectangle(x, y, width, height)
  407.   _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  408.   G.FillRectangle(_Gradient, _Rectangle)
  409.   End Sub
  410. #End Region
  411.  
  412. End Class
  413. MustInherit Class ThemeContainerControl
  414.   Inherits ContainerControl
  415.  
  416. #Region " Initialization "
  417.  
  418.   Protected G As Graphics, B As Bitmap
  419.   Sub New()
  420.   SetStyle(DirectCast(139270, ControlStyles), True)
  421.   B = New Bitmap(1, 1)
  422.   G = Graphics.FromImage(B)
  423.   End Sub
  424.  
  425.   Sub AllowTransparent()
  426.   SetStyle(ControlStyles.Opaque, False)
  427.   SetStyle(ControlStyles.SupportsTransparentBackColor, True)
  428.   End Sub
  429.  
  430. #End Region
  431.  
  432. #Region " Convienence "
  433.  
  434.   MustOverride Sub PaintHook()
  435.   Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  436.   If Width = 0 OrElse Height = 0 Then Return
  437.   PaintHook()
  438.   e.Graphics.DrawImage(B, 0, 0)
  439.   End Sub
  440.  
  441.   Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  442.   If Not Width = 0 AndAlso Not Height = 0 Then
  443.   B = New Bitmap(Width, Height)
  444.   G = Graphics.FromImage(B)
  445.   Invalidate()
  446.   End If
  447.   MyBase.OnSizeChanged(e)
  448.   End Sub
  449.  
  450.   Private _NoRounding As Boolean
  451.   Property NoRounding() As Boolean
  452.   Get
  453.   Return _NoRounding
  454.   End Get
  455.   Set(ByVal v As Boolean)
  456.   _NoRounding = v
  457.   Invalidate()
  458.   End Set
  459.   End Property
  460.  
  461.   Private _Rectangle As Rectangle
  462.   Private _Gradient As LinearGradientBrush
  463.  
  464.   Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  465.   If _NoRounding Then Return
  466.   B.SetPixel(rect.X, rect.Y, c)
  467.   B.SetPixel(rect.X + (rect.Width - 1), rect.Y, c)
  468.   B.SetPixel(rect.X, rect.Y + (rect.Height - 1), c)
  469.   B.SetPixel(rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), c)
  470.   End Sub
  471.  
  472.   Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  473.   G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  474.   G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  475.   End Sub
  476.  
  477.   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)
  478.   _Rectangle = New Rectangle(x, y, width, height)
  479.   _Gradient = New LinearGradientBrush(_Rectangle, c1, c2, angle)
  480.   G.FillRectangle(_Gradient, _Rectangle)
  481.   End Sub
  482. #End Region
  483.  
  484. End Class
  485.  
  486. Class AdobeTheme
  487.   Inherits Theme
  488.   Enum TextAlign As Integer
  489.   Left = 0
  490.   Center = 1
  491.   Right = 2
  492.   End Enum
  493.  
  494.   Private TA As TextAlign
  495.   Public Property TextAlignment() As TextAlign
  496.   Get
  497.   Return TA
  498.   End Get
  499.   Set(ByVal value As TextAlign)
  500.   TA = value
  501.   Invalidate()
  502.   End Set
  503.   End Property
  504.  
  505.  
  506.   Sub New()
  507.   MoveHeight = 19
  508.   TransparencyKey = Color.Fuchsia
  509.   Me.Resizable = False
  510.   BackColor = Color.FromArgb(51, 51, 51)
  511.   Me.Font = New Font("Microsoft Sans Serif", 9, FontStyle.Bold)
  512.   Me.TextAlignment = Left
  513.   End Sub
  514.  
  515.   Public Overrides Sub PaintHook()
  516.   G.Clear(Color.FromArgb(68, 68, 68))
  517.   DrawGradient(Color.FromArgb(51, 51, 51), Color.FromArgb(51, 51, 51), 0, 0, Width, 37, 45S)
  518.   G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(31, 31, 31))), 0, 37, Width, 37)
  519.   G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), 0, 38, Width, 38)
  520.   G.FillRectangle(New SolidBrush(Color.FromArgb(68, 68, 68)), 1, 39, Width - 2, Height - 39 - 2)
  521.   Select Case TA
  522.   Case 0
  523.   DrawText(HorizontalAlignment.Left, Color.FromArgb(120, Color.Black), 12, 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  524.   DrawText(HorizontalAlignment.Left, Color.White, 10, 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  525.   Case 1
  526.   DrawText(HorizontalAlignment.Center, Color.FromArgb(120, Color.Black), -1, 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  527.   DrawText(HorizontalAlignment.Center, Color.White, 1, 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  528.   Case 2
  529.   DrawText(HorizontalAlignment.Right, Color.FromArgb(120, Color.Black), -1 + CInt(G.MeasureString(Text, Font).Width / 6), 18, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  530.   DrawText(HorizontalAlignment.Right, Color.White, 1 + CInt(G.MeasureString(Text, Font).Width / 6), 16, New Font("Microsoft Sans Serif", 10, FontStyle.Bold))
  531.   End Select
  532.  
  533.   G.FillRectangle(New SolidBrush(Color.FromArgb(51, 51, 51)), 1, Height - 37, Width - 2, Height - 2)
  534.   G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(31, 31, 31))), 0, Height - 37, Width, Height - 37)
  535.   G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(60, 60, 60))), 0, Height - 38, Width, Height - 38)
  536.  
  537.   DrawBorders(Pens.Black, Pens.Gray, ClientRectangle)
  538.   DrawCorners(Color.Fuchsia, ClientRectangle)
  539.   End Sub
  540. End Class
  541.  
  542. Class AdobeButton
  543.   Inherits ThemeControl
  544.  
  545. #Region " Properties "
  546.  
  547.   Private _Orange As Boolean
  548.   Public Property Orange() As Boolean
  549.   Get
  550.   Return _Orange
  551.   End Get
  552.   Set(ByVal value As Boolean)
  553.   _Orange = value
  554.   Invalidate()
  555.   End Set
  556.   End Property
  557.  
  558. #End Region
  559.  
  560.   Sub New()
  561.   BackColor = Color.FromArgb(51, 51, 51)
  562.   End Sub
  563.  
  564.   Overrides Sub PaintHook()
  565.   G.Clear(Color.FromArgb(102, 102, 102))
  566.   Dim gC As Integer = 15
  567.   Dim _text As Color = Color.White
  568.   Dim C1, C2, C3, C4 As Color
  569.  
  570.   Select Case _Orange
  571.   Case True
  572.   C1 = Color.FromArgb(255, 209, 51)
  573.   C2 = Color.FromArgb(255, 165, 13)
  574.   C3 = Color.FromArgb(255, 195, 13)
  575.   C4 = Color.FromArgb(255, 163, 0)
  576.   _text = Color.White
  577.   Case False
  578.   C1 = Color.FromArgb(105, 105, 105)
  579.   C2 = Color.FromArgb(56, 56, 56)
  580.   C3 = Color.FromArgb(73, 73, 73)
  581.   C4 = Color.FromArgb(48, 48, 48)
  582.   End Select
  583.  
  584.   DrawGradient(C1, C2, 0, 0, Width, Height, 90S)
  585.   DrawGradient(C3, C4, 1, 1, Width - 2, Height - 2, 90S)
  586.  
  587.   Select Case MouseState
  588.   Case State.MouseNone
  589.   'NULL
  590.   Case State.MouseOver
  591.   Select Case _Orange
  592.   Case True
  593.   _text = Color.Black
  594.   End Select
  595.   gC = 10
  596.   Case State.MouseDown
  597.   Select Case _Orange
  598.   Case True
  599.   _text = Color.White
  600.   End Select
  601.   gC = 5
  602.   End Select
  603.  
  604.   For i = 1 To 5
  605.   G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(Int(255 / ((i * gC))), Color.Black))), New Rectangle(i, i, Width - 1 - (i * 2), Height - 1 - (i * 2)))
  606.   Next
  607.  
  608.   DrawBorders(Pens.Black, Pens.Transparent, ClientRectangle)
  609.   DrawText(HorizontalAlignment.Center, _text, -2, 0)
  610.   End Sub
  611. End Class
  612.  
  613. Class AdobeCheck
  614.   Inherits ThemeControl
  615.  
  616. #Region " Properties "
  617.   Private _CheckedState As Boolean
  618.   Public Property CheckedState() As Boolean
  619.   Get
  620.   Return _CheckedState
  621.   End Get
  622.   Set(ByVal v As Boolean)
  623.   _CheckedState = v
  624.   Invalidate()
  625.   End Set
  626.   End Property
  627. #End Region
  628.  
  629.   Sub New()
  630.   'Default properties
  631.   Size = New Size(90, 15)
  632.   MinimumSize = New Size(16, 16)
  633.   MaximumSize = New Size(600, 16)
  634.   CheckedState = False
  635.   End Sub
  636.  
  637.   Public Overrides Sub PaintHook()
  638.   G.Clear(Color.FromArgb(68, 68, 68))
  639.  
  640.   Select Case CheckedState
  641.   Case True
  642.   'Fill with blue
  643.   DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, 15, 15, 90S)
  644.   DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, 9, 9, 90S)
  645.   DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, 7, 7, 90S)
  646.   Case False
  647.   'Fill with gray
  648.   DrawGradient(Color.FromArgb(80, 80, 80), Color.FromArgb(60, 60, 60), 0, 0, 15, 15, 90S)
  649.   End Select
  650.  
  651.   'Draw Box (After Fill so no overflow)
  652.   DrawBorders(Pens.Black, Pens.DimGray, New Rectangle(0, 0, 15, 15))
  653.  
  654.   'Draw Shadow
  655.   DrawText(HorizontalAlignment.Left, Color.Black, 18, 1)
  656.  
  657.   'Draw Text
  658.   DrawText(HorizontalAlignment.Left, Color.White, 17, 0)
  659.   End Sub
  660.  
  661.   Sub changeCheck() Handles Me.Click
  662.   Select Case CheckedState
  663.   Case True
  664.   CheckedState = False
  665.   Case False
  666.   CheckedState = True
  667.   End Select
  668.   End Sub
  669. End Class
  670.  
  671. Class AdobeProgressBar
  672.   Inherits ThemeControl
  673.   Private _Maximum As Integer
  674.   Public Property Maximum() As Integer
  675.   Get
  676.   Return _Maximum
  677.   End Get
  678.   Set(ByVal v As Integer)
  679.   Select Case v
  680.   Case Is < _Value
  681.   _Value = v
  682.   End Select
  683.   _Maximum = v
  684.   Invalidate()
  685.   End Set
  686.   End Property
  687.   Private _Value As Integer
  688.   Public Property Value() As Integer
  689.   Get
  690.   Return _Value
  691.   End Get
  692.   Set(ByVal v As Integer)
  693.   Select Case v
  694.   Case Is > _Maximum
  695.   v = _Maximum
  696.   End Select
  697.   _Value = v
  698.   Invalidate()
  699.   End Set
  700.   End Property
  701.   Overrides Sub PaintHook()
  702.   G.Clear(Color.FromArgb(51, 51, 51))
  703.   'Fill
  704.   Select Case _Value
  705.   Case Is > 6
  706.   DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, CInt(_Value / _Maximum * Width) - 6, Height - 6, 90S)
  707.   DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, CInt(_Value / _Maximum * Width) - 8, Height - 8, 90S)
  708.   Case Is > 1
  709.   DrawGradient(Color.FromArgb(132, 192, 240), Color.FromArgb(78, 123, 168), 3, 3, CInt(_Value / _Maximum * Width), Height - 6, 90S)
  710.   DrawGradient(Color.FromArgb(98, 159, 220), Color.FromArgb(62, 102, 147), 4, 4, CInt(_Value / _Maximum * Width) - 2, Height - 8, 90S)
  711.   End Select
  712.  
  713.   'Borders
  714.   G.DrawRectangle(Pens.Black, 0, 0, Width - 1, Height - 1)
  715.   G.DrawRectangle(Pens.Gray, 1, 1, Width - 3, Height - 3)
  716.   End Sub
  717.   Public Sub Increment(ByVal Amount As Integer)
  718.   If Me.Value + Amount > Maximum Then
  719.   Me.Value = Maximum
  720.   Else
  721.   Me.Value += Amount
  722.   End If
  723.   End Sub
  724. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement