Advertisement
LordPankake

[VB.net] PV Theme - [12 Controls | Dark]

Sep 6th, 2014
1,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  PixelVision
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Created: 8/23/2014, Last edited: 9/6/2014
  7. '|===========================================================|
  8. #Region "Base Classes"
  9. Public Class ThemedControl : Inherits Control
  10.     Public D As New DrawUtils
  11.     Public State As MouseState = MouseState.None
  12.     Public Pal As Palette
  13.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  14.     End Sub
  15.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  16.         MyBase.OnMouseEnter(e)
  17.         State = MouseState.Over
  18.         Invalidate()
  19.     End Sub
  20.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  21.         MyBase.OnMouseDown(e)
  22.         State = MouseState.Down
  23.         Invalidate()
  24.     End Sub
  25.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  26.         MyBase.OnMouseLeave(e)
  27.         State = MouseState.None
  28.         Invalidate()
  29.     End Sub
  30.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  31.         MyBase.OnMouseUp(e)
  32.         State = MouseState.Over
  33.         Invalidate()
  34.     End Sub
  35.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  36.         MyBase.OnTextChanged(e)
  37.         Invalidate()
  38.     End Sub
  39.     Sub New()
  40.         MyBase.New()
  41.         MinimumSize = New Size(20, 20)
  42.         ForeColor = Color.FromArgb(146, 149, 152)
  43.         Font = New Font("Segoe UI", 10.0F)
  44.         DoubleBuffered = True
  45.         Pal = New Palette
  46.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  47.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  48.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  49.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  50.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  51.         BackColor = Pal.ColDim
  52.     End Sub
  53. End Class
  54. Public Class ThemedTrackbar : Inherits TrackBar
  55.     Public D As New DrawUtils
  56.     Public State As MouseState = MouseState.None
  57.     Public Pal As Palette
  58.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  59.     End Sub
  60.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  61.         MyBase.OnMouseEnter(e)
  62.         State = MouseState.Over
  63.         Invalidate()
  64.     End Sub
  65.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  66.         MyBase.OnMouseDown(e)
  67.         State = MouseState.Down
  68.         Invalidate()
  69.     End Sub
  70.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  71.         MyBase.OnMouseLeave(e)
  72.         State = MouseState.None
  73.         Invalidate()
  74.     End Sub
  75.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  76.         MyBase.OnMouseUp(e)
  77.         State = MouseState.Over
  78.         Invalidate()
  79.     End Sub
  80.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  81.         MyBase.OnTextChanged(e)
  82.         Invalidate()
  83.     End Sub
  84.     Sub New()
  85.         MyBase.New()
  86.         MinimumSize = New Size(20, 20)
  87.         ForeColor = Color.FromArgb(146, 149, 152)
  88.         Font = New Font("Segoe UI", 10.0F)
  89.         DoubleBuffered = True
  90.         Pal = New Palette
  91.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  92.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  93.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  94.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  95.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  96.         BackColor = Pal.ColDim
  97.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  98.     End Sub
  99. End Class
  100. Public Class ThemedTextbox : Inherits TextBox
  101.     Public D As New DrawUtils
  102.     Public State As MouseState = MouseState.None
  103.     Public Pal As Palette
  104.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  105.     End Sub
  106.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  107.         MyBase.OnMouseEnter(e)
  108.         State = MouseState.Over
  109.         Invalidate()
  110.     End Sub
  111.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  112.         MyBase.OnMouseDown(e)
  113.         State = MouseState.Down
  114.         Invalidate()
  115.     End Sub
  116.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  117.         MyBase.OnMouseLeave(e)
  118.         State = MouseState.None
  119.         Invalidate()
  120.     End Sub
  121.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  122.         MyBase.OnMouseUp(e)
  123.         State = MouseState.Over
  124.         Invalidate()
  125.     End Sub
  126.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  127.         MyBase.OnTextChanged(e)
  128.         Invalidate()
  129.     End Sub
  130.     Sub New()
  131.         MyBase.New()
  132.         MinimumSize = New Size(20, 20)
  133.         ForeColor = Color.FromArgb(146, 149, 152)
  134.         Font = New Font("Segoe UI", 10.0F)
  135.         DoubleBuffered = True
  136.         Pal = New Palette
  137.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  138.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  139.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  140.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  141.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  142.         BackColor = Pal.ColDim
  143.     End Sub
  144. End Class
  145. Public Class ThemedContainer : Inherits ContainerControl
  146.     Public D As New DrawUtils
  147.     Protected Drag As Boolean = True
  148.     Public State As MouseState = MouseState.None
  149.     Protected TopCap As Boolean = False
  150.     Protected SizeCap As Boolean = False
  151.     Public Pal As Palette
  152.     Protected MouseP As Point = New Point(0, 0)
  153.     Protected TopGrip As Integer
  154.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  155.     End Sub
  156.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  157.         MyBase.OnMouseEnter(e)
  158.         State = MouseState.Over
  159.         Invalidate()
  160.     End Sub
  161.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  162.         MyBase.OnMouseDown(e)
  163.         State = MouseState.Down
  164.         If e.Button = Windows.Forms.MouseButtons.Left Then
  165.             If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  166.                 TopCap = True : MouseP = e.Location
  167.             ElseIf Drag And New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  168.                 SizeCap = True : MouseP = e.Location
  169.             End If
  170.         End If
  171.     End Sub
  172.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  173.         MyBase.OnMouseLeave(e)
  174.         State = MouseState.None
  175.         Invalidate()
  176.     End Sub
  177.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  178.         MyBase.OnMouseUp(e)
  179.         State = MouseState.Over
  180.         TopCap = False
  181.         If Drag Then
  182.             SizeCap = False
  183.         End If
  184.  
  185.     End Sub
  186.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  187.         MyBase.OnMouseMove(e)
  188.  
  189.         If TopCap Then
  190.             Parent.Location = MousePosition - MouseP
  191.         End If
  192.         If Drag And SizeCap Then
  193.             MouseP = e.Location
  194.             Parent.Size = New Size(MouseP)
  195.             Invalidate()
  196.         End If
  197.  
  198.     End Sub
  199.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  200.         MyBase.OnTextChanged(e)
  201.         Invalidate()
  202.     End Sub
  203.     Sub New()
  204.         MyBase.New()
  205.         MinimumSize = New Size(20, 20)
  206.         ForeColor = Color.FromArgb(146, 149, 152)
  207.         Font = New Font("Trebuchet MS", 10.0F)
  208.         DoubleBuffered = True
  209.         Pal = New Palette
  210.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  211.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  212.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  213.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  214.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  215.         BackColor = Pal.ColDim
  216.     End Sub
  217. End Class
  218. Public Class ThemedTabControl : Inherits TabControl
  219.     Public D As New DrawUtils
  220.     Public State As MouseState = MouseState.None
  221.     Public Pal As Palette
  222.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  223.     End Sub
  224.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  225.         MyBase.OnMouseEnter(e)
  226.         State = MouseState.Over
  227.         Invalidate()
  228.     End Sub
  229.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  230.         MyBase.OnMouseDown(e)
  231.         State = MouseState.Down
  232.         Invalidate()
  233.     End Sub
  234.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  235.         MyBase.OnMouseLeave(e)
  236.         State = MouseState.None
  237.         Invalidate()
  238.     End Sub
  239.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  240.         MyBase.OnMouseUp(e)
  241.         State = MouseState.Over
  242.         Invalidate()
  243.     End Sub
  244.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  245.         MyBase.OnTextChanged(e)
  246.         Invalidate()
  247.     End Sub
  248.     Sub New()
  249.         MyBase.New()
  250.         MinimumSize = New Size(20, 20)
  251.         ForeColor = Color.FromArgb(146, 149, 152)
  252.         Font = New Font("Segoe UI", 10.0F)
  253.         DoubleBuffered = True
  254.         Pal = New Palette
  255.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  256.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  257.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  258.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  259.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  260.         BackColor = Pal.ColDim
  261.         Alignment = TabAlignment.Top
  262.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  263.     End Sub
  264. End Class
  265. Public Class ThemedListControl : Inherits listbox
  266.     Public D As New DrawUtils
  267.     Public State As MouseState = MouseState.None
  268.     Public Pal As Palette
  269.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  270.     End Sub
  271.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  272.         MyBase.OnMouseEnter(e)
  273.         State = MouseState.Over
  274.         Invalidate()
  275.     End Sub
  276.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  277.         MyBase.OnMouseDown(e)
  278.         State = MouseState.Down
  279.         Invalidate()
  280.     End Sub
  281.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  282.         MyBase.OnMouseLeave(e)
  283.         State = MouseState.None
  284.         Invalidate()
  285.     End Sub
  286.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  287.         MyBase.OnMouseUp(e)
  288.         State = MouseState.Over
  289.         Invalidate()
  290.     End Sub
  291.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  292.         MyBase.OnTextChanged(e)
  293.         Invalidate()
  294.     End Sub
  295.     Sub New()
  296.         MyBase.New()
  297.         MinimumSize = New Size(20, 20)
  298.         ForeColor = Color.FromArgb(146, 149, 152)
  299.         Font = New Font("Segoe UI", 10.0F)
  300.         DoubleBuffered = True
  301.         Pal = New Palette
  302.         Pal.ColHighest = Color.FromArgb(100, 110, 120)
  303.         Pal.ColHigh = Color.FromArgb(65, 70, 75)
  304.         Pal.ColMed = Color.FromArgb(40, 42, 45)
  305.         Pal.ColDim = Color.FromArgb(30, 32, 35)
  306.         Pal.ColDark = Color.FromArgb(15, 17, 19)
  307.         BackColor = Pal.ColDim
  308.     End Sub
  309. End Class
  310. #End Region
  311. #Region "Theme"
  312. Public Class PVForm : Inherits ThemedContainer
  313.     Sub New()
  314.         MyBase.New()
  315.         MinimumSize = New Size(305, 150)
  316.         Dock = DockStyle.Fill
  317.         TopGrip = 30
  318.         Font = New Font("Segoe UI", 10.0F)
  319.         BackColor = Color.FromArgb(21, 23, 25)
  320.     End Sub
  321.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  322.         Dim G As Graphics = e.Graphics
  323.         MyBase.OnPaint(e)
  324.         Try
  325.             Me.ParentForm.TransparencyKey = Color.Fuchsia
  326.             Me.ParentForm.MinimumSize = MinimumSize
  327.             If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  328.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  329.             End If
  330.         Catch ex As Exception : End Try
  331.         G.Clear(Me.ParentForm.TransparencyKey)
  332.  
  333.         '| Main drawing
  334.        Dim BorderRect As New Rectangle(0, 0, Width - 1, Height - 1)
  335.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, Height - 3)
  336.         G.FillRectangle(New SolidBrush(Pal.ColDim), BorderRect)
  337.  
  338.         '|=========================|
  339.        '| The top textured bit of the theme is 'first'
  340.        '| The second area for menu objects is 'second'
  341.        '|=========================|
  342.        '| Top Rect
  343.        Dim FirstTexturedRect As New Rectangle(0, 0, Width - 1, TopGrip)
  344.         Dim FirstDiagonalHatch As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Pal.ColDim, Color.Transparent)
  345.         Dim FirstLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip), Pal.ColHigh, Pal.ColDim)
  346.         Dim FirstShineRect As New Rectangle(0, 0, Width - 1, TopGrip / 2)
  347.         Dim FirstShineLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip * (3 / 5)), Color.FromArgb(120, Pal.ColHighest), Color.FromArgb(10, Pal.ColHighest))
  348.         Dim test As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip * (3 / 5)), Color.FromArgb(60, Pal.ColDim), Color.FromArgb(10, Pal.ColDim))
  349.         G.FillRectangle(FirstLGB, FirstTexturedRect)
  350.         G.FillRectangle(FirstDiagonalHatch, FirstTexturedRect)
  351.         G.FillRectangle(test, FirstShineRect)
  352.         G.FillRectangle(FirstShineLGB, FirstShineRect)
  353.         G.DrawLine(New Pen(Color.FromArgb(150, Color.Black)), New Point(0, TopGrip), New Point(Width - 1, TopGrip))
  354.         G.DrawLine(New Pen(Color.FromArgb(60, Pal.ColHighest)), New Point(0, TopGrip + 1), New Point(Width - 1, TopGrip + 1))
  355.  
  356.  
  357.         '| Second Top Rect
  358.        Dim SecondMenuHeight As Integer = TopGrip * 2.4
  359.         Dim SecondMenuRect As New Rectangle(0, TopGrip, Width - 1, SecondMenuHeight)
  360.         Dim BlahRect As New Rectangle(0, SecondMenuHeight - 20, Width - 1, 22)
  361.         Dim SecondLGB As New LinearGradientBrush(New Point(0, SecondMenuHeight - 20), New Point(0, SecondMenuHeight - 10 + 22), Pal.ColDim, Pal.ColDark)
  362.         G.FillRectangle(SecondLGB, BlahRect)
  363.         G.DrawLine(New Pen(Color.FromArgb(150, Color.Black)), New Point(0, SecondMenuHeight), New Point(Width - 1, SecondMenuHeight))
  364.         G.DrawLine(New Pen(Color.FromArgb(60, Pal.ColHighest)), New Point(0, SecondMenuHeight + 1), New Point(Width - 1, SecondMenuHeight + 1))
  365.  
  366.         '| Below Second Top Rect
  367.        G.FillRectangle(New SolidBrush(Color.FromArgb(150, Pal.ColDark)), New Rectangle(0, SecondMenuHeight, Width - 1, Height - SecondMenuHeight))
  368.  
  369.         '| Borders and finalizations
  370.        G.DrawRectangle(Pens.Black, BorderRect)
  371.         G.DrawRectangle(New Pen(Color.FromArgb(60, Pal.ColHighest)), BorderInnerRect)
  372.         D.DrawTextWithShadow(G, New Rectangle(5, 0, Width - 31, TopGrip), Text, Font, HorizontalAlignment.Left, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  373.     End Sub
  374. End Class
  375. Public Class PVEmbeddedButton : Inherits ThemedControl
  376.     Sub New()
  377.         MyBase.New()
  378.         Font = New Font("Trebuchet MS", 10.0F)
  379.     End Sub
  380.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  381.         Dim G As Graphics = e.Graphics
  382.         MyBase.OnPaint(e)
  383.         Try
  384.             BackColor = Me.Parent.BackColor
  385.         Catch ex As Exception : End Try
  386.         G.Clear(BackColor)
  387.         G.SmoothingMode = SmoothingMode.HighQuality
  388.  
  389.  
  390.         Dim BorderRect As New Rectangle(0, 0, Width - 1, Height - 1)
  391.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, Height - 3)
  392.         Dim ButtonRect As New Rectangle(5, 5, Width - 11, Height - 11)
  393.  
  394.  
  395.         '| Drawing the button's hole into the form (Whats the whole that a button goes into? There even a name for that???)
  396.        Dim Out1Path As GraphicsPath = D.RoundRect(BorderRect, 3)
  397.         Dim Out2Path As GraphicsPath = D.RoundRect(BorderInnerRect, 5)
  398.         Dim Out2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  399.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), BorderInnerRect)
  400.         G.DrawPath(New Pen(Out2LGB, 3), Out2Path)
  401.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), Out1Path)
  402.  
  403.         '| Drawing the button
  404.        Dim InnerButtonWidth As Integer = 10
  405.         Dim ButtonPath As GraphicsPath = D.RoundRect(ButtonRect, 4)
  406.         Dim ButtonInnerPath As GraphicsPath = D.RoundRect(New Rectangle(ButtonRect.X + InnerButtonWidth, ButtonRect.Y, ButtonRect.Width - (InnerButtonWidth * 2), ButtonRect.Height), 4)
  407.         Dim ButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y + 1, ButtonRect.Width, ButtonRect.Height - 2), 4)
  408.         Select Case State
  409.             Case MouseState.None
  410.                 G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), ButtonPath)
  411.                 G.FillPath(New SolidBrush(Pal.ColDim), ButtonInnerPath)
  412.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  413.             Case MouseState.Over
  414.                 G.FillPath(New SolidBrush(Color.FromArgb(255, Pal.ColDim)), ButtonPath)
  415.                 G.FillPath(New SolidBrush(Color.FromArgb(Pal.ColDim.R + 10, Pal.ColDim.G + 10, Pal.ColDim.B + 10)), ButtonInnerPath)
  416.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  417.             Case MouseState.Down
  418.                 G.FillPath(New SolidBrush(Color.FromArgb(70, Pal.ColDim)), ButtonPath)
  419.                 G.FillPath(New SolidBrush(Pal.ColDim), ButtonInnerPath)
  420.                 G.FillPath(New SolidBrush(Color.FromArgb(50, Pal.ColDark)), ButtonInnerPath)
  421.                 D.FillGradientBeam(G, Color.FromArgb(35, Color.Black), Color.FromArgb(14, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  422.         End Select
  423.         If State = MouseState.Down Then
  424.             ButtonHighlightPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y + 1, ButtonRect.Width, ButtonRect.Height - 1), 4)
  425.             G.DrawPath(New Pen(Color.FromArgb(100, Color.Black), 3), ButtonHighlightPath)
  426.             D.DrawTextWithShadow(G, BorderInnerRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(200, Pal.ColHighest), Color.Black)
  427.  
  428.         Else
  429.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), ButtonHighlightPath)
  430.             D.DrawTextWithShadow(G, BorderInnerRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  431.  
  432.         End If
  433.         G.DrawPath(Pens.Black, ButtonPath)
  434.  
  435.     End Sub
  436. End Class
  437. Public Class PVButton : Inherits ThemedControl
  438.     Sub New()
  439.         MyBase.New()
  440.         Font = New Font("Trebuchet MS", 10.0F)      
  441.     End Sub
  442.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  443.         Dim G As Graphics = e.Graphics
  444.         MyBase.OnPaint(e)
  445.         Try
  446.             BackColor = Me.Parent.BackColor
  447.         Catch ex As Exception : End Try
  448.         G.Clear(BackColor)
  449.         G.SmoothingMode = SmoothingMode.HighQuality
  450.  
  451.         '| Drawing the button
  452.        Dim ButtonRect As New Rectangle(0, 0, Width - 1, Height - 1)
  453.         Dim Roundness As Integer = 4
  454.         If Size.Width <= 30 And Size.Height <= 30 Then
  455.             Roundness = 2
  456.         End If
  457.         Dim ButtonPath As GraphicsPath = D.RoundRect(ButtonRect, Roundness)
  458.         Dim ButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y + 1, ButtonRect.Width, ButtonRect.Height - 2), 4)
  459.         Select Case State
  460.             Case MouseState.None
  461.                 G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), ButtonPath)
  462.                 G.FillPath(New SolidBrush(Pal.ColDim), ButtonPath)
  463.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  464.             Case MouseState.Over
  465.                 G.FillPath(New SolidBrush(Color.FromArgb(255, Pal.ColDim)), ButtonPath)
  466.                 G.FillPath(New SolidBrush(Color.FromArgb(Pal.ColDim.R + 10, Pal.ColDim.G + 10, Pal.ColDim.B + 10)), ButtonPath)
  467.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  468.             Case MouseState.Down
  469.                 G.FillPath(New SolidBrush(Color.FromArgb(70, Pal.ColDim)), ButtonPath)
  470.                 G.FillPath(New SolidBrush(Pal.ColDim), ButtonPath)
  471.                 G.FillPath(New SolidBrush(Color.FromArgb(50, Pal.ColDark)), ButtonPath)
  472.                 D.FillGradientBeam(G, Color.FromArgb(35, Color.Black), Color.FromArgb(14, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  473.         End Select
  474.         If State = MouseState.Down Then
  475.             ButtonHighlightPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y + 1, ButtonRect.Width, ButtonRect.Height - 1), 4)
  476.             G.DrawPath(New Pen(Color.FromArgb(100, Color.Black), 3), ButtonHighlightPath)
  477.             D.DrawTextWithShadow(G, ButtonRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(200, Pal.ColHighest), Color.Black)
  478.  
  479.         Else
  480.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), ButtonHighlightPath)
  481.             D.DrawTextWithShadow(G, ButtonRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  482.  
  483.         End If
  484.         G.DrawPath(Pens.Black, ButtonPath)
  485.  
  486.     End Sub
  487. End Class
  488. Public Class PVGroupbox : Inherits ThemedContainer
  489.     Sub New()
  490.         MyBase.New()
  491.         Font = New Font("Trebuchet MS", 10.0F)
  492.     End Sub
  493.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  494.         Dim G As Graphics = e.Graphics
  495.         MyBase.OnPaint(e)
  496.         Try
  497.             BackColor = Me.Parent.BackColor
  498.         Catch ex As Exception
  499.  
  500.         End Try
  501.         G.Clear(BackColor)
  502.         G.SmoothingMode = SmoothingMode.HighQuality
  503.  
  504.  
  505.         Dim BorderRect As New Rectangle(0, 0, Width - 1, Height - 1)
  506.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, Height - 3)
  507.  
  508.         '| Pretty much the same as the button, minus the button itself. Looked good as a container.
  509.        Dim Out1Path As GraphicsPath = D.RoundRect(BorderRect, 3)
  510.         Dim Out2Path As GraphicsPath = D.RoundRect(BorderInnerRect, 5)
  511.         Dim Out2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  512.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.FromArgb(0, 0, 10))), BorderInnerRect)
  513.         G.DrawPath(New Pen(Out2LGB, 3), Out2Path)
  514.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), Out1Path)
  515.  
  516.         '| Drawing the text area
  517.        If Text.Length > 0 Then
  518.             Dim TextRect As New Rectangle(1, 1, G.MeasureString(Text, Font).ToSize.Width, G.MeasureString(Text, Font).ToSize.Height + 5)
  519.             Dim TextInnerRect As New Rectangle(1, 2, G.MeasureString(Text, Font).ToSize.Width, G.MeasureString(Text, Font).ToSize.Height + 5 - 1)
  520.             Dim TextInnerRect2 As New Rectangle(1, 1, G.MeasureString(Text, Font).ToSize.Width, G.MeasureString(Text, Font).ToSize.Height + 5 - 1)
  521.             Dim TextDropshadow As New Rectangle(2, 2, G.MeasureString(Text, Font).ToSize.Width - 1, G.MeasureString(Text, Font).ToSize.Height + 4)
  522.  
  523.  
  524.             Dim TextPath As GraphicsPath = D.RoundRect(TextRect, 3)
  525.             Dim TextInnerPath As GraphicsPath = D.RoundRect(TextInnerRect, 3)
  526.             Dim TextInnerPath2 As GraphicsPath = D.RoundRect(TextInnerRect2, 3)
  527.             Dim TextDSPath As GraphicsPath = D.RoundRect(TextDropshadow, 3)
  528.  
  529.             G.DrawPath(New Pen(Color.Black, 2), TextDSPath)
  530.             G.FillPath(New SolidBrush(Pal.ColDim), TextPath)
  531.             G.DrawPath(New Pen(Color.FromArgb(45, Pal.ColHighest)), TextInnerPath)
  532.             G.DrawPath(New Pen(Color.FromArgb(30, Pal.ColHighest)), TextInnerPath2)
  533.             G.DrawPath(New Pen(Color.Black), TextPath)
  534.             D.DrawTextWithShadow(G, New Rectangle(TextInnerRect.X - 10, TextInnerRect.Y + 1, TextInnerRect.Width + 20, TextInnerRect.Height - 4), Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  535.         End If
  536.     End Sub
  537. End Class
  538. Public Class PVTextbox : Inherits ThemedTextbox
  539.     Public Property BorderColor As Color = Color.FromArgb(200, Pal.ColHighest)
  540.     Public Property InteriorColor As Color = Color.FromArgb(150, Color.WhiteSmoke)
  541.     Sub New()
  542.         MyBase.New()
  543.         SetStyle(ControlStyles.UserPaint, True)
  544.         SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
  545.  
  546.         BackColor = Pal.ColDark
  547.         BorderStyle = Windows.Forms.BorderStyle.None
  548.         Multiline = True
  549.         Font = New Font("Trebuchet MS", 10.0F)
  550.     End Sub
  551.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  552.         Dim G As Graphics = e.Graphics
  553.         MyBase.OnPaint(e)
  554.  
  555.         If Not Multiline Then
  556.             Height = 21
  557.         End If
  558.  
  559.         G.Clear(BackColor)
  560.         G.SmoothingMode = SmoothingMode.HighQuality
  561.  
  562.         Dim BorderRect As New Rectangle(0, 0, Width - 1, Height - 1)
  563.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, Height - 3)
  564.         Dim ButtonRect As New Rectangle(5, 5, Width - 11, Height - 11)
  565.  
  566.  
  567.         '| Drawing the textbox
  568.        Dim Out1Path As GraphicsPath = D.RoundRect(BorderRect, 3)
  569.         Dim Out2Path As GraphicsPath = D.RoundRect(BorderInnerRect, 5)
  570.         Dim Out2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  571.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), BorderInnerRect)
  572.         G.DrawPath(New Pen(Out2LGB, 3), Out2Path)
  573.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), Out1Path)
  574.  
  575.  
  576.         'My D.drawText method seemed to cause issues.
  577.        G.DrawString(Text, Font, New SolidBrush(InteriorColor), New Point(3, 2))
  578.     End Sub
  579. End Class
  580. Public Class PVTabControl_Top : Inherits ThemedTabControl
  581.     Sub New()
  582.         MyBase.New()
  583.         ItemSize = New Size(0, 60)
  584.         Padding = New Size(18, 0)
  585.         Font = New Font("Trebuchet MS", 10.0F)
  586.     End Sub
  587.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  588.         Dim G As Graphics = e.Graphics
  589.         MyBase.OnPaint(e)
  590.         Try
  591.             BackColor = Me.Parent.BackColor
  592.             G.Clear(Me.Parent.BackColor)
  593.         Catch ex As Exception
  594.             G.Clear(Pal.ColDim)
  595.         End Try
  596.         G.SmoothingMode = SmoothingMode.HighQuality
  597.  
  598.         '| Drawing the base Container
  599.        Dim OffsetY As Integer = 58
  600.         Dim ContBorderRect As New Rectangle(0, OffsetY, Width - 1, Height - 1 - OffsetY)
  601.         Dim ContBorderInnerRect As New Rectangle(1, OffsetY + 1, Width - 3, Height - 3 - OffsetY)
  602.         Dim ContPath1 As GraphicsPath = D.RoundRect(ContBorderRect, 3)
  603.         Dim ContPath2 As GraphicsPath = D.RoundRect(ContBorderInnerRect, 5)
  604.         Dim ContPath2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(200, Color.Black), Color.FromArgb(60, Pal.ColDim))
  605.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), ContBorderInnerRect)
  606.         G.DrawPath(New Pen(ContPath2LGB, 3), ContPath2)
  607.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), ContPath1)
  608.  
  609.         For i = 0 To TabCount - 1
  610.             '| Drawinh the tabs
  611.            Dim TabRectBase As Rectangle = GetTabRect(i)
  612.             Dim ButtonOffset As Integer = 7
  613.             Dim XOFF As Integer = 2
  614.             Dim TabRect As New Rectangle(XOFF + TabRectBase.X, TabRectBase.Y, TabRectBase.Width - 1 - XOFF * 2, TabRectBase.Height - 1 - ButtonOffset)
  615.             Dim TabInnerRect As New Rectangle(XOFF + TabRectBase.X + 1, TabRectBase.Y + 1, TabRectBase.Width - 3 - XOFF * 2, TabRectBase.Height - 3 - ButtonOffset)
  616.             Dim TabInnerButtonRect As New Rectangle(XOFF + TabRectBase.X + 5, TabRectBase.Y + 5, TabRectBase.Width - 11 - XOFF * 2, TabRectBase.Height - 11 - ButtonOffset)
  617.  
  618.             '| Drawing the tab button's hole into the form (Whats the whole that a button goes into? There even a name for that???)
  619.            Dim TabRectPath As GraphicsPath = D.RoundRect(TabRect, 3)
  620.             Dim TabInnerRectPath As GraphicsPath = D.RoundRect(TabInnerRect, 5)
  621.             Dim TabInnerRectPathLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  622.             G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), TabInnerRect)
  623.             G.DrawPath(New Pen(TabInnerRectPathLGB, 3), TabInnerRectPath)
  624.             G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), TabRectPath)
  625.  
  626.             '| Drawing the tab button
  627.            Dim InnerButtonWidth As Integer = 10
  628.             Dim TabInnerButtonPath As GraphicsPath = D.RoundRect(TabInnerButtonRect, 4)
  629.             Dim TabInnermostButtonPath As GraphicsPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X + InnerButtonWidth, TabInnerButtonRect.Y, TabInnerButtonRect.Width - (InnerButtonWidth * 2), TabInnerButtonRect.Height), 4)
  630.             Dim TabInnerButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X, TabInnerButtonRect.Y + 1, TabInnerButtonRect.Width, TabInnerButtonRect.Height - 2), 4)
  631.  
  632.             If i = SelectedIndex Then
  633.                 G.FillPath(New SolidBrush(Color.FromArgb(70, Pal.ColDim)), TabInnerButtonPath)
  634.                 G.FillPath(New SolidBrush(Pal.ColDim), TabInnermostButtonPath)
  635.                 G.FillPath(New SolidBrush(Color.FromArgb(50, Pal.ColDark)), TabInnermostButtonPath)
  636.                 D.FillGradientBeam(G, Color.FromArgb(35, Color.Black), Color.FromArgb(14, Pal.ColHighest), TabInnerButtonRect, GradientAlignment.Vertical)
  637.                 TabInnerButtonHighlightPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X, TabInnerButtonRect.Y + 1, TabInnerButtonRect.Width, TabInnerButtonRect.Height - 1), 4)
  638.                 G.DrawPath(New Pen(Color.FromArgb(100, Color.Black), 3), TabInnerButtonHighlightPath)
  639.                 D.DrawTextWithShadow(G, TabInnerRect, TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(200, Pal.ColHighest), Color.Black)
  640.             Else
  641.                 G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), TabInnerButtonPath)
  642.                 G.FillPath(New SolidBrush(Pal.ColDim), TabInnermostButtonPath)
  643.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), TabInnerButtonRect, GradientAlignment.Vertical)
  644.                 G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), TabInnerButtonHighlightPath)
  645.                 D.DrawTextWithShadow(G, TabInnerRect, TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  646.             End If
  647.  
  648.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), TabInnerButtonHighlightPath)
  649.             D.DrawTextWithShadow(G, TabInnerRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  650.             G.DrawPath(Pens.Black, TabInnerButtonPath)
  651.  
  652.             '| Changes the tab's BG color to match the surroundings.
  653.            Try
  654.                 Dim ParentCol As Color = Me.Parent.BackColor
  655.                 Dim MixCol As Color = Pal.ColDark
  656.                 MixCol = Color.FromArgb((MixCol.R + ParentCol.R) / 2, (MixCol.G + ParentCol.G) / 2, (MixCol.B + ParentCol.B) / 2)
  657.                 TabPages(i).BackColor = MixCol
  658.             Catch : End Try
  659.         Next
  660.     End Sub
  661. End Class
  662. Public Class PVTabControl_Side : Inherits ThemedTabControl
  663.     Sub New()
  664.         MyBase.New()
  665.         Alignment = TabAlignment.Left
  666.         DoubleBuffered = True
  667.         SizeMode = TabSizeMode.Fixed
  668.         ItemSize = New Size(50, 100)
  669.         Font = New Font("Trebuchet MS", 10.0F)
  670.     End Sub
  671.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  672.         Dim G As Graphics = e.Graphics
  673.         MyBase.OnPaint(e)
  674.         Try
  675.          
  676.             BackColor = Me.Parent.BackColor
  677.             G.Clear(Me.Parent.BackColor)
  678.         Catch ex As Exception
  679.             G.Clear(Pal.ColDim)
  680.         End Try
  681.         G.SmoothingMode = SmoothingMode.HighQuality
  682.  
  683.         '| Drawing the base Container
  684.        Dim ContXOffset As Integer = 100
  685.         Dim ContBorderRect As New Rectangle(ContXOffset, 0, Width - 1 - ContXOffset, Height - 1)
  686.         Dim ContBorderInnerRect As New Rectangle(ContXOffset + 1, 1, Width - 3 - ContXOffset, Height - 3)
  687.         Dim ContPath1 As GraphicsPath = D.RoundRect(ContBorderRect, 3)
  688.         Dim ContPath2 As GraphicsPath = D.RoundRect(ContBorderInnerRect, 5)
  689.         Dim ContPath2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(200, Color.Black), Color.FromArgb(60, Pal.ColDim))
  690.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), ContBorderInnerRect)
  691.         G.DrawPath(New Pen(ContPath2LGB, 3), ContPath2)
  692.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), ContPath1)
  693.  
  694.         For i = 0 To TabCount - 1
  695.             '| Drawinh the tabs
  696.            Dim TabRectBase As Rectangle = GetTabRect(i)
  697.             Dim WidthOffset As Integer = 3
  698.             Dim YOffset As Integer = 2
  699.             Dim XOffset As Integer = -2
  700.  
  701.             Dim TabRect As New Rectangle(XOffset + TabRectBase.X, YOffset + TabRectBase.Y, TabRectBase.Width - 1 - WidthOffset, TabRectBase.Height - 1 - YOffset)
  702.             Dim TabInnerRect As New Rectangle(XOffset + TabRectBase.X + 1, YOffset + TabRectBase.Y + 1, TabRectBase.Width - 3 - WidthOffset, TabRectBase.Height - 3 - YOffset)
  703.             Dim TabInnerButtonRect As New Rectangle(XOffset + TabRectBase.X + 5, YOffset + TabRectBase.Y + 5, TabRectBase.Width - 11 - WidthOffset, TabRectBase.Height - 11 - YOffset)
  704.  
  705.             '| Drawing the tab button's hole into the form (Whats the whole that a button goes into? There even a name for that???)
  706.            Dim TabRectPath As GraphicsPath = D.RoundRect(TabRect, 3)
  707.             Dim TabInnerRectPath As GraphicsPath = D.RoundRect(TabInnerRect, 5)
  708.             Dim TabInnerRectPathLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  709.             G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), TabInnerRect)
  710.             G.DrawPath(New Pen(TabInnerRectPathLGB, 3), TabInnerRectPath)
  711.             G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), TabRectPath)
  712.  
  713.             '| Drawing the tab button
  714.            Dim InnerButtonWidth As Integer = 10
  715.             Dim TabInnerButtonPath As GraphicsPath = D.RoundRect(TabInnerButtonRect, 4)
  716.             Dim TabInnermostButtonPath As GraphicsPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X + InnerButtonWidth, TabInnerButtonRect.Y, TabInnerButtonRect.Width - (InnerButtonWidth * 2), TabInnerButtonRect.Height), 4)
  717.             Dim TabInnerButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X, TabInnerButtonRect.Y + 1, TabInnerButtonRect.Width, TabInnerButtonRect.Height - 2), 4)
  718.  
  719.             If i = SelectedIndex Then
  720.                 G.FillPath(New SolidBrush(Color.FromArgb(70, Pal.ColDim)), TabInnerButtonPath)
  721.                 G.FillPath(New SolidBrush(Pal.ColDim), TabInnermostButtonPath)
  722.                 G.FillPath(New SolidBrush(Color.FromArgb(50, Pal.ColDark)), TabInnermostButtonPath)
  723.                 D.FillGradientBeam(G, Color.FromArgb(35, Color.Black), Color.FromArgb(14, Pal.ColHighest), TabInnerButtonRect, GradientAlignment.Vertical)
  724.                 TabInnerButtonHighlightPath = D.RoundRect(New Rectangle(TabInnerButtonRect.X, TabInnerButtonRect.Y + 1, TabInnerButtonRect.Width, TabInnerButtonRect.Height - 1), 4)
  725.                 G.DrawPath(New Pen(Color.FromArgb(100, Color.Black), 3), TabInnerButtonHighlightPath)
  726.                 D.DrawTextWithShadow(G, TabInnerRect, TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(200, Pal.ColHighest), Color.Black)
  727.             Else
  728.                 G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), TabInnerButtonPath)
  729.                 G.FillPath(New SolidBrush(Pal.ColDim), TabInnermostButtonPath)
  730.                 D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), TabInnerButtonRect, GradientAlignment.Vertical)
  731.                 G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), TabInnerButtonHighlightPath)
  732.                 D.DrawTextWithShadow(G, TabInnerRect, TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  733.             End If
  734.  
  735.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), TabInnerButtonHighlightPath)
  736.             D.DrawTextWithShadow(G, TabInnerRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(120, Color.WhiteSmoke), Color.Black)
  737.             G.DrawPath(Pens.Black, TabInnerButtonPath)
  738.  
  739.             '| Changes the tab's BG color to match the surroundings.
  740.            Try
  741.                 Dim ParentCol As Color = Me.Parent.BackColor
  742.                 Dim MixCol As Color = Pal.ColDark
  743.                 MixCol = Color.FromArgb((MixCol.R + ParentCol.R) / 2, (MixCol.G + ParentCol.G) / 2, (MixCol.B + ParentCol.B) / 2)
  744.                 TabPages(i).BackColor = MixCol
  745.             Catch : End Try
  746.         Next
  747.     End Sub
  748. End Class
  749. Public Class PVProgressBar : Inherits ThemedControl
  750.     Private PValue As Integer = 50
  751.     Public Property Value() As Integer
  752.         Get
  753.             Return PValue
  754.         End Get
  755.         Set(ByVal value As Integer)
  756.             Invalidate()
  757.             PValue = value
  758.         End Set
  759.     End Property
  760.     Public Property Minimum As Integer = 0
  761.     Public Property Maximum As Integer = 100
  762.     Sub New()
  763.         MyBase.New()
  764.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or ControlStyles.UserPaint Or ControlStyles.ResizeRedraw, True)
  765.         BackColor = Pal.ColDark
  766.         MinimumSize = New Size(21, 21)
  767.         Font = New Font("Trebuchet MS", 10.0F)
  768.         Value = 50
  769.     End Sub
  770.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  771.         Dim G As Graphics = e.Graphics
  772.         MyBase.OnPaint(e)
  773.         'Height = 30
  774.        ' Height = 21
  775.        '| If lazy, put back to 21, else
  776.        '| http://cdns2.freepik.com/foto-gratuito/barra-di-avanzamento-ui_29-20000356.jpg
  777.        Dim ProgHeight As Integer = 21
  778.  
  779.         G.Clear(BackColor)
  780.         Try
  781.             Dim s As String = (Me.Parent).GetType().Name
  782.             If s.Contains("PVGroupbox") Then
  783.                 G.FillRectangle(New SolidBrush(Color.FromArgb(39, Pal.ColDim)), New Rectangle(0, 0, Width, Height))
  784.             End If
  785.         Catch ex As Exception
  786.  
  787.         End Try
  788.      
  789.         G.SmoothingMode = SmoothingMode.HighQuality
  790.         Dim BorderRect As New Rectangle(0, 0, Width - 1, ProgHeight - 1)
  791.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, ProgHeight - 3)
  792.         Dim ButtonRect As New Rectangle(5, 5, Width - 11, ProgHeight - 11)
  793.         '| Drawing the BG / assigning main variables
  794.        Dim Out1Path As GraphicsPath = D.RoundRect(BorderRect, 3)
  795.         Dim Out2Path As GraphicsPath = D.RoundRect(BorderInnerRect, 5)
  796.         Dim Out2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, ProgHeight), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  797.         G.DrawPath(New Pen(Out2LGB, 3), Out2Path)
  798.         D.FillDualGradPath(G, Color.FromArgb(100, Color.Black), Color.Transparent, BorderRect, Out2Path, GradientAlignment.Horizontal)
  799.         '| Drawing the bar
  800.        Dim BarRect As New Rectangle(2, 2, ValueToPercentage(PValue) * Width - 4, ProgHeight - 5)
  801.         If PValue > 0 Then
  802.             Dim BarPath As GraphicsPath = D.RoundRect(BarRect, 3)
  803.             Dim BarHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(BarRect.X, BarRect.Y, BarRect.Width, BarRect.Height / 2), 4)
  804.             Dim BarHighlightLGB As New LinearGradientBrush(New Point(0, 0), New Point(0, BarRect.Height / 2 + 1), Color.FromArgb(60, Color.AliceBlue), Color.FromArgb(100, Color.White))
  805.             Dim DiagonalHatch As HatchBrush = New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.Transparent, Color.FromArgb(15, Color.AliceBlue))
  806.             D.FillDualGradPath(G, Color.FromArgb(45, 75, 210), Color.FromArgb(65, 135, 255), BarRect, BarPath, GradientAlignment.Horizontal)
  807.             G.FillPath(DiagonalHatch, BarPath)
  808.             G.FillPath(BarHighlightLGB, BarHighlightPath)
  809.             D.FillDualGradPath(G, Color.FromArgb(140, Color.FromArgb(10, 30, 100)), Color.FromArgb(10, Color.FromArgb(20, 50, 160)), BarRect, BarPath, GradientAlignment.Horizontal)
  810.             G.DrawPath(New Pen(Pal.ColDark), BarPath)
  811.         End If
  812.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), Out1Path)
  813.         If True Then
  814.             Dim BarText As String = FormatPercent(ValueToPercentage(PValue)).Replace(".00", "")
  815.             Dim TextSize As Size = G.MeasureString(BarText, Font).ToSize
  816.             If Height < 38 Then
  817.                 Dim Opacity As Integer = 0
  818.                 Opacity = ValueToPercentage(PValue) * 500
  819.                 If Opacity > 255 Then
  820.                     Opacity = 255
  821.                 End If
  822.  
  823.                 D.DrawTextWithShadow(G, New Rectangle(BarRect.Width - TextSize.Width, 0, 100, BarRect.Height + 3), BarText, Font, HorizontalAlignment.Left, Color.FromArgb(Opacity, Color.White), Color.FromArgb(Opacity, Color.Black))
  824.             Else
  825.                 Dim PercentPath As New GraphicsPath
  826.                 Dim StartX As Integer = Width - 51
  827.                 With PercentPath
  828.                     .AddLine(New Point(StartX, 20), New Point(StartX + 20, 38))
  829.                     .AddLine(New Point(StartX + 20, 38), New Point(StartX + 50, 38))
  830.                     .AddLine(New Point(StartX + 50, 38), New Point(StartX + 50, 19))
  831.                 End With
  832.  
  833.                 G.SmoothingMode = SmoothingMode.None
  834.                 G.FillRectangle(New SolidBrush(Pal.ColDark), New Rectangle(StartX, 20, 50, 1))
  835.                 G.DrawLine(New Pen(Pal.ColDark), New Point(StartX + 49, 17), New Point(StartX + 49, 19))
  836.                 G.SmoothingMode = SmoothingMode.HighQuality
  837.  
  838.                 Dim FillLGB As New LinearGradientBrush(New Point(0, 19), New Point(0, 39), Color.FromArgb(100, Pal.ColDim), Color.FromArgb(85, Color.Black))
  839.                 G.FillPath(FillLGB, PercentPath)
  840.                 D.DrawTextWithShadow(G, New Rectangle(Width - TextSize.Width, 13, 100, 30), BarText, Font, HorizontalAlignment.Left, Color.FromArgb(140, Color.WhiteSmoke), Pal.ColDark)
  841.                 G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), PercentPath)
  842.             End If
  843.         End If
  844.     End Sub
  845.     Private Function ValueToPercentage(val As Integer) As Single
  846.         Dim min = Minimum
  847.         Dim max = Maximum
  848.         Return (val - min) / (max - min)
  849.         'vertical:  Return 1 - (value - min) / (max - min)
  850.    End Function
  851. End Class
  852. Public Class PVNumericUD : Inherits ThemedControl
  853.     Private WithEvents TxtBox As New PVTextbox
  854.     Private WithEvents BtnUp As New PVButton
  855.     Private WithEvents BtnDown As New PVButton
  856.     Public Property ButtonChange As Integer = 1
  857.     Public Property Minimum As Integer = 1
  858.     Public Property Maximum As Integer = 100
  859.  
  860.     '| Used the MouseDown event because it doesn't use a delay like the click one does.
  861.    Protected Sub BtnUp_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnUp.MouseDown
  862.         Value = Value + ButtonChange
  863.     End Sub
  864.     Protected Sub BtnDown_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnDown.MouseDown
  865.         Value = Value - ButtonChange
  866.     End Sub
  867.  
  868.     Public Property Value() As Integer
  869.         Get
  870.             Dim Ret As Integer = 0
  871.             Try : Ret = CInt(TxtBox.Text) : Catch ex As Exception : End Try
  872.             Return Ret
  873.         End Get
  874.         Set(ByVal val As Integer)
  875.             If val <= Maximum And val >= Minimum Then
  876.                 TxtBox.Text = val
  877.                 Invalidate()
  878.             End If
  879.         End Set
  880.     End Property
  881.     Sub New()
  882.         MyBase.New()
  883.         Size = New Point(300, 300)
  884.         Font = New Font("Trebuchet MS", 10.0F)
  885.         TxtBox.Text = 0
  886.         Controls.Add(TxtBox)
  887.         Controls.Add(BtnUp)
  888.         Controls.Add(BtnDown)
  889.     End Sub
  890.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  891.         Dim G As Graphics = e.Graphics
  892.         MyBase.OnPaint(e)
  893.         G.Clear(Me.Parent.BackColor)
  894.         Height = 30
  895.         BtnUp.MinimumSize = New Size(15, 15)
  896.         BtnUp.Size = New Size(10, 10)
  897.         BtnUp.Location = New Point(Size.Width - BtnUp.Width, 0)
  898.         BtnUp.Font = New Font("Trebuchet MS", 10.0F)
  899.         BtnUp.Text = "แดง"
  900.         BtnDown.MinimumSize = New Size(15, 15)
  901.         BtnDown.Size = New Size(10, 10)
  902.         BtnDown.Location = New Point(Size.Width - BtnUp.Width, BtnUp.Size.Height)
  903.         BtnDown.Font = New Font("Trebuchet MS", 10.0F, FontStyle.Bold)
  904.         BtnDown.Text = "v"
  905.         TxtBox.Location = New Point(0, 0)
  906.         TxtBox.Multiline = True
  907.         TxtBox.Height = 30
  908.         TxtBox.Width = BtnUp.Location.X - 2
  909.     End Sub
  910. End Class
  911. Public Class PVCheckbox : Inherits ThemedControl
  912.     Public Property Checked As Boolean
  913.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  914.         MyBase.OnMouseDown(e)
  915.         Checked = Not Checked
  916.         BackColor = Color.FromArgb(21, 23, 25)
  917.     End Sub
  918.     Sub New()
  919.         MyBase.New()
  920.         Font = New Font("Trebuchet MS", 10.0F)
  921.     End Sub
  922.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  923.         Try
  924.             BackColor = Me.Parent.BackColor
  925.         Catch ex As Exception : End Try
  926.         Dim G As Graphics = e.Graphics
  927.         MyBase.OnPaint(e)
  928.         G.Clear(BackColor)
  929.         G.SmoothingMode = SmoothingMode.HighQuality
  930.  
  931.         Height = 20
  932.         Dim x As New Rectangle(0, 0, Height - 2, Height - 2)
  933.         Dim x2 As New Rectangle(0, 1, Height - 2, Height - 2)
  934.         Dim y As GraphicsPath = D.RoundRect(x, 3)
  935.         Dim y2 As GraphicsPath = D.RoundRect(x2, 3)
  936.  
  937.         G.DrawPath(New Pen(Pal.ColHigh), y2)
  938.         G.FillPath(New SolidBrush(Pal.ColDark), y)
  939.         G.DrawPath(New Pen(Color.FromArgb(200, Color.Black)), y)
  940.  
  941.         If Checked Then
  942.             Dim chkPoly As Rectangle = New Rectangle(1 + (Height - 6) / 4, 1 + (Height - 6) / 4, (Height - 6) \ 2 + 2, (Height - 6) \ 2 + 4)
  943.             Dim Poly As New GraphicsPath
  944.             With Poly
  945.                 .AddLine(New Point(chkPoly.X, chkPoly.Y + chkPoly.Height \ 2), New Point(chkPoly.X + chkPoly.Width \ 2, chkPoly.Y + chkPoly.Height))
  946.                 .AddLine(New Point(chkPoly.X + chkPoly.Width \ 2, chkPoly.Y + chkPoly.Height), New Point(chkPoly.X + chkPoly.Width, chkPoly.Y - 2))
  947.             End With
  948.             G.DrawPath(New Pen(Color.FromArgb(255, Pal.ColHighest), 2), Poly)
  949.         End If
  950.  
  951.         D.DrawTextWithShadow(G, New Rectangle(Height, 0, Width - Height, Height - 4), Text, Font, HorizontalAlignment.Left, Pal.ColHighest, Color.Black)
  952.     End Sub
  953. End Class
  954. Public Class PVRadiobutton : Inherits ThemedControl
  955.     Public Property Checked As Boolean
  956.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  957.         MyBase.OnMouseDown(e)
  958.         For Each Cont As Control In Parent.Controls
  959.             If TypeOf Cont Is PVRadiobutton Then
  960.                 DirectCast(Cont, PVRadiobutton).Checked = False
  961.                 Cont.Invalidate()
  962.             End If
  963.         Next
  964.         Checked = True
  965.     End Sub
  966.     Sub New()
  967.         MyBase.New()
  968.         Font = New Font("Trebuchet MS", 10.0F)
  969.          BackColor = Color.FromArgb(21, 23, 25)
  970.     End Sub
  971.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  972.         Dim G As Graphics = e.Graphics
  973.         MyBase.OnPaint(e)
  974.         Try
  975.             BackColor = Me.Parent.BackColor
  976.         Catch ex As Exception : End Try
  977.         G.Clear(BackColor)
  978.         G.SmoothingMode = SmoothingMode.HighQuality
  979.  
  980.         Height = 20
  981.         Dim x As New Rectangle(0, 0, Height - 2, Height - 2)
  982.         Dim x2 As New Rectangle(0, 1, Height - 2, Height - 2)
  983.  
  984.  
  985.         G.DrawEllipse(New Pen(Pal.ColHigh), x2)
  986.         G.FillEllipse(New SolidBrush(Pal.ColDark), x)
  987.         G.DrawEllipse(New Pen(Color.FromArgb(200, Color.Black)), x)
  988.  
  989.         If Checked Then
  990.             Dim x3 As New Rectangle(3, 3, Height - 8, Height - 8)
  991.             G.FillEllipse(New SolidBrush(Pal.ColHighest), x3)
  992.         End If
  993.  
  994.         D.DrawTextWithShadow(G, New Rectangle(Height, 0, Width, Height - 4), Text, Font, HorizontalAlignment.Left, Pal.ColHighest, Color.Black)
  995.  
  996.     End Sub
  997. End Class
  998. Public Class PVListbox : Inherits ThemedListControl
  999.     Public Property TextAlignment As HorizontalAlignment = HorizontalAlignment.Center
  1000.     Sub New()
  1001.         MyBase.New()
  1002.         IntegralHeight = False
  1003.         ItemHeight = 24
  1004.         Font = New Font("Segoe UI Semilight", 12.0F)
  1005.         ForeColor = Pal.ColHighest
  1006.         DrawMode = DrawMode.OwnerDrawVariable
  1007.         BorderStyle = BorderStyle.None
  1008.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  1009.     End Sub
  1010.  
  1011.     Protected Sub OnItemPaint(ByVal G As Graphics, ByVal i As Integer)
  1012.         Dim FirstItemOffset As Integer = 0
  1013.         Dim RectOffset As Integer = 1
  1014.         If i = 0 Then
  1015.             FirstItemOffset = 3
  1016.         End If
  1017.         Dim ItemRect As New Rectangle(4, RectOffset + FirstItemOffset + i * ItemHeight, Width - 10, ItemHeight - (RectOffset * 2) - (FirstItemOffset) - 0)    
  1018.         Dim ButtonPath As GraphicsPath = D.RoundRect(ItemRect, 4)
  1019.         Dim ButtonInnerPath As GraphicsPath = D.RoundRect(New Rectangle(ItemRect.X, ItemRect.Y, ItemRect.Width, ItemRect.Height), 4)
  1020.         Dim ButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(ItemRect.X, ItemRect.Y + 1, ItemRect.Width, ItemRect.Height - 2), 4)
  1021.  
  1022.         G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), ButtonPath)
  1023.         G.FillPath(New SolidBrush(Pal.ColDim), ButtonInnerPath)
  1024.         If i = SelectedIndex Then
  1025.             G.FillPath(New SolidBrush(Color.FromArgb(50, 50, 170, 250)), ButtonInnerPath)
  1026.         End If
  1027.  
  1028.         If i = SelectedIndex Then
  1029.             G.DrawPath(New Pen(Color.FromArgb(160, Pal.ColHighest)), ButtonHighlightPath)
  1030.             G.DrawPath(Pens.Black, ButtonPath)
  1031.             D.FillGradientBeam(G, Color.FromArgb(40, Color.Black), Color.FromArgb(30, Pal.ColHighest), ItemRect, GradientAlignment.Vertical)
  1032.         Else
  1033.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), ButtonHighlightPath)
  1034.             G.DrawPath(Pens.Black, ButtonPath)
  1035.             D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ItemRect, GradientAlignment.Vertical)
  1036.         End If  
  1037.  
  1038.         Dim TextCol As Color = Color.WhiteSmoke
  1039.         If i = SelectedIndex Then : TextCol = Color.FromArgb(50, 170, 250) : End If
  1040.         D.DrawTextWithShadow(G, ItemRect, Items(i).ToString(), Font, TextAlignment, TextCol, Color.Black)
  1041.     End Sub
  1042.  
  1043.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  1044.         Dim G As Graphics = e.Graphics
  1045.         MyBase.OnPaint(e)
  1046.         G.Clear(Me.Parent.BackColor)
  1047.         G.SmoothingMode = SmoothingMode.HighQuality
  1048.         BorderStyle = BorderStyle.None
  1049.  
  1050.  
  1051.  
  1052.         Dim BorderRect As New Rectangle(0, 0, Width - 1, Height - 1)
  1053.         Dim BorderInnerRect As New Rectangle(1, 1, Width - 3, Height - 3)
  1054.         Dim ButtonRect As New Rectangle(3, 1, Width - 7, Height - 3)
  1055.  
  1056.  
  1057.         '| Drawing the button's hole into the form (Whats the whole that a button goes into? There even a name for that???)
  1058.        Dim Out1Path As GraphicsPath = D.RoundRect(BorderRect, 3)
  1059.         Dim Out2Path As GraphicsPath = D.RoundRect(BorderInnerRect, 5)
  1060.         Dim Out2LGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(150, Color.Black), Color.FromArgb(60, Pal.ColDim))
  1061.         G.FillRectangle(New SolidBrush(Color.FromArgb(35, Color.Black)), BorderInnerRect)
  1062.         G.DrawPath(New Pen(Out2LGB, 3), Out2Path)
  1063.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest)), Out1Path)
  1064.  
  1065.         '| Drawing the button
  1066.        Dim ButtonPath As GraphicsPath = D.RoundRect(ButtonRect, 4)
  1067.         Dim ButtonInnerPath As GraphicsPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y, ButtonRect.Width, ButtonRect.Height), 4)
  1068.         Dim ButtonHighlightPath As GraphicsPath = D.RoundRect(New Rectangle(ButtonRect.X, ButtonRect.Y + 1, ButtonRect.Width, ButtonRect.Height - 2), 4)
  1069.         If False Then
  1070.             G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDim)), ButtonPath)
  1071.             G.FillPath(New SolidBrush(Pal.ColDim), ButtonInnerPath)
  1072.             D.FillGradientBeam(G, Color.FromArgb(20, Color.Black), Color.FromArgb(20, Pal.ColHighest), ButtonRect, GradientAlignment.Vertical)
  1073.  
  1074.             G.DrawPath(New Pen(Color.FromArgb(60, Pal.ColHighest)), ButtonHighlightPath)
  1075.             G.DrawPath(Pens.Black, ButtonPath)
  1076.         End If
  1077.    
  1078.  
  1079.  
  1080.         Dim x As Integer = 0
  1081.         For Each i As Object In Items
  1082.             OnItemPaint(G, x)
  1083.             x += 1
  1084.         Next
  1085.     End Sub
  1086. End Class
  1087. #End Region
  1088.  
  1089. #Region "Theme Utility Stuff"
  1090. Public Class Palette
  1091.     Public ColHighest As Color
  1092.     Public ColHigh As Color
  1093.     Public ColMed As Color
  1094.     Public ColDim As Color
  1095.     Public ColDark As Color
  1096. End Class
  1097. Public Enum MouseState As Byte
  1098.     None = 0
  1099.     Over = 1
  1100.     Down = 2
  1101.     Block = 3
  1102. End Enum
  1103. Public Enum GradientAlignment As Byte
  1104.     Vertical = 0
  1105.     Horizontal = 1
  1106. End Enum
  1107. Public Class DrawUtils
  1108.     Public Sub FillGradientBeam(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal align As GradientAlignment)
  1109.         Dim stored As SmoothingMode = g.SmoothingMode
  1110.         Dim Blend As New ColorBlend
  1111.         g.SmoothingMode = SmoothingMode.HighQuality
  1112.         Select Case align
  1113.             Case GradientAlignment.Vertical
  1114.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
  1115.                 Blend.Positions = {0, 1 / 2, 1}
  1116.                 Blend.Colors = {Col1, Col2, Col1}
  1117.                 PathGradient.InterpolationColors = Blend
  1118.                 g.FillRectangle(PathGradient, rect)
  1119.             Case GradientAlignment.Horizontal
  1120.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
  1121.                 Blend.Positions = {0, 1 / 2, 1}
  1122.                 Blend.Colors = {Col1, Col2, Col1}
  1123.                 PathGradient.InterpolationColors = Blend
  1124.                 PathGradient.RotateTransform(0)
  1125.                 g.FillRectangle(PathGradient, rect)
  1126.         End Select
  1127.         g.SmoothingMode = stored
  1128.     End Sub
  1129.     Public Sub DrawTextWithShadow(ByVal G As Graphics, ByVal ContRect As Rectangle, ByVal Text As String, ByVal TFont As Font, ByVal TAlign As HorizontalAlignment, ByVal TColor As Color, ByVal BColor As Color)
  1130.         DrawText(G, New Rectangle(ContRect.X + 1, ContRect.Y + 1, ContRect.Width, ContRect.Height), Text, TFont, TAlign, BColor)
  1131.         DrawText(G, ContRect, Text, TFont, TAlign, TColor)
  1132.     End Sub
  1133.     Public Sub FillDualGradPath(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal gp As GraphicsPath, ByVal align As GradientAlignment)
  1134.         Dim stored As SmoothingMode = g.SmoothingMode
  1135.         Dim Blend As New ColorBlend
  1136.         g.SmoothingMode = SmoothingMode.HighQuality
  1137.         Select Case align
  1138.             Case GradientAlignment.Vertical
  1139.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
  1140.                 Blend.Positions = {0, 1 / 2, 1}
  1141.                 Blend.Colors = {Col1, Col2, Col1}
  1142.                 PathGradient.InterpolationColors = Blend
  1143.                 g.FillPath(PathGradient, gp)
  1144.             Case GradientAlignment.Horizontal
  1145.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
  1146.                 Blend.Positions = {0, 1 / 2, 1}
  1147.                 Blend.Colors = {Col1, Col2, Col1}
  1148.                 PathGradient.InterpolationColors = Blend
  1149.                 PathGradient.RotateTransform(0)
  1150.                 g.FillPath(PathGradient, gp)
  1151.         End Select
  1152.         g.SmoothingMode = stored
  1153.     End Sub
  1154.     Public Sub DrawText(ByVal G As Graphics, ByVal ContRect As Rectangle, ByVal Text As String, ByVal TFont As Font, ByVal TAlign As HorizontalAlignment, ByVal TColor As Color)
  1155.         If String.IsNullOrEmpty(Text) Then Return
  1156.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  1157.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  1158.         Select Case TAlign
  1159.             Case HorizontalAlignment.Left
  1160.                 Dim sf As New StringFormat
  1161.                 sf.LineAlignment = StringAlignment.Near
  1162.                 sf.Alignment = StringAlignment.Near
  1163.                 G.DrawString(Text, TFont, New SolidBrush(TColor), New Rectangle(ContRect.X, ContRect.Y + ContRect.Height / 2 - TextSize.Height / 2, ContRect.Width, ContRect.Height), sf)
  1164.             Case HorizontalAlignment.Right
  1165.                 Dim sf As New StringFormat
  1166.                 sf.LineAlignment = StringAlignment.Far
  1167.                 sf.Alignment = StringAlignment.Far
  1168.                 G.DrawString(Text, TFont, New SolidBrush(TColor), New Rectangle(ContRect.X, ContRect.Y, ContRect.Width, ContRect.Height / 2 + TextSize.Height / 2), sf)
  1169.             Case HorizontalAlignment.Center
  1170.                 Dim sf As New StringFormat
  1171.                 sf.LineAlignment = StringAlignment.Center
  1172.                 sf.Alignment = StringAlignment.Center
  1173.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect, sf)
  1174.         End Select
  1175.     End Sub
  1176.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  1177.         Dim Path As New GraphicsPath
  1178.         Dim ArcRectangleWidth As Integer = Curve * 2
  1179.         With Path
  1180.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  1181.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  1182.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  1183.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  1184.             .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  1185.         End With
  1186.         Return Path
  1187.     End Function
  1188.     Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  1189.         Dim Path As GraphicsPath = New GraphicsPath()
  1190.         Dim ArcRectangleWidth As Integer = Curve * 2
  1191.         With Path
  1192.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  1193.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  1194.             .AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height))
  1195.             .AddLine(New Point(Rectangle.X, Rectangle.Height + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  1196.         End With
  1197.         Return Path
  1198.     End Function
  1199. End Class
  1200. #End Region
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement