Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D
- '|===========================================================|
- '|===| Hades Theme
- '| Creator: LordPankake
- '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
- '| Requested By: http://www.hackforums.net/member.php?action=profile&uid=1813735
- '| Created: 8/6/2014, Last edited: 8/7/2014
- '|===========================================================|
- #Region "Base Classes"
- Public Class ThemedControl : Inherits Control
- Public D As New DrawUtils
- Public State As MouseState = MouseState.None
- Public Pal As Palette
- Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- MinimumSize = New Size(5, 5)
- ForeColor = Color.FromArgb(146, 149, 152)
- Font = New Font("Segoe UI", 10.0F)
- DoubleBuffered = True
- Pal = New Palette
- Pal.ColHighest = Color.FromArgb(100, 100, 100)
- Pal.ColHigh = Color.FromArgb(65, 65, 65)
- Pal.ColMed = Color.FromArgb(40, 40, 40)
- Pal.ColDim = Color.FromArgb(30, 30, 30)
- Pal.ColDark = Color.FromArgb(15, 15, 15)
- BackColor = Pal.ColDim
- End Sub
- End Class
- Public Class ThemedTabControl : Inherits TabControl
- Public D As New DrawUtils
- Public State As MouseState = MouseState.None
- Public Pal As Palette
- Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- MinimumSize = New Size(20, 20)
- ForeColor = Color.FromArgb(146, 149, 152)
- Font = New Font("Segoe UI", 10.0F)
- DoubleBuffered = True
- Pal = New Palette
- Pal.ColHighest = Color.FromArgb(100, 100, 100)
- Pal.ColHigh = Color.FromArgb(65, 65, 65)
- Pal.ColMed = Color.FromArgb(40, 40, 40)
- Pal.ColDim = Color.FromArgb(30, 30, 30)
- Pal.ColDark = Color.FromArgb(15, 15, 15)
- BackColor = Pal.ColDim
- End Sub
- End Class
- Public Class ThemedContainer : Inherits ContainerControl
- Public D As New DrawUtils
- Protected Drag As Boolean = True
- Public State As MouseState = MouseState.None
- Protected TopCap As Boolean = False
- Protected SizeCap As Boolean = False
- Public Pal As Palette
- Protected MouseP As Point = New Point(0, 0)
- Protected TopGrip As Integer
- Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
- End Sub
- Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down
- If e.Button = Windows.Forms.MouseButtons.Left Then
- If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
- TopCap = True : MouseP = e.Location
- ElseIf Drag And New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
- SizeCap = True : MouseP = e.Location
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over
- TopCap = False
- If Drag Then
- SizeCap = False
- End If
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- If TopCap Then
- Parent.Location = MousePosition - MouseP
- End If
- If Drag And SizeCap Then
- MouseP = e.Location
- Parent.Size = New Size(MouseP)
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Sub New()
- MyBase.New()
- MinimumSize = New Size(20, 20)
- ForeColor = Color.FromArgb(146, 149, 152)
- Font = New Font("Trebuchet MS", 10.0F)
- DoubleBuffered = True
- Pal = New Palette
- Pal.ColHighest = Color.FromArgb(100, 100, 100)
- Pal.ColHigh = Color.FromArgb(65, 65, 65)
- Pal.ColMed = Color.FromArgb(40, 40, 40)
- Pal.ColDim = Color.FromArgb(30, 30, 30)
- Pal.ColDark = Color.FromArgb(15, 15, 15)
- BackColor = Pal.ColDim
- End Sub
- End Class
- #End Region
- #Region "Theme Objects"
- Public Class HadesTheme : Inherits ThemedContainer
- Public Property TextAlignment As HorizontalAlignment = HorizontalAlignment.Left
- Sub New()
- MyBase.New()
- Drag = False
- MinimumSize = New Size(100, 100)
- Dock = DockStyle.Fill
- TopGrip = 27
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- '||| Setup/all the default things your main theme control should do
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- '| Don't want to have to manually change the formBorderStyle. For the lazy
- '| Same goes for the transperency key
- Try
- Me.ParentForm.TransparencyKey = Color.Fuchsia
- Me.ParentForm.MinimumSize = MinimumSize
- If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
- Me.ParentForm.FormBorderStyle = FormBorderStyle.None
- End If
- Catch ex As Exception : End Try
- G.Clear(Me.ParentForm.TransparencyKey)
- '|||| The blob of graphics variables
- '| The main GP for drawing the borders and fills.
- Dim FormFillPath As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 8)
- '| Used for inner glow.
- Dim FormInnerPath1 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 1, Width - 1, Height - 1), 8)
- Dim FormInnerPath2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 2, Width - 1, Height - 1), 8)
- '| Using colorblend (see below), this won't turn up black.
- Dim InnerPathGradient As New LinearGradientBrush(New Point(0, 0), New Point(0, Width), Color.Black, Color.Black)
- Dim Blend As New ColorBlend
- '| Used for the slight fade/sharp overlays at the top of the form
- Dim TopGradientPath1 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip), 8)
- Dim TopGradientPath2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip / 2), 8)
- Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TopGrip * 4), New Point(0, TopGrip), Pal.ColHigh, Color.Transparent)
- Dim TopGradient2 As New LinearGradientBrush(New Point(0, -TopGrip * 3), New Point(0, TopGrip * (2 / 3)), Color.WhiteSmoke, Color.Transparent)
- '| The pattern used on the form BG.
- Dim TextureBrush As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
- '|||| Drawing
- '|Filling the form with a default color, drawing a pattern, then applying the top gradients.
- G.FillPath(New SolidBrush(Pal.ColDim), FormFillPath)
- G.FillPath(TextureBrush, FormFillPath)
- G.FillPath(TopGradient1, TopGradientPath1)
- G.FillPath(TopGradient2, TopGradientPath2)
- G.SmoothingMode = SmoothingMode.HighQuality
- '| Assigns positions for the color changes
- Blend.Positions = {0, 1 / 2, 1}
- '| Assigns colors for those poitions
- Blend.Colors = {Pal.ColHigh, Color.FromArgb(Pal.ColHigh.R + 70, Pal.ColHigh.R + 70, Pal.ColHigh.R + 70), Pal.ColHigh}
- '| Assigns the color changes to the LinearBrush
- InnerPathGradient.InterpolationColors = Blend
- '| Rotates the gradient to 90's (for the center glow)
- InnerPathGradient.RotateTransform(90)
- G.DrawPath(New Pen(InnerPathGradient), FormInnerPath1)
- G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest.R, Pal.ColHighest.R, Pal.ColHighest.R)), FormInnerPath2)
- '| Borders. No smoothing because smoothing causes transperencyKey blurring
- G.SmoothingMode = SmoothingMode.None
- G.DrawPath(Pens.Black, FormFillPath)
- '| Title text rendering
- Dim TextRect As New Rectangle(5, 0, Width - 11, TopGrip)
- D.DrawTextWithShadow(G, TextRect, Text, Font, TextAlignment, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class HadesTopControl : Inherits ThemedControl
- '| On mouse up because on occasion, the user clicks a button, second guesses, moves off and the window closes anyway.
- '| Or at least I do that and hate programs that do that. Change to OnMouseDown if that doesn't irritate you.
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Down
- Invalidate()
- If e.X <= 22 Then
- FindForm.Close()
- Else
- FindForm.WindowState = FormWindowState.Minimized
- End If
- End Sub
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 10.0F)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- '| Since this control is optimized to be a certain size, it's forced to stick to these dimensions.
- Size = New Size(40, 20)
- '| And now that this is a child of a form, transperency is no longer a problem. Smooth away!
- G.SmoothingMode = SmoothingMode.HighQuality
- '| Blob of variable declarations
- Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, Height - 2), 3)
- Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 3)
- Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 3)
- Dim Blend As New ColorBlend
- Dim GradientPath As New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 2), Color.Black, Color.Black)
- '| Filles in the control
- Select Case State
- Case MouseState.None
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColHigh, Pal.ColDark, Pal.ColDark, Pal.ColDark}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- Case MouseState.Over
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColHighest, Pal.ColDim, Pal.ColDim, Pal.ColDim}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- Case MouseState.Down
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColMed, Color.Black, Color.Black, Color.Black}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- End Select
- '| Finishes up the borders of the control
- G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
- G.DrawPath(Pens.Black, Border1)
- G.DrawLine(New Pen(Pal.ColHigh), New Point(20, 2), New Point(20, Height - 2))
- G.DrawLine(Pens.Black, New Point(21, 0), New Point(21, Height - 2))
- G.DrawLine(New Pen(Pal.ColHigh), New Point(22, 0), New Point(22, Height - 2))
- '| Text rects/renders for the X and - buttons.
- Dim TextRectX As New Rectangle(6, 1, Width, Height - 4)
- Dim TextRectMin As New Rectangle(25, -20, Width, 5)
- D.DrawTextWithShadow(G, TextRectX, "X", Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
- D.DrawTextWithShadow(G, TextRectMin, "_", Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class HadesButton : Inherits ThemedControl
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 10.0F)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- G.SmoothingMode = SmoothingMode.HighQuality
- '| Blob of variable declarations
- Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, Height - 2), 3)
- Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 3)
- Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 3)
- Dim Blend As New ColorBlend
- Dim GradientPath As New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 2), Color.Black, Color.Black)
- Dim DownColor As Color = Color.FromArgb(Pal.ColMed.R - 20, Pal.ColMed.R - 20, Pal.ColMed.R - 20)
- '| Filles in the control
- Select Case State
- Case MouseState.None
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColHigh, Pal.ColDim, Pal.ColDim, Pal.ColDark}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- Case MouseState.Over
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColHighest, Pal.ColMed, Pal.ColMed, Pal.ColDim}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- Case MouseState.Down
- Blend.Positions = {0, 1 / 3, 2 / 3, 1}
- Blend.Colors = {Pal.ColMed, DownColor, DownColor, DownColor}
- GradientPath.InterpolationColors = Blend
- G.FillPath(GradientPath, Rect1)
- End Select
- '| Finishes up the borders of the control
- G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
- G.DrawPath(Pens.Black, Border1)
- '| And again, the text drawing.
- Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
- D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class HadesTextbox : Inherits ThemedControl
- #Region "Textbox Data"
- Private WithEvents TxtBox As New TextBox
- Private TempSize As Size
- Public Property MaxCharacters As Integer
- Public Property Multiline() As Boolean
- Get
- Return TxtBox.Multiline
- End Get
- Set(ByVal v As Boolean)
- TxtBox.Multiline = v
- Invalidate()
- End Set
- End Property
- Public Property TextAlign As HorizontalAlignment
- Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
- MyBase.OnSizeChanged(e)
- If Not Size.Height = 21 Then
- TempSize = Size
- End If
- If Not IsNothing(TxtBox) Then
- TxtBox.Size = New Size(Width - 8, Height - 8)
- End If
- Invalidate()
- End Sub
- Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
- MyBase.OnFontChanged(e)
- If Not IsNothing(TxtBox) Then
- TxtBox.Font = Font
- End If
- End Sub
- Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
- MyBase.OnGotFocus(e)
- TxtBox.Focus()
- End Sub
- Private Sub TextChngTxtBox() Handles TxtBox.TextChanged
- Text = TxtBox.Text
- End Sub
- Private Sub TextChng() Handles MyBase.TextChanged
- TxtBox.Text = Text
- End Sub
- Public Sub SetReadOnly(ByVal Bool As Boolean)
- TxtBox.ReadOnly = Bool
- End Sub
- Private Sub SetupTextbox()
- TxtBox.MaxLength = 30000
- TxtBox.Size = New Size(New Point(50, 21))
- TxtBox.Multiline = True
- TxtBox.BackColor = Pal.ColDark
- TxtBox.ForeColor = Color.FromArgb(144, 144, 144)
- TxtBox.Text = String.Empty
- TxtBox.TextAlign = HorizontalAlignment.Left
- TxtBox.BorderStyle = BorderStyle.None
- TxtBox.Location = New Point(6, 4)
- TxtBox.Font = Font
- TxtBox.Size = New Size(Width - 11, Height - 8)
- End Sub
- #End Region
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 8.5F)
- Multiline = False
- TextAlign = HorizontalAlignment.Left
- SetupTextbox()
- Controls.Add(TxtBox)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Pal.ColDark)
- If Not TxtBox.Multiline Then
- TxtBox.Location = New Point(4, TxtBox.Top)
- If (TxtBox.Width + TxtBox.Left) > Width - 3 And TxtBox.Width > 5 Then
- TxtBox.Width -= 1
- End If
- Size = New Size(New Point(Width, 23))
- Else
- TxtBox.Location = New Point(4, TxtBox.Top)
- Size = TempSize
- End If
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim PathHiglight As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 5)
- Dim PathOutline As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 5)
- G.DrawPath(New Pen(Pal.ColHighest), PathHiglight)
- G.DrawPath(New Pen(Color.Black, 2), PathOutline)
- End Sub
- End Class
- Public Class HadesCheckbox : Inherits ThemedControl
- Public Property Checked As Boolean
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- Checked = Not Checked
- End Sub
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 10.0F)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- Height = 18
- G.SmoothingMode = SmoothingMode.HighQuality
- '| Checkbox base
- Dim HighlightPath As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Height, Height - 2), 4)
- Dim OutlinePath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Height, Height - 2), 4)
- '| The Check
- If Checked Then
- Dim FillGradient As New LinearGradientBrush(New Point(2, 2), New Point(2, Height - 3), Pal.ColHighest, Pal.ColDark)
- G.FillPath(FillGradient, OutlinePath)
- Else
- G.FillPath(New SolidBrush(Pal.ColDark), OutlinePath)
- End If
- G.DrawPath(New Pen(Pal.ColHighest), HighlightPath)
- G.DrawPath(New Pen(Color.Black, 1), OutlinePath)
- D.DrawTextWithShadow(G, New Rectangle(25, 0, Width - 25, Height - 2), Text, Font, HorizontalAlignment.Left, Color.WhiteSmoke, Color.Black)
- End Sub
- End Class
- Public Class HadesRadiobutton : Inherits ThemedControl
- Public Property Checked As Boolean
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- For Each Cont As Control In Parent.Controls
- If TypeOf Cont Is HadesRadiobutton Then
- DirectCast(Cont, HadesRadiobutton).Checked = False
- Cont.Invalidate()
- End If
- Next
- Checked = True
- End Sub
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 10.0F)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- Height = 18
- G.SmoothingMode = SmoothingMode.HighQuality
- '| The Check
- If Checked Then
- Dim FillGradient As New LinearGradientBrush(New Point(2, 2), New Point(2, Height - 3), Pal.ColHighest, Pal.ColDark)
- G.FillEllipse(FillGradient, New Rectangle(0, 0, Height, Height - 2))
- Else
- G.FillEllipse(New SolidBrush(Pal.ColDark), New Rectangle(0, 0, Height, Height - 2))
- End If
- '| Radiobutton base
- G.DrawEllipse(New Pen(Pal.ColHighest), New Rectangle(0, 1, Height, Height - 2))
- G.DrawEllipse(New Pen(Color.Black, 1), New Rectangle(0, 0, Height, Height - 2))
- D.DrawTextWithShadow(G, New Rectangle(25, 0, Width - 25, Height - 2), Text, Font, HorizontalAlignment.Left, Color.WhiteSmoke, Color.Black)
- End Sub
- End Class
- Public Class HadesGroupbox : Inherits ThemedContainer
- Public Property TextAlignment As HorizontalAlignment = HorizontalAlignment.Left
- Sub New()
- MyBase.New()
- TopGrip = 21
- BackColor = Pal.ColDark
- Drag = False
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim DR As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
- Dim DR2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip - 1), 5)
- Dim DR3 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip / 2 + 1), 5)
- Dim BGRect As New Rectangle(0, TopGrip, Width - 1, Height - TopGrip)
- Dim LGB1 As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip), Pal.ColMed, Pal.ColDark)
- Dim LGB2 As New LinearGradientBrush(New Point(0, -(TopGrip * 6)), New Point(0, TopGrip), Color.WhiteSmoke, Color.Transparent)
- Dim HTB As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
- G.FillPath(LGB1, DR2)
- G.FillPath(HTB, DR2)
- G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDark.R, Pal.ColDark.R, Pal.ColDark.R)), DR2)
- G.FillPath(LGB2, DR3)
- G.FillRectangle(New SolidBrush(Pal.ColDark), BGRect)
- G.DrawLine(Pens.Black, New Point(0, TopGrip), New Point(Width - 1, TopGrip))
- G.DrawPath(Pens.Black, DR)
- D.DrawTextWithShadow(G, New Rectangle(2, 0, Width - 3, TopGrip - 1), Text, Font, TextAlignment, Color.WhiteSmoke, Color.Black)
- End Sub
- End Class
- Public Class HadesNumericUD : Inherits ThemedControl
- Private WithEvents TxtBox As New HadesTextbox
- Private WithEvents BtnUp As New HadesButton
- Private WithEvents BtnDown As New HadesButton
- Public Property ButtonChange As Integer = 1
- Public Property Minimum As Integer = 1
- Public Property Maximum As Integer = 100
- '| Used the MouseDown event because it doesn't use a delay like the click one does.
- Protected Sub BtnUp_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnUp.MouseDown
- Value = Value + ButtonChange
- End Sub
- Protected Sub BtnDown_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnDown.MouseDown
- Value = Value - ButtonChange
- End Sub
- Public Property Value() As Integer
- Get
- Dim Ret As Integer = 0
- Try : Ret = CInt(TxtBox.Text) : Catch ex As Exception : End Try
- Return Ret
- End Get
- Set(ByVal val As Integer)
- If val <= Maximum And val >= Minimum Then
- TxtBox.Text = val
- Invalidate()
- End If
- End Set
- End Property
- Sub New()
- MyBase.New()
- Size = New Point(300, 300)
- Font = New Font("Trebuchet MS", 10.0F)
- TxtBox.Text = 0
- Controls.Add(TxtBox)
- Controls.Add(BtnUp)
- Controls.Add(BtnDown)
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- Height = 30
- BtnUp.Size = New Size(15, 15)
- BtnUp.Location = New Point(Size.Width - BtnUp.Width, 0)
- BtnUp.Font = New Font("Trebuchet MS", 10.0F)
- BtnUp.Text = "ᴧ"
- BtnDown.Size = New Size(15, 15)
- BtnDown.Location = New Point(Size.Width - BtnUp.Width, BtnUp.Size.Height)
- BtnDown.Font = New Font("Trebuchet MS", 10.0F, FontStyle.Bold)
- BtnDown.Text = "v"
- TxtBox.Location = New Point(0, 0)
- TxtBox.SetReadOnly(True)
- TxtBox.Multiline = True
- TxtBox.Height = 30
- TxtBox.Width = BtnUp.Location.X - 2
- End Sub
- End Class
- Public Class HadesTabControl : Inherits ThemedTabControl
- Sub New()
- MyBase.New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
- ItemSize = New Size(0, 25)
- Padding = New Size(20, 0)
- Alignment = TabAlignment.Top
- Font = New Font("Trebuchet MS", 10.0F)
- End Sub
- '| This in entirety is a clusterfuck... I'm ashamed to have even made this
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- G.Clear(Me.Parent.BackColor)
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim FontColor As New Color
- Dim TextureBrush As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
- G.FillRectangle(New SolidBrush(Pal.ColDim), New Rectangle(0, 0, Width, Height))
- G.FillRectangle(TextureBrush, New Rectangle(0, 0, Width, Height))
- For i = 0 To TabCount - 1
- Dim TabRect As Rectangle = GetTabRect(i)
- Dim TabPath As New GraphicsPath
- With TabPath
- .AddLine(New Point(TabRect.X + 2, TabRect.Y + TabRect.Height), New Point(TabRect.X + 10, TabRect.Y))
- .AddLine(New Point(TabRect.X + 10, TabRect.Y), New Point(TabRect.X + TabRect.Width - 10, TabRect.Y))
- .AddLine(New Point(TabRect.X + TabRect.Width - 10, TabRect.Y), New Point(TabRect.X + TabRect.Width - 2, TabRect.Y + TabRect.Height))
- .AddLine(New Point(TabRect.X + TabRect.Width - 2, TabRect.Y + TabRect.Height), New Point(TabRect.X, TabRect.Y + TabRect.Height))
- End With
- TabPath.CloseFigure()
- Dim Offset1 As New Matrix()
- Offset1.Translate(0, 1)
- Dim OffsetNeg1 As New Matrix()
- OffsetNeg1.Translate(0, -1)
- Dim Offset5 As New Matrix()
- Offset5.Translate(0, 5)
- If i = SelectedIndex Then
- G.FillPath(New SolidBrush(Pal.ColHighest), TabPath)
- TabPath.Transform(Offset1)
- TabPath.Transform(Offset1)
- G.FillPath(New SolidBrush(Pal.ColDim), TabPath)
- Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TabRect.Height), New Point(0, TabRect.Height + 4), Pal.ColHighest, Color.Transparent)
- G.FillPath(TopGradient1, TabPath)
- Offset1.Translate(0, -3)
- FontColor = Color.FromArgb(255, 255, 255)
- Dim titleX As Integer = (TabRect.Location.X + TabRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2) + 2
- Dim titleY As Integer = (TabRect.Location.Y + TabRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)
- G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))
- Else
- TabPath.Transform(Offset5)
- G.FillPath(New SolidBrush(Pal.ColHigh), TabPath)
- TabPath.Transform(Offset1)
- G.FillPath(New SolidBrush(Pal.ColDark), TabPath)
- FontColor = Color.FromArgb(155, 155, 155)
- Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TabRect.Height), New Point(0, TabRect.Height + 4), Color.Transparent, Color.FromArgb(11, 11, 11))
- G.FillPath(TopGradient1, TabPath)
- Offset1.Translate(0, -2)
- Dim titleX As Integer = (TabRect.Location.X + TabRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2) + 3
- Dim titleY As Integer = (TabRect.Location.Y + TabRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2) + 3
- G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))
- End If
- Offset1.Scale(1, 1.05)
- TabPath.Transform(Offset1)
- TabPath.Transform(OffsetNeg1)
- G.DrawPath(Pens.Black, TabPath)
- Try : TabPages(i).BackColor = Pal.ColDark : Catch : End Try
- Next
- G.FillPath(New SolidBrush(Pal.ColDark), D.RoundedTopRect(New Rectangle(0, 25, Width - 1, Height - 26), 5))
- G.DrawPath(Pens.Black, D.RoundedTopRect(New Rectangle(0, 25, Width - 1, Height - 26), 5))
- End Sub
- End Class
- #End Region
- '|===========================================================|
- #Region "Theme Utility Stuff"
- Public Class Palette
- Public ColHighest As Color
- Public ColHigh As Color
- Public ColMed As Color
- Public ColDim As Color
- Public ColDark As Color
- End Class
- Public Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- Block = 3
- End Enum
- Public Enum GradientAlignment As Byte
- Vertical = 0
- Horizontal = 1
- End Enum
- Public Class DrawUtils
- Public Sub FillGradientBeam(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal align As GradientAlignment)
- Dim stored As SmoothingMode = g.SmoothingMode
- Dim Blend As New ColorBlend
- g.SmoothingMode = SmoothingMode.HighQuality
- Select Case align
- Case GradientAlignment.Vertical
- Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
- Blend.Positions = {0, 1 / 2, 1}
- Blend.Colors = {Col1, Col2, Col1}
- PathGradient.InterpolationColors = Blend
- g.FillRectangle(PathGradient, rect)
- Case GradientAlignment.Horizontal
- Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
- Blend.Positions = {0, 1 / 2, 1}
- Blend.Colors = {Col1, Col2, Col1}
- PathGradient.InterpolationColors = Blend
- PathGradient.RotateTransform(0)
- g.FillRectangle(PathGradient, rect)
- End Select
- g.SmoothingMode = stored
- End Sub
- 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)
- DrawText(G, New Rectangle(ContRect.X, ContRect.Y + 2, ContRect.Width + 1, ContRect.Height + 2), Text, TFont, TAlign, BColor)
- DrawText(G, ContRect, Text, TFont, TAlign, TColor)
- End Sub
- 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)
- If String.IsNullOrEmpty(Text) Then Return
- Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
- Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
- Select Case TAlign
- Case HorizontalAlignment.Left
- G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
- Case HorizontalAlignment.Right
- G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width - TextSize.Width - 5, CenteredY)
- Case HorizontalAlignment.Center
- G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
- End Select
- End Sub
- Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim Path As New GraphicsPath
- Dim ArcRectangleWidth As Integer = Curve * 2
- With Path
- .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- End With
- Return Path
- End Function
- Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim Path As GraphicsPath = New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- With Path
- .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- .AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height))
- .AddLine(New Point(Rectangle.X, Rectangle.Height + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
- End With
- Return Path
- End Function
- End Class
- #End Region
Advertisement
Add Comment
Please, Sign In to add comment