Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Thanks to Aeonhack and other
- 'You need paste here ThemeBase 1.5.4, then delete first two lines
- 'VERSION 1.0, 30.07.2015
- Imports System.Drawing.Drawing2D
- Imports System.ComponentModel
- Class MetroButton
- Inherits ThemeControl154
- Sub New()
- Height = 45
- Width = 120
- SetColor("ButtonColor", Color.Black)
- SetColor("TextColor", Color.White)
- Font = New Font("Segoe UI", 12)
- End Sub
- Dim buttonc As Color
- Dim textc As Brush
- Protected Overrides Sub ColorHook()
- buttonc = GetColor("ButtonColor")
- textc = GetBrush("TextColor")
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(buttonc)
- Select Case State
- Case MouseState.None
- DrawText(textc, HorizontalAlignment.Center, 0, 0)
- Case MouseState.Over
- G.FillRectangle(New SolidBrush(Color.FromArgb(25, Color.Black)), New Rectangle(0, 0, Width, Height))
- DrawText(textc, HorizontalAlignment.Center, 0, 0)
- Case MouseState.Down
- G.FillRectangle(New SolidBrush(Color.FromArgb(50, Color.Black)), New Rectangle(0, 0, Width, Height))
- DrawText(textc, HorizontalAlignment.Center, 0, 0)
- End Select
- End Sub
- End Class
- Class MetroTheme
- Inherits ThemeContainer154
- Sub New()
- TransparencyKey = Color.Fuchsia
- BackColor = Color.White
- Font = New Font("Segoe UI", 10)
- SetColor("BorderColor", Color.Black)
- SetColor("TextColor", Color.White)
- End Sub
- Dim Borderc As Color
- Dim Textc As Brush
- Protected Overrides Sub ColorHook()
- Borderc = GetColor("BorderColor")
- Textc = GetBrush("TextColor")
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(Borderc)
- G.FillRectangle(New SolidBrush(BackColor), New Rectangle(6, 36, Width - 13, Height - 43))
- G.DrawString(FindForm.Text, Font, Textc, New Point(30, 9))
- G.DrawIcon(FindForm.Icon, New Rectangle(6, 10, 16, 16))
- DrawCorners(Color.Fuchsia)
- End Sub
- End Class
- Class MetroProgressBar
- Inherits ThemeControl154
- Dim backgroundc As Color
- Dim progressc As Brush
- Dim borderc As Pen
- Private _Maximum As Integer = 100
- Public Property Maximum() As Integer
- Get
- Return _Maximum
- End Get
- Set(ByVal v As Integer)
- If v < 0 Then v = 0
- If v < _Value Then _Value = v
- _Maximum = v
- Invalidate()
- End Set
- End Property
- Private _Value As Integer
- Public Property Value() As Integer
- Get
- Return _Value
- End Get
- Set(ByVal v As Integer)
- If v > _Maximum Then v = _Maximum
- _Value = v
- Invalidate()
- End Set
- End Property
- Sub New()
- SetColor("ProgressColor", Color.Black)
- SetColor("BackgroundColor", Color.White)
- SetColor("BorderColor", Color.Black)
- End Sub
- Protected Overrides Sub ColorHook()
- backgroundc = GetColor("BackgroundColor")
- progressc = GetBrush("ProgressColor")
- borderc = GetPen("BorderColor")
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- G.FillRectangle(progressc, 0, 0, CInt(_Value / _Maximum * Width), Height)
- G.FillRectangle(progressc, New Rectangle(0, 0, CInt(_Value / _Maximum * Width), Height))
- DrawGradient(Color.FromArgb(0, Color.White), Color.FromArgb(0, Color.White), ClientRectangle)
- DrawBorders(borderc, ClientRectangle)
- End Sub
- End Class
- <DefaultEvent("TextChanged")>
- Class MetroTextBox
- Inherits ThemeControl154
- Private _TextAlign As HorizontalAlignment = HorizontalAlignment.Left
- Property TextAlign() As HorizontalAlignment
- Get
- Return _TextAlign
- End Get
- Set(ByVal value As HorizontalAlignment)
- _TextAlign = value
- If Base IsNot Nothing Then
- Base.TextAlign = value
- End If
- End Set
- End Property
- Private _MaxLength As Integer = 32767
- Property MaxLength() As Integer
- Get
- Return _MaxLength
- End Get
- Set(ByVal value As Integer)
- _MaxLength = value
- If Base IsNot Nothing Then
- Base.MaxLength = value
- End If
- End Set
- End Property
- Private _ReadOnly As Boolean
- Property [ReadOnly]() As Boolean
- Get
- Return _ReadOnly
- End Get
- Set(ByVal value As Boolean)
- _ReadOnly = value
- If Base IsNot Nothing Then
- Base.ReadOnly = value
- End If
- End Set
- End Property
- Private _UseSystemPasswordChar As Boolean
- Property UseSystemPasswordChar() As Boolean
- Get
- Return _UseSystemPasswordChar
- End Get
- Set(ByVal value As Boolean)
- _UseSystemPasswordChar = value
- If Base IsNot Nothing Then
- Base.UseSystemPasswordChar = value
- End If
- End Set
- End Property
- Private _Multiline As Boolean
- Property Multiline() As Boolean
- Get
- Return _Multiline
- End Get
- Set(ByVal value As Boolean)
- _Multiline = value
- If Base IsNot Nothing Then
- Base.Multiline = value
- If value Then
- LockHeight = 0
- Base.Height = Height - 11
- Else
- LockHeight = Base.Height + 11
- End If
- End If
- End Set
- End Property
- Overrides Property Text() As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- If Base IsNot Nothing Then
- Base.Text = value
- End If
- End Set
- End Property
- Overrides Property Font() As Font
- Get
- Return MyBase.Font
- End Get
- Set(ByVal value As Font)
- MyBase.Font = value
- If Base IsNot Nothing Then
- Base.Font = value
- Base.Location = New Point(3, 5)
- Base.Width = Width - 6
- If Not _Multiline Then
- LockHeight = Base.Height + 11
- End If
- End If
- End Set
- End Property
- Protected Overrides Sub OnCreation()
- If Not Controls.Contains(Base) Then
- Controls.Add(Base)
- End If
- End Sub
- Private Base As TextBox
- Sub New()
- Base = New TextBox
- Base.Font = Font
- Base.Text = Text
- Base.MaxLength = _MaxLength
- Base.Multiline = _Multiline
- Base.ReadOnly = _ReadOnly
- Base.UseSystemPasswordChar = _UseSystemPasswordChar
- Base.BorderStyle = BorderStyle.None
- Base.Location = New Point(4, 4)
- Base.Width = Width - 10
- If _Multiline Then
- Base.Height = Height - 11
- Else
- LockHeight = Base.Height + 11
- End If
- AddHandler Base.TextChanged, AddressOf OnBaseTextChanged
- AddHandler Base.KeyDown, AddressOf OnBaseKeyDown
- SetColor("TextColor", Color.Black)
- SetColor("BackgroundColor", Color.White)
- SetColor("BorderColor", Color.Black)
- End Sub
- Private backgroundc As Color
- Private borderc As Pen
- Private textc As Brush
- Protected Overrides Sub ColorHook()
- backgroundc = GetColor("BackgroundColor")
- borderc = GetPen("BorderColor")
- textc = GetBrush("TextColor")
- Base.BackColor = GetColor("BackgroundColor")
- Base.ForeColor = GetColor("TextColor")
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- DrawBorders(borderc)
- End Sub
- Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
- Text = Base.Text
- End Sub
- Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
- If e.Control AndAlso e.KeyCode = Keys.A Then
- Base.SelectAll()
- e.SuppressKeyPress = True
- End If
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- Base.Location = New Point(4, 5)
- Base.Width = Width - 8
- If _Multiline Then
- Base.Height = Height - 5
- End If
- MyBase.OnResize(e)
- End Sub
- End Class
- <DefaultEvent("CheckedChanged")>
- Class MetroCheckBox
- Inherits ThemeControl154
- Sub New()
- LockHeight = 20
- Width = 120
- SetColor("TextColor", Color.Black)
- SetColor("BackgroundColor", Color.White)
- SetColor("CheckColor", Color.Black)
- SetColor("BorderColor", Color.Black)
- SetColor("CheckBackgroundColor", Color.White)
- Font = New Font("Arial", 12)
- End Sub
- Private X As Integer
- Private textc As Color
- Private backgroundc As Color
- Private checkc As Brush
- Private borderc As Color
- Private checkbackgroundc As Color
- Protected Overrides Sub ColorHook()
- textc = GetColor("TextColor")
- backgroundc = GetColor("BackgroundColor")
- checkc = GetBrush("CheckColor")
- borderc = GetColor("BorderColor")
- checkbackgroundc = GetColor("CheckBackgroundColor")
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- X = e.Location.X
- Invalidate()
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- If _Checked Then
- G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
- G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
- Else
- G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
- G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
- End If
- If State = MouseState.Over And X < 15 Then
- G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
- G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
- ElseIf State = MouseState.Down And X < 15 Then
- G.FillRectangle(New SolidBrush(borderc), New Rectangle(0, 0, 20, 20))
- G.FillRectangle(New SolidBrush(checkbackgroundc), New Rectangle(1, 1, 20 - 2, 20 - 2))
- End If
- If _Checked Then G.DrawString("a", New Font("Marlett", 20), checkc, New Point(-7, -5))
- DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 25, 0)
- End Sub
- Private _Checked As Boolean
- Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- _Checked = Not _Checked
- RaiseEvent CheckedChanged(Me)
- MyBase.OnMouseDown(e)
- End Sub
- Event CheckedChanged(ByVal sender As Object)
- End Class
- <DefaultEvent("CheckedChanged")>
- Class MetroRadioButton
- Inherits ThemeControl154
- Sub New()
- LockHeight = 20
- SetColor("TextColor", Color.Black)
- SetColor("BackgroundColor", Color.White)
- SetColor("CheckColor", Color.Black)
- SetColor("BorderColor", Color.Black)
- Font = New Font("Segoe UI", 12)
- Width = 120
- End Sub
- Private X As Integer
- Private textc As Color
- Private backgroundc As Color
- Private checkc As Color
- Private borderc As Color
- Protected Overrides Sub ColorHook()
- textc = GetColor("TextColor")
- backgroundc = GetColor("BackgroundColor")
- checkc = GetColor("CheckColor")
- borderc = GetColor("BorderColor")
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- X = e.Location.X
- Invalidate()
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- G.SmoothingMode = SmoothingMode.HighQuality
- If _Checked Then
- G.DrawEllipse(New Pen(borderc), New Rectangle(New Point(0, 0), New Size(20, 20)))
- G.FillEllipse(New SolidBrush(checkc), New Rectangle(New Point(3, 3), New Size(14, 14)))
- Else
- G.DrawEllipse(New Pen(borderc), New Rectangle(New Point(0, 0), New Size(20, 20)))
- DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 22, 0)
- End If
- If _Checked Then DrawText(New SolidBrush(textc), HorizontalAlignment.Left, 22, 0)
- End Sub
- Private _Field As Integer = 21
- Property Field() As Integer
- Get
- Return _Field
- End Get
- Set(ByVal value As Integer)
- If value < 4 Then Return
- _Field = value
- LockHeight = value
- Invalidate()
- End Set
- End Property
- Private _Checked As Boolean
- Property Checked() As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal value As Boolean)
- _Checked = value
- InvalidateControls()
- RaiseEvent CheckedChanged(Me)
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- If Not _Checked Then Checked = True
- MyBase.OnMouseDown(e)
- End Sub
- Event CheckedChanged(ByVal sender As Object)
- Protected Overrides Sub OnCreation()
- InvalidateControls()
- End Sub
- Private Sub InvalidateControls()
- If Not IsHandleCreated OrElse Not _Checked Then Return
- For Each C As Control In Parent.Controls
- If C IsNot Me AndAlso TypeOf C Is MetroRadioButton Then
- DirectCast(C, MetroRadioButton).Checked = False
- End If
- Next
- End Sub
- End Class
- Class MetroGroupBox
- Inherits ThemeContainer154
- Sub New()
- ControlMode = True
- SetColor("BackgroundColor", Color.Black)
- SetColor("InsideBackgroundColor", Color.White)
- SetColor("TextColor", Color.White)
- End Sub
- Dim backgroundc As Color
- Dim insidebackgroundc As Color
- Dim textc As Brush
- Protected Overrides Sub ColorHook()
- backgroundc = GetColor("BackgroundColor")
- insidebackgroundc = GetColor("InsideBackgroundColor")
- textc = GetBrush("TextColor")
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- G.FillRectangle(New SolidBrush(insidebackgroundc), New Rectangle(1, 25, Width - 2, Height - 26))
- DrawText(textc, HorizontalAlignment.Left, 2, 0)
- End Sub
- End Class
- Class MetroControls
- Inherits ThemeControl154
- Private X As Integer
- Dim backgroundc As Color
- Dim edgec As Pen
- Dim iconsc As Color
- Dim glowc As SolidBrush
- Dim a, b, c As Integer
- Protected Overrides Sub ColorHook()
- iconsc = GetColor("IconsColor")
- backgroundc = GetColor("BackgroundColor")
- End Sub
- Sub New()
- IsAnimated = True
- SetColor("IconsColor", Color.White)
- SetColor("BackgroundColor", Color.Transparent)
- Me.Size = New Size(84, 18)
- Me.Anchor = AnchorStyles.Top Or AnchorStyles.Right
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- MyBase.OnMouseMove(e)
- X = e.X
- Invalidate()
- End Sub
- Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
- MyBase.OnClick(e)
- If X <= 22 Then
- FindForm.WindowState = FormWindowState.Minimized
- ElseIf X > 22 And X <= 46 Then
- If FindForm.WindowState = FormWindowState.Maximized Then FindForm.WindowState = FormWindowState.Normal Else FindForm.WindowState = FormWindowState.Maximized
- Else
- FindForm.Close()
- End If
- End Sub
- Protected Overrides Sub OnAnimation()
- MyBase.OnAnimation()
- Select Case State
- Case MouseState.Over
- If a < 24 And X <= 22 Then
- a += 4
- If b > 0 Then
- b -= 4
- End If
- If c > 0 Then
- c -= 4
- End If
- If b < 0 Then b = 0
- If c < 0 Then c = 0
- Invalidate()
- Application.DoEvents()
- End If
- If b < 24 And X > 22 And X <= 46 Then
- b += 4
- If a > 0 Then
- a -= 4
- End If
- If a < 0 Then a = 0
- If c > 0 Then
- c -= 4
- End If
- If c < 0 Then c = 0
- Invalidate()
- Application.DoEvents()
- End If
- If c < 32 And X > 46 Then
- c += 4
- If a > 0 Then
- a -= 4
- End If
- If b > 0 Then
- b -= 4
- End If
- If a < 0 Then a = 0
- If b < 0 Then b = 0
- Invalidate()
- Application.DoEvents()
- End If
- Case MouseState.None
- If a > 0 Then
- a -= 4
- End If
- If b > 0 Then
- b -= 4
- End If
- If c > 0 Then
- c -= 4
- End If
- If a < 0 Then a = 0
- If b < 0 Then b = 0
- If c < 0 Then c = 0
- Invalidate()
- Application.DoEvents()
- End Select
- End Sub
- Protected Overrides Sub PaintHook()
- G.Clear(backgroundc)
- Dim SB1 As New SolidBrush(Color.FromArgb(a, Color.Black))
- Dim SB1_ As New SolidBrush(Color.FromArgb(b, Color.Black))
- Dim SB2 As New SolidBrush(Color.FromArgb(c, Color.Black))
- Dim SB3 As New SolidBrush(Color.FromArgb(20, Color.Black))
- Select Case State
- Case MouseState.Down
- If X <= 22 Then
- a = 0
- G.FillRectangle(SB3, New Rectangle(0, 0, 21, 17))
- ElseIf X > 22 And X <= 46 Then
- b = 0
- G.FillRectangle(SB3, New Rectangle(23, 0, 22, 17))
- Else
- c = 0
- G.FillRectangle(SB3, New Rectangle(47, 0, 36, 17))
- End If
- Case Else
- If X <= 22 Then
- G.FillRectangle(SB1, New Rectangle(0, 0, 21, 17))
- ElseIf X > 22 And X <= 46 Then
- G.FillRectangle(SB1_, New Rectangle(23, 0, 22, 17))
- Else
- G.FillRectangle(SB2, New Rectangle(47, 0, 36, 17))
- End If
- End Select
- G.DrawString("0", New Font("Marlett", 8.25), GetBrush("IconsColor"), New Point(5, 4))
- If FindForm.WindowState <> FormWindowState.Maximized Then G.DrawString("1", New Font("Marlett", 8), GetBrush("IconsColor"), New Point(28, 4)) Else G.DrawString("2", New Font("Marlett", 8.25), GetBrush("IconsColor"), New Point(28, 4))
- G.DrawString("r", New Font("Marlett", 10), GetBrush("IconsColor"), New Point(56, 3))
- End Sub
- End Class
- Class MetroLabel
- Inherits Label
- Sub New()
- Font = New Font("Segoe UI", 12)
- ForeColor = Color.Black
- BackColor = Color.Transparent
- End Sub
- End Class
- Class MetroTabControl
- Inherits TabControl
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.ResizeRedraw Or
- ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True)
- ItemSize = New Size(0, 30)
- Font = New Font("Segoe UI", 8)
- End Sub
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- Dim G As Graphics = e.Graphics
- Dim borderc As New Pen(Color.Black)
- Dim fontc As New Color
- Dim fillRect As New Rectangle(2, ItemSize.Height + 2, Width - 6, Height - ItemSize.Height - 3)
- G.SmoothingMode = SmoothingMode.HighQuality
- G.Clear(Parent.BackColor)
- G.FillRectangle(Brushes.White, fillRect)
- G.DrawRectangle(borderc, fillRect)
- For i = 0 To TabCount - 1
- Dim mainRect As Rectangle = GetTabRect(i)
- If i = SelectedIndex Then
- G.FillRectangle(New SolidBrush(Color.White), mainRect)
- G.DrawRectangle(borderc, mainRect)
- G.DrawLine(New Pen(Color.Black), New Point(mainRect.X + 1, mainRect.Y), New Point(mainRect.X + mainRect.Width - 1, mainRect.Y))
- G.DrawLine(Pens.White, New Point(mainRect.X + 1, mainRect.Y + mainRect.Height), New Point(mainRect.X + mainRect.Width - 1, mainRect.Y + mainRect.Height))
- fontc = Color.Black
- Else
- G.FillRectangle(New SolidBrush(Color.White), mainRect)
- G.DrawRectangle(borderc, mainRect)
- fontc = Color.Black
- End If
- Dim titleX As Integer = (mainRect.Location.X + mainRect.Width / 2) - (G.MeasureString(TabPages(i).Text, Font).Width / 2)
- Dim titleY As Integer = (mainRect.Location.Y + mainRect.Height / 2) - (G.MeasureString(TabPages(i).Text, Font).Height / 2)
- G.DrawString(TabPages(i).Text, Font, New SolidBrush(fontc), New Point(titleX, titleY))
- Try : TabPages(i).BackColor = Color.White : Catch : End Try
- Next
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement