Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing.Drawing2D, System.ComponentModel, System.Windows.Forms
- Imports System.Drawing.Text
- ''' <summary>
- ''' Metro UI Theme
- ''' Creator: .NETGuard
- ''' Version: 1.0.0
- ''' Credit : Isynthesis
- ''' </summary>
- ''' <remarks></remarks>
- Module Helpers
- #Region " Variables"
- Friend G As Graphics, B As Bitmap
- Friend _FlatColor As Color = Color.FromArgb(35, 168, 109)
- Friend NearSF As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
- Friend CenterSF As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
- #End Region
- #Region " Functions"
- Public Function ImageToCode(ByVal Img As Bitmap) As String
- Return Convert.ToBase64String(DirectCast(System.ComponentModel.TypeDescriptor.GetConverter(Img).ConvertTo(Img, GetType(Byte())), Byte()))
- End Function
- Public Function CodeToImage(ByVal Code As String) As Image
- Return Image.FromStream(New System.IO.MemoryStream(Convert.FromBase64String(Code)))
- End Function
- Public Function FullRectangle(S As Size, Subtract As Boolean) As Rectangle
- If Subtract Then
- Return New Rectangle(0, 0, S.Width - 1, S.Height - 1)
- Else
- Return New Rectangle(0, 0, S.Width, S.Height)
- End If
- End Function
- Public Function GreyColor(G As UInteger) As Color
- Return Color.FromArgb(G, G, G)
- End Function
- Public Sub FillRoundRect(G As Graphics, R As Rectangle, Curve As Integer, C As Color)
- Using B As New SolidBrush(C)
- G.FillPie(B, R.X, R.Y, Curve, Curve, 180, 90)
- G.FillPie(B, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
- G.FillPie(B, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
- G.FillPie(B, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
- G.FillRectangle(B, CInt(R.X + Curve / 2), R.Y, R.Width - Curve, CInt(Curve / 2))
- G.FillRectangle(B, R.X, CInt(R.Y + Curve / 2), R.Width, R.Height - Curve)
- G.FillRectangle(B, CInt(R.X + Curve / 2), CInt(R.Y + R.Height - Curve / 2), R.Width - Curve, CInt(Curve / 2))
- End Using
- End Sub
- Public Sub DrawRoundRect(G As Graphics, R As Rectangle, Curve As Integer, C As Color)
- Using P As New Pen(C)
- G.DrawArc(P, R.X, R.Y, Curve, Curve, 180, 90)
- G.DrawLine(P, CInt(R.X + Curve / 2), R.Y, CInt(R.X + R.Width - Curve / 2), R.Y)
- G.DrawArc(P, R.X + R.Width - Curve, R.Y, Curve, Curve, 270, 90)
- G.DrawLine(P, R.X, CInt(R.Y + Curve / 2), R.X, CInt(R.Y + R.Height - Curve / 2))
- G.DrawLine(P, CInt(R.X + R.Width), CInt(R.Y + Curve / 2), CInt(R.X + R.Width), CInt(R.Y + R.Height - Curve / 2))
- G.DrawLine(P, CInt(R.X + Curve / 2), CInt(R.Y + R.Height), CInt(R.X + R.Width - Curve / 2), CInt(R.Y + R.Height))
- G.DrawArc(P, R.X, R.Y + R.Height - Curve, Curve, Curve, 90, 90)
- G.DrawArc(P, R.X + R.Width - Curve, R.Y + R.Height - Curve, Curve, Curve, 0, 90)
- End Using
- End Sub
- Public Function RoundRec(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim P As GraphicsPath = New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- Return P
- End Function
- Public Function RoundRect(x!, y!, w!, h!, Optional r! = 0.3, Optional TL As Boolean = True, Optional TR As Boolean = True, Optional BR As Boolean = True, Optional BL As Boolean = True) As GraphicsPath
- Dim d! = Math.Min(w, h) * r, xw = x + w, yh = y + h
- RoundRect = New GraphicsPath
- With RoundRect
- If TL Then .AddArc(x, y, d, d, 180, 90) Else .AddLine(x, y, x, y)
- If TR Then .AddArc(xw - d, y, d, d, 270, 90) Else .AddLine(xw, y, xw, y)
- If BR Then .AddArc(xw - d, yh - d, d, d, 0, 90) Else .AddLine(xw, yh, xw, yh)
- If BL Then .AddArc(x, yh - d, d, d, 90, 90) Else .AddLine(x, yh, x, yh)
- .CloseFigure()
- End With
- End Function
- '-- Credit: AeonHack
- Public Function DrawArrow(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
- Dim GP As New GraphicsPath()
- Dim W As Integer = 12
- Dim H As Integer = 6
- If flip Then
- GP.AddLine(x + 1, y, x + W + 1, y)
- GP.AddLine(x + W, y, x + H, y + H - 1)
- Else
- GP.AddLine(x, y + H, x + W, y + H)
- GP.AddLine(x + W, y + H, x + H, y)
- End If
- GP.CloseFigure()
- Return GP
- End Function
- #End Region
- End Module
- Module Draw
- Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim P As GraphicsPath = New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- Return P
- End Function
- Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
- Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
- Dim P As GraphicsPath = New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- Return P
- End Function
- Public Function DrawArrowZ(x As Integer, y As Integer, flip As Boolean) As GraphicsPath
- Dim GP As New GraphicsPath()
- Dim W As Integer = 18
- Dim H As Integer = 9
- If flip Then
- GP.AddLine(x + 1, y, x + W + 1, y)
- GP.AddLine(x + W, y, x + H, y + H - 1)
- Else
- GP.AddLine(x, y + H, x + W, y + H)
- GP.AddLine(x + W, y + H, x + H, y)
- End If
- GP.CloseFigure()
- Return GP
- End Function
- Public Sub InnerGlowRounded(ByVal G As Graphics, ByVal Rectangle As Rectangle, ByVal Degree As Integer, ByVal Colors As Color())
- Dim SubtractTwo As Integer = 1
- Dim AddOne As Integer = 0
- For Each c In Colors
- G.DrawPath(New Pen(New SolidBrush(Color.FromArgb(c.R, c.B, c.G))), Draw.RoundRect(Rectangle.X + AddOne, Rectangle.Y + AddOne, Rectangle.Width - SubtractTwo, Rectangle.Height - SubtractTwo, Degree))
- SubtractTwo += 2
- AddOne += 1
- Next
- End Sub
- Private Function ImageFromCode(ByRef str$) As Image
- Dim imageBytes As Byte() = Convert.FromBase64String(str)
- Dim ms As New IO.MemoryStream(imageBytes, 0, imageBytes.Length) : ms.Write(imageBytes, 0, imageBytes.Length)
- Dim i As Image = Image.FromStream(ms, True) : Return i
- End Function
- Public Function TiledTextureFromCode(ByVal str As String) As TextureBrush
- Return New TextureBrush(Draw.ImageFromCode(str), WrapMode.Tile)
- End Function
- End Module
- #Region " Mouse States"
- Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- Block = 3
- End Enum
- #End Region
- Class MetroForm : Inherits ContainerControl
- #Region " Variables"
- Private W, H As Integer
- Private Cap As Boolean = False
- Private _HeaderMaximize As Boolean = False
- Private _UseIcon As Boolean = False
- Private MousePoint As New Point(0, 0)
- Private MoveHeight = 50
- #End Region
- #Region " Properties"
- #Region " Colors"
- Enum BarColor
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Colors")> _
- Public Property BarStyle() As BarColor
- Get
- Return _BarStyle
- End Get
- Set(value As BarColor)
- _BarStyle = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property HeaderColor() As Color
- Get
- Return _HeaderColor
- End Get
- Set(value As Color)
- _HeaderColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property BaseColor() As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property BorderColor() As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property FlatColor() As Color
- Get
- Return _FlatColor
- End Get
- Set(value As Color)
- _FlatColor = value
- End Set
- End Property
- #End Region
- #Region " Options"
- <Category("Options")> _
- Public Property UseIon() As Boolean
- Get
- Return _UseIcon
- End Get
- Set(value As Boolean)
- _UseIcon = value
- End Set
- End Property
- <Category("Options")> _
- Public Property HeaderMaximize As Boolean
- Get
- Return _UseIcon
- End Get
- Set(value As Boolean)
- _UseIcon = value
- End Set
- End Property
- #End Region
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
- Cap = True
- MousePoint = e.Location
- End If
- End Sub
- Private Sub FormSkin_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles Me.MouseDoubleClick
- If HeaderMaximize Then
- If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
- If FindForm.WindowState = FormWindowState.Normal Then
- FindForm.WindowState = FormWindowState.Maximized : FindForm.Refresh()
- ElseIf FindForm.WindowState = FormWindowState.Maximized Then
- FindForm.WindowState = FormWindowState.Normal : FindForm.Refresh()
- End If
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e) : Cap = False
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- If Cap Then
- Parent.Location = MousePosition - MousePoint
- End If
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- ParentForm.FormBorderStyle = FormBorderStyle.None
- ParentForm.AllowTransparency = False
- ParentForm.TransparencyKey = Color.Fuchsia
- ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
- Dock = DockStyle.Fill
- Invalidate()
- End Sub
- #End Region
- #Region " Colors"
- #Region " Dark Colors"
- Private _BarStyle
- Private _BarColor As Color
- Private _HeaderColor As Color = Color.FromArgb(45, 47, 49)
- Private _BaseColor As Color = Color.FromArgb(255, 255, 255)
- Private _BorderColor As Color = Color.FromArgb(53, 58, 60)
- Private TextColor As Color = Color.FromArgb(234, 234, 234)
- #End Region
- #Region " Light Colors"
- Private _HeaderLight As Color = Color.FromArgb(171, 171, 172)
- Private _BaseLight As Color = Color.FromArgb(196, 199, 200)
- Public TextLight As Color = Color.FromArgb(45, 47, 49)
- #End Region
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Color.White
- BarStyle = BarColor.Navy
- Font = New Font("Segoe UI", 12)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width : H = Height
- Dim Base As New Rectangle(0, 0, W, H), Header As New Rectangle(0, 0, W, 50)
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- '-- Base
- Select Case BarStyle
- Case BarColor.Darcula
- _BarColor = Color.FromArgb(60, 63, 65)
- Case BarColor.Pink
- _BarColor = Color.FromArgb(220, 79, 173)
- Case BarColor.Navy
- _BarColor = Color.FromArgb(0, 114, 198)
- Case BarColor.Red
- _BarColor = Color.FromArgb(206, 53, 44)
- Case BarColor.Green
- _BarColor = Color.FromArgb(96, 169, 23)
- Case BarColor.Orange
- _BarColor = Color.FromArgb(250, 104, 0)
- End Select
- .FillRectangle(New SolidBrush(_BaseColor), Base)
- '-- Header
- .FillRectangle(New SolidBrush(_BarColor), Header)
- '-- Logo
- If _UseIcon = True Then
- .DrawString("", New Font("Segoe UI Symbol", 20), New SolidBrush(TextColor), New Rectangle(3, 6, W, H), NearSF)
- .DrawLine(New Pen(Color.FromArgb(255, 255, 255)), 50, 0, 50, H)
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(60, 14, W, H), NearSF)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(26, 14, W, H), NearSF)
- End If
- '-- Border
- '.DrawRectangle(New Pen(_BorderColor), Base)
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroButton : Inherits Control
- #Region " Variables"
- Private W, H As Integer
- Private _Rounded As Boolean = False
- Private State As MouseState = MouseState.None
- #End Region
- #Region " Properties"
- #Region " Colors"
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- End Set
- End Property
- <Category("Options")> _
- Public Property Rounded As Boolean
- Get
- Return _Rounded
- End Get
- Set(value As Boolean)
- _Rounded = value
- End Set
- End Property
- #End Region
- Private O As _ButtonColor
- <Flags()> _
- Enum _ButtonColor
- Dark
- Primary
- Success
- Info
- Danger
- Warning
- Pink
- End Enum
- <Category("Options")> _
- Public Property ButtonStyle() As _ButtonColor
- Get
- Return O
- End Get
- Set(value As _ButtonColor)
- O = value
- End Set
- End Property
- #Region " Mouse States"
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- #End Region
- #Region " Colors"
- Private _ButtonStyle
- Private _ButtonStylePushed As Color
- Private _BaseColor As Color = _FlatColor
- Private _TextColor As Color = Color.FromArgb(243, 243, 243)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- Size = New Size(106, 32)
- BackColor = Color.Transparent
- Font = New Font("Segoe UI", 12)
- Cursor = Cursors.Hand
- ButtonStyle = _ButtonColor.Primary
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Dim GP As New GraphicsPath
- Dim Base As New Rectangle(0, 0, W, H)
- Select Case ButtonStyle
- Case _ButtonColor.Primary
- _ButtonStyle = Color.FromArgb(0, 114, 198)
- _ButtonStylePushed = Color.FromArgb(27, 110, 174)
- Case _ButtonColor.Success
- _ButtonStyle = Color.FromArgb(96, 169, 23)
- _ButtonStylePushed = Color.FromArgb(18, 128, 35)
- Case _ButtonColor.Info
- _ButtonStyle = Color.FromArgb(89, 205, 226)
- _ButtonStylePushed = Color.FromArgb(27, 161, 226)
- Case _ButtonColor.Dark
- _ButtonStyle = Color.FromArgb(60, 63, 65)
- _ButtonStylePushed = Color.FromArgb(48, 51, 52)
- Case _ButtonColor.Pink
- _ButtonStyle = Color.FromArgb(220, 79, 173)
- _ButtonStylePushed = Color.FromArgb(154, 22, 90)
- Case _ButtonColor.Danger
- _ButtonStyle = Color.FromArgb(206, 53, 44)
- _ButtonStylePushed = Color.FromArgb(154, 22, 22)
- Case _ButtonColor.Warning
- _ButtonStyle = Color.FromArgb(250, 104, 0)
- _ButtonStylePushed = Color.FromArgb(191, 90, 21)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- Select Case State
- Case MouseState.None
- '-- Base
- .FillRectangle(New SolidBrush(_ButtonStyle), Base)
- '-- Text
- .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
- Case MouseState.Over
- '-- Base
- .FillRectangle(New SolidBrush(_ButtonStyle), Base)
- '.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.White)), Base)
- '-- Text
- .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
- Case MouseState.Down
- '-- Base
- .FillRectangle(New SolidBrush(_ButtonStylePushed), Base)
- '.FillRectangle(New SolidBrush(Color.FromArgb(20, Color.Black)), Base)
- '-- Text
- .DrawString(Text, Font, New SolidBrush(_TextColor), Base, CenterSF)
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroInput : Inherits Control
- #Region " Variables"
- Private W, H As Integer
- Private _Rounded As Boolean = False
- Private State As MouseState = MouseState.None
- Private _FileName As String
- #End Region
- #Region " Properties"
- #Region " Colors"
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- End Set
- End Property
- <Category("Options")> _
- Public Property Rounded As Boolean
- Get
- Return _Rounded
- End Get
- Set(value As Boolean)
- _Rounded = value
- End Set
- End Property
- <Category("Options")> _
- Public Property FileName As String
- Get
- Return _FileName
- End Get
- Set(value As String)
- _FileName = value
- End Set
- End Property
- #End Region
- Private O As _ButtonColor
- <Flags()> _
- Enum _ButtonColor
- Dark
- Primary
- Success
- Info
- Danger
- Warning
- Pink
- End Enum
- <Category("Options")> _
- Public Property ButtonStyle() As _ButtonColor
- Get
- Return O
- End Get
- Set(value As _ButtonColor)
- O = value
- End Set
- End Property
- #Region " Mouse States"
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- #End Region
- #Region " Colors"
- Private _ButtonStyle
- Private _ButtonStylePushed As Color
- Private _BaseColor As Color = _FlatColor
- Private _TextColor As Color = Color.FromArgb(243, 243, 243)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- Size = New Size(178, 32)
- BackColor = Color.Transparent
- Font = New Font("Segoe UI", 12)
- Cursor = Cursors.Hand
- ButtonStyle = _ButtonColor.Primary
- Text = ""
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Dim GP As New GraphicsPath
- Dim Base As New Rectangle(0, 0, W, H)
- Select Case ButtonStyle
- Case _ButtonColor.Primary
- _ButtonStyle = Color.FromArgb(0, 114, 198)
- _ButtonStylePushed = Color.FromArgb(27, 110, 174)
- Case _ButtonColor.Success
- _ButtonStyle = Color.FromArgb(96, 169, 23)
- _ButtonStylePushed = Color.FromArgb(18, 128, 35)
- Case _ButtonColor.Info
- _ButtonStyle = Color.FromArgb(89, 205, 226)
- _ButtonStylePushed = Color.FromArgb(27, 161, 226)
- Case _ButtonColor.Dark
- _ButtonStyle = Color.FromArgb(60, 63, 65)
- _ButtonStylePushed = Color.FromArgb(48, 51, 52)
- Case _ButtonColor.Pink
- _ButtonStyle = Color.FromArgb(220, 79, 173)
- _ButtonStylePushed = Color.FromArgb(154, 22, 90)
- Case _ButtonColor.Danger
- _ButtonStyle = Color.FromArgb(206, 53, 44)
- _ButtonStylePushed = Color.FromArgb(154, 22, 22)
- Case _ButtonColor.Warning
- _ButtonStyle = Color.FromArgb(250, 104, 0)
- _ButtonStylePushed = Color.FromArgb(191, 90, 21)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 4
- .Clear(BackColor)
- Select Case State
- Case MouseState.None
- '-- Base
- DrawRoundRect(G, FullRectangle(Base.Size, True), 1, Color.FromArgb(238, 238, 238))
- '-- Text
- .DrawString(Text, New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), Base, CenterSF)
- .DrawString("", New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), New Rectangle(145, 5, W, H))
- Case MouseState.Over
- '-- Base
- DrawRoundRect(G, FullRectangle(Base.Size, True), 1, _ButtonStyle)
- '-- Text
- .DrawString(Text, New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), Base, CenterSF)
- .DrawString("", New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), New Rectangle(145, 5, W, H))
- Case MouseState.Down
- '-- Base
- DrawRoundRect(G, FullRectangle(Base.Size, True), 1, _ButtonStyle)
- '-- Text
- .DrawString(Text, New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), Base, CenterSF)
- .DrawString("", New Font("Segoe UI Symbol", 12), New SolidBrush(Color.Black), New Rectangle(145, 5, W, H))
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- <DefaultEvent("TextChanged")>
- Class MetroTextbox
- Inherits Control
- #Region " Private "
- Private WithEvents TB As New TextBox
- Private G As Graphics
- Private State As MouseState
- Private IsDown As Boolean
- Private _EnabledCalc As Boolean
- Private _allowpassword As Boolean = False
- Private _maxChars As Integer = 32767
- Private _textAlignment As HorizontalAlignment
- Private _multiLine As Boolean = False
- Private _readOnly As Boolean = False
- Private _TextBoxStyle
- Private _TextBoxState
- #End Region
- #Region " Properties "
- Private O2 As _TextBoxStates
- <Flags()> _
- Enum _TextBoxStates
- None
- Eror
- Warning
- Success
- Required
- End Enum
- Private O As _TextBoxColor
- <Flags()> _
- Enum _TextBoxColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property TextBoxStyle() As _TextBoxColor
- Get
- Return O
- End Get
- Set(value As _TextBoxColor)
- O = value
- End Set
- End Property
- <Category("Options")> _
- Public Property TextBoxState() As _TextBoxStates
- Get
- Return O2
- End Get
- Set(value As _TextBoxStates)
- O2 = value
- End Set
- End Property
- Public Shadows Property Enabled As Boolean
- Get
- Return EnabledCalc
- End Get
- Set(value As Boolean)
- TB.Enabled = value
- _EnabledCalc = value
- Invalidate()
- End Set
- End Property
- <DisplayName("Enabled")>
- Public Property EnabledCalc As Boolean
- Get
- Return _EnabledCalc
- End Get
- Set(value As Boolean)
- Enabled = value
- Invalidate()
- End Set
- End Property
- Public Shadows Property UseSystemPasswordChar() As Boolean
- Get
- Return _allowpassword
- End Get
- Set(ByVal value As Boolean)
- TB.UseSystemPasswordChar = UseSystemPasswordChar
- _allowpassword = value
- Invalidate()
- End Set
- End Property
- Public Shadows Property MaxLength() As Integer
- Get
- Return _maxChars
- End Get
- Set(ByVal value As Integer)
- _maxChars = value
- TB.MaxLength = MaxLength
- Invalidate()
- End Set
- End Property
- Public Shadows Property TextAlign() As HorizontalAlignment
- Get
- Return _textAlignment
- End Get
- Set(ByVal value As HorizontalAlignment)
- _textAlignment = value
- Invalidate()
- End Set
- End Property
- Public Shadows Property MultiLine() As Boolean
- Get
- Return _multiLine
- End Get
- Set(ByVal value As Boolean)
- _multiLine = value
- TB.Multiline = value
- OnResize(EventArgs.Empty)
- Invalidate()
- End Set
- End Property
- Public Shadows Property [ReadOnly]() As Boolean
- Get
- Return _readOnly
- End Get
- Set(ByVal value As Boolean)
- _readOnly = value
- If TB IsNot Nothing Then
- TB.ReadOnly = value
- End If
- End Set
- End Property
- #End Region
- #Region " Control "
- Protected Overrides Sub OnTextChanged(ByVal e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnBackColorChanged(ByVal e As EventArgs)
- MyBase.OnBackColorChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnForeColorChanged(ByVal e As EventArgs)
- MyBase.OnForeColorChanged(e)
- TB.ForeColor = ForeColor
- Invalidate()
- End Sub
- Protected Overrides Sub OnFontChanged(ByVal e As EventArgs)
- MyBase.OnFontChanged(e)
- TB.Font = Font
- End Sub
- Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
- MyBase.OnGotFocus(e)
- TB.Focus()
- End Sub
- Private Sub TextChangeTb() Handles TB.TextChanged
- Text = TB.Text
- End Sub
- Private Sub TextChng() Handles MyBase.TextChanged
- TB.Text = Text
- End Sub
- Public Sub NewTextBox()
- With TB
- .Text = String.Empty
- .BackColor = Color.White
- .ForeColor = Color.FromArgb(66, 78, 90)
- .TextAlign = HorizontalAlignment.Left
- .BorderStyle = BorderStyle.None
- .Location = New Point(3, 3)
- .Font = New Font("Segoe UI", 12)
- .Size = New Size(Width - 3, Height - 3)
- .UseSystemPasswordChar = UseSystemPasswordChar
- End With
- End Sub
- Sub New()
- MyBase.New()
- NewTextBox()
- Controls.Add(TB)
- SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- TextAlign = HorizontalAlignment.Left
- ForeColor = Color.FromArgb(66, 78, 90)
- Font = New Font("Segoe UI", 12)
- Size = New Size(145, 31)
- TextBoxStyle = _TextBoxColor.Navy
- _TextBoxState = _TextBoxStates.None
- Enabled = True
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- G = e.Graphics
- G.SmoothingMode = SmoothingMode.HighQuality
- MyBase.OnPaint(e)
- G.Clear(Parent.BackColor)
- Select Case TextBoxStyle
- Case _TextBoxColor.Grey
- _TextBoxStyle = Color.FromArgb(217, 217, 217)
- Case _TextBoxColor.Darcula
- _TextBoxStyle = Color.FromArgb(60, 63, 65)
- Case _TextBoxColor.Pink
- _TextBoxStyle = Color.FromArgb(220, 79, 173)
- Case _TextBoxColor.Navy
- _TextBoxStyle = Color.FromArgb(0, 114, 198)
- Case _TextBoxColor.Red
- _TextBoxStyle = Color.FromArgb(206, 53, 44)
- Case _TextBoxColor.Green
- _TextBoxStyle = Color.FromArgb(96, 169, 23)
- Case _TextBoxColor.Orange
- _TextBoxStyle = Color.FromArgb(250, 104, 0)
- End Select
- Select Case TextBoxState
- Case _TextBoxStates.None
- _TextBoxState = Color.FromArgb(217, 217, 217)
- Case _TextBoxStates.Eror
- _TextBoxState = Color.FromArgb(206, 53, 44)
- Case _TextBoxStates.Warning
- _TextBoxState = Color.FromArgb(227, 200, 0)
- Case _TextBoxStates.Success
- _TextBoxState = Color.FromArgb(96, 169, 23)
- Case _TextBoxStates.Required
- _TextBoxState = Color.FromArgb(0, 114, 198)
- End Select
- If Enabled Then
- If TextBoxState <> _TextBoxStates.None Then
- TB.ForeColor = Color.FromArgb(66, 78, 90)
- DrawRoundRect(G, FullRectangle(Size, True), 1, _TextBoxState)
- Else
- TB.ForeColor = Color.FromArgb(66, 78, 90)
- If State = MouseState.Down Then
- DrawRoundRect(G, FullRectangle(Size, True), 1, _TextBoxStyle)
- Else
- DrawRoundRect(G, FullRectangle(Size, True), 1, Color.FromArgb(217, 217, 217))
- End If
- End If
- Else
- DrawRoundRect(G, FullRectangle(Size, True), 1, Color.FromArgb(235, 235, 228))
- TB.BackColor = Color.FromArgb(235, 235, 228)
- Dim rekt As New Rectangle(0, 0, Width, Height)
- FillRoundRect(G, rekt, 1, Color.FromArgb(235, 235, 228))
- End If
- TB.TextAlign = TextAlign
- TB.UseSystemPasswordChar = UseSystemPasswordChar
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- If Not MultiLine Then
- Dim tbheight As Integer = TB.Height
- TB.Location = New Point(10, CType(((Height / 2) - (tbheight / 2) - 0), Integer))
- TB.Size = New Size(Width - 20, tbheight)
- Else
- TB.Location = New Point(10, 10)
- TB.Size = New Size(Width - 20, Height - 20)
- End If
- End Sub
- Protected Overrides Sub OnEnter(e As EventArgs)
- MyBase.OnEnter(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnLeave(e As EventArgs)
- MyBase.OnLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- End Class
- <DefaultEvent("CheckedChanged")>
- Class MetroCheckBox
- Inherits Control
- #Region " Public "
- Public Event CheckedChanged(sender As Object, e As EventArgs)
- #End Region
- #Region " Private "
- Private State As MouseState
- Private ETC As Color = Nothing
- Private G As Graphics
- Private _EnabledCalc As Boolean
- Private _Checked As Boolean
- Private _Bold As Boolean
- Private _Indeterminate As Boolean
- #End Region
- #Region " Properties "
- Private _CheckBoxStyle
- Private O As _CheckBoxColor
- <Flags()> _
- Enum _CheckBoxColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property CheckBoxStyle() As _CheckBoxColor
- Get
- Return O
- End Get
- Set(value As _CheckBoxColor)
- O = value
- End Set
- End Property
- Public Property Indeterminate As Boolean
- Get
- Return _Indeterminate
- End Get
- Set(value As Boolean)
- _Indeterminate = value
- Invalidate()
- End Set
- End Property
- Public Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Public Shadows Property Enabled As Boolean
- Get
- Return EnabledCalc
- End Get
- Set(value As Boolean)
- _EnabledCalc = value
- Invalidate()
- End Set
- End Property
- <DisplayName("Enabled")>
- Public Property EnabledCalc As Boolean
- Get
- Return _EnabledCalc
- End Get
- Set(value As Boolean)
- Enabled = value
- Invalidate()
- End Set
- End Property
- Public Property Bold As Boolean
- Get
- Return _Bold
- End Get
- Set(value As Boolean)
- _Bold = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Control "
- Sub New()
- DoubleBuffered = True
- ForeColor = Color.FromArgb(66, 78, 90)
- Font = New Font("Segoe UI", 12)
- Size = New Size(160, 27)
- Enabled = True
- Indeterminate = False
- CheckBoxStyle = _CheckBoxColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- G = e.Graphics
- G.SmoothingMode = SmoothingMode.HighQuality
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- MyBase.OnPaint(e)
- G.Clear(Parent.BackColor)
- Select Case CheckBoxStyle
- Case _CheckBoxColor.Grey
- _CheckBoxStyle = Color.FromArgb(217, 217, 217)
- Case _CheckBoxColor.Darcula
- _CheckBoxStyle = Color.FromArgb(60, 63, 65)
- Case _CheckBoxColor.Pink
- _CheckBoxStyle = Color.FromArgb(220, 79, 173)
- Case _CheckBoxColor.Navy
- _CheckBoxStyle = Color.FromArgb(0, 114, 198)
- Case _CheckBoxColor.Red
- _CheckBoxStyle = Color.FromArgb(206, 53, 44)
- Case _CheckBoxColor.Green
- _CheckBoxStyle = Color.FromArgb(96, 169, 23)
- Case _CheckBoxColor.Orange
- _CheckBoxStyle = Color.FromArgb(250, 104, 0)
- End Select
- If Enabled Then
- ETC = Color.FromArgb(66, 78, 90)
- Using B As New SolidBrush(ETC)
- If Bold Then
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- Else
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- End If
- End Using
- Select Case State
- Case MouseState.Over, MouseState.Down
- DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 1, _CheckBoxStyle)
- Case Else
- DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 1, Color.FromArgb(217, 217, 217))
- End Select
- If Checked Then
- If Indeterminate Then
- G.DrawString("⬛", New Font("Segoe UI Symbol", 10), New SolidBrush(_CheckBoxStyle), New Point(6, 4))
- Else
- G.DrawString("", New Font("Segoe UI Symbol", 8), New SolidBrush(_CheckBoxStyle), New Point(4, 5))
- End If
- End If
- Else
- ETC = Color.FromArgb(202, 202, 202)
- Using B As New SolidBrush(ETC)
- If Bold Then
- G.DrawString(Text, New Font("Segoe UI", 12), New SolidBrush(ETC), New Point(32, 4))
- Else
- G.DrawString(Text, New Font("Segoe UI", 12), New SolidBrush(ETC), New Point(32, 4))
- End If
- End Using
- DrawRoundRect(G, New Rectangle(3, 3, 20, 20), 1, Color.FromArgb(217, 217, 217))
- If Checked Then
- If Indeterminate Then
- G.DrawString("⬛", New Font("Segoe UI Symbol", 10), New SolidBrush(ETC), New Point(6, 4))
- Else
- G.DrawString("", New Font("Segoe UI Symbol", 8), New SolidBrush(ETC), New Point(4, 5))
- End If
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- If Enabled Then
- Checked = Not Checked
- RaiseEvent CheckedChanged(Me, e)
- End If
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- End Class
- <DefaultEvent("CheckedChanged")>
- Class MetroRadioButton
- Inherits Control
- #Region " Public "
- Public Event CheckedChanged(sender As Object, e As EventArgs)
- #End Region
- #Region " Private "
- Private State As MouseState
- Private ETC As Color = Nothing
- Private G As Graphics
- Private _EnabledCalc As Boolean
- Private _Checked As Boolean
- Private _Bold As Boolean
- #End Region
- #Region " Properties "
- Private _RadioStyle
- Private O As _RadioColor
- <Flags()> _
- Enum _RadioColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property RadioStyle() As _RadioColor
- Get
- Return O
- End Get
- Set(value As _RadioColor)
- O = value
- End Set
- End Property
- Public Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Public Shadows Property Enabled As Boolean
- Get
- Return EnabledCalc
- End Get
- Set(value As Boolean)
- _EnabledCalc = value
- Invalidate()
- End Set
- End Property
- <DisplayName("Enabled")>
- Public Property EnabledCalc As Boolean
- Get
- Return _EnabledCalc
- End Get
- Set(value As Boolean)
- Enabled = value
- Invalidate()
- End Set
- End Property
- Public Property Bold As Boolean
- Get
- Return _Bold
- End Get
- Set(value As Boolean)
- _Bold = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region " Control "
- Sub New()
- DoubleBuffered = True
- ForeColor = Color.FromArgb(66, 78, 90)
- Font = New Font("Segoe UI", 12)
- Size = New Size(160, 27)
- Enabled = True
- _RadioStyle = _RadioColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- G = e.Graphics
- G.SmoothingMode = SmoothingMode.HighQuality
- G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- MyBase.OnPaint(e)
- G.Clear(Parent.BackColor)
- Select Case RadioStyle
- Case _RadioColor.Grey
- _RadioStyle = Color.FromArgb(217, 217, 217)
- Case _RadioColor.Darcula
- _RadioStyle = Color.FromArgb(60, 63, 65)
- Case _RadioColor.Pink
- _RadioStyle = Color.FromArgb(220, 79, 173)
- Case _RadioColor.Navy
- _RadioStyle = Color.FromArgb(0, 114, 198)
- Case _RadioColor.Red
- _RadioStyle = Color.FromArgb(206, 53, 44)
- Case _RadioColor.Green
- _RadioStyle = Color.FromArgb(96, 169, 23)
- Case _RadioColor.Orange
- _RadioStyle = Color.FromArgb(250, 104, 0)
- End Select
- If Enabled Then
- ETC = Color.FromArgb(66, 78, 90)
- Select Case State
- Case MouseState.Over, MouseState.Down
- Using P As New Pen(New SolidBrush(_RadioStyle))
- G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
- End Using
- Case Else
- Using P As New Pen(GreyColor(190))
- G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
- End Using
- End Select
- If Checked Then
- Using B As New SolidBrush(_RadioStyle)
- G.FillEllipse(B, New Rectangle(7, 7, 12, 12))
- End Using
- End If
- Using B As New SolidBrush(ETC)
- If Bold Then
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- Else
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- End If
- End Using
- Else
- ETC = Color.FromArgb(217, 217, 217)
- Using P As New Pen(ETC)
- G.DrawEllipse(P, New Rectangle(2, 2, 22, 22))
- End Using
- If Checked Then
- Using B As New SolidBrush(Color.FromArgb(34, 146, 208))
- G.FillEllipse(B, New Rectangle(7, 7, 12, 12))
- End Using
- End If
- Using B As New SolidBrush(ETC)
- If Bold Then
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- Else
- G.DrawString(Text, New Font("Segoe UI", 12), B, New Point(32, 4))
- End If
- End Using
- End If
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- If Enabled Then
- If Not Checked Then
- For Each C As Control In Parent.Controls
- If TypeOf C Is MetroRadioButton Then
- DirectCast(C, MetroRadioButton).Checked = False
- End If
- Next
- End If
- Checked = True
- RaiseEvent CheckedChanged(Me, e)
- End If
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- End Class
- <DefaultEvent("CheckedChanged")> Class MetroSwitcher : Inherits Control
- #Region " Variables"
- Private W, H As Integer
- Private O As _Options
- Private _Checked As Boolean = False
- Private State As MouseState = MouseState.None
- Private _EnabledCalc As Boolean
- #End Region
- #Region " Properties"
- Public Event CheckedChanged(ByVal sender As Object)
- Public Shadows Property Enabled As Boolean
- Get
- Return EnabledCalc
- End Get
- Set(value As Boolean)
- _EnabledCalc = value
- Invalidate()
- End Set
- End Property
- <DisplayName("Enabled")>
- Public Property EnabledCalc As Boolean
- Get
- Return _EnabledCalc
- End Get
- Set(value As Boolean)
- Enabled = value
- Invalidate()
- End Set
- End Property
- <Flags()> _
- Enum _Options
- Modern
- Original
- End Enum
- #Region " Options"
- Private _ToggleStyle
- Private Oz As _ToggleColor
- <Flags()> _
- Enum _ToggleColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property ToggleStyle() As _ToggleColor
- Get
- Return Oz
- End Get
- Set(value As _ToggleColor)
- Oz = value
- End Set
- End Property
- <Category("Options")> _
- Public Property Options As _Options
- Get
- Return O
- End Get
- Set(value As _Options)
- O = value
- End Set
- End Property
- <Category("Options")> _
- Public Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(value As Boolean)
- _Checked = value
- End Set
- End Property
- #End Region
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Width = 60
- Height = 33
- End Sub
- #Region " Mouse States"
- Protected Overrides Sub OnMouseEnter(ByVal e As System.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 System.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 OnClick(e As EventArgs)
- MyBase.OnClick(e)
- _Checked = Not _Checked
- RaiseEvent CheckedChanged(Me)
- End Sub
- #End Region
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Size = New Size(44, Height + 1)
- Cursor = Cursors.Hand
- Font = New Font("Segoe UI", 10)
- Size = New Size(60, 33)
- Enabled = True
- _ToggleStyle = _ToggleColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Dim GP, GP2, GP3, GPa, GPb As New GraphicsPath
- Dim Base As New Rectangle(0, 0, W, H), Toggle As New Rectangle(CInt(W \ 2), 0, 38, H), Toggle2 As New Rectangle(CInt(W \ 2), 0, 38, H)
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- Select Case ToggleStyle
- Case _ToggleColor.Grey
- _ToggleStyle = Color.FromArgb(217, 217, 217)
- Case _ToggleColor.Darcula
- _ToggleStyle = Color.FromArgb(60, 63, 65)
- Case _ToggleColor.Pink
- _ToggleStyle = Color.FromArgb(220, 79, 173)
- Case _ToggleColor.Navy
- _ToggleStyle = Color.FromArgb(0, 114, 198)
- Case _ToggleColor.Red
- _ToggleStyle = Color.FromArgb(206, 53, 44)
- Case _ToggleColor.Green
- _ToggleStyle = Color.FromArgb(96, 169, 23)
- Case _ToggleColor.Orange
- _ToggleStyle = Color.FromArgb(250, 104, 0)
- End Select
- Select Case O
- Case _Options.Modern
- '-- Base
- If Enabled Then
- If Checked Then
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 7)
- Toggle = New Rectangle(W - 32, 7, 22, H - 7)
- Toggle2 = New Rectangle(W - 33, 7, 24, H - 6)
- GP2.AddEllipse(Toggle)
- GP3.AddEllipse(Toggle2)
- .FillPath(New SolidBrush(_ToggleStyle), GP)
- .FillPath(New SolidBrush(Color.FromArgb(197, 197, 197)), GP3)
- .FillPath(New SolidBrush(Color.White), GP2)
- Else
- '-- Base
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 7)
- Toggle = New Rectangle(W - 52, 7, 24, H - 7)
- Toggle2 = New Rectangle(W - 52, 7, 24, H - 6)
- GP2.Reset()
- GP3.Reset()
- GP2.AddEllipse(Toggle)
- GP3.AddEllipse(Toggle2)
- .FillPath(New SolidBrush(Color.FromArgb(146, 146, 146)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(197, 197, 197)), GP3)
- .FillPath(New SolidBrush(Color.White), GP2)
- End If
- Else
- If Checked Then
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 7)
- Toggle = New Rectangle(W - 32, 7, 22, H - 7)
- Toggle2 = New Rectangle(W - 33, 7, 24, H - 6)
- GP2.AddEllipse(Toggle)
- GP3.AddEllipse(Toggle2)
- .FillPath(New SolidBrush(Color.FromArgb(146, 146, 146)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(222, 222, 222)), GP3)
- .FillPath(New SolidBrush(Color.FromArgb(189, 189, 189)), GP2)
- Else
- '-- Base
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 7)
- Toggle = New Rectangle(W - 52, 7, 24, H - 7)
- Toggle2 = New Rectangle(W - 52, 7, 24, H - 6)
- GP2.Reset()
- GP3.Reset()
- GP2.AddEllipse(Toggle)
- GP3.AddEllipse(Toggle2)
- .FillPath(New SolidBrush(Color.FromArgb(146, 146, 146)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(222, 222, 222)), GP3)
- .FillPath(New SolidBrush(Color.FromArgb(189, 189, 189)), GP2)
- End If
- End If
- Case _Options.Original
- If Enabled Then
- If Checked Then
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 1)
- GPa = Helpers.RoundRec(New Rectangle(8, 13, W - 20, 16), 1)
- Toggle = New Rectangle(W - 29, 10, 20, H - 12)
- GP2.AddRectangle(Toggle)
- ''
- GPb = Helpers.RoundRec(New Rectangle(4, 9, W - 12, 22), 1)
- .FillPath(New SolidBrush(Color.FromArgb(166, 166, 166)), GPb)
- ''
- .FillPath(New SolidBrush(Color.White), GPa)
- Dim GPa2 = Helpers.RoundRec(New Rectangle(8, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa2)
- Dim GPa3 = Helpers.RoundRec(New Rectangle(7, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa3)
- Dim GPa4 = Helpers.RoundRec(New Rectangle(7, 11, W - 18, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa4)
- .FillPath(New SolidBrush(_ToggleStyle), GP)
- .FillPath(New SolidBrush(Color.FromArgb(51, 51, 51)), GP2)
- 'rgb(166,166,166)
- Else
- '-- Base
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 1)
- GPa = Helpers.RoundRec(New Rectangle(8, 13, W - 20, 16), 1)
- Toggle = New Rectangle(W - 55, 10, 20, H - 12)
- GP2.AddRectangle(Toggle)
- ''
- GPb = Helpers.RoundRec(New Rectangle(4, 9, W - 12, 22), 1)
- .FillPath(New SolidBrush(Color.FromArgb(166, 166, 166)), GPb)
- ''
- .FillPath(New SolidBrush(Color.White), GPa)
- Dim GPa2 = Helpers.RoundRec(New Rectangle(8, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa2)
- Dim GPa3 = Helpers.RoundRec(New Rectangle(7, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa3)
- Dim GPa4 = Helpers.RoundRec(New Rectangle(7, 11, W - 18, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa4)
- .FillPath(New SolidBrush(Color.FromArgb(166, 166, 166)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(51, 51, 51)), GP2)
- End If
- Else
- If Checked Then
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 1)
- GPa = Helpers.RoundRec(New Rectangle(8, 13, W - 20, 16), 1)
- Toggle = New Rectangle(W - 29, 10, 20, H - 12)
- GP2.AddRectangle(Toggle)
- ''
- GPb = Helpers.RoundRec(New Rectangle(4, 9, W - 12, 22), 1)
- .FillPath(New SolidBrush(Color.FromArgb(166, 166, 166)), GPb)
- ''
- .FillPath(New SolidBrush(Color.White), GPa)
- Dim GPa2 = Helpers.RoundRec(New Rectangle(8, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa2)
- Dim GPa3 = Helpers.RoundRec(New Rectangle(7, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa3)
- Dim GPa4 = Helpers.RoundRec(New Rectangle(7, 11, W - 18, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa4)
- .FillPath(New SolidBrush(Color.FromArgb(230, 230, 230)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(138, 138, 138)), GP2)
- Else
- '-- Base
- .Clear(BackColor)
- GP = Helpers.RoundRec(New Rectangle(8, 12, W - 20, 16), 1)
- GPa = Helpers.RoundRec(New Rectangle(8, 13, W - 20, 16), 1)
- Toggle = New Rectangle(W - 55, 10, 20, H - 12)
- GP2.AddRectangle(Toggle)
- ''
- GPb = Helpers.RoundRec(New Rectangle(4, 9, W - 12, 22), 1)
- .FillPath(New SolidBrush(Color.FromArgb(166, 166, 166)), GPb)
- ''
- .FillPath(New SolidBrush(Color.White), GPa)
- Dim GPa2 = Helpers.RoundRec(New Rectangle(8, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa2)
- Dim GPa3 = Helpers.RoundRec(New Rectangle(7, 13, W - 19, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa3)
- Dim GPa4 = Helpers.RoundRec(New Rectangle(7, 11, W - 18, 16), 1)
- .FillPath(New SolidBrush(Color.White), GPa4)
- .FillPath(New SolidBrush(Color.FromArgb(230, 230, 230)), GP)
- .FillPath(New SolidBrush(Color.FromArgb(138, 138, 138)), GP2)
- End If
- End If
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- <DefaultEvent("Scroll")> Class MetroInputRange : Inherits Control
- #Region " Variables"
- Private W, H As Integer
- Private Val As Integer
- Private Bool As Boolean
- Private Track As Rectangle
- #End Region
- #Region " Properties"
- Private _RangeStyle
- Private O As _RangeColor
- <Flags()> _
- Enum _RangeColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property RangeStyle() As _RangeColor
- Get
- Return O
- End Get
- Set(value As _RangeColor)
- O = value
- End Set
- End Property
- #Region " Mouse States"
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = Windows.Forms.MouseButtons.Left Then
- Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (Width - 11))
- Track = New Rectangle(Val, 0, 10, 20)
- Bool = Track.Contains(e.Location)
- End If
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- If Bool AndAlso e.X > -1 AndAlso e.X < (Width + 1) Then
- Value = _Minimum + CInt((_Maximum - _Minimum) * (e.X / Width))
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e) : Bool = False
- End Sub
- #End Region
- #Region " Colors"
- <Category("Colors")> _
- Public Property TrackColor As Color
- Get
- Return _TrackColor
- End Get
- Set(value As Color)
- _TrackColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property HatchColor As Color
- Get
- Return _HatchColor
- End Get
- Set(value As Color)
- _HatchColor = value
- End Set
- End Property
- #End Region
- Event Scroll(ByVal sender As Object)
- Private _Minimum As Integer
- Public Property Minimum As Integer
- Get
- Return Minimum
- End Get
- Set(value As Integer)
- If value < 0 Then
- End If
- _Minimum = value
- If value > _Value Then _Value = value
- If value > _Maximum Then _Maximum = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Integer = 10
- Public Property Maximum As Integer
- Get
- Return _Maximum
- End Get
- Set(value As Integer)
- If value < 0 Then
- End If
- _Maximum = value
- If value < _Value Then _Value = value
- If value < _Minimum Then _Minimum = value
- Invalidate()
- End Set
- End Property
- Private _Value As Integer
- Public Property Value As Integer
- Get
- Return _Value
- End Get
- Set(value As Integer)
- If value = _Value Then Return
- If value > _Maximum OrElse value < _Minimum Then
- End If
- _Value = value
- Invalidate()
- RaiseEvent Scroll(Me)
- End Set
- End Property
- Private _ShowValue As Boolean = False
- Public Property ShowValue As Boolean
- Get
- Return _ShowValue
- End Get
- Set(value As Boolean)
- _ShowValue = value
- End Set
- End Property
- Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
- MyBase.OnKeyDown(e)
- If e.KeyCode = Keys.Subtract Then
- If Value = 0 Then Exit Sub
- Value -= 1
- ElseIf e.KeyCode = Keys.Add Then
- If Value = _Maximum Then Exit Sub
- Value += 1
- End If
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 23
- End Sub
- #End Region
- #Region " Colors"
- Private BaseColor As Color = Color.FromArgb(45, 47, 49)
- Private _TrackColor As Color = Color.FromArgb(55, 55, 55)
- Private SliderColor As Color = Color.FromArgb(25, 27, 29)
- Private _HatchColor As Color = Color.FromArgb(23, 148, 92)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- Height = 18
- _RangeStyle = _RangeColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Dim Base As New Rectangle(1, 5, W, 15)
- Dim GP, GP2 As New GraphicsPath
- Select Case RangeStyle
- Case _RangeColor.Grey
- _RangeStyle = Color.FromArgb(217, 217, 217)
- Case _RangeColor.Darcula
- _RangeStyle = Color.FromArgb(60, 63, 65)
- Case _RangeColor.Pink
- _RangeStyle = Color.FromArgb(220, 79, 173)
- Case _RangeColor.Navy
- _RangeStyle = Color.FromArgb(0, 114, 198)
- Case _RangeColor.Red
- _RangeStyle = Color.FromArgb(206, 53, 44)
- Case _RangeColor.Green
- _RangeStyle = Color.FromArgb(96, 169, 23)
- Case _RangeColor.Orange
- _RangeStyle = Color.FromArgb(250, 104, 0)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(Color.White)
- '-- Value
- Val = CInt((_Value - _Minimum) / (_Maximum - _Minimum) * (W - 10))
- Track = New Rectangle(Val, 5, 10, 15)
- '-- Base
- GP.AddRectangle(Base)
- .SetClip(GP)
- .FillRectangle(New SolidBrush(_RangeStyle), New Rectangle(0, 0, W, 20))
- .FillRectangle(New SolidBrush(_RangeStyle), New Rectangle(0, 0, Track.X + Track.Width, 20))
- .ResetClip()
- '-- Slider/Knob
- GP2.AddRectangle(Track)
- .FillPath(New SolidBrush(Color.FromArgb(55, 55, 55)), GP2)
- '-- Show the value
- If ShowValue Then
- .DrawString(Value, New Font("Segoe UI", 8), New SolidBrush(Color.FromArgb(255, 255, 255)), New Rectangle(Val, 7, 10, 15), New StringFormat() _
- With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Far})
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroTabControl : Inherits TabControl
- #Region " Variables"
- Private W, H As Integer
- Private _TabStyle
- #End Region
- #Region " Properties"
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- #Region " Colors"
- Private O As _TabColor
- <Flags()> _
- Enum _TabColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property TabStyle() As _TabColor
- Get
- Return O
- End Get
- Set(value As _TabColor)
- O = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property ActiveColor As Color
- Get
- Return _ActiveColor
- End Get
- Set(value As Color)
- _ActiveColor = value
- End Set
- End Property
- #End Region
- #End Region
- #Region " Colors"
- Private BGColor As Color = Color.White
- Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
- Private _ActiveColor As Color = _FlatColor
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Color.FromArgb(6, 70, 73)
- Font = New Font("Segoe UI", 10)
- SizeMode = TabSizeMode.Fixed
- ItemSize = New Size(120, 40)
- _TabStyle = _TabColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Select Case TabStyle
- Case _TabColor.Grey
- _TabStyle = Color.FromArgb(217, 217, 217)
- Case _TabColor.Darcula
- _TabStyle = Color.FromArgb(60, 63, 65)
- Case _TabColor.Pink
- _TabStyle = Color.FromArgb(220, 79, 173)
- Case _TabColor.Navy
- _TabStyle = Color.FromArgb(0, 114, 198)
- Case _TabColor.Red
- _TabStyle = Color.FromArgb(206, 53, 44)
- Case _TabColor.Green
- _TabStyle = Color.FromArgb(96, 169, 23)
- Case _TabColor.Orange
- _TabStyle = Color.FromArgb(250, 104, 0)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(Color.White)
- Try : SelectedTab.BackColor = BGColor : Catch : End Try
- For i = 0 To TabCount - 1
- Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
- Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
- Dim Bae As New Rectangle(New Point(4, Base.Location.Y + 40), New Size(SelectedTab.Width, GetTabRect(i).Height - 25))
- If i = SelectedIndex Then
- '-- Basea
- .FillRectangle(New SolidBrush(_TabStyle), BaseSize)
- .FillRectangle(New SolidBrush(_TabStyle), Bae)
- '-- ImageList
- If ImageList IsNot Nothing Then
- Try
- If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
- '-- Image
- .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
- '-- Text
- .DrawString(" " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
- End If
- Else
- '-- Base
- .FillRectangle(New SolidBrush(Color.White), BaseSize)
- '-- ImageList
- If ImageList IsNot Nothing Then
- Try
- If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
- '-- Image
- .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
- '-- Text
- .DrawString(" " & TabPages(i).Text, Font, New SolidBrush(Color.Black), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.Black), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.Black), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End If
- End If
- Next
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroTopMenu : Inherits TabControl
- #Region " Variables"
- Private W, H As Integer
- Private _TabStyle
- #End Region
- #Region " Properties"
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- #Region " Colors"
- Private O As _TabColor
- <Flags()> _
- Enum _TabColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property TabStyle() As _TabColor
- Get
- Return O
- End Get
- Set(value As _TabColor)
- O = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property ActiveColor As Color
- Get
- Return _ActiveColor
- End Get
- Set(value As Color)
- _ActiveColor = value
- End Set
- End Property
- #End Region
- #End Region
- #Region " Colors"
- Private BGColor As Color = Color.White
- Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
- Private _ActiveColor As Color = _FlatColor
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- Font = New Font("Segoe UI Symbol", 12)
- SizeMode = TabSizeMode.Fixed
- ItemSize = New Size(120, 45)
- _TabStyle = _TabColor.Red
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Select Case TabStyle
- Case _TabColor.Grey
- _TabStyle = Color.FromArgb(217, 217, 217)
- Case _TabColor.Darcula
- _TabStyle = Color.FromArgb(60, 63, 65)
- Case _TabColor.Pink
- _TabStyle = Color.FromArgb(220, 79, 173)
- Case _TabColor.Navy
- _TabStyle = Color.FromArgb(0, 114, 198)
- Case _TabColor.Red
- _TabStyle = Color.FromArgb(206, 53, 44)
- Case _TabColor.Green
- _TabStyle = Color.FromArgb(96, 169, 23)
- Case _TabColor.Orange
- _TabStyle = Color.FromArgb(250, 104, 0)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(_TabStyle)
- Try : SelectedTab.BackColor = BGColor : Catch : End Try
- For i = 0 To TabCount - 1
- Dim Base As New Rectangle(New Point(GetTabRect(i).Location.X + 2, GetTabRect(i).Location.Y), New Size(GetTabRect(i).Width, GetTabRect(i).Height))
- Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
- Dim Bae As New Rectangle(New Point(0, Base.Location.Y + 47), New Size(SelectedTab.Width + 20, SelectedTab.Height + 25))
- If i = SelectedIndex Then
- '-- Basea
- '.FillRectangle(New SolidBrush(_TabStyle), BaseSize)
- .FillRectangle(New SolidBrush(Color.White), Bae)
- '-- ImageList
- If ImageList IsNot Nothing Then
- Try
- If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
- '-- Image
- .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
- '-- Text
- .DrawString(" " & TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, Brushes.White, BaseSize, CenterSF)
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- '-- Text
- .DrawString(TabPages(i).Text + "", Font, Brushes.White, BaseSize, CenterSF)
- End If
- Else
- '-- Base
- .FillRectangle(New SolidBrush(_TabStyle), BaseSize)
- '-- ImageList
- If ImageList IsNot Nothing Then
- Try
- If ImageList.Images(TabPages(i).ImageIndex) IsNot Nothing Then
- '-- Image
- .DrawImage(ImageList.Images(TabPages(i).ImageIndex), New Point(BaseSize.Location.X + 8, BaseSize.Location.Y + 6))
- '-- Text
- .DrawString(" " & TabPages(i).Text, Font, New SolidBrush(Color.Black), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- Else
- '-- Text
- .DrawString(TabPages(i).Text, Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- '-- Text
- .DrawString(TabPages(i).Text + "", Font, New SolidBrush(Color.White), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End If
- End If
- Next
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroGroupBox : Inherits ContainerControl
- #Region " Variables"
- Private W, H As Integer
- Private _ShowText As Boolean = True
- Private _HasBody As Boolean = True
- Private _Style
- #End Region
- #Region " Properties"
- Private O As _GroupBoxColor
- <Flags()> _
- Enum _GroupBoxColor
- Grey
- Darcula
- Pink
- Navy
- Red
- Green
- Orange
- End Enum
- <Category("Options")> _
- Public Property GroupBoxStyle() As _GroupBoxColor
- Get
- Return O
- End Get
- Set(value As _GroupBoxColor)
- O = value
- End Set
- End Property
- Public Property ShowText As Boolean
- Get
- Return _ShowText
- End Get
- Set(value As Boolean)
- _ShowText = value
- End Set
- End Property
- Public Property HasBody As Boolean
- Get
- Return _HasBody
- End Get
- Set(value As Boolean)
- _HasBody = value
- End Set
- End Property
- #End Region
- #Region " Colors"
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- BackColor = Color.Transparent
- Size = New Size(240, 180)
- Font = New Font("Segoe ui", 12)
- _Style = _GroupBoxColor.Navy
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- W = Width - 1 : H = Height - 1
- Dim GP, GP2, GP3 As New GraphicsPath
- Dim Base As New Rectangle(8, 8, W - 16, H - 16)
- Dim Header As New Rectangle(8, 8, W - 16, 40)
- Select Case GroupBoxStyle
- Case _GroupBoxColor.Grey
- _Style = Color.FromArgb(217, 217, 217)
- Case _GroupBoxColor.Darcula
- _Style = Color.FromArgb(60, 63, 65)
- Case _GroupBoxColor.Pink
- _Style = Color.FromArgb(220, 79, 173)
- Case _GroupBoxColor.Navy
- _Style = Color.FromArgb(0, 114, 198)
- Case _GroupBoxColor.Red
- _Style = Color.FromArgb(206, 53, 44)
- Case _GroupBoxColor.Green
- _Style = Color.FromArgb(96, 169, 23)
- Case _GroupBoxColor.Orange
- _Style = Color.FromArgb(250, 104, 0)
- End Select
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- '-- Base
- GP = Helpers.RoundRec(Base, 1)
- GP2 = Helpers.RoundRec(Header, 1)
- If _HasBody Then
- .FillPath(New SolidBrush(_Style), GP)
- .FillPath(New SolidBrush(_Style), GP2)
- Else
- .FillPath(New SolidBrush(_Style), GP2)
- End If
- '-- if ShowText
- If ShowText Then
- .DrawString(Text, Font, New SolidBrush(Color.White), New Rectangle(16, 16, W, H), NearSF)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroClose : Inherits Control
- #Region " Variables"
- Private State As MouseState = MouseState.None
- Private x As Integer
- #End Region
- #Region " Properties"
- #Region " Mouse States"
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- x = e.X : Invalidate()
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- Environment.Exit(0)
- End Sub
- #End Region
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(18, 18)
- End Sub
- #Region " Colors"
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- End Set
- End Property
- #End Region
- #End Region
- #Region " Colors"
- Private _BaseColor As Color = Color.FromArgb(168, 35, 35)
- Private _TextColor As Color = Color.FromArgb(243, 243, 243)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Color.FromArgb(0, 114, 198)
- Size = New Size(20, 20)
- Anchor = AnchorStyles.Top Or AnchorStyles.Right
- Font = New Font("Marlett", 18)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height)
- Dim G As Graphics = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- '-- Base
- .FillRectangle(New SolidBrush(Color.FromArgb(0, 114, 198)), Base)
- '-- X
- .DrawString("r", Font, New SolidBrush(Color.White), New Rectangle(0, 0, Width, Height), CenterSF)
- '-- Hover/down
- 'Select Case State
- ' Case MouseState.Over
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
- ' Case MouseState.Down
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
- 'End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroMax : Inherits Control
- #Region " Variables"
- Private State As MouseState = MouseState.None
- Private x As Integer
- #End Region
- #Region " Properties"
- #Region " Mouse States"
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- x = e.X : Invalidate()
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- Select Case FindForm.WindowState
- Case FormWindowState.Maximized
- FindForm.WindowState = FormWindowState.Normal
- Case FormWindowState.Normal
- FindForm.WindowState = FormWindowState.Maximized
- End Select
- End Sub
- #End Region
- #Region " Colors"
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- End Set
- End Property
- #End Region
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(20, 20)
- End Sub
- #End Region
- #Region " Colors"
- Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
- Private _TextColor As Color = Color.FromArgb(243, 243, 243)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Color.FromArgb(0, 114, 198)
- Size = New Size(20, 20)
- Anchor = AnchorStyles.Top Or AnchorStyles.Right
- Font = New Font("Marlett", 18)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height)
- Dim G As Graphics = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- '-- Base
- .FillRectangle(New SolidBrush(Color.FromArgb(0, 114, 198)), Base)
- '-- Maximize
- .DrawString("1", Font, New SolidBrush(Color.White), New Rectangle(1, 1, Width, Height), CenterSF)
- '-- Hover/down
- 'Select Case State
- ' Case MouseState.Over
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
- ' Case MouseState.Down
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
- 'End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroMini : Inherits Control
- #Region " Variables"
- Private State As MouseState = MouseState.None
- Private x As Integer
- #End Region
- #Region " Properties"
- #Region " Mouse States"
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MyBase.OnMouseEnter(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- State = MouseState.Down : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- x = e.X : Invalidate()
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- Select Case FindForm.WindowState
- Case FormWindowState.Normal
- FindForm.WindowState = FormWindowState.Minimized
- Case FormWindowState.Maximized
- FindForm.WindowState = FormWindowState.Minimized
- End Select
- End Sub
- #End Region
- #Region " Colors"
- <Category("Colors")> _
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Colors")> _
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- End Set
- End Property
- #End Region
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(20, 20)
- End Sub
- #End Region
- #Region " Colors"
- Private _BaseColor As Color = Color.FromArgb(45, 47, 49)
- Private _TextColor As Color = Color.FromArgb(243, 243, 243)
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or _
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Color.FromArgb(0, 114, 198)
- Size = New Size(20, 20)
- Anchor = AnchorStyles.Top Or AnchorStyles.Right
- Font = New Font("Marlett", 18)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height)
- Dim G As Graphics = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = 2
- .PixelOffsetMode = 2
- .TextRenderingHint = 5
- .Clear(BackColor)
- '-- Base
- .FillRectangle(New SolidBrush(Color.FromArgb(0, 114, 198)), Base)
- '-- Minimize
- .DrawString("0", Font, New SolidBrush(Color.White), New Rectangle(2, 1, Width, Height), CenterSF)
- '-- Hover/down
- 'Select Case State
- ' Case MouseState.Over
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.White)), Base)
- ' Case MouseState.Down
- ' .FillRectangle(New SolidBrush(Color.FromArgb(30, Color.Black)), Base)
- 'End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = 7
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Class MetroLabel : Inherits Label
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Sub New()
- SetStyle(ControlStyles.SupportsTransparentBackColor, True)
- Font = New Font("Segoe UI", 12)
- ForeColor = Color.Black
- BackColor = Color.Transparent
- Text = Text
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment