Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D
- '|===========================================================|
- '|===| Slice Theme (Re-creation)
- '| Creator: LordPankake
- '| HF Account: http://www.hackforums.net/member.php?action=profile&uid=1828119
- '| Created: 8/5/2014, Last edited: 8/13/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(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 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
- ' ItemSize = New Size(0, 25)
- ' Padding = New Size(20, 0)
- Alignment = TabAlignment.Top
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
- 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 And Drag Then
- If New Rectangle(0, 0, Width, TopGrip).Contains(e.Location) Then
- TopCap = True : MouseP = e.Location
- ElseIf 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
- If Drag Then
- TopCap = False
- SizeCap = False
- End If
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- If Drag Then
- If TopCap Then
- Parent.Location = MousePosition - MouseP
- End If
- If SizeCap Then
- MouseP = e.Location
- Parent.Size = New Size(MouseP)
- Invalidate()
- End If
- 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 SliceForm : Inherits ThemedContainer
- Public Property SolidTop As Boolean
- Sub New()
- MyBase.New()
- MinimumSize = New Size(305, 150)
- Dock = DockStyle.Fill
- TopGrip = 27
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
- Dim G As Graphics = e.Graphics
- MyBase.OnPaint(e)
- 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)
- '| Details behind the main shape
- Dim DrawRect As New Rectangle(140, 3, Width - 281, Height - 7)
- Dim DrawRectHatch As New HatchBrush(HatchStyle.DarkDownwardDiagonal, Color.Transparent, Pal.ColMed)
- D.FillGradientBeam(G, Color.FromArgb(Pal.ColDim.R + 4, Pal.ColDim.R + 4, Pal.ColDim.R + 4), Pal.ColDark, DrawRect, GradientAlignment.Vertical)
- G.FillRectangle(DrawRectHatch, DrawRect)
- G.FillRectangle(New SolidBrush(Color.FromArgb(80, 1, 1, 1)), DrawRect)
- D.FillGradientBeam(G, Pal.ColDark, Color.Transparent, New Rectangle(50, 3, Width - 101, Height - 7), GradientAlignment.Vertical)
- ' Behind details - glow
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(60, 150, 150, 150), New Rectangle(120, 3, Width - 241, TopGrip), GradientAlignment.Vertical)
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, 3, Width - 241, 4), GradientAlignment.Vertical)
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, 16, Width - 241, 4), GradientAlignment.Vertical)
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(60, 150, 150, 150), New Rectangle(120, Height - 4 - TopGrip, Width - 241, TopGrip), GradientAlignment.Vertical)
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, Height - 8, Width - 241, 4), GradientAlignment.Vertical)
- D.FillGradientBeam(G, Color.FromArgb(20, 0, 0, 0), Color.FromArgb(20, 150, 150, 150), New Rectangle(120, Height - 21, Width - 241, 4), GradientAlignment.Vertical)
- G.DrawRectangle(Pens.Black, DrawRect)
- '| Creation of the main shape.
- Dim MainPath As New GraphicsPath
- Dim Curve As Integer = 6
- Dim ArcRectangleWidth As Integer = Curve * 2
- With MainPath
- .AddArc(New Rectangle(0, 0, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- .AddLine(New Point(140, 0), New Point(160, 20))
- .AddLine(New Point(Width - 161, 20), New Point(Width - 141, 0))
- .AddArc(New Rectangle(Width - ArcRectangleWidth - 1, 0, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- .AddArc(New Rectangle(Width - ArcRectangleWidth - 1, Height - ArcRectangleWidth - 1, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- .AddLine(New Point(Width - 141, Height - 1), New Point(Width - 161, Height - 21))
- .AddLine(New Point(160, Height - 21), New Point(140, Height - 1))
- .AddArc(New Rectangle(0, Height - ArcRectangleWidth - 1, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- .AddLine(New Point(0, Height - ArcRectangleWidth - 1), New Point(0, Curve + 0))
- End With
- '| Initial Fill
- G.FillPath(New SolidBrush(Pal.ColDim), MainPath)
- G.SmoothingMode = SmoothingMode.HighQuality
- '| Drawing the inner glow
- Dim GlowPath As GraphicsPath = MainPath
- Dim GlowBrush As PathGradientBrush
- GlowBrush = New PathGradientBrush(GlowPath)
- GlowBrush.CenterColor = Color.Transparent
- GlowBrush.SurroundColors = {Color.FromArgb(Pal.ColHigh.R - 15, Pal.ColHigh.R - 15, Pal.ColHigh.R - 15)}
- GlowBrush.FocusScales = New PointF(1.0F, 0.9F)
- GlowBrush.CenterPoint = New Point(Width / 2, Height / 2)
- G.FillPath(GlowBrush, GlowPath)
- '| Fixing the sides (from glow)
- G.SmoothingMode = SmoothingMode.None
- G.DrawLine(Pens.Black, New Point(0, 5), New Point(0, Height - 6))
- G.DrawLine(Pens.Black, New Point(Width - 1, 5), New Point(Width - 1, Height - 6))
- '| Drawing the text and final shape outline
- D.DrawTextWithShadow(G, New Rectangle(0, 1, 140, TopGrip), Text, Font, HorizontalAlignment.Center, Color.FromArgb(160, 160, 160), Color.Black)
- G.DrawPath(New Pen(Brushes.Black, 1), MainPath)
- End Sub
- End Class
- Public Class SliceTopButton : Inherits ThemedControl
- Public Property Action As BtnAction = BtnAction.Close
- Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down
- Invalidate()
- If e.X > Location.X Then
- End If
- If Action = BtnAction.Close Then
- FindForm.Close()
- Else
- FindForm.WindowState = FormWindowState.Minimized
- End If
- End Sub
- Enum BtnAction
- Close
- Minimize
- End Enum
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 12.0F, FontStyle.Bold)
- 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 BorderPath As GraphicsPath = D.RoundedTopRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
- Dim FillPath As GraphicsPath = D.RoundedTopRect(New Rectangle(1, 1, Width - 3, Height - 3), 5)
- '| Setup the rotate/shift
- Dim RotateMatrix As New Matrix
- RotateMatrix.RotateAt(180, New Point(Width / 2, Height / 2))
- RotateMatrix.Translate(1, 1)
- '| Transform the paths to rotate (Don't feel like duplicating draw method)
- BorderPath.Transform(RotateMatrix)
- FillPath.Transform(RotateMatrix)
- Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
- '| Handling colors/text based on the action
- If Action = BtnAction.Close Then
- Select Case State
- Case MouseState.None
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(200, 40, 40), Color.FromArgb(150, 40, 40))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 88, 66), Color.FromArgb(200, 80, 60))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- Case MouseState.Over
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 40, 40), Color.FromArgb(200, 40, 40))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(255, 133, 100), Color.FromArgb(200, 90, 75))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- Case MouseState.Down
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(188, 20, 20), Color.FromArgb(140, 5, 5))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(222, 44, 22), Color.FromArgb(180, 22, 5))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- End Select
- D.DrawTextWithShadow(G, TextRect, "X", Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
- Else
- Select Case State
- Case MouseState.None
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(40, 40, 200), Color.FromArgb(40, 40, 150))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(66, 88, 255), Color.FromArgb(60, 80, 200))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- Case MouseState.Over
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(40, 40, 255), Color.FromArgb(40, 40, 200))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(100, 133, 200), Color.FromArgb(75, 90, 170))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- Case MouseState.Down
- Dim FillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(20, 40, 188), Color.FromArgb(5, 20, 140))
- Dim DrawGB As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.FromArgb(22, 44, 222), Color.FromArgb(5, 22, 180))
- G.FillPath(FillGB, FillPath)
- G.DrawPath(New Pen(DrawGB), FillPath)
- End Select
- D.DrawTextWithShadow(G, TextRect, "-", Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
- End If
- G.DrawPath(Pens.Black, BorderPath)
- D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class SliceButton : 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
- Dim BorderPath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2)
- Dim FillPath As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2)
- Dim TextRect As New Rectangle(0, 0, Width, Height - 4)
- '| Handling colors/text based on the action
- Select Case State
- Case MouseState.None
- Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColMed, Pal.ColDim)
- G.FillPath(BtnBrush, FillPath)
- G.DrawPath(New Pen(Pal.ColHigh), FillPath)
- D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(199, 199, 199), Color.Black)
- Case MouseState.Over
- Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColHigh, Pal.ColMed)
- G.FillPath(BtnBrush, FillPath)
- G.DrawPath(New Pen(Pal.ColHighest), FillPath)
- D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.WhiteSmoke, Color.Black)
- Case MouseState.Down
- Dim BtnBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Pal.ColDim, Pal.ColDark)
- G.FillPath(BtnBrush, FillPath)
- G.DrawPath(New Pen(Pal.ColMed), FillPath)
- D.DrawTextWithShadow(G, TextRect, Text, Font, HorizontalAlignment.Center, Color.FromArgb(144, 144, 144), Color.Black)
- End Select
- G.DrawPath(Pens.Black, BorderPath)
- End Sub
- End Class
- Public Class SliceTextbox : Inherits ThemedControl
- #Region "Textbox Data"
- Private WithEvents TxtBox As New TextBox
- Private TempSize As Size
- Public Property TxtReadOnly As Boolean
- 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
- Private Sub SetupTextbox()
- TxtBox.MaxLength = 30000
- TxtBox.Size = New Size(New Point(50, 21))
- TxtBox.Multiline = True
- TxtBox.BackColor = Pal.ColMed
- TxtBox.ForeColor = Color.FromArgb(199, 199, 199)
- TxtBox.Text = String.Empty
- TxtBox.TextAlign = HorizontalAlignment.Left
- TxtBox.BorderStyle = BorderStyle.None
- TxtBox.Location = New Point(4, 4)
- TxtBox.Font = Font
- TxtBox.Size = New Size(Width - 8, Height - 8)
- End Sub
- #End Region
- Sub New()
- MyBase.New()
- Font = New Font("Trebuchet MS", 8.5F)
- TxtReadOnly = False
- 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(Me.Parent.BackColor)
- If Not TxtBox.Multiline Then
- TxtBox.Location = New Point(6, 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, 21))
- Else
- TxtBox.Location = New Point(3, TxtBox.Top)
- Size = TempSize
- End If
- G.SmoothingMode = SmoothingMode.HighQuality
- 'Color.FromArgb(Pal.ColMed.R - 10, Pal.ColMed.R - 10, Pal.ColMed.R - 10) instead of ColDark
- G.FillPath(New SolidBrush(Pal.ColMed), D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2))
- G.DrawPath(New Pen(Pal.ColHigh), D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 2))
- G.DrawPath(New Pen(Pal.ColDark), D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 2))
- End Sub
- End Class
- Public Class SliceCheckbox : 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 = 21
- G.SmoothingMode = SmoothingMode.HighQuality
- Dim BorderPath As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Height - 1, Height - 1), 3)
- Dim FillPath As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Height - 3, Height - 3), 3)
- If Checked Then
- G.FillPath(New SolidBrush(Pal.ColHigh), FillPath)
- G.DrawPath(New Pen(Pal.ColHighest), FillPath)
- Else
- G.FillPath(New SolidBrush(Pal.ColMed), FillPath)
- G.DrawPath(New Pen(Pal.ColHigh), FillPath)
- End If
- G.DrawPath(Pens.Black, BorderPath)
- D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Height - 4, Height - 2), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class SliceRadiobutton : 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 SliceRadiobutton Then
- DirectCast(Cont, SliceRadiobutton).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 = 21
- G.SmoothingMode = SmoothingMode.HighQuality
- If Checked Then
- G.FillEllipse(New SolidBrush(Pal.ColHigh), New Rectangle(1, 1, Height - 3, Height - 3))
- G.DrawEllipse(New Pen(Pal.ColHighest), New Rectangle(1, 1, Height - 3, Height - 3))
- Else
- G.FillEllipse(New SolidBrush(Pal.ColMed), New Rectangle(1, 1, Height - 3, Height - 3))
- G.DrawEllipse(New Pen(Pal.ColHigh), New Rectangle(1, 1, Height - 3, Height - 3))
- End If
- G.DrawEllipse(Pens.Black, New Rectangle(0, 0, Height - 1, Height - 1))
- D.DrawTextWithShadow(G, New Rectangle(Height + 3, 0, Height - 4, Height - 2), Text, Font, HorizontalAlignment.Left, Color.FromArgb(199, 199, 199), Color.Black)
- End Sub
- End Class
- Public Class SliceGroupbox : Inherits ThemedContainer
- Sub New()
- MyBase.New()
- 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 BorderPath1 As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, Height - 1), 5)
- Dim BorderPath2 As GraphicsPath = D.RoundRect(New Rectangle(1, 1, Width - 3, Height - 3), 5)
- G.DrawPath(New Pen(Pal.ColHigh), BorderPath2)
- G.DrawPath(New Pen(Pal.ColDark), BorderPath1)
- End Sub
- End Class
- Public Class SliceTabControl : Inherits ThemedTabControl
- Sub New()
- MyBase.New()
- ItemSize = New Size(0, 60)
- Padding = New Size(20, 0)
- 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
- 'Idea, draw the entire bar (roundRect) and draw the 'down' state if the index is the selected one. All the sparator lines will be drawn regardless
- Dim barheight As Integer = 50
- Dim MainBar As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, barheight), 5)
- Dim MainBarHighlight As GraphicsPath = D.RoundRect(New Rectangle(0, 1, Width - 1, barheight - 2), 5)
- Dim MainBarSub As GraphicsPath = D.RoundRect(New Rectangle(0, 0, Width - 1, barheight + 6), 5)
- Dim MainBarFillGB As New LinearGradientBrush(New Point(0, 0), New Point(0, barheight), Pal.ColHighest, Pal.ColHigh)
- Dim MainBarOutlineGB As New LinearGradientBrush(New Point(0, 0), New Point(0, barheight), Pal.ColDark, Color.Black)
- G.FillPath(New SolidBrush(Color.FromArgb(Pal.ColHigh.R - 11, Pal.ColHigh.R - 11, Pal.ColHigh.R - 11)), MainBarSub)
- G.FillPath(MainBarFillGB, MainBar)
- G.DrawPath(New Pen(Pal.ColHighest), MainBarHighlight)
- G.DrawPath(New Pen(MainBarOutlineGB), MainBar)
- G.DrawPath(New Pen(MainBarOutlineGB), MainBarSub)
- For i = 0 To TabCount - 1
- Dim TabRect As Rectangle = GetTabRect(i)
- Dim LineX As Integer = TabRect.X + TabRect.Width - 1
- If i = SelectedIndex Then
- G.FillRectangle(New SolidBrush(Me.Parent.BackColor), New Rectangle(TabRect.X - 1, -5, TabRect.Width + 1, TabRect.Height + 10))
- G.FillRectangle(New SolidBrush(Pal.ColHighest), New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight))
- D.FillGradientBeam(G, Color.FromArgb(50, 200, 200, 200), Color.Transparent, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight), GradientAlignment.Horizontal)
- G.DrawRectangle(Pens.Black, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight))
- G.DrawLine(Pens.Black, New Point(LineX + 1, 0), New Point(LineX + 1, barheight))
- D.DrawTextWithShadow(G, New Rectangle(TabRect.X - 1, 10, TabRect.Width + 1, barheight + 10), TabPages(i).Text, Font, HorizontalAlignment.Center, Color.WhiteSmoke, Color.Black)
- Else
- G.DrawLine(Pens.Black, New Point(LineX, 0), New Point(LineX, barheight))
- D.DrawTextWithShadow(G, New Rectangle(TabRect.X - 1, 5, TabRect.Width + 1, barheight), TabPages(i).Text, Font, HorizontalAlignment.Center, Color.FromArgb(155, 155, 155), Color.Black)
- End If
- Try : TabPages(i).BackColor = Me.Parent.BackColor : Catch : End Try
- Next
- 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.X + ContRect.Width - TextSize.Width - 5, CenteredY)
- Case HorizontalAlignment.Center
- G.DrawString(Text, TFont, New SolidBrush(TColor), ContRect.X + 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