LordPankake

[VB.net] Hades Theme - [9 Controls | Dark]

Aug 6th, 2014
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Drawing.Drawing2D
  2. '|===========================================================|
  3. '|===|  Hades Theme
  4. '| Creator: LordPankake
  5. '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
  6. '| Requested By: http://www.hackforums.net/member.php?action=profile&uid=1813735
  7. '| Created: 8/6/2014, Last edited: 8/7/2014
  8. '|===========================================================|
  9. #Region "Base Classes"
  10. Public Class ThemedControl : Inherits Control
  11.     Public D As New DrawUtils
  12.     Public State As MouseState = MouseState.None
  13.     Public Pal As Palette
  14.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  15.     End Sub
  16.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  17.         MyBase.OnMouseEnter(e)
  18.         State = MouseState.Over
  19.         Invalidate()
  20.     End Sub
  21.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  22.         MyBase.OnMouseDown(e)
  23.         State = MouseState.Down
  24.         Invalidate()
  25.     End Sub
  26.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  27.         MyBase.OnMouseLeave(e)
  28.         State = MouseState.None
  29.         Invalidate()
  30.     End Sub
  31.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  32.         MyBase.OnMouseUp(e)
  33.         State = MouseState.Over
  34.         Invalidate()
  35.     End Sub
  36.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  37.         MyBase.OnTextChanged(e)
  38.         Invalidate()
  39.     End Sub
  40.     Sub New()
  41.         MyBase.New()
  42.         MinimumSize = New Size(5, 5)
  43.         ForeColor = Color.FromArgb(146, 149, 152)
  44.         Font = New Font("Segoe UI", 10.0F)
  45.         DoubleBuffered = True
  46.         Pal = New Palette
  47.         Pal.ColHighest = Color.FromArgb(100, 100, 100)
  48.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  49.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  50.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  51.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  52.         BackColor = Pal.ColDim
  53.     End Sub
  54. End Class
  55. Public Class ThemedTabControl : Inherits TabControl
  56.     Public D As New DrawUtils
  57.     Public State As MouseState = MouseState.None
  58.     Public Pal As Palette
  59.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  60.     End Sub
  61.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  62.         MyBase.OnMouseEnter(e)
  63.         State = MouseState.Over
  64.         Invalidate()
  65.     End Sub
  66.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  67.         MyBase.OnMouseDown(e)
  68.         State = MouseState.Down
  69.         Invalidate()
  70.     End Sub
  71.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  72.         MyBase.OnMouseLeave(e)
  73.         State = MouseState.None
  74.         Invalidate()
  75.     End Sub
  76.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  77.         MyBase.OnMouseUp(e)
  78.         State = MouseState.Over
  79.         Invalidate()
  80.     End Sub
  81.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  82.         MyBase.OnTextChanged(e)
  83.         Invalidate()
  84.     End Sub
  85.     Sub New()
  86.         MyBase.New()
  87.         MinimumSize = New Size(20, 20)
  88.         ForeColor = Color.FromArgb(146, 149, 152)
  89.         Font = New Font("Segoe UI", 10.0F)
  90.         DoubleBuffered = True
  91.         Pal = New Palette
  92.         Pal.ColHighest = Color.FromArgb(100, 100, 100)
  93.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  94.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  95.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  96.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  97.         BackColor = Pal.ColDim
  98.     End Sub
  99. End Class
  100. Public Class ThemedContainer : Inherits ContainerControl
  101.     Public D As New DrawUtils
  102.     Protected Drag As Boolean = True
  103.     Public State As MouseState = MouseState.None
  104.     Protected TopCap As Boolean = False
  105.     Protected SizeCap As Boolean = False
  106.     Public Pal As Palette
  107.     Protected MouseP As Point = New Point(0, 0)
  108.     Protected TopGrip As Integer
  109.     Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
  110.     End Sub
  111.     Protected Overrides Sub OnMouseEnter(ByVal e As EventArgs)
  112.         MyBase.OnMouseEnter(e)
  113.         State = MouseState.Over
  114.         Invalidate()
  115.     End Sub
  116.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  117.         MyBase.OnMouseDown(e)
  118.         State = MouseState.Down
  119.         If e.Button = Windows.Forms.MouseButtons.Left Then
  120.             If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
  121.                 TopCap = True : MouseP = e.Location
  122.             ElseIf Drag And New Rectangle(Width - 15, Height - 15, 15, 15).Contains(e.Location) Then
  123.                 SizeCap = True : MouseP = e.Location
  124.             End If
  125.         End If
  126.     End Sub
  127.     Protected Overrides Sub OnMouseLeave(ByVal e As EventArgs)
  128.         MyBase.OnMouseLeave(e)
  129.         State = MouseState.None
  130.         Invalidate()
  131.     End Sub
  132.     Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  133.         MyBase.OnMouseUp(e)
  134.         State = MouseState.Over
  135.         TopCap = False
  136.         If Drag Then
  137.             SizeCap = False
  138.         End If
  139.  
  140.     End Sub
  141.     Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
  142.         MyBase.OnMouseMove(e)
  143.  
  144.         If TopCap Then
  145.             Parent.Location = MousePosition - MouseP
  146.         End If
  147.         If Drag And SizeCap Then
  148.             MouseP = e.Location
  149.             Parent.Size = New Size(MouseP)
  150.             Invalidate()
  151.         End If
  152.  
  153.     End Sub
  154.     Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
  155.         MyBase.OnTextChanged(e)
  156.         Invalidate()
  157.     End Sub
  158.     Sub New()
  159.         MyBase.New()
  160.         MinimumSize = New Size(20, 20)
  161.         ForeColor = Color.FromArgb(146, 149, 152)
  162.         Font = New Font("Trebuchet MS", 10.0F)
  163.         DoubleBuffered = True
  164.         Pal = New Palette
  165.         Pal.ColHighest = Color.FromArgb(100, 100, 100)
  166.         Pal.ColHigh = Color.FromArgb(65, 65, 65)
  167.         Pal.ColMed = Color.FromArgb(40, 40, 40)
  168.         Pal.ColDim = Color.FromArgb(30, 30, 30)
  169.         Pal.ColDark = Color.FromArgb(15, 15, 15)
  170.         BackColor = Pal.ColDim
  171.     End Sub
  172. End Class
  173. #End Region
  174. #Region "Theme Objects"
  175. Public Class HadesTheme : Inherits ThemedContainer
  176.     Public Property TextAlignment As HorizontalAlignment = HorizontalAlignment.Left
  177.     Sub New()
  178.         MyBase.New()
  179.         Drag = False
  180.         MinimumSize = New Size(100, 100)
  181.         Dock = DockStyle.Fill
  182.         TopGrip = 27
  183.     End Sub
  184.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  185.         '||| Setup/all the default things your main theme control should do
  186.        Dim G As Graphics = e.Graphics
  187.         MyBase.OnPaint(e)
  188.         '| Don't want to have to manually change the formBorderStyle. For the lazy
  189.        '| Same goes for the transperency key
  190.        Try
  191.             Me.ParentForm.TransparencyKey = Color.Fuchsia
  192.             Me.ParentForm.MinimumSize = MinimumSize
  193.             If Not Me.ParentForm.FormBorderStyle = FormBorderStyle.None Then
  194.                 Me.ParentForm.FormBorderStyle = FormBorderStyle.None
  195.             End If
  196.         Catch ex As Exception : End Try
  197.         G.Clear(Me.ParentForm.TransparencyKey)
  198.  
  199.         '|||| The blob of graphics variables
  200.        '| The main GP for drawing the borders and fills.
  201.        Dim FormFillPath As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 8)
  202.  
  203.         '| Used for inner glow.
  204.        Dim FormInnerPath1 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 1, Width - 1, Height - 1), 8)
  205.         Dim FormInnerPath2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 2, Width - 1, Height - 1), 8)
  206.         '| Using colorblend (see below), this won't turn up black.
  207.        Dim InnerPathGradient As New LinearGradientBrush(New Point(0, 0), New Point(0, Width), Color.Black, Color.Black)
  208.         Dim Blend As New ColorBlend
  209.  
  210.         '| Used for the slight fade/sharp overlays at the top of the form
  211.        Dim TopGradientPath1 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip), 8)
  212.         Dim TopGradientPath2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip / 2), 8)
  213.         Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TopGrip * 4), New Point(0, TopGrip), Pal.ColHigh, Color.Transparent)
  214.         Dim TopGradient2 As New LinearGradientBrush(New Point(0, -TopGrip * 3), New Point(0, TopGrip * (2 / 3)), Color.WhiteSmoke, Color.Transparent)
  215.  
  216.         '| The pattern used on the form BG.
  217.        Dim TextureBrush As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
  218.  
  219.         '|||| Drawing
  220.        '|Filling the form with a default color, drawing a pattern, then applying the top gradients.
  221.        G.FillPath(New SolidBrush(Pal.ColDim), FormFillPath)
  222.         G.FillPath(TextureBrush, FormFillPath)
  223.         G.FillPath(TopGradient1, TopGradientPath1)
  224.         G.FillPath(TopGradient2, TopGradientPath2)
  225.  
  226.         G.SmoothingMode = SmoothingMode.HighQuality
  227.         '| Assigns positions for the color changes
  228.        Blend.Positions = {0, 1 / 2, 1}
  229.         '| Assigns colors for those poitions
  230.        Blend.Colors = {Pal.ColHigh, Color.FromArgb(Pal.ColHigh.R + 70, Pal.ColHigh.R + 70, Pal.ColHigh.R + 70), Pal.ColHigh}
  231.         '| Assigns the color changes to the LinearBrush
  232.        InnerPathGradient.InterpolationColors = Blend
  233.         '| Rotates the gradient to 90's (for the center glow)
  234.        InnerPathGradient.RotateTransform(90)
  235.         G.DrawPath(New Pen(InnerPathGradient), FormInnerPath1)
  236.         G.DrawPath(New Pen(Color.FromArgb(100, Pal.ColHighest.R, Pal.ColHighest.R, Pal.ColHighest.R)), FormInnerPath2)
  237.  
  238.         '| Borders. No smoothing because smoothing causes transperencyKey blurring
  239.        G.SmoothingMode = SmoothingMode.None
  240.         G.DrawPath(Pens.Black, FormFillPath)
  241.  
  242.         '| Title text rendering
  243.        Dim TextRect As New Rectangle(5, 0, Width - 11, TopGrip)
  244.         D.DrawTextWithShadow(G, TextRect, Text, Font, TextAlignment, Color.FromArgb(199, 199, 199), Color.Black)
  245.     End Sub
  246. End Class
  247. Public Class HadesTopControl : Inherits ThemedControl
  248.     '| On mouse up because on occasion, the user clicks a button, second guesses, moves off and the window closes anyway.
  249.    '| Or at least I do that and hate programs that do that. Change to OnMouseDown if that doesn't irritate you.
  250.    Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
  251.         MyBase.OnMouseUp(e)
  252.         State = MouseState.Down
  253.         Invalidate()
  254.         If e.X <= 22 Then
  255.             FindForm.Close()
  256.         Else
  257.             FindForm.WindowState = FormWindowState.Minimized
  258.         End If
  259.     End Sub
  260.     Sub New()
  261.         MyBase.New()
  262.         Font = New Font("Trebuchet MS", 10.0F)
  263.     End Sub
  264.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  265.         Dim G As Graphics = e.Graphics
  266.         MyBase.OnPaint(e)
  267.         G.Clear(Me.Parent.BackColor)
  268.         '| Since this control is optimized to be a certain size, it's forced to stick to these dimensions.
  269.        Size = New Size(40, 20)
  270.         '| And now that this is a child of a form, transperency is no longer a problem. Smooth away!
  271.        G.SmoothingMode = SmoothingMode.HighQuality
  272.  
  273.         '| Blob of variable declarations
  274.        Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, Height - 2), 3)
  275.         Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 3)
  276.         Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 3)
  277.         Dim Blend As New ColorBlend
  278.         Dim GradientPath As New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 2), Color.Black, Color.Black)
  279.  
  280.         '| Filles in the control
  281.        Select Case State
  282.             Case MouseState.None
  283.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  284.                 Blend.Colors = {Pal.ColHigh, Pal.ColDark, Pal.ColDark, Pal.ColDark}
  285.                 GradientPath.InterpolationColors = Blend
  286.                 G.FillPath(GradientPath, Rect1)
  287.             Case MouseState.Over
  288.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  289.                 Blend.Colors = {Pal.ColHighest, Pal.ColDim, Pal.ColDim, Pal.ColDim}
  290.                 GradientPath.InterpolationColors = Blend
  291.                 G.FillPath(GradientPath, Rect1)
  292.             Case MouseState.Down
  293.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  294.                 Blend.Colors = {Pal.ColMed, Color.Black, Color.Black, Color.Black}
  295.                 GradientPath.InterpolationColors = Blend
  296.                 G.FillPath(GradientPath, Rect1)
  297.         End Select
  298.  
  299.         '| Finishes up the borders of the control
  300.        G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
  301.         G.DrawPath(Pens.Black, Border1)
  302.         G.DrawLine(New Pen(Pal.ColHigh), New Point(20, 2), New Point(20, Height - 2))
  303.         G.DrawLine(Pens.Black, New Point(21, 0), New Point(21, Height - 2))
  304.         G.DrawLine(New Pen(Pal.ColHigh), New Point(22, 0), New Point(22, Height - 2))
  305.  
  306.         '| Text rects/renders for the X and - buttons.
  307.        Dim TextRectX As New Rectangle(6, 1, Width, Height - 4)
  308.         Dim TextRectMin As New Rectangle(25, -20, Width, 5)
  309.         D.DrawTextWithShadow(G, TextRectX, "X", Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  310.         D.DrawTextWithShadow(G, TextRectMin, "_", Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
  311.  
  312.     End Sub
  313. End Class
  314. Public Class HadesButton : Inherits ThemedControl
  315.     Sub New()
  316.         MyBase.New()
  317.         Font = New Font("Trebuchet MS", 10.0F)
  318.     End Sub
  319.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  320.         Dim G As Graphics = e.Graphics
  321.         MyBase.OnPaint(e)
  322.         G.Clear(Me.Parent.BackColor)
  323.         G.SmoothingMode = SmoothingMode.HighQuality
  324.         '| Blob of variable declarations
  325.        Dim Rect1 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 2, Height - 2), 3)
  326.         Dim Border1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 3)
  327.         Dim Border2 As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 3)
  328.         Dim Blend As New ColorBlend
  329.         Dim GradientPath As New LinearGradientBrush(New Point(1, 1), New Point(1, Height - 2), Color.Black, Color.Black)
  330.         Dim DownColor As Color = Color.FromArgb(Pal.ColMed.R - 20, Pal.ColMed.R - 20, Pal.ColMed.R - 20)
  331.         '| Filles in the control
  332.        Select Case State
  333.             Case MouseState.None
  334.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  335.                 Blend.Colors = {Pal.ColHigh, Pal.ColDim, Pal.ColDim, Pal.ColDark}
  336.                 GradientPath.InterpolationColors = Blend
  337.                 G.FillPath(GradientPath, Rect1)
  338.             Case MouseState.Over
  339.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  340.                 Blend.Colors = {Pal.ColHighest, Pal.ColMed, Pal.ColMed, Pal.ColDim}
  341.                 GradientPath.InterpolationColors = Blend
  342.                 G.FillPath(GradientPath, Rect1)
  343.             Case MouseState.Down
  344.                 Blend.Positions = {0, 1 / 3, 2 / 3, 1}
  345.                 Blend.Colors = {Pal.ColMed, DownColor, DownColor, DownColor}
  346.                 GradientPath.InterpolationColors = Blend
  347.                 G.FillPath(GradientPath, Rect1)
  348.         End Select
  349.  
  350.         '| Finishes up the borders of the control
  351.        G.DrawPath(New Pen(New SolidBrush(Pal.ColHighest)), Border2)
  352.         G.DrawPath(Pens.Black, Border1)
  353.  
  354.         '| And again, the text drawing.
  355.        Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
  356.         D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
  357.     End Sub
  358. End Class
  359. Public Class HadesTextbox : Inherits ThemedControl
  360. #Region "Textbox Data"
  361.     Private WithEvents TxtBox As New TextBox
  362.     Private TempSize As Size
  363.     Public Property MaxCharacters As Integer
  364.     Public Property Multiline() As Boolean
  365.         Get
  366.             Return TxtBox.Multiline
  367.         End Get
  368.         Set(ByVal v As Boolean)
  369.             TxtBox.Multiline = v
  370.             Invalidate()
  371.         End Set
  372.     End Property
  373.     Public Property TextAlign As HorizontalAlignment
  374.     Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
  375.         MyBase.OnSizeChanged(e)
  376.         If Not Size.Height = 21 Then
  377.             TempSize = Size
  378.         End If
  379.         If Not IsNothing(TxtBox) Then
  380.             TxtBox.Size = New Size(Width - 8, Height - 8)
  381.         End If
  382.  
  383.         Invalidate()
  384.     End Sub
  385.     Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
  386.         MyBase.OnFontChanged(e)
  387.         If Not IsNothing(TxtBox) Then
  388.             TxtBox.Font = Font
  389.         End If
  390.  
  391.     End Sub
  392.     Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
  393.         MyBase.OnGotFocus(e)
  394.         TxtBox.Focus()
  395.     End Sub
  396.     Private Sub TextChngTxtBox() Handles TxtBox.TextChanged
  397.         Text = TxtBox.Text
  398.     End Sub
  399.     Private Sub TextChng() Handles MyBase.TextChanged
  400.         TxtBox.Text = Text
  401.     End Sub
  402.     Public Sub SetReadOnly(ByVal Bool As Boolean)
  403.         TxtBox.ReadOnly = Bool
  404.     End Sub
  405.     Private Sub SetupTextbox()
  406.  
  407.         TxtBox.MaxLength = 30000
  408.         TxtBox.Size = New Size(New Point(50, 21))
  409.         TxtBox.Multiline = True
  410.         TxtBox.BackColor = Pal.ColDark
  411.         TxtBox.ForeColor = Color.FromArgb(144, 144, 144)
  412.         TxtBox.Text = String.Empty
  413.         TxtBox.TextAlign = HorizontalAlignment.Left
  414.         TxtBox.BorderStyle = BorderStyle.None
  415.         TxtBox.Location = New Point(6, 4)
  416.         TxtBox.Font = Font
  417.         TxtBox.Size = New Size(Width - 11, Height - 8)
  418.     End Sub
  419. #End Region
  420.     Sub New()
  421.         MyBase.New()
  422.         Font = New Font("Trebuchet MS", 8.5F)
  423.         Multiline = False
  424.         TextAlign = HorizontalAlignment.Left
  425.         SetupTextbox()
  426.         Controls.Add(TxtBox)
  427.     End Sub
  428.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  429.         Dim G As Graphics = e.Graphics
  430.         MyBase.OnPaint(e)
  431.         G.Clear(Pal.ColDark)
  432.         If Not TxtBox.Multiline Then
  433.             TxtBox.Location = New Point(4, TxtBox.Top)
  434.             If (TxtBox.Width + TxtBox.Left) > Width - 3 And TxtBox.Width > 5 Then
  435.                 TxtBox.Width -= 1
  436.             End If
  437.             Size = New Size(New Point(Width, 23))
  438.         Else
  439.             TxtBox.Location = New Point(4, TxtBox.Top)
  440.             Size = TempSize
  441.         End If
  442.         G.SmoothingMode = SmoothingMode.HighQuality
  443.  
  444.  
  445.         Dim PathHiglight As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, Height - 2), 5)
  446.         Dim PathOutline As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 5)
  447.         G.DrawPath(New Pen(Pal.ColHighest), PathHiglight)
  448.         G.DrawPath(New Pen(Color.Black, 2), PathOutline)
  449.     End Sub
  450. End Class
  451. Public Class HadesCheckbox : Inherits ThemedControl
  452.     Public Property Checked As Boolean
  453.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  454.         MyBase.OnMouseDown(e)
  455.         Checked = Not Checked
  456.     End Sub
  457.     Sub New()
  458.         MyBase.New()
  459.         Font = New Font("Trebuchet MS", 10.0F)
  460.     End Sub
  461.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  462.         Dim G As Graphics = e.Graphics
  463.         MyBase.OnPaint(e)
  464.         G.Clear(Me.Parent.BackColor)
  465.         Height = 18
  466.         G.SmoothingMode = SmoothingMode.HighQuality
  467.  
  468.         '| Checkbox base
  469.        Dim HighlightPath As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Height, Height - 2), 4)
  470.         Dim OutlinePath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Height, Height - 2), 4)
  471.  
  472.         '| The Check
  473.        If Checked Then
  474.             Dim FillGradient As New LinearGradientBrush(New Point(2, 2), New Point(2, Height - 3), Pal.ColHighest, Pal.ColDark)
  475.             G.FillPath(FillGradient, OutlinePath)
  476.         Else
  477.             G.FillPath(New SolidBrush(Pal.ColDark), OutlinePath)
  478.         End If
  479.         G.DrawPath(New Pen(Pal.ColHighest), HighlightPath)
  480.         G.DrawPath(New Pen(Color.Black, 1), OutlinePath)
  481.         D.DrawTextWithShadow(G, New Rectangle(25, 0, Width - 25, Height - 2), Text, Font, HorizontalAlignment.Left, Color.WhiteSmoke, Color.Black)
  482.     End Sub
  483. End Class
  484. Public Class HadesRadiobutton : Inherits ThemedControl
  485.     Public Property Checked As Boolean
  486.     Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  487.         MyBase.OnMouseDown(e)
  488.         For Each Cont As Control In Parent.Controls
  489.             If TypeOf Cont Is HadesRadiobutton Then
  490.                 DirectCast(Cont, HadesRadiobutton).Checked = False
  491.                 Cont.Invalidate()
  492.             End If
  493.         Next
  494.         Checked = True
  495.     End Sub
  496.     Sub New()
  497.         MyBase.New()
  498.         Font = New Font("Trebuchet MS", 10.0F)
  499.     End Sub
  500.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  501.         Dim G As Graphics = e.Graphics
  502.         MyBase.OnPaint(e)
  503.         G.Clear(Me.Parent.BackColor)
  504.         Height = 18
  505.         G.SmoothingMode = SmoothingMode.HighQuality
  506.  
  507.         '| The Check
  508.        If Checked Then
  509.             Dim FillGradient As New LinearGradientBrush(New Point(2, 2), New Point(2, Height - 3), Pal.ColHighest, Pal.ColDark)
  510.             G.FillEllipse(FillGradient, New Rectangle(0, 0, Height, Height - 2))
  511.         Else
  512.             G.FillEllipse(New SolidBrush(Pal.ColDark), New Rectangle(0, 0, Height, Height - 2))
  513.         End If
  514.         '| Radiobutton base
  515.        G.DrawEllipse(New Pen(Pal.ColHighest), New Rectangle(0, 1, Height, Height - 2))
  516.         G.DrawEllipse(New Pen(Color.Black, 1), New Rectangle(0, 0, Height, Height - 2))
  517.         D.DrawTextWithShadow(G, New Rectangle(25, 0, Width - 25, Height - 2), Text, Font, HorizontalAlignment.Left, Color.WhiteSmoke, Color.Black)
  518.     End Sub
  519. End Class
  520. Public Class HadesGroupbox : Inherits ThemedContainer
  521.     Public Property TextAlignment As HorizontalAlignment = HorizontalAlignment.Left
  522.  
  523.     Sub New()
  524.         MyBase.New()
  525.         TopGrip = 21
  526.         BackColor = Pal.ColDark
  527.         Drag = False
  528.     End Sub
  529.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  530.         Dim G As Graphics = e.Graphics
  531.         MyBase.OnPaint(e)
  532.         G.Clear(Me.Parent.BackColor)
  533.         G.SmoothingMode = SmoothingMode.HighQuality
  534.         Dim DR As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
  535.         Dim DR2 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip - 1), 5)
  536.         Dim DR3 As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, TopGrip / 2 + 1), 5)
  537.  
  538.         Dim BGRect As New Rectangle(0, TopGrip, Width - 1, Height - TopGrip)
  539.         Dim LGB1 As New LinearGradientBrush(New Point(0, 0), New Point(0, TopGrip), Pal.ColMed, Pal.ColDark)
  540.         Dim LGB2 As New LinearGradientBrush(New Point(0, -(TopGrip * 6)), New Point(0, TopGrip), Color.WhiteSmoke, Color.Transparent)
  541.         Dim HTB As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
  542.  
  543.         G.FillPath(LGB1, DR2)
  544.         G.FillPath(HTB, DR2)
  545.         G.FillPath(New SolidBrush(Color.FromArgb(100, Pal.ColDark.R, Pal.ColDark.R, Pal.ColDark.R)), DR2)
  546.         G.FillPath(LGB2, DR3)
  547.         G.FillRectangle(New SolidBrush(Pal.ColDark), BGRect)
  548.         G.DrawLine(Pens.Black, New Point(0, TopGrip), New Point(Width - 1, TopGrip))
  549.         G.DrawPath(Pens.Black, DR)
  550.         D.DrawTextWithShadow(G, New Rectangle(2, 0, Width - 3, TopGrip - 1), Text, Font, TextAlignment, Color.WhiteSmoke, Color.Black)
  551.  
  552.     End Sub
  553. End Class
  554. Public Class HadesNumericUD : Inherits ThemedControl
  555.     Private WithEvents TxtBox As New HadesTextbox
  556.     Private WithEvents BtnUp As New HadesButton
  557.     Private WithEvents BtnDown As New HadesButton
  558.     Public Property ButtonChange As Integer = 1
  559.     Public Property Minimum As Integer = 1
  560.     Public Property Maximum As Integer = 100
  561.  
  562.     '| Used the MouseDown event because it doesn't use a delay like the click one does.
  563.    Protected Sub BtnUp_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnUp.MouseDown
  564.         Value = Value + ButtonChange
  565.     End Sub
  566.     Protected Sub BtnDown_Down(ByVal Sender As Object, ByVal e As System.EventArgs) Handles BtnDown.MouseDown
  567.         Value = Value - ButtonChange
  568.     End Sub
  569.  
  570.     Public Property Value() As Integer
  571.         Get
  572.             Dim Ret As Integer = 0
  573.             Try : Ret = CInt(TxtBox.Text) : Catch ex As Exception : End Try
  574.             Return Ret
  575.         End Get
  576.         Set(ByVal val As Integer)
  577.             If val <= Maximum And val >= Minimum Then
  578.                 TxtBox.Text = val
  579.                 Invalidate()
  580.             End If
  581.         End Set
  582.     End Property
  583.     Sub New()
  584.         MyBase.New()
  585.         Size = New Point(300, 300)
  586.         Font = New Font("Trebuchet MS", 10.0F)
  587.         TxtBox.Text = 0
  588.         Controls.Add(TxtBox)
  589.         Controls.Add(BtnUp)
  590.         Controls.Add(BtnDown)
  591.     End Sub
  592.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  593.         Dim G As Graphics = e.Graphics
  594.         MyBase.OnPaint(e)
  595.         G.Clear(Me.Parent.BackColor)
  596.         Height = 30
  597.         BtnUp.Size = New Size(15, 15)
  598.         BtnUp.Location = New Point(Size.Width - BtnUp.Width, 0)
  599.         BtnUp.Font = New Font("Trebuchet MS", 10.0F)
  600.         BtnUp.Text = "ᴧ"
  601.         BtnDown.Size = New Size(15, 15)
  602.         BtnDown.Location = New Point(Size.Width - BtnUp.Width, BtnUp.Size.Height)
  603.         BtnDown.Font = New Font("Trebuchet MS", 10.0F, FontStyle.Bold)
  604.         BtnDown.Text = "v"
  605.         TxtBox.Location = New Point(0, 0)
  606.         TxtBox.SetReadOnly(True)
  607.         TxtBox.Multiline = True
  608.         TxtBox.Height = 30
  609.         TxtBox.Width = BtnUp.Location.X - 2
  610.     End Sub
  611. End Class
  612. Public Class HadesTabControl : Inherits ThemedTabControl
  613.     Sub New()
  614.         MyBase.New()
  615.         SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
  616.         ItemSize = New Size(0, 25)
  617.         Padding = New Size(20, 0)
  618.         Alignment = TabAlignment.Top
  619.         Font = New Font("Trebuchet MS", 10.0F)
  620.     End Sub
  621.  
  622.     '| This in entirety is a clusterfuck... I'm ashamed to have even made this
  623.    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
  624.         Dim G As Graphics = e.Graphics
  625.         MyBase.OnPaint(e)
  626.         G.Clear(Me.Parent.BackColor)
  627.         G.SmoothingMode = SmoothingMode.HighQuality
  628.         Dim FontColor As New Color
  629.         Dim TextureBrush As New HatchBrush(HatchStyle.Trellis, Pal.ColDark, Color.Transparent)
  630.         G.FillRectangle(New SolidBrush(Pal.ColDim), New Rectangle(0, 0, Width, Height))
  631.         G.FillRectangle(TextureBrush, New Rectangle(0, 0, Width, Height))
  632.         For i = 0 To TabCount - 1
  633.             Dim TabRect As Rectangle = GetTabRect(i)
  634.             Dim TabPath As New GraphicsPath
  635.             With TabPath
  636.                 .AddLine(New Point(TabRect.X + 2, TabRect.Y + TabRect.Height), New Point(TabRect.X + 10, TabRect.Y))
  637.                 .AddLine(New Point(TabRect.X + 10, TabRect.Y), New Point(TabRect.X + TabRect.Width - 10, TabRect.Y))
  638.                 .AddLine(New Point(TabRect.X + TabRect.Width - 10, TabRect.Y), New Point(TabRect.X + TabRect.Width - 2, TabRect.Y + TabRect.Height))
  639.                 .AddLine(New Point(TabRect.X + TabRect.Width - 2, TabRect.Y + TabRect.Height), New Point(TabRect.X, TabRect.Y + TabRect.Height))
  640.             End With
  641.             TabPath.CloseFigure()
  642.  
  643.             Dim Offset1 As New Matrix()
  644.             Offset1.Translate(0, 1)
  645.             Dim OffsetNeg1 As New Matrix()
  646.             OffsetNeg1.Translate(0, -1)
  647.             Dim Offset5 As New Matrix()
  648.             Offset5.Translate(0, 5)
  649.  
  650.             If i = SelectedIndex Then
  651.                 G.FillPath(New SolidBrush(Pal.ColHighest), TabPath)
  652.                 TabPath.Transform(Offset1)
  653.                 TabPath.Transform(Offset1)
  654.                 G.FillPath(New SolidBrush(Pal.ColDim), TabPath)
  655.                 Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TabRect.Height), New Point(0, TabRect.Height + 4), Pal.ColHighest, Color.Transparent)
  656.  
  657.                 G.FillPath(TopGradient1, TabPath)
  658.                 Offset1.Translate(0, -3)
  659.                 FontColor = Color.FromArgb(255, 255, 255)
  660.                 Dim titleX As Integer = (TabRect.Location.X + TabRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2) + 2
  661.                 Dim titleY As Integer = (TabRect.Location.Y + TabRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)
  662.                 G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))
  663.             Else
  664.                 TabPath.Transform(Offset5)
  665.                 G.FillPath(New SolidBrush(Pal.ColHigh), TabPath)
  666.                 TabPath.Transform(Offset1)
  667.                 G.FillPath(New SolidBrush(Pal.ColDark), TabPath)
  668.                 FontColor = Color.FromArgb(155, 155, 155)
  669.                 Dim TopGradient1 As New LinearGradientBrush(New Point(0, -TabRect.Height), New Point(0, TabRect.Height + 4), Color.Transparent, Color.FromArgb(11, 11, 11))
  670.  
  671.                 G.FillPath(TopGradient1, TabPath)
  672.                 Offset1.Translate(0, -2)
  673.                 Dim titleX As Integer = (TabRect.Location.X + TabRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2) + 3
  674.                 Dim titleY As Integer = (TabRect.Location.Y + TabRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2) + 3
  675.                 G.DrawString(TabPages(i).Text, Font, New SolidBrush(FontColor), New Point(titleX, titleY))
  676.             End If
  677.  
  678.             Offset1.Scale(1, 1.05)
  679.             TabPath.Transform(Offset1)
  680.             TabPath.Transform(OffsetNeg1)
  681.             G.DrawPath(Pens.Black, TabPath)
  682.  
  683.             Try : TabPages(i).BackColor = Pal.ColDark : Catch : End Try
  684.         Next
  685.         G.FillPath(New SolidBrush(Pal.ColDark), D.RoundedTopRect(New Rectangle(0, 25, Width - 1, Height - 26), 5))
  686.         G.DrawPath(Pens.Black, D.RoundedTopRect(New Rectangle(0, 25, Width - 1, Height - 26), 5))    
  687.     End Sub
  688. End Class
  689. #End Region
  690. '|===========================================================|
  691. #Region "Theme Utility Stuff"
  692. Public Class Palette
  693.     Public ColHighest As Color
  694.     Public ColHigh As Color
  695.     Public ColMed As Color
  696.     Public ColDim As Color
  697.     Public ColDark As Color
  698. End Class
  699. Public Enum MouseState As Byte
  700.     None = 0
  701.     Over = 1
  702.     Down = 2
  703.     Block = 3
  704. End Enum
  705. Public Enum GradientAlignment As Byte
  706.     Vertical = 0
  707.     Horizontal = 1
  708. End Enum
  709. Public Class DrawUtils
  710.     Public Sub FillGradientBeam(ByVal g As Graphics, ByVal Col1 As Color, ByVal Col2 As Color, ByVal rect As Rectangle, ByVal align As GradientAlignment)
  711.         Dim stored As SmoothingMode = g.SmoothingMode
  712.         Dim Blend As New ColorBlend
  713.         g.SmoothingMode = SmoothingMode.HighQuality
  714.         Select Case align
  715.             Case GradientAlignment.Vertical
  716.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X + rect.Width - 1, rect.Y), Color.Black, Color.Black)
  717.                 Blend.Positions = {0, 1 / 2, 1}
  718.                 Blend.Colors = {Col1, Col2, Col1}
  719.                 PathGradient.InterpolationColors = Blend
  720.                 g.FillRectangle(PathGradient, rect)
  721.             Case GradientAlignment.Horizontal
  722.                 Dim PathGradient As New LinearGradientBrush(New Point(rect.X, rect.Y), New Point(rect.X, rect.Y + rect.Height), Color.Black, Color.Black)
  723.                 Blend.Positions = {0, 1 / 2, 1}
  724.                 Blend.Colors = {Col1, Col2, Col1}
  725.                 PathGradient.InterpolationColors = Blend
  726.                 PathGradient.RotateTransform(0)
  727.                 g.FillRectangle(PathGradient, rect)
  728.         End Select
  729.         g.SmoothingMode = stored
  730.     End Sub
  731.     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)
  732.         DrawText(G, New Rectangle(ContRect.X, ContRect.Y + 2, ContRect.Width + 1, ContRect.Height + 2), Text, TFont, TAlign, BColor)
  733.         DrawText(G, ContRect, Text, TFont, TAlign, TColor)
  734.     End Sub
  735.     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)
  736.         If String.IsNullOrEmpty(Text) Then Return
  737.         Dim TextSize As Size = G.MeasureString(Text, TFont).ToSize
  738.         Dim CenteredY As Integer = ContRect.Height \ 2 - TextSize.Height \ 2
  739.         Select Case TAlign
  740.             Case HorizontalAlignment.Left
  741.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X, CenteredY)
  742.             Case HorizontalAlignment.Right
  743.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width - TextSize.Width - 5, CenteredY)
  744.             Case HorizontalAlignment.Center
  745.                 G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.Width \ 2 - TextSize.Width \ 2, CenteredY)
  746.         End Select
  747.     End Sub
  748.     Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  749.         Dim Path As New GraphicsPath
  750.         Dim ArcRectangleWidth As Integer = Curve * 2
  751.         With Path
  752.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  753.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  754.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
  755.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
  756.             .AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
  757.         End With
  758.         Return Path
  759.     End Function
  760.     Public Function RoundedTopRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
  761.         Dim Path As GraphicsPath = New GraphicsPath()
  762.         Dim ArcRectangleWidth As Integer = Curve * 2
  763.         With Path
  764.             .AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
  765.             .AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
  766.             .AddLine(New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + ArcRectangleWidth), New Point(Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height))
  767.             .AddLine(New Point(Rectangle.X, Rectangle.Height + Rectangle.Y), New Point(Rectangle.X, Rectangle.Y + Curve))
  768.         End With
  769.         Return Path
  770.     End Function
  771. End Class
  772. #End Region
Advertisement
Add Comment
Please, Sign In to add comment