LordPankake

[VB.Net] StR Theme - [6 Controls | Dark]

Aug 5th, 2014
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  StR Theme
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Created: 8/1/2014, Last edited: 8/5/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.         BackColor = Color.FromArgb(34, 34, 34)
  46.         Pal = New Palette
  47.         Pal.ColHighest = Color.FromArgb(70, 70, 70)
  48.         Pal.ColHigh = Color.FromArgb(46, 46, 46)
  49.         Pal.ColMed = Color.FromArgb(33, 33, 33)
  50.         Pal.ColDim = Color.FromArgb(22, 22, 22)
  51.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  52.     End Sub
  53. End Class
  54. Public Class ThemedContainer : Inherits ContainerControl
  55.     Public D As New DrawUtils
  56.     Protected Drag As Boolean = True
  57.     Public State As MouseState = MouseState.None
  58.     Protected TopCap As Boolean = False
  59.     Protected SizeCap As Boolean = False
  60.     Public Pal As Palette
  61.     Protected MouseP As Point = New Point(0, 0)
  62.     Protected TopGrip As Integer
  63.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  64.     End Sub
  65.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  66.         MyBase.OnMouseEnter(e)
  67.         State = MouseState.Over
  68.         Invalidate()
  69.     End Sub
  70.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  71.         MyBase.OnMouseDown(e)
  72.         State = MouseState.Down
  73.         If e.Button = Windows.Forms.MouseButtons.Left And Drag Then
  74.             If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  75.                 TopCap = True : MouseP = e.Location
  76.             ElseIf New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  77.                 SizeCap = True : MouseP = e.Location
  78.             End If
  79.         End If
  80.     End Sub
  81.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  82.         MyBase.OnMouseLeave(e)
  83.         State = MouseState.None
  84.         Invalidate()
  85.     End Sub
  86.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  87.         MyBase.OnMouseUp(e)
  88.         State = MouseState.Over
  89.         If Drag Then
  90.             TopCap = False
  91.             SizeCap = False
  92.         End If
  93.  
  94.     End Sub
  95.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  96.         MyBase.OnMouseMove(e)
  97.         If Drag Then
  98.             If TopCap Then
  99.                 Parent.Location = MousePosition - MouseP
  100.             End If
  101.             If SizeCap Then
  102.                 MouseP = e.Location
  103.                 Parent.Size = New Size(MouseP)
  104.                 Invalidate()
  105.             End If
  106.         End If    
  107.     End Sub
  108.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  109.         MyBase.OnTextChanged(e)
  110.         Invalidate()
  111.     End Sub
  112.     Sub New()
  113.         MyBase.New()
  114.         MinimumSize = New Size(20, 20)
  115.         ForeColor = Color.FromArgb(146, 149, 152)
  116.         Font = New Font("Trebuchet MS", 10.0F)
  117.         DoubleBuffered = True
  118.         BackColor = Color.FromArgb(34, 34, 34)
  119.         Pal = New Palette
  120.         Pal.ColHighest = Color.FromArgb(70, 70, 70)
  121.         Pal.ColHigh = Color.FromArgb(46, 46, 46)
  122.         Pal.ColMed = Color.FromArgb(33, 33, 33)
  123.         Pal.ColDim = Color.FromArgb(16, 16, 16)
  124.         Pal.ColDark = Color.FromArgb(12, 12, 12)
  125.     End Sub
  126. End Class
  127. #End Region
  128. #Region "Theme Objects"
  129. Public Class StRForm : Inherits ThemedContainer
  130.     Public Property SolidTop As Boolean
  131.     Sub New()
  132.         MyBase.New()
  133.         Dock = DockStyle.Fill
  134.         TopGrip = 26
  135.     End Sub
  136.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  137.         Dim G As Graphics = e.Graphics
  138.         MyBase.OnPaint(e)
  139.         Try
  140.             If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  141.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  142.             End If
  143.         Catch ex As Exception : End Try
  144.         G.Clear(Me.ParentForm.TransparencyKey)
  145.         Dim TopGlowGradient As New LinearGradientBrush(New Point(0, 0), New Point(0, (TopGrip / 2) + 4), Color.FromArgb(140, Pal.ColHighest.R + 44, Pal.ColHighest.R + 44, Pal.ColHighest.R + 44), Color.Transparent)
  146.         Dim DiagonalBrush As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(Pal.ColMed.R, Pal.ColMed.R, Pal.ColMed.R), Color.Transparent)
  147.         Dim LeftGripPath As New GraphicsPath
  148.         Dim RightGripPath As New GraphicsPath
  149.  
  150.         LeftGripPath.AddRectangle(New Rectangle(0, 0, G.MeasureString(Text, Font).Width + 2, TopGrip + 1))
  151.         LeftGripPath.AddRectangle(New Rectangle(0, TopGrip + 1, 8, Height))
  152.      
  153.         '|========= Outer Base =========|
  154.        G.FillRectangle(New SolidBrush(Color.FromArgb(Pal.ColMed.R - 12, Pal.ColMed.R - 12, Pal.ColMed.R - 12)), New Rectangle(0, 0, Width - 1, Height - 1))
  155.         G.FillRectangle(DiagonalBrush, New Rectangle(0, 0, Width - 1, Height - 1))
  156.         G.FillPath(New SolidBrush(Pal.ColDim), LeftGripPath)
  157.         ' G.DrawPath(Pens.Black, LeftGripPath)
  158.        Dim DrawLeft As Boolean
  159.         Dim LeftMostX As Integer
  160.         Dim DrawSideLines As Boolean = True
  161.         For Each cont As Control In Controls
  162.             If cont.Location.Y < TopGrip Then
  163.                 DrawLeft = True
  164.                 LeftMostX = cont.Location.X
  165.             End If
  166.         Next
  167.         RightGripPath.AddRectangle(New Rectangle(LeftMostX - 4, 0, Width, TopGrip + 1))
  168.         RightGripPath.AddRectangle(New Rectangle(Width - 9, TopGrip + 1, 8, Height))
  169.         If DrawLeft Then
  170.             G.FillPath(New SolidBrush(Pal.ColDim), RightGripPath)
  171.         End If
  172.         If Math.Abs((LeftMostX - 4) - (G.MeasureString(Text, Font).Width + 2)) < 100 Or SolidTop Then
  173.             DrawSideLines = False
  174.             G.FillRectangle(New SolidBrush(Pal.ColDim), New Rectangle(0, 0, Width, TopGrip + 1))
  175.         End If
  176.  
  177.         D.FillGradientBeam(G, Color.FromArgb(140, Pal.ColHighest.R - 10, Pal.ColHighest.R - 10, Pal.ColHighest.R - 10), New Rectangle(1, 1, Width - 1, Height - 1), GradientAlignment.Vertical)
  178.         G.DrawRectangle(New Pen(Pal.ColHigh), New Rectangle(1, 1, Width - 3, Height - 3))
  179.         G.DrawLine(New Pen(New SolidBrush(Pal.ColDim)), New Point(2, Height - 2), New Point(8, Height - 2))
  180.         G.DrawLine(Pens.Black, New Point(8, Height - 8), New Point(8, Height - 1))
  181.         G.DrawLine(Pens.Black, New Point(Width - 9, Height - 8), New Point(Width - 9, Height - 1))
  182.         If DrawSideLines Then
  183.             G.DrawLine(Pens.Black, New Point(G.MeasureString(Text, Font).Width + 2, 0), New Point(G.MeasureString(Text, Font).Width + 2, TopGrip + 1))
  184.             G.DrawLine(Pens.Black, New Point(LeftMostX - 4, 0), New Point(LeftMostX - 4, TopGrip + 1))
  185.         End If
  186.         G.FillRectangle(TopGlowGradient, New Rectangle(0, 0, Width - 1, TopGrip / 2 + 1))
  187.  
  188.         '|========= Inner Base =========|
  189.        Dim InnerRect As New Rectangle(8, TopGrip + 1, Width - 17, Height - TopGrip * 2 + 17)
  190.         G.FillRectangle(New SolidBrush(Pal.ColDim), InnerRect)
  191.         G.DrawRectangle(Pens.Black, InnerRect)
  192.  
  193.  
  194.         '|========= Finalizations =========|
  195.        G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  196.         D.DrawTextWithShadow(G, New Rectangle(6, 0, Width, TopGrip + 1), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  197.     End Sub
  198. End Class
  199. Public Class StRTopButton : Inherits ThemedControl
  200.     Sub New()
  201.         MyBase.New()
  202.         Font = New Font("Trebuchet MS", 10.0F)
  203.     End Sub
  204.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  205.         Dim G As Graphics = e.Graphics
  206.         MyBase.OnPaint(e)
  207.         G.Clear(Me.Parent.BackColor)
  208.         G.SmoothingMode = SmoothingMode.HighQuality
  209.  
  210.         Dim ColBase As Integer
  211.         Dim ColDiff As Integer
  212.         Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, (Height / 3) * 2), 2)
  213.         Dim Rect2 As GraphicsPath = D.RoundRect(New Rectangle(1, (Height / 3) + 1, Width - 2, Height - 1), 2)
  214.         Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2)
  215.         Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 2)
  216.         Select Case State
  217.             Case MouseState.None
  218.                 ColBase = 26
  219.                 ColDiff = 7
  220.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  221.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  222.             Case MouseState.Over
  223.                 ColBase = 34
  224.                 ColDiff = 7
  225.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  226.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  227.             Case MouseState.Down
  228.                 ColBase = 20
  229.                 ColDiff = 3
  230.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  231.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  232.         End Select
  233.         G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
  234.         G.DrawPath(Pens.Black, Border1)
  235.  
  236.         Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
  237.         D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  238.     End Sub
  239. End Class
  240. Public Class StRButton : Inherits ThemedControl
  241.     Sub New()
  242.         MyBase.New()
  243.         Font = New Font("Trebuchet MS", 10.0F)
  244.     End Sub
  245.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  246.         Dim G As Graphics = e.Graphics
  247.         MyBase.OnPaint(e)
  248.         G.Clear(Me.Parent.BackColor)
  249.         G.SmoothingMode = SmoothingMode.HighQuality
  250.  
  251.         Dim ColBase As Integer
  252.         Dim ColDiff As Integer
  253.         Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, (Height / 3) * 2), 2)
  254.         Dim Rect2 As GraphicsPath = D.RoundRect(New Rectangle(1, (Height / 3) + 1, Width - 2, Height - 1), 2)
  255.         Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2)
  256.         Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 2)
  257.         Select Case State
  258.             Case MouseState.None
  259.                 ColBase = 37
  260.                 ColDiff = 6
  261.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  262.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  263.             Case MouseState.Over
  264.                 ColBase = 53
  265.                 ColDiff = 6
  266.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  267.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  268.             Case MouseState.Down
  269.                 ColBase = 30
  270.                 ColDiff = 6
  271.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase + ColDiff, ColBase + ColDiff, ColBase + ColDiff)), Rect1)
  272.                 G.FillPath(New SolidBrush(Color.FromArgb(ColBase - ColDiff, ColBase - ColDiff, ColBase - ColDiff)), Rect2)
  273.         End Select
  274.         G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
  275.         G.DrawPath(Pens.Black, Border1)
  276.         Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
  277.         D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)    
  278.     End Sub
  279. End Class
  280. Public Class StRTextbox : Inherits ThemedControl
  281. #Region "Textbox Data"
  282.     Private WithEvents TxtBox As New TextBox
  283.     Private TempSize As Size
  284.     Public Property TxtReadOnly As Boolean
  285.     Public Property MaxCharacters As Integer
  286.     Public Property Multiline() As Boolean
  287.         Get
  288.             Return TxtBox.Multiline
  289.         End Get
  290.         Set(ByVal v As Boolean)
  291.             TxtBox.Multiline = v
  292.             Invalidate()
  293.         End Set
  294.     End Property
  295.     Public Property TextAlign As HorizontalAlignment
  296.     Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  297.         MyBase.OnSizeChanged(e)
  298.         If Not Size.Height = 21 Then
  299.             TempSize = Size
  300.         End If
  301.         If Not IsNothing(TxtBox) Then
  302.             TxtBox.Size = New Size(Width - 8, Height - 8)
  303.         End If
  304.  
  305.         Invalidate()
  306.     End Sub
  307.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  308.         MyBase.OnFontChanged(e)
  309.         If Not IsNothing(TxtBox) Then
  310.             TxtBox.Font = Font
  311.         End If
  312.  
  313.     End Sub
  314.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  315.         MyBase.OnGotFocus(e)
  316.         TxtBox.Focus()
  317.     End Sub
  318.     Private Sub TextChngTxtBox() Handles TxtBox.TextChanged
  319.         Text = TxtBox.Text
  320.     End Sub
  321.     Private Sub TextChng() Handles MyBase.TextChanged
  322.         TxtBox.Text = Text
  323.     End Sub
  324.     Private Sub SetupTextbox()
  325.  
  326.         TxtBox.MaxLength = 30000
  327.         TxtBox.Size = New Size(New Point(50, 21))
  328.         TxtBox.Multiline = True
  329.         TxtBox.BackColor = Pal.ColDim
  330.         TxtBox.ForeColor = Color.FromArgb(199, 199, 199)
  331.         TxtBox.Text = String.Empty
  332.         TxtBox.TextAlign = HorizontalAlignment.Left
  333.         TxtBox.BorderStyle = BorderStyle.None
  334.         TxtBox.Location = New Point(4, 4)
  335.         TxtBox.Font = Font
  336.         TxtBox.Size = New Size(Width - 8, Height - 8)
  337.     End Sub
  338. #End Region
  339.     Sub New()
  340.         MyBase.New()
  341.         Font = New Font("Trebuchet MS", 8.5F)
  342.         TxtReadOnly = False
  343.         Multiline = False
  344.         TextAlign = HorizontalAlignment.Left
  345.         SetupTextbox()
  346.         Controls.Add(TxtBox)
  347.     End Sub
  348.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  349.         Dim G As Graphics = e.Graphics
  350.         MyBase.OnPaint(e)
  351.         G.Clear(Me.Parent.BackColor)
  352.         If Not TxtBox.Multiline Then
  353.             TxtBox.Location = New Point(6, TxtBox.Top)
  354.             If (TxtBox.Width + TxtBox.Left) > Width - 3 And TxtBox.Width > 5 Then
  355.                 TxtBox.Width -= 1
  356.             End If
  357.             Size = New Size(New Point(Width, 21))
  358.         Else
  359.             TxtBox.Location = New Point(3, TxtBox.Top)
  360.             Size = TempSize
  361.         End If
  362.         G.FillRectangle(New SolidBrush(Pal.ColDim), New Rectangle(0, 0, Width - 1, Height - 1))
  363.         G.DrawRectangle(New Pen(Pal.ColHigh), New Rectangle(1, 1, Width - 3, Height - 3))
  364.         G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  365.     End Sub
  366. End Class
  367. Public Class StRCheckPanel : Inherits ThemedControl
  368.     Public Property Checked As Boolean
  369.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  370.         MyBase.OnMouseDown(e)
  371.         Checked = Not Checked
  372.     End Sub
  373.     Sub New()
  374.         MyBase.New()
  375.         Font = New Font("Trebuchet MS", 10.0F)
  376.     End Sub
  377.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  378.         Dim G As Graphics = e.Graphics
  379.         MyBase.OnPaint(e)
  380.         G.Clear(Me.Parent.BackColor)
  381.         G.SmoothingMode = SmoothingMode.HighQuality
  382.         Height = 21
  383.  
  384.         Dim CheckRect As GraphicsPath = D.RoundRect(New Rectangle(1, 1, 20, 20), 2)
  385.         Dim BorderBlack As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2)
  386.         Dim BorderHighlight As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 2)
  387.  
  388.         If Checked Then
  389.             Select Case State
  390.                 Case MouseState.None, MouseState.Down
  391.                     G.FillPath(New SolidBrush(Color.FromArgb(33, 45, 70)), CheckRect)
  392.                 Case MouseState.Over
  393.                     G.FillPath(New SolidBrush(Color.FromArgb(44, 66, 90)), CheckRect)
  394.             End Select
  395.         Else
  396.             G.FillPath(New SolidBrush(Color.FromArgb(22, 22, 22)), CheckRect)
  397.         End If
  398.  
  399.         G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), BorderHighlight)
  400.         G.DrawLine(Pens.Black, New Point(22, 0), New Point(22, Height - 2))
  401.         G.DrawPath(Pens.Black, BorderBlack)
  402.         Dim TextRect As New Rectangle(25, 0, Width - 25, Height - 2)
  403.         D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  404.     End Sub
  405. End Class
  406. Public Class StRGroupbox : Inherits ThemedContainer
  407.     Sub New()
  408.         MyBase.New()
  409.         Drag = False
  410.     End Sub
  411.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  412.         Dim G As Graphics = e.Graphics
  413.         MyBase.OnPaint(e)
  414.  
  415.         G.Clear(Me.Parent.BackColor)
  416.         Dim TopGlowGradient As New LinearGradientBrush(New Point(0, 0), New Point(0, 21), Color.FromArgb(Pal.ColHighest.R - 15, Pal.ColHighest.R - 15, Pal.ColHighest.R - 15), Color.Transparent)
  417.  
  418.         '|========= Base =========|
  419.        G.FillRectangle(New SolidBrush(Pal.ColMed), New Rectangle(0, 0, Width - 1, Height - 1))
  420.         G.DrawRectangle(New Pen(Pal.ColHigh), New Rectangle(1, 1, Width - 3, Height - 3))
  421.         G.FillRectangle(TopGlowGradient, New Rectangle(0, 0, Width - 1, TopGrip / 2))
  422.  
  423.         '|========= Top =========|
  424.        G.FillRectangle(TopGlowGradient, New Rectangle(0, 0, Width, 21))
  425.         G.FillRectangle(New SolidBrush(Color.FromArgb(100, Pal.ColDark.R, Pal.ColDark.R, Pal.ColDark.R)), New Rectangle(1, 24, Width - 2, Height - 25))
  426.         G.DrawLine(Pens.Black, New Point(0, 25), New Point(Width, 25))
  427.         G.DrawLine(New Pen(New SolidBrush(Pal.ColHigh)), New Point(2, 26), New Point(Width - 2, 26))
  428.  
  429.         '|========= Finalizations =========|
  430.        G.DrawRectangle(Pens.Black, New Rectangle(0, 0, Width - 1, Height - 1))
  431.         D.DrawTextWithShadow(G, New Rectangle(6, 0, Width, 24), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  432.     End Sub
  433. End Class
  434. #End Region
  435. '|===========================================================|
  436. #Region "Theme Utility Stuff"
  437. Public Class Palette
  438.     Public ColHighest As Color
  439.     Public ColHigh As Color
  440.     Public ColMed As Color
  441.     Public ColDim As Color
  442.     Public ColDark As Color
  443. End Class
  444. Public Enum MouseState As Byte
  445.     None = 0
  446.     Over = 1
  447.     Down = 2
  448.     Block = 3
  449. End Enum
  450. Public Enum GradientAlignment As Byte
  451.     Vertical = 0
  452.     Horizontal = 1
  453. End Enum
  454. Public Class DrawUtils
  455.     Public Sub FillGradientBeam(ByVal g As Graphics, ByVal Col As Color, ByVal rect As Rectangle, ByVal align As GradientAlignment)
  456.         Dim LGB1, LGB2 As LinearGradientBrush
  457.         Dim stored As SmoothingMode = g.SmoothingMode
  458.         g.SmoothingMode = SmoothingMode.HighQuality
  459.         Select Case align
  460.             Case GradientAlignment.Vertical
  461.                 LGB1 = New LinearGradientBrush(New Point(rect.X - 1, rect.Y), New Point(rect.X + (rect.Width / 2) + 2, rect.Y), Color.Transparent, Col)
  462.                 LGB2 = New LinearGradientBrush(New Point(rect.X + (rect.Width / 2), rect.Y), New Point((rect.X + rect.Width) + 1, rect.Y), Col, Color.Transparent)
  463.  
  464.                 g.FillRectangle(LGB1, New Rectangle(rect.X, rect.Y, (rect.Width / 2), rect.Height))
  465.                 g.FillRectangle(LGB2, New Rectangle(rect.X + (rect.Width / 2), rect.Y, rect.Width / 2, rect.Height))
  466.             Case GradientAlignment.Horizontal
  467.                 LGB1 = New LinearGradientBrush(New Point(rect.X, rect.Y - 1), New Point(rect.X, rect.Y + (rect.Height / 2) + 2), Color.Transparent, Col)
  468.                 LGB2 = New LinearGradientBrush(New Point(rect.X, rect.Y + (rect.Height / 2) - 2), New Point(rect.X, rect.Y + rect.Height), Col, Color.Transparent)
  469.                 g.FillRectangle(LGB1, New Rectangle(rect.X, rect.Y, rect.Width, (rect.Height / 2) + 1))
  470.                 g.FillRectangle(LGB2, New Rectangle(rect.X, rect.Y + (rect.Height / 2) - 2, rect.Width, rect.Height / 2))
  471.         End Select
  472.         g.SmoothingMode = stored
  473.     End Sub
  474.     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)
  475.         DrawText(G, New Rectangle(ContRect.X, ContRect.Y + 2, ContRect.Width + 1, ContRect.Height + 2), Text, TFont, TAlign, BColor)
  476.         DrawText(G, ContRect, Text, TFont, TAlign, TColor)
  477.     End Sub
  478.     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)
  479.         If String.IsNullOrEmpty(Text) Then Return
  480.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  481.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  482.         Select Case TAlign
  483.             Case HorizontalAlignment.Left
  484.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
  485.             Case HorizontalAlignment.Right
  486.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width - TextSize.Width - 5, CenteredY)
  487.             Case HorizontalAlignment.Center
  488.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
  489.         End Select
  490.     End Sub
  491.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  492.         Dim P As New GraphicsPath
  493.         Dim ArcRectangleWidth As Integer = Curve * 2
  494.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  495.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  496.         P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  497.         P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  498.         P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  499.         Return P
  500.     End Function
  501. End Class
  502. #End Region
Advertisement
Add Comment
Please, Sign In to add comment