Advertisement
Awaken

Slurms Makenzi - Purityx Theme - Hack Forums!

Jul 11th, 2011
2,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 23.95 KB | None | 0 0
  1. 'Creator: Slurms Makenzi
  2. 'Thanks Aeon for theme class!
  3. 'Date: 7/7/2011
  4. 'Site: www.loungeforum.net
  5. 'Version: 1.0
  6. 'Thanks xZ3ROxPROJ3CTx
  7.  
  8. '
  9.  
  10. '\\\\\\\\\\\\\\\Use Credits Were Credits Are Needed///////////////////
  11.  
  12. '
  13.  
  14. #Region "Imports"
  15. Imports System.Drawing.Drawing2D
  16. Imports System.ComponentModel
  17. Imports System.Runtime.InteropServices
  18. #End Region
  19. MustInherit Class Theme
  20.     Inherits ContainerControl
  21.  
  22. #Region " Initialization "
  23.  
  24.     Protected G As Graphics
  25.     Sub New()
  26.         SetStyle(DirectCast(139270, ControlStyles), True)
  27.     End Sub
  28.  
  29.     Private ParentIsForm As Boolean
  30.     Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
  31.         Dock = DockStyle.Fill
  32.         ParentIsForm = TypeOf Parent Is Form
  33.         If ParentIsForm Then
  34.             If Not _TransparencyKey = Color.Empty Then ParentForm.TransparencyKey = _TransparencyKey
  35.             ParentForm.FormBorderStyle = FormBorderStyle.None
  36.         End If
  37.         MyBase.OnHandleCreated(e)
  38.     End Sub
  39.  
  40.     Overrides Property Text As String
  41.         Get
  42.             Return MyBase.Text
  43.         End Get
  44.         Set(ByVal v As String)
  45.             MyBase.Text = v
  46.             Invalidate()
  47.         End Set
  48.     End Property
  49. #End Region
  50.  
  51. #Region " Sizing and Movement "
  52.  
  53.     Private _Resizable As Boolean = True
  54.     Property Resizable() As Boolean
  55.         Get
  56.             Return _Resizable
  57.         End Get
  58.         Set(ByVal value As Boolean)
  59.             _Resizable = value
  60.         End Set
  61.     End Property
  62.  
  63.     Private _MoveHeight As Integer = 24
  64.     Property MoveHeight() As Integer
  65.         Get
  66.             Return _MoveHeight
  67.         End Get
  68.         Set(ByVal v As Integer)
  69.             _MoveHeight = v
  70.             Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  71.         End Set
  72.     End Property
  73.  
  74.     Private Flag As IntPtr
  75.     Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
  76.         If Not e.Button = MouseButtons.Left Then Return
  77.         If ParentIsForm Then If ParentForm.WindowState = FormWindowState.Maximized Then Return
  78.  
  79.         If Header.Contains(e.Location) Then
  80.             Flag = New IntPtr(2)
  81.         ElseIf Current.Position = 0 Or Not _Resizable Then
  82.             Return
  83.         Else
  84.             Flag = New IntPtr(Current.Position)
  85.         End If
  86.  
  87.         Capture = False
  88.         DefWndProc(Message.Create(Parent.Handle, 161, Flag, Nothing))
  89.  
  90.         MyBase.OnMouseDown(e)
  91.     End Sub
  92.  
  93.     Private Structure Pointer
  94.         ReadOnly Cursor As Cursor, Position As Byte
  95.         Sub New(ByVal c As Cursor, ByVal p As Byte)
  96.             Cursor = c
  97.             Position = p
  98.         End Sub
  99.     End Structure
  100.  
  101.     Private F1, F2, F3, F4 As Boolean, PTC As Point
  102.     Private Function GetPointer() As Pointer
  103.         PTC = PointToClient(MousePosition)
  104.         F1 = PTC.X < 7
  105.         F2 = PTC.X > Width - 7
  106.         F3 = PTC.Y < 7
  107.         F4 = PTC.Y > Height - 7
  108.  
  109.         If F1 And F3 Then Return New Pointer(Cursors.SizeNWSE, 13)
  110.         If F1 And F4 Then Return New Pointer(Cursors.SizeNESW, 16)
  111.         If F2 And F3 Then Return New Pointer(Cursors.SizeNESW, 14)
  112.         If F2 And F4 Then Return New Pointer(Cursors.SizeNWSE, 17)
  113.         If F1 Then Return New Pointer(Cursors.SizeWE, 10)
  114.         If F2 Then Return New Pointer(Cursors.SizeWE, 11)
  115.         If F3 Then Return New Pointer(Cursors.SizeNS, 12)
  116.         If F4 Then Return New Pointer(Cursors.SizeNS, 15)
  117.         Return New Pointer(Cursors.Default, 0)
  118.     End Function
  119.  
  120.     Private Current, Pending As Pointer
  121.     Private Sub SetCurrent()
  122.         Pending = GetPointer()
  123.         If Current.Position = Pending.Position Then Return
  124.         Current = GetPointer()
  125.         Cursor = Current.Cursor
  126.     End Sub
  127.  
  128.     Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
  129.         If _Resizable Then SetCurrent()
  130.         MyBase.OnMouseMove(e)
  131.     End Sub
  132.  
  133.     Protected Header As Rectangle
  134.     Protected Overrides Sub OnSizeChanged(ByVal e As EventArgs)
  135.         If Width = 0 OrElse Height = 0 Then Return
  136.         Header = New Rectangle(7, 7, Width - 14, _MoveHeight - 7)
  137.         Invalidate()
  138.         MyBase.OnSizeChanged(e)
  139.     End Sub
  140.  
  141. #End Region
  142.  
  143. #Region " Convienence "
  144.  
  145.     MustOverride Sub PaintHook()
  146.     Protected NotOverridable Overrides Sub OnPaint(ByVal e As PaintEventArgs)
  147.         If Width = 0 OrElse Height = 0 Then Return
  148.         G = e.Graphics
  149.         PaintHook()
  150.     End Sub
  151.  
  152.     Private _TransparencyKey As Color
  153.     Property TransparencyKey() As Color
  154.         Get
  155.             Return _TransparencyKey
  156.         End Get
  157.         Set(ByVal v As Color)
  158.             _TransparencyKey = v
  159.             Invalidate()
  160.         End Set
  161.     End Property
  162.  
  163.     Private _Image As Image
  164.     Property Image() As Image
  165.         Get
  166.             Return _Image
  167.         End Get
  168.         Set(ByVal value As Image)
  169.             _Image = value
  170.             Invalidate()
  171.         End Set
  172.     End Property
  173.     ReadOnly Property ImageWidth() As Integer
  174.         Get
  175.             If _Image Is Nothing Then Return 0
  176.             Return _Image.Width
  177.         End Get
  178.     End Property
  179.  
  180.     Private _Size As Size
  181.     Private _Rectangle As Rectangle
  182.     Private _Gradient As LinearGradientBrush
  183.     Private _Brush As SolidBrush
  184.  
  185.     Protected Sub DrawCorners(ByVal c As Color, ByVal rect As Rectangle)
  186.         _Brush = New SolidBrush(c)
  187.         G.FillRectangle(_Brush, rect.X, rect.Y, 1, 1)
  188.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y, 1, 1)
  189.         G.FillRectangle(_Brush, rect.X, rect.Y + (rect.Height - 1), 1, 1)
  190.         G.FillRectangle(_Brush, rect.X + (rect.Width - 1), rect.Y + (rect.Height - 1), 1, 1)
  191.     End Sub
  192.  
  193.     Protected Sub DrawBorders(ByVal p1 As Pen, ByVal p2 As Pen, ByVal rect As Rectangle)
  194.         G.DrawRectangle(p1, rect.X, rect.Y, rect.Width - 1, rect.Height - 1)
  195.         G.DrawRectangle(p2, rect.X + 1, rect.Y + 1, rect.Width - 3, rect.Height - 3)
  196.     End Sub
  197.  
  198.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer)
  199.         DrawText(a, c, x, 0)
  200.     End Sub
  201.     Protected Sub DrawText(ByVal a As HorizontalAlignment, ByVal c As Color, ByVal x As Integer, ByVal y As Integer)
  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, Font, _Brush, x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  209.             Case HorizontalAlignment.Right
  210.                 G.DrawString(Text, Font, _Brush, Width - _Size.Width - x, _MoveHeight \ 2 - _Size.Height \ 2 + y)
  211.             Case HorizontalAlignment.Center
  212.                 G.DrawString(Text, Font, _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. Public Class Draw
  486.     Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  487.         Dim R As New Rectangle(x, y, width, height)
  488.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  489.             g.FillRectangle(T, R)
  490.         End Using
  491.     End Sub
  492.     Shared Sub Gradient(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal r As Rectangle)
  493.         Using T As New LinearGradientBrush(R, c1, c2, LinearGradientMode.Vertical)
  494.             g.FillRectangle(T, R)
  495.         End Using
  496.     End Sub
  497.     Shared Sub Blend(ByVal g As Graphics, ByVal c1 As Color, ByVal c2 As Color, ByVal c3 As Color, ByVal c As Single, ByVal d As Integer, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer)
  498.         Dim v As New ColorBlend(3)
  499.         V.Colors = New Color() {c1, c2, c3}
  500.         V.Positions = New Single() {0, c, 1}
  501.         Dim R As New Rectangle(x, y, width, height)
  502.         Using T As New LinearGradientBrush(R, c1, c1, CType(d, LinearGradientMode))
  503.             T.InterpolationColors = v : g.FillRectangle(T, R)
  504.         End Using
  505.     End Sub
  506.     Shared Function RoundedRectangle(ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer, ByVal cornerwidth As Integer, ByVal PenWidth As Integer) As GraphicsPath
  507.         Dim p As New GraphicsPath
  508.         p.StartFigure()
  509.         p.AddArc(New Rectangle(x, y, cornerwidth, cornerwidth), 180, 90)
  510.         p.AddLine(cornerwidth, y, width - cornerwidth - PenWidth, y)
  511.  
  512.         p.AddArc(New Rectangle(width - cornerwidth - PenWidth, y, cornerwidth, cornerwidth), -90, 90)
  513.         p.AddLine(width - PenWidth, cornerwidth, width - PenWidth, height - cornerwidth - PenWidth)
  514.  
  515.         p.AddArc(New Rectangle(width - cornerwidth - PenWidth, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 0, 90)
  516.         p.AddLine(width - cornerwidth - PenWidth, height - PenWidth, cornerwidth, height - PenWidth)
  517.  
  518.         p.AddArc(New Rectangle(x, height - cornerwidth - PenWidth, cornerwidth, cornerwidth), 90, 90)
  519.         p.CloseFigure()
  520.  
  521.         Return p
  522.     End Function
  523.  
  524.     Shared Sub BackGround(ByVal width As Integer, ByVal height As Integer, ByVal G As Graphics)
  525.  
  526.         Dim P1 As Color = Color.FromArgb(29, 25, 22)
  527.         Dim P2 As Color = Color.FromArgb(35, 31, 28)
  528.  
  529.         For y As Integer = 0 To height Step 4
  530.             For x As Integer = 0 To width Step 4
  531.                 G.FillRectangle(New SolidBrush(P1), New Rectangle(x, y, 1, 1))
  532.                 G.FillRectangle(New SolidBrush(P2), New Rectangle(x, y + 1, 1, 1))
  533.                 Try
  534.                     G.FillRectangle(New SolidBrush(P1), New Rectangle(x + 2, y + 2, 1, 1))
  535.                     G.FillRectangle(New SolidBrush(P2), New Rectangle(x + 2, y + 3, 1, 1))
  536.                 Catch
  537.                 End Try
  538.             Next
  539.         Next
  540.     End Sub
  541. End Class
  542. Class PurityxTheme
  543.     Inherits Theme
  544.  
  545.     Sub New()
  546.         Resizable = False
  547.         BackColor = Color.FromKnownColor(KnownColor.Control)
  548.         MoveHeight = 25
  549.         TransparencyKey = Color.Fuchsia
  550.     End Sub
  551.  
  552.     Public Overrides Sub PaintHook()
  553.         G.Clear(BackColor)   ' Clear the form first
  554.  
  555.         'DrawGradient(Color.FromArgb(64, 64, 64), Color.FromArgb(32, 32, 32), 0, 0, Width, Height, 90S)   ' Form Gradient
  556.         G.Clear(Color.FromArgb(60, 60, 60))
  557.         DrawGradient(Color.FromArgb(45, 40, 45), Color.FromArgb(32, 32, 32), 0, 0, Width, 25, 90S)   ' Form Top Bar
  558.  
  559.         G.DrawLine(Pens.Black, 0, 25, Width, 25)   ' Top Line
  560.         'G.DrawLine(Pens.Black, 0, Height - 25, Width, Height - 25)   ' Bottom Line
  561.  
  562.         DrawCorners(Color.Fuchsia, ClientRectangle)   ' Then draw some clean corners
  563.         DrawBorders(Pens.Black, Pens.DimGray, ClientRectangle)   ' Then we draw our form borders
  564.  
  565.         DrawText(HorizontalAlignment.Left, Color.Red, 7, 1)   ' Finally, we draw our text
  566.     End Sub
  567. End Class ' Theme Code
  568. Class PurityxButton
  569.     Inherits ThemeControl
  570.  
  571.     Overrides Sub PaintHook()
  572.         Select Case MouseState
  573.             Case State.MouseNone
  574.                 G.Clear(Color.Red)
  575.                 DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, Width, Height, 90S)
  576.             Case State.MouseOver
  577.                 G.Clear(Color.Red)
  578.                 DrawGradient(Color.FromArgb(62, 62, 62), Color.FromArgb(38, 38, 38), 0, 0, Width, Height, 90S)
  579.             Case State.MouseDown
  580.                 G.Clear(Color.DarkRed)
  581.                 DrawGradient(Color.FromArgb(38, 38, 38), Color.FromArgb(62, 62, 62), 0, 0, Width, Height, 90S)
  582.         End Select
  583.  
  584.         DrawBorders(Pens.Black, Pens.DimGray, ClientRectangle)   ' Form Border
  585.         DrawCorners(Color.Black, ClientRectangle)   ' Clean Corners
  586.         DrawText(HorizontalAlignment.Center, Color.Red, 0)
  587.     End Sub
  588. End Class ' Button Code
  589. Public Class PurityxLabel
  590.     Inherits Label
  591.     Sub New()
  592.         Font = New Font("Arial", 8)
  593.         ForeColor = Color.Red
  594.         BackColor = Color.Transparent
  595.     End Sub
  596. End Class ' Label Code
  597. Public Class PurityxSeperator
  598.     Inherits Control
  599.  
  600.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  601.         Using b As New Bitmap(Width, Height)
  602.             Using g As Graphics = Graphics.FromImage(b)
  603.                 g.Clear(BackColor)
  604.  
  605.                 Dim P1 As Color = Color.FromArgb(255, 255, 255)
  606.                 Dim P2 As Color = Color.FromArgb(255, 255, 255)
  607.                 g.FillRectangle(New SolidBrush(Color.FromArgb(62, 62, 62)), New Rectangle(0, 0, Width, Height))
  608.  
  609.  
  610.                 Dim GRec As New Rectangle(0, Height / 2, Width / 5, 2)
  611.                 Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, Color.Transparent, P2, LinearGradientMode.Horizontal)
  612.                     g.FillRectangle(GBrush, GRec)
  613.                 End Using
  614.                 g.DrawLine(New Pen(P2, 2), New Point(GRec.Width, GRec.Y + 1), New Point(Width - GRec.Width + 1, GRec.Y + 1))
  615.  
  616.                 GRec = New Rectangle(Width - (Width / 5), Height / 2, Width / 5, 2)
  617.                 Using GBrush As LinearGradientBrush = New LinearGradientBrush(GRec, P2, Color.Transparent, LinearGradientMode.Horizontal)
  618.                     g.FillRectangle(GBrush, GRec)
  619.                 End Using
  620.                 e.Graphics.DrawImage(b, 0, 0)
  621.             End Using
  622.         End Using
  623.         MyBase.OnPaint(e)
  624.     End Sub
  625. End Class ' Seperator Code
  626. Class PurityxGroupbox
  627.     Inherits Panel
  628.     Dim Bg As Color = Color.FromArgb(62, 62, 62)
  629.     Dim PC2 As Color = Color.FromArgb(204, 204, 204)
  630.     Dim FC As Color = Color.FromArgb(204, 204, 204)
  631.     Dim p As Pen
  632.     Dim sb As SolidBrush
  633.     Sub New()
  634.         BackColor = Bg
  635.     End Sub
  636.     Dim _t As String = ""
  637.     Public Property Header() As String
  638.         Get
  639.             Return _t
  640.         End Get
  641.         Set(ByVal value As String)
  642.             _t = value
  643.             Invalidate()
  644.         End Set
  645.     End Property
  646.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  647.         Using b As New Bitmap(Width, Height)
  648.             Using g As Graphics = Graphics.FromImage(b)
  649.                 p = New Pen(PC2)
  650.                 sb = New SolidBrush(Bg)
  651.                 Dim M As SizeF = g.MeasureString(_t, Font)
  652.                 Dim Outline As GraphicsPath = Draw.RoundedRectangle(0, M.Height / 2, Width - 1, Height - 1, 10, 1)
  653.                 g.Clear(BackColor)
  654.                 g.FillRectangle(sb, New Rectangle(0, M.Height / 2, Width - 1, Height - 1))
  655.                 g.DrawPath(p, Outline)
  656.  
  657.                 g.FillRectangle(sb, New Rectangle(10, (M.Height / 2) - 2, M.Width + 10, M.Height))
  658.                 sb = New SolidBrush(FC)
  659.                 g.DrawString(MyBase.Text, MyBase.Font, Brushes.White, 7, 1)
  660.                 e.Graphics.DrawImage(b, 0, 0)
  661.             End Using
  662.         End Using
  663.         MyBase.OnPaint(e)
  664.     End Sub
  665. End Class ' GroupBox Code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement