Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Drawing, System.Drawing.Drawing2D, System.Drawing.Text, System.Windows.Forms, System.ComponentModel
- 'Name (Theme): Advanced UI
- 'Inspired by: Flat UI (by iSynthesis), LogIn (by Xertz), Driver Booster (by IObit)
- 'Creator: Intelligent Software Development (ISD)
- 'Version: 1.0.0 (Release Version)
- 'Date Created: 05/07/2015
- 'Release Date: 08/30/2015
- 'Created with: Visual Studio Community 2015 (.NET Framework 4.6)
- 'Support/Feedback:
- ' E-Mail; IntSofDev@outlook.com (Recommended for Support)
- ' Steam; http://steamcommunity.com/id/IntelligentSoftwareDevelopment
- ' High-Minded; https://high-minded.net/members/isd.21157/
- ' CoderBay; https://www.coderbay.net/index.php?/user/102-isd/
- ' MPGH; http://www.mpgh.net/forum/member.php?u=2616998
- ' Hack Forums; http://www.hackforums.net/member.php?action=profile&uid=2807959
- Module Support
- #Region "Variables"
- Friend G As Graphics, B As Bitmap
- Friend Near As New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near}
- Friend Center As New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center}
- Friend Far As New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Far}
- Friend ColorBlendPositions() As Single = {0.0, 0.33, 0.66, 1.0}
- 'Colors
- Friend Black As Color = Color.FromArgb(50, 50, 50) 'Black
- Friend Gray As Color = Color.FromArgb(70, 70, 70) 'Gray
- Friend White As Color = Color.FromArgb(255, 255, 255) 'White
- Friend Orange As Color = Color.FromArgb(250, 190, 60) 'Orange
- Friend Red As Color = Color.FromArgb(220, 85, 100) 'Red
- Friend Green As Color = Color.FromArgb(35, 170, 110) 'Green
- Friend Blue As Color = Color.FromArgb(0, 130, 255) 'Blue
- #End Region
- #Region "Functions"
- Public Function rRectangle(ByVal Rectangle As Rectangle, ByVal Curve As Integer) As GraphicsPath
- Dim GP As New GraphicsPath()
- Dim ArcRectangleWidth As Integer = Curve * 2
- GP.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -180, 90)
- GP.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
- GP.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
- GP.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
- GP.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth + Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
- Return GP
- End Function
- #End Region
- #Region "Mouse States"
- Enum MouseState As Byte
- None = 0
- Over = 1
- Down = 2
- Block = 3
- End Enum
- #End Region
- End Module
- Public Class FormUI : Inherits ContainerControl
- #Region "Variables"
- Private x As Integer
- Private State As MouseState = MouseState.None
- Private MousePoint As New Point(0, 0)
- Private MoveHeight As Integer = 50
- Private Cap As Boolean = False
- #End Region
- #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)
- If e.Button = MouseButtons.Left And New Rectangle(0, 0, Width, MoveHeight).Contains(e.Location) Then
- If Movable Then
- Cap = True
- MousePoint = e.Location
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e) : Cap = False
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- If Cap Then
- Parent.Location = MousePosition - CType(MousePoint, Size)
- End If
- x = e.X : Invalidate()
- End Sub
- #End Region
- #Region "Properties"
- <Flags()>
- Enum HTP
- Left
- Center
- Right
- End Enum
- <Flags()>
- Enum BTP
- Left
- Center
- Right
- End Enum
- <Flags()>
- Enum LS
- Normal
- ColorBlend
- End Enum
- Private _LineStyle As LS = LS.Normal
- <Category("Properties")>
- Public Property LineStyle As LS
- Get
- Return _LineStyle
- End Get
- Set(value As LS)
- _LineStyle = value
- Invalidate()
- End Set
- End Property
- Private _ShowIcon As Boolean = True
- <Category("Properties")>
- Public Property ShowIcon As Boolean
- Get
- Return _ShowIcon
- End Get
- Set(value As Boolean)
- _ShowIcon = value
- Invalidate()
- End Set
- End Property
- Private _HeaderTextPosition As HTP = HTP.Left
- <Category("Properties")>
- Public Property HeaderTextPosition As HTP
- Get
- Return _HeaderTextPosition
- End Get
- Set(value As HTP)
- _HeaderTextPosition = value
- Invalidate()
- End Set
- End Property
- Private _BottomTextPosition As BTP = BTP.Center
- <Category("Properties")>
- Public Property BottomTextPosition As BTP
- Get
- Return _BottomTextPosition
- End Get
- Set(value As BTP)
- _BottomTextPosition = value
- Invalidate()
- End Set
- End Property
- Private _ShowVersion As Boolean = False
- <Category("Properties")>
- Public Property ShowVersion As Boolean
- Get
- Return _ShowVersion
- End Get
- Set(value As Boolean)
- _ShowVersion = value
- Invalidate()
- End Set
- End Property
- Private _Version As String
- <Category("Properties")>
- Public Property Version As String
- Get
- Return _Version
- End Get
- Set(value As String)
- _Version = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _BorderColorIntensity As Integer = 255
- <Category("Properties")>
- Public Property BorderColorIntensity As Integer
- Get
- Return _BorderColorIntensity
- End Get
- Set(value As Integer)
- _BorderColorIntensity = value
- Invalidate()
- End Set
- End Property
- Private _Header As Boolean = True
- <Category("Properties")>
- Public Property Header As Boolean
- Get
- Return _Header
- End Get
- Set(value As Boolean)
- _Header = value
- Invalidate()
- End Set
- End Property
- Private _ShinyHeader As Boolean = False
- <Category("Properties")>
- Public Property ShinyHeader As Boolean
- Get
- Return _ShinyHeader
- End Get
- Set(value As Boolean)
- _ShinyHeader = value
- Invalidate()
- End Set
- End Property
- Private _ShinyIntensity As Integer = 15
- <Category("Properties")>
- Public Property ShinyIntensity As Integer
- Get
- Return _ShinyIntensity
- End Get
- Set(value As Integer)
- _ShinyIntensity = value
- Invalidate()
- End Set
- End Property
- Private _TopLine As Boolean = False
- <Category("Properties")>
- Public Property TopLine As Boolean
- Get
- Return _TopLine
- End Get
- Set(value As Boolean)
- _TopLine = value
- Invalidate()
- End Set
- End Property
- Private _BottomBar As Boolean = True
- <Category("Properties")>
- Public Property BottomBar As Boolean
- Get
- Return _BottomBar
- End Get
- Set(value As Boolean)
- _BottomBar = value
- Invalidate()
- End Set
- End Property
- Private _BottomText As String
- <Category("Properties")>
- Public Property BottomText As String
- Get
- Return _BottomText
- End Get
- Set(value As String)
- _BottomText = value
- Invalidate()
- End Set
- End Property
- Private _BottomLine As Boolean = False
- <Category("Properties")>
- Public Property BottomLine As Boolean
- Get
- Return _BottomLine
- End Get
- Set(value As Boolean)
- _BottomLine = value
- Invalidate()
- End Set
- End Property
- Private _Movable As Boolean = True
- <Category("Properties")>
- Public Property Movable As Boolean
- Get
- Return _Movable
- End Get
- Set(value As Boolean)
- _Movable = value
- End Set
- End Property
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- ParentForm.FormBorderStyle = FormBorderStyle.None
- ParentForm.AllowTransparency = True
- ParentForm.TransparencyKey = Color.Fuchsia
- ParentForm.FindForm.StartPosition = FormStartPosition.CenterScreen
- Dock = DockStyle.Fill
- Invalidate()
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HeaderColor As Color
- Get
- Return _HeaderColor
- End Get
- Set(value As Color)
- _HeaderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BottomBarColor As Color
- Get
- Return _BottomBarColor
- End Get
- Set(value As Color)
- _BottomBarColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ShinyColor As Color
- Get
- Return _ShinyColor
- End Get
- Set(value As Color)
- _ShinyColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property LineColor As Color
- Get
- Return _LineColor
- End Get
- Set(value As Color)
- _LineColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Gray
- Private _HeaderColor As Color = Black
- Private _BottomBarColor As Color = Black
- Private _BorderColor As Color = White
- Private _ShinyColor As Color = White
- Private _LineColor As Color = White
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- Private _TextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Font = New Font("Segoe UI", 12)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim GP As New GraphicsPath
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim LineColorBlend As New ColorBlend(4), LineBrush As New LinearGradientBrush(Base, Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Header
- If Header Then
- .FillRectangle(New SolidBrush(HeaderColor), New Rectangle(0, 0, Width, 50))
- 'ShinyHeader
- If ShinyHeader Then
- .FillRectangle(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), New Rectangle(0, 0, Width, CInt(50 / 2)))
- End If
- End If
- 'BottomBar
- If BottomBar Then
- .FillRectangle(New SolidBrush(BottomBarColor), New Rectangle(0, Height - 50, Width, 50))
- End If
- If Header Then
- 'Text & Icon
- Select Case HeaderTextPosition
- Case HTP.Left
- If ShowVersion Then
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(48, 6, Width, Height), Near)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(48, 26, Width, Height), Near)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(14, 6, Width, Height), Near)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(14, 26, Width, Height), Near)
- End If
- Else
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(48, 14, Width, Height), Near)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(14, 14, Width, Height), Near)
- End If
- End If
- Case HTP.Center
- If ShowVersion Then
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(25, -8, Width, 53), Center)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(25, 10, Width, 53), Center)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(25, -8, Width, 53), Center)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(25, 10, Width, 53), Center)
- End If
- Else
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(25, 0, Width, 53), Center)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, 53), Center)
- End If
- End If
- Case HTP.Right
- If ShowVersion Then
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(-13, -8, Width, 38), Far)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(-13, 8, Width, 38), Far)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(-13, -8, Width, 38), Far)
- .DrawString(Version, New Font("Segoe UI", 10), New SolidBrush(TextColor), New Rectangle(-13, 8, Width, 38), Far)
- End If
- Else
- If ShowIcon Then
- .DrawIcon(FindForm.Icon, New Rectangle(14, 15, 22, 22))
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(-13, 0, Width, 38), Far)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(-13, 0, Width, 38), Far)
- End If
- End If
- End Select
- 'Bottom Text
- Select Case BottomTextPosition
- Case BTP.Left
- .DrawString(BottomText, Font, New SolidBrush(TextColor), New Rectangle(6, 0, Width, Height + Height - 50), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Center})
- Case BTP.Center
- .DrawString(BottomText, Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height + Height - 50), Center)
- Case BTP.Right
- .DrawString(BottomText, Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width - 6, Height + Height - 50), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
- End Select
- End If
- 'Border
- If Border Then
- .DrawRectangle(New Pen(Color.FromArgb(BorderColorIntensity, BorderColor)), Base)
- End If
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- LineColorBlend.Colors = Colors
- LineColorBlend.Positions = ColorBlendPositions
- LineBrush.InterpolationColors = LineColorBlend
- If Header Then
- 'TopLine
- If TopLine Then
- Select Case LineStyle
- Case LS.Normal
- If Border Then
- .DrawLine(New Pen(LineColor), 1, 50, Width - 1, 50)
- Else
- .DrawLine(New Pen(LineColor), 0, 50, Width, 50)
- End If
- Case LS.ColorBlend
- .DrawLine(New Pen(LineBrush), 0, 50, Width, 50)
- End Select
- End If
- End If
- If BottomBar Then
- 'BottomLine
- If BottomLine Then
- Select Case LineStyle
- Case LS.Normal
- If Border Then
- .DrawLine(New Pen(LineColor), 1, Height - 50, Width - 1, Height - 50)
- Else
- .DrawLine(New Pen(LineColor), 0, Height - 50, Width, Height - 50)
- End If
- Case LS.ColorBlend
- .DrawLine(New Pen(LineBrush), 0, Height - 50, Width, Height - 50)
- End Select
- End If
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class CloseButton : Inherits Control
- #Region "Variables"
- Private x As Integer
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : 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)
- If CloseChoice = CC.Form Then
- Parent.FindForm.Close()
- Else
- Environment.Exit(0)
- End If
- End Sub
- #End Region
- #Region "Properties"
- Enum CC
- Form
- Application
- End Enum
- Private _CloseChoice As CC = CC.Form
- <Category("Properties")>
- Public Property CloseChoice As CC
- Get
- Return _CloseChoice
- End Get
- Set(value As CC)
- _CloseChoice = value
- End Set
- End Property
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(18, 18)
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverColor As Color
- Get
- Return _HoverColor
- End Get
- Set(value As Color)
- _HoverColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Color.Transparent
- Private _TextColor As Color = White
- Private _HoverColor As Color = Red
- #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(18, 18)
- Margin = New Padding(3, 7, 3, 3)
- Font = New Font("Marlett", 12)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Text
- .DrawString("r", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, 19), Center)
- 'Hover
- Select Case State
- Case MouseState.Over
- .DrawString("r", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, 19), Center)
- Case MouseState.Down
- .DrawString("r", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, 19), Center)
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class MaximizeButton : Inherits Control
- #Region "Variables"
- Private x As Integer
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : 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 "Properties"
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(18, 18)
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverColor As Color
- Get
- Return _HoverColor
- End Get
- Set(value As Color)
- _HoverColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Color.Transparent
- Private _TextColor As Color = White
- Private _HoverColor As Color = Green
- #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(18, 18)
- Margin = New Padding(3, 7, 3, 3)
- Font = New Font("Marlett", 12)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Text
- If FindForm.WindowState = FormWindowState.Maximized Then
- .DrawString("2", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), Center)
- ElseIf FindForm.WindowState = FormWindowState.Normal Then
- .DrawString("1", Font, New SolidBrush(TextColor), New Rectangle(1, 1, Width, Height), Center)
- End If
- 'Hover
- Select Case State
- Case MouseState.Over
- If FindForm.WindowState = FormWindowState.Maximized Then
- .DrawString("2", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, Height), Center)
- ElseIf FindForm.WindowState = FormWindowState.Normal Then
- .DrawString("1", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, Height), Center)
- End If
- Case MouseState.Down
- If FindForm.WindowState = FormWindowState.Maximized Then
- .DrawString("2", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, Height), Center)
- ElseIf FindForm.WindowState = FormWindowState.Normal Then
- .DrawString("1", Font, New SolidBrush(HoverColor), New Rectangle(1, 1, Width, Height), Center)
- End If
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class MinimizeButton : Inherits Control
- #Region "Variables"
- Private x As Integer
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : 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
- End Select
- End Sub
- #End Region
- #Region "Properties"
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Size = New Size(18, 18)
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverColor As Color
- Get
- Return _HoverColor
- End Get
- Set(value As Color)
- _HoverColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Color.Transparent
- Private _TextColor As Color = White
- Private _HoverColor As Color = Green
- #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(18, 18)
- Margin = New Padding(3, 7, 3, 3)
- Font = New Font("Marlett", 12)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim B As New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Text
- .DrawString("0", Font, New SolidBrush(TextColor), New Rectangle(2, 1, Width, Height), Center)
- 'Hover
- Select Case State
- Case MouseState.Over
- .DrawString("0", Font, New SolidBrush(HoverColor), New Rectangle(2, 1, Width, Height), Center)
- Case MouseState.Down
- .DrawString("0", Font, New SolidBrush(HoverColor), New Rectangle(2, 1, Width, Height), Center)
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class Button : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(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
- #Region "Properties"
- <Flags()>
- Enum BS
- Normal
- ColorBlend
- End Enum
- Private _BorderStyle As BS = BS.Normal
- <Category("Properties")>
- Public Property BorderStyle As BS
- Get
- Return _BorderStyle
- End Get
- Set(value As BS)
- _BorderStyle = value
- Invalidate()
- End Set
- End Property
- Private _Rounded As Boolean = False
- <Category("Properties")>
- Public Property Rounded As Boolean
- Get
- Return _Rounded
- End Get
- Set(value As Boolean)
- _Rounded = value
- Invalidate()
- End Set
- End Property
- Private _Rounding As Integer = 8
- <Category("Properties")>
- Public Property Rounding As Integer
- Get
- Return _Rounding
- End Get
- Set(value As Integer)
- _Rounding = value
- Invalidate()
- End Set
- End Property
- Private _HoverColorIntensity As Integer = 15
- <Category("Properties")>
- Public Property HoverColorIntensity As Integer
- Get
- Return _HoverColorIntensity
- End Get
- Set(value As Integer)
- _HoverColorIntensity = value
- End Set
- End Property
- Private _DownColorIntensity As Integer = 30
- <Category("Properties")>
- Public Property DownColorIntensity As Integer
- Get
- Return _DownColorIntensity
- End Get
- Set(value As Integer)
- _DownColorIntensity = value
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _BorderColorIntensity As Integer = 255
- <Category("Properties")>
- Public Property BorderColorIntensity As Integer
- Get
- Return _BorderColorIntensity
- End Get
- Set(value As Integer)
- _BorderColorIntensity = value
- Invalidate()
- End Set
- End Property
- Private _Shiny As Boolean = False
- <Category("Properties")>
- Public Property Shiny As Boolean
- Get
- Return _Shiny
- End Get
- Set(value As Boolean)
- _Shiny = value
- Invalidate()
- End Set
- End Property
- Private _ShinyIntensity As Integer = 15
- <Category("Properties")>
- Public Property ShinyIntensity As Integer
- Get
- Return _ShinyIntensity
- End Get
- Set(value As Integer)
- _ShinyIntensity = value
- Invalidate()
- End Set
- End Property
- Private _ShinyRounding As Integer = 8
- <Category("Properties")>
- Public Property ShinyRounding As Integer
- Get
- Return _ShinyRounding
- End Get
- Set(value As Integer)
- _ShinyRounding = value
- End Set
- End Property
- Private _ShowImage As Boolean = False
- <Category("Properties")>
- Public Property ShowImage As Boolean
- Get
- Return _ShowImage
- End Get
- Set(value As Boolean)
- _ShowImage = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverColor As Color
- Get
- Return _HoverColor
- End Get
- Set(value As Color)
- _HoverColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property DownColor As Color
- Get
- Return _DownColor
- End Get
- Set(value As Color)
- _DownColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverBorderColor As Color
- Get
- Return _HoverBorderColor
- End Get
- Set(value As Color)
- _HoverBorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property DownBorderColor As Color
- Get
- Return _DownBorderColor
- End Get
- Set(value As Color)
- _DownBorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ShinyColor As Color
- Get
- Return _ShinyColor
- End Get
- Set(value As Color)
- _ShinyColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _HoverColor As Color = White
- Private _DownColor As Color = Color.Black
- Private _HoverBorderColor As Color = White
- Private _DownBorderColor As Color = White
- Private _BorderColor As Color = White
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- Private _ShinyColor As Color = White
- Private _TextColor As Color = White
- #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(128, 32)
- Font = New Font("Segoe UI", 12)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim BorderColorBlend As New ColorBlend(4), BorderBrush As New LinearGradientBrush(Base, Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- If Rounded Then
- 'Base
- .FillPath(New SolidBrush(BaseColor), Support.rRectangle(Base, Rounding))
- Select Case State
- Case MouseState.Over
- .FillPath(New SolidBrush(Color.FromArgb(HoverColorIntensity, HoverColor)), Support.rRectangle(Base, Rounding))
- Case MouseState.Down
- .FillPath(New SolidBrush(Color.FromArgb(DownColorIntensity, DownColor)), Support.rRectangle(Base, Rounding))
- End Select
- 'Shiny
- If Shiny Then
- .FillPath(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), Support.rRectangle(New Rectangle(0, 0, Width, CInt(Height / 2)), ShinyRounding))
- End If
- Else
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- Select Case State
- Case MouseState.Over
- .FillRectangle(New SolidBrush(Color.FromArgb(HoverColorIntensity, HoverColor)), Base)
- Case MouseState.Down
- .FillRectangle(New SolidBrush(Color.FromArgb(DownColorIntensity, DownColor)), Base)
- End Select
- 'Shiny
- If Shiny Then
- .FillRectangle(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), New Rectangle(0, 0, Width, CInt(Height / 2)))
- End If
- End If
- 'Text
- .DrawString(Text, Font, New SolidBrush(TextColor), Base, Center)
- 'Border
- If Rounded Then : Else
- If Border Then
- Select Case BorderStyle
- Case BS.Normal
- .DrawRectangle(New Pen(Color.FromArgb(BorderColorIntensity, BorderColor)), Base)
- Case BS.ColorBlend
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- BorderColorBlend.Colors = Colors
- BorderColorBlend.Positions = ColorBlendPositions
- BorderBrush.InterpolationColors = BorderColorBlend
- .DrawLine(New Pen(BorderBrush), New Point(0, 0), New Point(Width, 0))
- .DrawLine(New Pen(BorderBrush), New Point(0, Height), New Point(Width, Height))
- .DrawLine(New Pen(BorderBrush), New Point(0, 0), New Point(0, Height))
- .DrawLine(New Pen(BorderBrush), New Point(Width, 0), New Point(Width, Height))
- End Select
- End If
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.DrawImage(DirectCast(B.Clone(), Image), 0, 0)
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class RoundedButton : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(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
- #Region "Properties"
- <Flags()>
- Enum BS
- Small
- Normal
- Big
- End Enum
- Private _ButtonSize As BS = BS.Normal
- <Category("Properties")>
- Public Property ButtonSize As BS
- Get
- Return _ButtonSize
- End Get
- Set(value As BS)
- _ButtonSize = value
- Select Case ButtonSize
- Case BS.Small
- Size = New Size(96, 96)
- Case BS.Normal
- Size = New Size(128, 128)
- Case BS.Big
- Size = New Size(160, 160)
- End Select
- Invalidate()
- End Set
- End Property
- Private _RingColorIntensity As Integer = 255
- <Category("Properties")>
- Public Property RingColorIntensity As Integer
- Get
- Return _RingColorIntensity
- End Get
- Set(value As Integer)
- _RingColorIntensity = value
- Invalidate()
- End Set
- End Property
- Private _HoverColorIntensity As Integer = 15
- <Category("Properties")>
- Public Property HoverColorIntensity As Integer
- Get
- Return _HoverColorIntensity
- End Get
- Set(value As Integer)
- _HoverColorIntensity = value
- End Set
- End Property
- Private _DownColorIntensity As Integer = 30
- <Category("Properties")>
- Public Property DownColorIntensity As Integer
- Get
- Return _DownColorIntensity
- End Get
- Set(value As Integer)
- _DownColorIntensity = value
- End Set
- End Property
- Private _BorderColorIntensity As Integer = 255
- <Category("Properties")>
- Public Property BorderColorIntensity As Integer
- Get
- Return _BorderColorIntensity
- End Get
- Set(value As Integer)
- _BorderColorIntensity = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Select Case ButtonSize
- Case BS.Small
- Width = 96
- Height = 96
- Case BS.Normal
- Width = 128
- Height = 128
- Case BS.Big
- Width = 160
- Height = 160
- End Select
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property RingColor As Color
- Get
- Return _RingColor
- End Get
- Set(value As Color)
- _RingColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverColor As Color
- Get
- Return _HoverColor
- End Get
- Set(value As Color)
- _HoverColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property DownColor As Color
- Get
- Return _DownColor
- End Get
- Set(value As Color)
- _DownColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _RingColor As Color = Green
- Private _HoverColor As Color = White
- Private _DownColor As Color = Color.Black
- Private _BorderColor As Color = Black
- Private _TextColor As Color = White
- #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(128, 128)
- Font = New Font("Segoe UI", 12)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim SideBlend As New ColorBlend(4), MiddleBlend As New ColorBlend(4),
- SideBrush As New LinearGradientBrush(New Point(0, 0), New Point(0, Height), Color.Black, Color.Black),
- MiddleBrush As New LinearGradientBrush(New Point(0, 0), New Point(45, Height), Color.Black, Color.Black)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Border
- .FillEllipse(New SolidBrush(Color.FromArgb(BorderColorIntensity, BorderColor)), Base)
- 'Side Ring
- .FillEllipse(New SolidBrush(Color.FromArgb(255, Black)), New Rectangle(1, 1, Width - 2, Height - 2))
- .FillEllipse(New SolidBrush(Color.FromArgb(10, White)), New Rectangle(1, 1, Width - 2, Height - 2))
- Select Case ButtonSize
- Case BS.Small
- 'Second Side Ring
- SideBlend.Colors(1) = Color.FromArgb(60, 150, 150, 150)
- SideBlend.Colors(2) = Color.FromArgb(255, 35, 35, 35)
- SideBlend.Positions = New Single() {0.0, 0.33, 0.66, 1.0}
- SideBrush.InterpolationColors = SideBlend
- .FillEllipse(SideBrush, New Rectangle(6, 6, Width - 12, Height - 12))
- 'Colored Ring
- .FillEllipse(New SolidBrush(Color.FromArgb(RingColorIntensity, RingColor)), New Rectangle(12, 12, Width - 24, Height - 24))
- 'Middle Button
- MiddleBlend.Colors(1) = Color.FromArgb(255, Black)
- MiddleBlend.Colors(2) = Color.FromArgb(255, 40, 40, 40)
- MiddleBlend.Colors(3) = Color.FromArgb(255, Gray)
- MiddleBlend.Positions = New Single() {0.0, 0.00, 0.66, 1.0}
- MiddleBrush.InterpolationColors = MiddleBlend
- .FillEllipse(MiddleBrush, New Rectangle(16, 16, Width - 32, Height - 32))
- Select Case State
- Case MouseState.Over
- .FillEllipse(New SolidBrush(Color.FromArgb(HoverColorIntensity, HoverColor)), New Rectangle(16, 16, Width - 32, Height - 32))
- Case MouseState.Down
- .FillEllipse(New SolidBrush(Color.FromArgb(DownColorIntensity, DownColor)), New Rectangle(16, 16, Width - 32, Height - 32))
- End Select
- Case BS.Normal
- 'Second Side Ring
- SideBlend.Colors(1) = Color.FromArgb(60, 150, 150, 150)
- SideBlend.Colors(2) = Color.FromArgb(255, 35, 35, 35)
- SideBlend.Positions = New Single() {0.0, 0.33, 0.66, 1.0}
- SideBrush.InterpolationColors = SideBlend
- .FillEllipse(SideBrush, New Rectangle(8, 8, Width - 16, Height - 16))
- 'Colored Ring
- .FillEllipse(New SolidBrush(Color.FromArgb(RingColorIntensity, RingColor)), New Rectangle(16, 16, Width - 32, Height - 32))
- 'Middle Button
- MiddleBlend.Colors(1) = Color.FromArgb(255, Black)
- MiddleBlend.Colors(2) = Color.FromArgb(255, 40, 40, 40)
- MiddleBlend.Colors(3) = Color.FromArgb(255, Gray)
- MiddleBlend.Positions = New Single() {0.0, 0.00, 0.66, 1.0}
- MiddleBrush.InterpolationColors = MiddleBlend
- .FillEllipse(MiddleBrush, New Rectangle(22, 22, Width - 44, Height - 44))
- Select Case State
- Case MouseState.Over
- .FillEllipse(New SolidBrush(Color.FromArgb(HoverColorIntensity, HoverColor)), New Rectangle(22, 22, Width - 44, Height - 44))
- Case MouseState.Down
- .FillEllipse(New SolidBrush(Color.FromArgb(DownColorIntensity, DownColor)), New Rectangle(22, 22, Width - 44, Height - 44))
- End Select
- Case BS.Big
- 'Second Side Ring
- SideBlend.Colors(1) = Color.FromArgb(60, 150, 150, 150)
- SideBlend.Colors(2) = Color.FromArgb(255, 35, 35, 35)
- SideBlend.Positions = New Single() {0.0, 0.33, 0.66, 1.0}
- SideBrush.InterpolationColors = SideBlend
- .FillEllipse(SideBrush, New Rectangle(10, 10, Width - 20, Height - 20))
- 'Colored Ring
- .FillEllipse(New SolidBrush(Color.FromArgb(RingColorIntensity, RingColor)), New Rectangle(20, 20, Width - 40, Height - 40))
- 'Middle Button
- MiddleBlend.Colors(1) = Color.FromArgb(255, 50, 50, 50)
- MiddleBlend.Colors(2) = Color.FromArgb(255, 40, 40, 40)
- MiddleBlend.Colors(3) = Color.FromArgb(255, Gray)
- MiddleBlend.Positions = New Single() {0.0, 0.00, 0.66, 1.0}
- MiddleBrush.InterpolationColors = MiddleBlend
- .FillEllipse(MiddleBrush, New Rectangle(28, 28, Width - 56, Height - 56))
- Select Case State
- Case MouseState.Over
- .FillEllipse(New SolidBrush(Color.FromArgb(HoverColorIntensity, HoverColor)), New Rectangle(28, 28, Width - 56, Height - 56))
- Case MouseState.Down
- .FillEllipse(New SolidBrush(Color.FromArgb(DownColorIntensity, DownColor)), New Rectangle(28, 28, Width - 56, Height - 56))
- End Select
- End Select
- 'Text
- .DrawString(Text, Font, New SolidBrush(TextColor), Base, Center)
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class Loader : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- Private WithEvents Timer As New Timer With {.Interval = 10, .Enabled = True}
- Private Maximum As Integer = 100
- Private Minimum As Integer = 0
- Private Value As Integer = 0
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(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
- #Region "Properties"
- <Flags()>
- Enum _Style
- Style1
- Style2
- End Enum
- Private _ChooseStyle As _Style = _Style.Style1
- <Category("Properties")>
- Public Property Style As _Style
- Get
- Return _ChooseStyle
- End Get
- Set(value As _Style)
- _ChooseStyle = value
- Invalidate()
- End Set
- End Property
- Private _TimerEnabled As Boolean = True
- <Category("Properties")>
- Public Property TimerEnabled As Boolean
- Get
- Return _TimerEnabled
- End Get
- Set(value As Boolean)
- _TimerEnabled = value
- If value Then
- Timer.Start()
- Else
- Timer.Stop()
- End If
- Invalidate()
- End Set
- End Property
- Private _TimerInterval As Integer = 10
- <Category("Properties")>
- Public Property TimerInterval As Integer
- Get
- Return _TimerInterval
- End Get
- Set(value As Integer)
- _TimerInterval = value
- Timer.Interval = value
- Invalidate()
- End Set
- End Property
- Private _Thickness As Single = 2
- <Category("Properties")>
- Public Property Thickness As Single
- Get
- Return _Thickness
- End Get
- Set(value As Single)
- _Thickness = value
- Invalidate()
- End Set
- End Property
- Public Sub Increment(ByVal Amount As Integer)
- Value += Amount
- End Sub
- Private _StartingAngleValue As Integer = 90
- Private _StartingAngle As Integer = 90
- <Category("Properties")>
- Public Property StartingAngle As Integer
- Get
- Return _StartingAngle
- End Get
- Set(value As Integer)
- _StartingAngle = value
- _StartingAngleValue = value
- End Set
- End Property
- Private _RotationAngleValue As Integer = 360
- Private _RotationAngle As Integer = 360
- <Category("Properties")>
- Public Property RotationAngle As Integer
- Get
- Return _RotationAngle
- End Get
- Set(value As Integer)
- _RotationAngle = value
- _RotationAngleValue = value
- End Set
- End Property
- Private _Length As Integer = 25
- <Category("Properties")>
- Public Property Length As Integer
- Get
- Return _Length
- End Get
- Set(value As Integer)
- _Length = value
- End Set
- End Property
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = Width
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property LoadingColor As Color
- Get
- Return _LoadingColor
- End Get
- Set(value As Color)
- _LoadingColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _LoadingColor As Color = Green
- #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(32, 32)
- Font = New Font("Segoe UI", 12)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .Clear(BackColor)
- .DrawArc(New Pen(New SolidBrush(LoadingColor), Thickness), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, _StartingAngleValue, CInt((_RotationAngleValue / Maximum) * Value))
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick
- Select Case Style
- Case _Style.Style1
- If Value = Maximum Then
- Value = Minimum
- Else
- Value += 1
- End If
- Case _Style.Style2
- Value = Length
- _StartingAngleValue += 1
- If _StartingAngleValue = RotationAngle + StartingAngle Then
- _StartingAngleValue = StartingAngle
- End If
- End Select
- Invalidate()
- End Sub
- End Class
- Public Class Toggle : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(e)
- State = MouseState.Over : Invalidate()
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e)
- _Checked = Not _Checked
- RaiseEvent CheckedChanged(Me)
- End Sub
- #End Region
- #Region "Properties"
- <Flags()>
- Enum S
- Style1
- Style2
- Style3
- End Enum
- Private _Style As S
- <Category("Properties")>
- Public Property Style As S
- Get
- Return _Style
- End Get
- Set(value As S)
- _Style = value
- Invalidate()
- End Set
- End Property
- Private _Rounded As Boolean = False
- <Category("Properties")>
- Public Property Rounded As Boolean
- Get
- Return _Rounded
- End Get
- Set(value As Boolean)
- _Rounded = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Public Event CheckedChanged(ByVal sender As Object)
- Private _Checked As Boolean
- <Category("Properties")>
- Public Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Width = 70
- Height = 34
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property OnColor As Color
- Get
- Return _OnColor
- End Get
- Set(value As Color)
- _OnColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property OffColor As Color
- Get
- Return _OffColor
- End Get
- Set(value As Color)
- _OffColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property OnTextColor As Color
- Get
- Return _OnTextColor
- End Get
- Set(value As Color)
- _OnTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property OffTextColor As Color
- Get
- Return _OffTextColor
- End Get
- Set(value As Color)
- _OffTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property HoverBorderColor As Color
- Get
- Return _HoverBorderColor
- End Get
- Set(value As Color)
- _HoverBorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property DownBorderColor As Color
- Get
- Return _DownBorderColor
- End Get
- Set(value As Color)
- _DownBorderColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _OnColor As Color = Green
- Private _OffColor As Color = Red
- Private _OnTextColor As Color = White
- Private _OffTextColor As Color = White
- Private _BorderColor As Color = White
- Private _HoverBorderColor As Color = White
- Private _DownBorderColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(70, 30)
- Font = New Font("Segoe UI", 10)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim GP, GP1 As New GraphicsPath
- Dim Base As New Rectangle(0, 0, Width, Height), Toggle As New Rectangle(CInt(Height \ 2), 0, 38, Height), Dot As New Rectangle(6, 6, Height - 12, Height - 12)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- Select Case Style
- Case S.Style1
- If Checked Then
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 9)
- GP1 = Support.rRectangle(New Rectangle(CInt(Width \ 2 + 5), 0, 30, Height), 9)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OnColor), GP1)
- 'Text
- .DrawString("ON", Font, New SolidBrush(OnTextColor), New Rectangle(8, 8, Width, Height), Near)
- Else
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OnColor), New Rectangle(CInt(Width \ 2 + 4), 1, 30, Height - 2))
- 'Text
- .DrawString("ON", Font, New SolidBrush(OnTextColor), New Rectangle(8, 8, Width, Height), Near)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- Else
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 9)
- GP1 = Support.rRectangle(New Rectangle(0, 0, 30, Height), 9)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OffColor), GP1)
- 'Text
- .DrawString("OFF", Font, New SolidBrush(OffTextColor), New Rectangle(14, 1, Width, Height), Center)
- Else
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OffColor), New Rectangle(1, 1, 30, Height - 2))
- 'Text
- .DrawString("OFF", Font, New SolidBrush(OffTextColor), New Rectangle(13, 1, Width, Height), Center)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- End If
- Case S.Style2
- If Checked Then
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 6)
- Toggle = New Rectangle(CInt(Width \ 2) - 5, 4, 36, Height - 8)
- GP1 = Support.rRectangle(Toggle, 4)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OnColor), GP1)
- 'Text
- .DrawString("ü", New Font("Wingdings", 14), New SolidBrush(OnTextColor), New Rectangle(4, 8, Width, Height), Near)
- Else
- 'Base
- Toggle = New Rectangle(CInt(Width \ 2) - 5, 4, 36, Height - 8)
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OnColor), Toggle)
- 'Text
- .DrawString("ü", New Font("Wingdings", 14), New SolidBrush(OnTextColor), New Rectangle(4, 8, Width, Height), Near)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- Else
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 6)
- Toggle = New Rectangle(4, 4, 36, Height - 8)
- GP1 = Support.rRectangle(Toggle, 4)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OffColor), GP1)
- 'Text
- .DrawString("r", New Font("Marlett", 8), New SolidBrush(OffTextColor), New Rectangle(20, 1, Width, Height), Center)
- Else
- 'Base
- Toggle = New Rectangle(4, 4, 36, Height - 8)
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OffColor), Toggle)
- 'Text
- .DrawString("r", New Font("Marlett", 8), New SolidBrush(OffTextColor), New Rectangle(20, 1, Width, Height), Center)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- End If
- Case S.Style3
- If Checked Then
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 16)
- Dot = New Rectangle(Width - 28, 6, Height - 12, Height - 12)
- GP1.AddEllipse(Dot)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OnColor), GP1)
- 'Text
- .DrawString("ON", Font, New SolidBrush(OnTextColor), New Rectangle(-12, 1, Width, Height), Center)
- Else
- 'Base
- Toggle = New Rectangle(Width - 26, 4, 22, Height - 8)
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OnColor), Toggle)
- 'Text
- .DrawString("ON", Font, New SolidBrush(OnTextColor), New Rectangle(-13, 1, Width, Height), Center)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- Else
- If Rounded Then
- 'Base
- GP = Support.rRectangle(Base, 16)
- GP1.AddEllipse(Dot)
- .FillPath(New SolidBrush(BaseColor), GP)
- .FillPath(New SolidBrush(OffColor), GP1)
- 'Text
- .DrawString("OFF", Font, New SolidBrush(OffTextColor), New Rectangle(12, 1, Width, Height), Center)
- Else
- 'Base
- Toggle = New Rectangle(4, 4, 22, Height - 8)
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(OffColor), Toggle)
- 'Text
- .DrawString("OFF", Font, New SolidBrush(OffTextColor), New Rectangle(11, 1, Width, Height), Center)
- 'Border
- If Border Then
- Select Case State
- Case MouseState.None
- .DrawRectangle(New Pen(BorderColor), Base)
- Case MouseState.Over
- .DrawRectangle(New Pen(HoverBorderColor), Base)
- Case MouseState.Down
- .DrawRectangle(New Pen(DownBorderColor), Base)
- End Select
- End If
- End If
- End If
- End Select
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class RadioButton : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- #End Region
- #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
- #Region "Properties"
- <Flags()>
- Enum HS
- None
- Border
- PopUp
- End Enum
- Private _HoverStyle As HS
- <Category("Properties")>
- Public Property HoverStyle As HS
- Get
- Return _HoverStyle
- End Get
- Set(value As HS)
- _HoverStyle = value
- End Set
- End Property
- Private _BorderColorIntensity As Integer = 150
- <Category("Properties")>
- Public Property BorderColorIntensity As Integer
- Get
- Return _BorderColorIntensity
- End Get
- Set(value As Integer)
- _BorderColorIntensity = value
- End Set
- End Property
- Event CheckedChanged(ByVal sender As Object)
- Private _Checked As Boolean
- <Category("Properties")>
- Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(value As Boolean)
- _Checked = value
- InvalidateControls()
- RaiseEvent CheckedChanged(Me)
- Invalidate()
- End Set
- End Property
- Private _HoverDotIntensity As Integer = 30
- <Category("Properties")>
- Public Property HoverDotIntensity As Integer
- Get
- Return _HoverDotIntensity
- End Get
- Set(value As Integer)
- _HoverDotIntensity = value
- End Set
- End Property
- Private _DownDotIntensity As Integer = 50
- <Category("Properties")>
- Public Property DownDotIntensity As Integer
- Get
- Return _DownDotIntensity
- End Get
- Set(value As Integer)
- _DownDotIntensity = value
- End Set
- End Property
- Private _Hover As Boolean = True
- <Category("Properties")>
- Property Hover As Boolean
- Get
- Return _Hover
- End Get
- Set(ByVal value As Boolean)
- _Hover = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnClick(e As EventArgs)
- If Not Checked Then Checked = True
- MyBase.OnClick(e)
- End Sub
- Private Sub InvalidateControls()
- If Not IsHandleCreated OrElse Not _Checked Then Return
- For Each CTRL As Control In Parent.Controls
- If CTRL IsNot Me AndAlso TypeOf CTRL Is RadioButton Then
- DirectCast(CTRL, RadioButton).Checked = False
- Invalidate()
- End If
- Next
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 22
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property DotColor As Color
- Get
- Return _DotColor
- End Get
- Set(value As Color)
- _DotColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Property HoverTextColor As Color
- Get
- Return _HoverTextColor
- End Get
- Set(value As Color)
- _HoverTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Property DownTextColor As Color
- Get
- Return _DownTextColor
- End Get
- Set(value As Color)
- _DownTextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _DotColor As Color = White
- Private _BorderColor As Color = White
- Private _TextColor As Color = White
- Private _HoverTextColor As Color = White
- Private _DownTextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(128, 22)
- Font = New Font("Segoe UI", 10)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(1, 2, Height - 5, Height - 5), Dot As New Rectangle(5, 6, Height - 13, Height - 13)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighSpeed
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillEllipse(New SolidBrush(BaseColor), Base)
- Select Case HoverStyle
- Case HS.Border
- 'Border
- Select Case State
- Case MouseState.Over
- .DrawEllipse(New Pen(Color.FromArgb(BorderColorIntensity, BorderColor)), Base)
- Case MouseState.Down
- .DrawEllipse(New Pen(Color.FromArgb(BorderColorIntensity, BorderColor)), Base)
- End Select
- Case HS.PopUp
- 'PopUp
- Select Case State
- Case MouseState.Over
- .FillEllipse(New SolidBrush(BaseColor), New Rectangle(0, 1, Height - 3, Height - 3))
- Case MouseState.Down
- .FillEllipse(New SolidBrush(BaseColor), New Rectangle(0, 1, Height - 3, Height - 3))
- End Select
- End Select
- 'If Checked
- If Checked Then
- .FillEllipse(New SolidBrush(DotColor), Dot)
- Else
- If Hover Then
- Select Case State
- Case MouseState.Over
- .FillEllipse(New SolidBrush(Color.FromArgb(HoverDotIntensity, DotColor)), Dot)
- Case MouseState.Down
- .FillEllipse(New SolidBrush(Color.FromArgb(DownDotIntensity, DotColor)), Dot)
- End Select
- End If
- End If
- 'Text
- If Hover Then
- Select Case State
- Case MouseState.None
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(20, 2, Width - 1, Height - 1), Near)
- Case MouseState.Over
- .DrawString(Text, Font, New SolidBrush(HoverTextColor), New Rectangle(20, 2, Width - 1, Height - 1), Near)
- Case MouseState.Down
- .DrawString(Text, Font, New SolidBrush(DownTextColor), New Rectangle(20, 2, Width - 1, Height - 1), Near)
- End Select
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(20, 2, Width - 1, Height - 1), Near)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class CheckBox : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- #End Region
- #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 OnMouseUp(e As MouseEventArgs)
- MyBase.OnMouseUp(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
- #Region "Properties"
- <Flags()>
- Enum S
- Hook
- Cross
- Rectangle
- End Enum
- Private _Style As S
- <Category("Properties")>
- Public Property Style As S
- Get
- Return _Style
- End Get
- Set(value As S)
- _Style = value
- Invalidate()
- End Set
- End Property
- Private _Checked As Boolean
- <Category("Properties")>
- Property Checked As Boolean
- Get
- Return _Checked
- End Get
- Set(ByVal value As Boolean)
- _Checked = value
- Invalidate()
- End Set
- End Property
- Private _HoverStyleIntensity As Integer = 30
- <Category("Properties")>
- Public Property HoverStyleIntensity As Integer
- Get
- Return _HoverStyleIntensity
- End Get
- Set(value As Integer)
- _HoverStyleIntensity = value
- End Set
- End Property
- Private _DownStyleIntensity As Integer = 50
- <Category("Properties")>
- Public Property DownStyleIntensity As Integer
- Get
- Return _DownStyleIntensity
- End Get
- Set(value As Integer)
- _DownStyleIntensity = value
- End Set
- End Property
- Private _Hover As Boolean = True
- <Category("Properties")>
- Property Hover As Boolean
- Get
- Return _Hover
- End Get
- Set(ByVal value As Boolean)
- _Hover = value
- Invalidate()
- End Set
- End Property
- Event CheckedChanged(ByVal sender As Object)
- Protected Overrides Sub OnClick(ByVal e As EventArgs)
- Checked = Not Checked
- RaiseEvent CheckedChanged(Me)
- MyBase.OnClick(e)
- End Sub
- Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 22
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property CheckedColor As Color
- Get
- Return _CheckedColor
- End Get
- Set(value As Color)
- _CheckedColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Property HoverTextColor As Color
- Get
- Return _HoverTextColor
- End Get
- Set(value As Color)
- _HoverTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Property DownTextColor As Color
- Get
- Return _DownTextColor
- End Get
- Set(value As Color)
- _DownTextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _CheckedColor As Color = White
- Private _TextColor As Color = White
- Private _HoverTextColor As Color = White
- Private _DownTextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(128, 22)
- Font = New Font("Segoe UI", 10)
- Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- If Style = S.Cross Then
- .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 2, Height - 6, Height - 5))
- Else
- .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 2, Height - 5, Height - 5))
- End If
- 'If Checked
- Select Case Style
- Case S.Hook
- If Checked Then
- Dim Polygon() As Point = {New Point(2, 12), New Point(4, 9), New Point(7, 13), New Point(13, 4), New Point(15, 7), New Point(7, 17)}
- .FillPolygon(New SolidBrush(CheckedColor), Polygon)
- Else
- If Hover Then
- Select Case State
- Case MouseState.Over
- Dim Polygon() As Point = {New Point(2, 12), New Point(4, 9), New Point(7, 13), New Point(13, 4), New Point(15, 7), New Point(7, 17)}
- .FillPolygon(New SolidBrush(Color.FromArgb(HoverStyleIntensity, CheckedColor)), Polygon)
- Case MouseState.Down
- Dim Polygon() As Point = {New Point(2, 12), New Point(4, 9), New Point(7, 13), New Point(13, 4), New Point(15, 7), New Point(7, 17)}
- .FillPolygon(New SolidBrush(Color.FromArgb(DownStyleIntensity, CheckedColor)), Polygon)
- End Select
- End If
- End If
- Case S.Cross
- If Checked Then
- .DrawString("r", New Font("Webdings", 12), New SolidBrush(CheckedColor), New Rectangle(-2, 0, Height, Height))
- Else
- If Hover Then
- Select Case State
- Case MouseState.Over
- .DrawString("r", New Font("Webdings", 12), New SolidBrush(Color.FromArgb(HoverStyleIntensity, CheckedColor)), New Rectangle(-2, 0, Height, Height))
- Case MouseState.Down
- .DrawString("r", New Font("Webdings", 12), New SolidBrush(Color.FromArgb(DownStyleIntensity, CheckedColor)), New Rectangle(-2, 0, Height, Height))
- End Select
- End If
- End If
- Case S.Rectangle
- If Checked Then
- .FillRectangle(New SolidBrush(CheckedColor), New Rectangle(3, 5, Height - 11, Height - 11))
- Else
- If Hover Then
- Select Case State
- Case MouseState.Over
- .FillRectangle(New SolidBrush(Color.FromArgb(HoverStyleIntensity, CheckedColor)), New Rectangle(3, 5, Height - 11, Height - 11))
- Case MouseState.Down
- .FillRectangle(New SolidBrush(Color.FromArgb(DownStyleIntensity, CheckedColor)), New Rectangle(3, 5, Height - 11, Height - 11))
- End Select
- End If
- End If
- End Select
- 'Text
- If Style = S.Cross Then
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(18, 1, Width, Height), Near)
- Else
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(19, 1, Width, Height), Near)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class TextBox : Inherits Control
- #Region "Variables"
- Private State As MouseState = MouseState.None
- Private WithEvents CTRL As Windows.Forms.TextBox
- #End Region
- #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 OnMouseLeave(e As EventArgs)
- MyBase.OnMouseLeave(e)
- State = MouseState.None : Invalidate()
- End Sub
- #End Region
- #Region "Properties"
- Private _TextAlignment As HorizontalAlignment = HorizontalAlignment.Left
- <Category("Properties")>
- Property TextAlignment As HorizontalAlignment
- Get
- Return _TextAlignment
- End Get
- Set(ByVal value As HorizontalAlignment)
- _TextAlignment = value
- If CTRL IsNot Nothing Then
- CTRL.TextAlign = value
- End If
- Invalidate()
- End Set
- End Property
- Private _Rounded As Boolean = False
- <Category("Properties")>
- Public Property Rounded As Boolean
- Get
- Return _Rounded
- End Get
- Set(value As Boolean)
- _Rounded = value
- Invalidate()
- End Set
- End Property
- Private _Rounding As Integer = 14
- <Category("Properties")>
- Public Property Rounding As Integer
- Get
- Return _Rounding
- End Get
- Set(value As Integer)
- _Rounding = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _MaxLength As Integer = 32767
- <Category("Properties")>
- Property MaxLength As Integer
- Get
- Return _MaxLength
- End Get
- Set(ByVal value As Integer)
- _MaxLength = value
- If CTRL IsNot Nothing Then
- CTRL.MaxLength = value
- End If
- Invalidate()
- End Set
- End Property
- Private _ReadOnly As Boolean
- <Category("Properties")>
- Property [ReadOnly] As Boolean
- Get
- Return _ReadOnly
- End Get
- Set(ByVal value As Boolean)
- _ReadOnly = value
- If CTRL IsNot Nothing Then
- CTRL.ReadOnly = value
- End If
- Invalidate()
- End Set
- End Property
- Private _UseSystemPasswordChar As Boolean
- <Category("Properties")>
- Property UseSystemPasswordChar As Boolean
- Get
- Return _UseSystemPasswordChar
- End Get
- Set(ByVal value As Boolean)
- _UseSystemPasswordChar = value
- If CTRL IsNot Nothing Then
- CTRL.UseSystemPasswordChar = value
- End If
- Invalidate()
- End Set
- End Property
- Private _Multiline As Boolean
- <Category("Properties")>
- Property Multiline As Boolean
- Get
- Return _Multiline
- End Get
- Set(ByVal value As Boolean)
- _Multiline = value
- If CTRL IsNot Nothing Then
- CTRL.Multiline = value
- If value Then
- CTRL.Height = Height - 14
- Else
- Height = CTRL.Height + 14
- End If
- End If
- Invalidate()
- End Set
- End Property
- <Category("Properties")>
- Overrides Property Text As String
- Get
- Return MyBase.Text
- End Get
- Set(ByVal value As String)
- MyBase.Text = value
- If CTRL IsNot Nothing Then
- CTRL.Text = value
- End If
- Invalidate()
- End Set
- End Property
- <Category("Properties")>
- Overrides Property Font As Font
- Get
- Return MyBase.Font
- End Get
- Set(ByVal value As Font)
- MyBase.Font = value
- If CTRL IsNot Nothing Then
- CTRL.Font = value
- CTRL.Location = New Point(3, 5)
- CTRL.Width = Width - 6
- If Not _Multiline Then
- Height = CTRL.Height + 14
- End If
- End If
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- If Not Controls.Contains(CTRL) Then
- Controls.Add(CTRL)
- End If
- End Sub
- Private Sub OnBaseTextChanged(ByVal s As Object, ByVal e As EventArgs)
- Text = CTRL.Text
- End Sub
- Private Sub OnBaseKeyDown(ByVal s As Object, ByVal e As KeyEventArgs)
- If e.Control AndAlso e.KeyCode = Keys.A Then
- CTRL.SelectAll()
- e.SuppressKeyPress = True
- End If
- If e.Control AndAlso e.KeyCode = Keys.C Then
- CTRL.Copy()
- e.SuppressKeyPress = True
- End If
- End Sub
- Protected Overrides Sub OnResize(ByVal e As EventArgs)
- CTRL.Location = New Point(7, 7)
- CTRL.Width = Width - 15
- If _Multiline Then
- CTRL.Height = Height - 14
- Else
- Height = CTRL.Height + 14
- End If
- MyBase.OnResize(e)
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor() As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _BorderColor As Color = White
- Private _TextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- CTRL = New System.Windows.Forms.TextBox
- CTRL.Font = New Font("Segoe UI", 10)
- CTRL.Cursor = Cursors.IBeam
- CTRL.BorderStyle = BorderStyle.None
- CTRL.Text = Text
- CTRL.MaxLength = _MaxLength
- CTRL.Multiline = _Multiline
- CTRL.ReadOnly = _ReadOnly
- CTRL.UseSystemPasswordChar = _UseSystemPasswordChar
- AddHandler CTRL.TextChanged, AddressOf OnBaseTextChanged
- AddHandler CTRL.KeyDown, AddressOf OnBaseKeyDown
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- If Rounded Then
- .FillPath(New SolidBrush(BaseColor), Support.rRectangle(Base, Rounding))
- Else
- .FillRectangle(New SolidBrush(BaseColor), Base)
- End If
- CTRL.BackColor = BaseColor
- 'Text Color
- CTRL.ForeColor = TextColor
- 'Border
- If Rounded Then : Else
- If Border Then
- .DrawRectangle(New Pen(BorderColor), Base)
- End If
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class TabControl : Inherits Windows.Forms.TabControl
- #Region "Properties"
- <Flags()>
- Enum S
- ActiveLine
- Normal
- Shiny
- End Enum
- Private _ActiveStyle As S
- <Category("Properties")>
- Public Property ActiveStyle As S
- Get
- Return _ActiveStyle
- End Get
- Set(value As S)
- _ActiveStyle = value
- Invalidate()
- End Set
- End Property
- Private _ActiveLineThickness As Single = 4
- <Category("Properties")>
- Public Property ActiveLineThickness As Single
- Get
- Return _ActiveLineThickness
- End Get
- Set(value As Single)
- _ActiveLineThickness = value
- Invalidate()
- End Set
- End Property
- Private _ShinyIntensity As Integer = 15
- <Category("Properties")>
- Public Property ShinyIntensity As Integer
- Get
- Return _ShinyIntensity
- End Get
- Set(value As Integer)
- _ShinyIntensity = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Alignment = TabAlignment.Top
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BackgroundColor As Color
- Get
- Return _BackgroundColor
- End Get
- Set(value As Color)
- _BackgroundColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ActiveColor As Color
- Get
- Return _ActiveColor
- End Get
- Set(value As Color)
- _ActiveColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ActiveLineColor As Color
- Get
- Return _ActiveLineColor
- End Get
- Set(value As Color)
- _ActiveLineColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ShinyColor As Color
- Get
- Return _ShinyColor
- End Get
- Set(value As Color)
- _ShinyColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _BackgroundColor As Color = Gray
- Private _ActiveColor As Color = Black
- Private _ActiveLineColor As Color = White
- Private _TextColor As Color = White
- Private _ShinyColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Font = New Font("Segoe UI", 10)
- SizeMode = TabSizeMode.Fixed
- ItemSize = New Size(120, 40)
- Size = New Size(512, 256)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BaseColor)
- Try : SelectedTab.BackColor = BackgroundColor : 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 - 2), New Size(GetTabRect(i).Width, GetTabRect(i).Height + 4))
- Dim Base1 As New Rectangle(New Point(GetTabRect(i).Location.X + 2, CInt(GetTabRect(i).Location.Y - ActiveLineThickness)), New Size(GetTabRect(i).Width, GetTabRect(i).Height + 4))
- Dim BaseSize As New Rectangle(Base.Location, New Size(Base.Width, Base.Height))
- Dim BaseSize1 As New Rectangle(Base1.Location, New Size(Base1.Width, Base1.Height))
- If i = SelectedIndex Then
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), BaseSize)
- Select Case ActiveStyle
- Case S.ActiveLine
- 'Active Line
- .FillRectangle(New SolidBrush(ActiveLineColor), BaseSize)
- 'TabRectangle
- .FillRectangle(New SolidBrush(ActiveColor), BaseSize1)
- Case Else
- 'TabRectangle
- .FillRectangle(New SolidBrush(ActiveColor), BaseSize)
- End Select
- Select Case ActiveStyle
- Case S.Shiny
- .FillRectangle(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), New Rectangle(Base.Location, New Size(Base.Width, CInt(Base.Height / 2))))
- End Select
- '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(TextColor), BaseSize, Center)
- Else
- 'Text
- Select Case ActiveStyle
- Case S.ActiveLine
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize1, Center)
- Case Else
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize, Center)
- End Select
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- 'Text
- Select Case ActiveStyle
- Case S.ActiveLine
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize1, Center)
- Case Else
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize, Center)
- End Select
- End If
- Else
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), 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(TextColor), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- Else
- 'Text
- Select Case ActiveStyle
- Case S.ActiveLine
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize1, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- Case Else
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End Select
- End If
- Catch ex As Exception
- Throw New Exception(ex.Message)
- End Try
- Else
- 'Text
- Select Case ActiveStyle
- Case S.ActiveLine
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize1, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- Case Else
- .DrawString(TabPages(i).Text, Font, New SolidBrush(TextColor), BaseSize, New StringFormat With {.LineAlignment = StringAlignment.Center, .Alignment = StringAlignment.Center})
- End Select
- End If
- End If
- Next
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class ProgressBar : Inherits Control
- #Region "Properties"
- <Flags()>
- Enum VTP
- Left
- Center
- Right
- End Enum
- <Flags()>
- Enum SVT
- Value
- Text
- End Enum
- <Flags()>
- Enum S
- Normal
- ColorBlend
- End Enum
- Private _ValueTextPosition As VTP
- <Category("Properties")>
- Public Property ValueTextPosition As VTP
- Get
- Return _ValueTextPosition
- End Get
- Set(value As VTP)
- _ValueTextPosition = value
- Invalidate()
- End Set
- End Property
- Private _ShowValueOrText As SVT
- <Category("Properties")>
- Public Property ShowValueOrText As SVT
- Get
- Return _ShowValueOrText
- End Get
- Set(value As SVT)
- _ShowValueOrText = value
- Invalidate()
- End Set
- End Property
- Private _Style As S
- <Category("Properties")>
- Public Property Style As S
- Get
- Return _Style
- End Get
- Set(value As S)
- _Style = value
- Invalidate()
- End Set
- End Property
- Private _ShowValuePercent As Boolean = True
- <Category("Properties")>
- Public Property ShowValuePercent As Boolean
- Get
- Return _ShowValuePercent
- End Get
- Set(value As Boolean)
- _ShowValuePercent = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Integer = 100
- <Category("Properties")>
- Public Property Maximum As Integer
- Get
- Return _Maximum
- End Get
- Set(v As Integer)
- Select Case v
- Case Is < _Value
- _Value = v
- End Select
- _Maximum = v
- Invalidate()
- End Set
- End Property
- Private _Value As Integer = 0
- <Category("Properties")>
- Public Property Value As Integer
- Get
- Select Case _Value
- Case 0
- Return 0
- Invalidate()
- Case Else
- Return _Value
- Invalidate()
- End Select
- End Get
- Set(v As Integer)
- Select Case v
- Case Is > _Maximum
- v = _Maximum
- Invalidate()
- End Select
- _Value = v
- Invalidate()
- End Set
- End Property
- Public Sub Increment(ByVal Amount As Integer)
- Value += Amount
- End Sub
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _Shiny As Boolean = True
- <Category("Properties")>
- Public Property Shiny As Boolean
- Get
- Return _Shiny
- End Get
- Set(value As Boolean)
- _Shiny = value
- Invalidate()
- End Set
- End Property
- Private _ShinyIntensity As Integer = 30
- <Category("Properties")>
- Public Property ShinyIntensity As Integer
- Get
- Return _ShinyIntensity
- End Get
- Set(value As Integer)
- _ShinyIntensity = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ProgressColor As Color
- Get
- Return _ProgressColor
- End Get
- Set(value As Color)
- _ProgressColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ValueTextColor As Color
- Get
- Return _ValueTextColor
- End Get
- Set(value As Color)
- _ValueTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ShinyColor As Color
- Get
- Return _ShinyColor
- End Get
- Set(value As Color)
- _ShinyColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _ProgressColor As Color = Green
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- Private _ValueTextColor As Color = White
- Private _BorderColor As Color = Black
- Private _ShinyColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(256, 28)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim ProgressColorBlend As New ColorBlend(4), ProgressBrush As New LinearGradientBrush(Base, Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Progress Value
- Dim cValue As Double = Value / Maximum * Width
- 'ColorBlend
- If Style = S.ColorBlend Then
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- ProgressColorBlend.Colors = Colors
- ProgressColorBlend.Positions = ColorBlendPositions
- ProgressBrush.InterpolationColors = ProgressColorBlend
- End If
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- Select Case Value
- Case 100
- 'Progress
- Select Case Style
- Case S.Normal
- If Border Then
- .FillRectangle(New SolidBrush(ProgressColor), New Rectangle(1, 1, CInt(cValue - 2), Height - 2))
- Else
- .FillRectangle(New SolidBrush(ProgressColor), New Rectangle(0, 0, CInt(cValue), Height))
- End If
- Case S.ColorBlend
- If Border Then
- .FillRectangle(ProgressBrush, New Rectangle(1, 1, CInt(cValue - 2), Height - 2))
- Else
- .FillRectangle(ProgressBrush, New Rectangle(0, 0, CInt(cValue), Height))
- End If
- End Select
- If Shiny Then
- 'Shiny
- .FillRectangle(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), New Rectangle(1, 1, CInt(cValue - 2), CInt(Height / 2 - 1)))
- End If
- Case Else
- 'Progress
- Select Case Style
- Case S.Normal
- If Border Then
- .FillRectangle(New SolidBrush(ProgressColor), New Rectangle(1, 1, CInt(cValue - 2), Height - 2))
- Else
- .FillRectangle(New SolidBrush(ProgressColor), New Rectangle(0, 0, CInt(cValue), Height))
- End If
- Case S.ColorBlend
- If Border Then
- .FillRectangle(ProgressBrush, New Rectangle(1, 1, CInt(cValue - 2), Height - 2))
- Else
- .FillRectangle(ProgressBrush, New Rectangle(0, 0, CInt(cValue), Height))
- End If
- End Select
- If Shiny Then
- 'Shiny
- .FillRectangle(New SolidBrush(Color.FromArgb(ShinyIntensity, ShinyColor)), New Rectangle(1, 1, CInt(cValue - 2), CInt(Height / 2 - 1)))
- End If
- 'Value & Percent
- Select Case _ShowValueOrText
- Case SVT.Value
- If ShowValuePercent Then
- Select Case ValueTextPosition
- Case VTP.Left
- .DrawString(Value & "%", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(2, 5, Width, Height), Near)
- Case VTP.Center
- .DrawString(Value & "%", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, 1, Width, Height), Center)
- Case VTP.Right
- .DrawString(Value & "%", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, -3, Width, Height), Far)
- End Select
- Else
- Select Case ValueTextPosition
- Case VTP.Left
- .DrawString(Value & "", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(2, 5, Width, Height), Near)
- Case VTP.Center
- .DrawString(Value & "", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, 1, Width, Height), Center)
- Case VTP.Right
- .DrawString(Value & "", New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, -3, Width, Height), Far)
- End Select
- End If
- End Select
- End Select
- 'Text
- Select Case _ShowValueOrText
- Case SVT.Text
- Select Case ValueTextPosition
- Case VTP.Left
- .DrawString(Text, New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(2, 5, Width, Height), Near)
- Case VTP.Center
- .DrawString(Text, New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, 1, Width, Height), Center)
- Case VTP.Right
- .DrawString(Text, New Font("Segoe UI", 10), New SolidBrush(ValueTextColor), New Rectangle(0, -3, Width, Height), Far)
- End Select
- End Select
- 'Border
- If Border Then
- .DrawRectangle(New Pen(BorderColor), Base)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class RoundedProgressBar : Inherits Control
- #Region "Properties"
- <Flags()>
- Enum S
- Normal
- ColorBlend
- End Enum
- <Flags()>
- Enum SVT
- Value
- Text
- End Enum
- Private _Style As S = S.Normal
- <Category("Properties")>
- Public Property Style As S
- Get
- Return _Style
- End Get
- Set(value As S)
- _Style = value
- Invalidate()
- End Set
- End Property
- Private _ShowValueOrText As SVT
- <Category("Properties")>
- Public Property ShowValueOrText As SVT
- Get
- Return _ShowValueOrText
- End Get
- Set(value As SVT)
- _ShowValueOrText = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _ShowValuePercent As Boolean = True
- <Category("Properties")>
- Public Property ShowValuePercent As Boolean
- Get
- Return _ShowValuePercent
- End Get
- Set(value As Boolean)
- _ShowValuePercent = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Integer = 100
- <Category("Properties")>
- Public Property Maximum As Integer
- Get
- Return _Maximum
- End Get
- Set(v As Integer)
- Select Case v
- Case Is < _Value
- _Value = v
- End Select
- _Maximum = v
- Invalidate()
- End Set
- End Property
- Private _Value As Integer = 0
- <Category("Properties")>
- Public Property Value As Integer
- Get
- Select Case _Value
- Case 0
- Return 0
- Invalidate()
- Case Else
- Return _Value
- Invalidate()
- End Select
- End Get
- Set(v As Integer)
- Select Case v
- Case Is > _Maximum
- v = _Maximum
- End Select
- _Value = v
- Invalidate()
- End Set
- End Property
- Public Sub Increment(ByVal Amount As Integer)
- Value += Amount
- End Sub
- Private _StartingAngle As Integer = 90
- <Category("Properties")>
- Public Property StartingAngle As Integer
- Get
- Return _StartingAngle
- End Get
- Set(value As Integer)
- _StartingAngle = value
- End Set
- End Property
- Private _RotationAngle As Integer = 360
- <Category("Properties")>
- Public Property RotationAngle As Integer
- Get
- Return _RotationAngle
- End Get
- Set(value As Integer)
- _RotationAngle = value
- End Set
- End Property
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = Width
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e)
- Invalidate()
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ProgressColor As Color
- Get
- Return _ProgressColor
- End Get
- Set(value As Color)
- _ProgressColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- <Category("Properties")>
- Public Property ValueTextColor As Color
- Get
- Return _ValueTextColor
- End Get
- Set(value As Color)
- _ValueTextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _ProgressColor As Color = Green
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- Private _BorderColor As Color = Black
- Private _ValueTextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(128, 128)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G = e.Graphics
- Dim BorderColorBlend As New ColorBlend(4), ProgressBrush As New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- BorderColorBlend.Colors = Colors
- BorderColorBlend.Positions = ColorBlendPositions
- ProgressBrush.InterpolationColors = BorderColorBlend
- If Border Then
- .DrawArc(New Pen(New SolidBrush(BorderColor), 6), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, StartingAngle - 3, RotationAngle + 5)
- End If
- Select Case Value
- Case Maximum
- Select Case Style
- Case S.Normal
- .DrawArc(New Pen(New SolidBrush(ProgressColor), 4), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, StartingAngle, CInt((RotationAngle / Maximum) * Value))
- Case S.ColorBlend
- .DrawArc(New Pen(ProgressBrush, 4), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, StartingAngle, RotationAngle)
- End Select
- Case Else
- Select Case Style
- Case S.Normal
- .DrawArc(New Pen(New SolidBrush(ProgressColor), 4), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, StartingAngle, CInt((RotationAngle / Maximum) * Value))
- Case S.ColorBlend
- .DrawArc(New Pen(ProgressBrush, 4), CInt(3 / 2) + 1, CInt(3 / 2) + 1, Width - 7, Height - 6, StartingAngle, CInt((RotationAngle / Maximum) * Value))
- End Select
- 'Value & Percent/Text
- Select Case ShowValueOrText
- Case SVT.Value
- If ShowValuePercent Then
- .DrawString(Value & "%", Font, New SolidBrush(ValueTextColor), New Point(CInt(Width / 2), CInt(Height / 2)), Center)
- Else
- .DrawString(Value & "", Font, New SolidBrush(ValueTextColor), New Point(CInt(Width / 2), CInt(Height / 2)), Center)
- End If
- Case SVT.Text
- .DrawString(Text, Font, New SolidBrush(ValueTextColor), New Point(CInt(Width / 2), CInt(Height / 2)), Center)
- End Select
- End Select
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- End With
- End Sub
- End Class
- Public Class ComboBox : Inherits Windows.Forms.ComboBox
- #Region "Variables"
- Private x As Integer
- Private State As MouseState = MouseState.None
- #End Region
- #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
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- x = e.Location.X
- If e.X < Width - 40 Then
- Cursor = Cursors.Default
- Else
- Cursor = Cursors.Hand
- End If
- Invalidate()
- End Sub
- Protected Overrides Sub OnDrawItem(e As DrawItemEventArgs)
- MyBase.OnDrawItem(e) : Invalidate()
- If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnClick(e As EventArgs)
- MyBase.OnClick(e) : Invalidate()
- End Sub
- #End Region
- #Region "Properties"
- <Flags()>
- Enum BS
- Normal
- Complete
- End Enum
- Private _BorderStyle As BS = BS.Complete
- <Category("Properties")>
- Public Property BorderStyle As BS
- Get
- Return _BorderStyle
- End Get
- Set(value As BS)
- _BorderStyle = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _StartIndex As Integer = 0
- Private Property StartIndex As Integer
- Get
- Return _StartIndex
- End Get
- Set(ByVal value As Integer)
- _StartIndex = value
- Try
- SelectedIndex = value
- Catch
- End Try
- Invalidate()
- End Set
- End Property
- Sub _DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles Me.DrawItem
- If e.Index < 0 Then Exit Sub
- e.DrawBackground()
- e.DrawFocusRectangle()
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .InterpolationMode = InterpolationMode.HighQualityBicubic
- End With
- If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
- 'Selected item
- e.Graphics.FillRectangle(New SolidBrush(SelectedHoverColor), e.Bounds)
- Else
- 'Not Selected
- e.Graphics.FillRectangle(New SolidBrush(BackgroundColor), e.Bounds)
- End If
- 'Text
- e.Graphics.DrawString(GetItemText(Items(e.Index)), New Font("Segoe UI", 8),
- Brushes.White, New Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height))
- e.Graphics.Dispose()
- End Sub
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 18
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property ButtonColor As Color
- Get
- Return _ButtonColor
- End Get
- Set(value As Color)
- _ButtonColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BackgroundColor As Color
- Get
- Return _BackgroundColor
- End Get
- Set(value As Color)
- _BackgroundColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ButtonLinesColor As Color
- Get
- Return _ButtonLinesColor
- End Get
- Set(value As Color)
- _ButtonLinesColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property SelectedHoverColor As Color
- Get
- Return _SelectedHoverColor
- End Get
- Set(value As Color)
- _SelectedHoverColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _ButtonColor As Color = Color.FromArgb(30, 30, 30)
- Private _BackgroundColor As Color = Black
- Private _ButtonLinesColor As Color = White
- Private _BorderColor As Color = White
- Private _SelectedHoverColor As Color = Gray
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Black
- Font = New Font("Segoe UI", 8)
- Cursor = Cursors.Hand
- ForeColor = Color.White
- DrawMode = DrawMode.OwnerDrawFixed
- DropDownStyle = ComboBoxStyle.DropDownList
- StartIndex = 0
- ItemHeight = 18
- End Sub
- Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim Button As New Rectangle(Width - 40, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BackgroundColor), Base)
- 'Button
- .FillRectangle(New SolidBrush(ButtonColor), Button)
- 'Lines
- .DrawLine(New Pen(New SolidBrush(ButtonLinesColor)), Width - 12, 6, Width - 28, 6)
- .DrawLine(New Pen(New SolidBrush(ButtonLinesColor)), Width - 12, 12, Width - 28, 12)
- .DrawLine(New Pen(New SolidBrush(ButtonLinesColor)), Width - 12, 18, Width - 28, 18)
- 'Text
- .DrawString(Text, Font, Brushes.White, New Point(4, 5), Near)
- 'Border
- If Border Then
- .DrawRectangle(New Pen(BorderColor), Base)
- Select Case BorderStyle
- Case BS.Complete
- .DrawLine(New Pen(BorderColor), Width - 40, 1, Width - 40, 23)
- End Select
- End If
- End With
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class ListBox : Inherits Control
- #Region "Variables"
- Private WithEvents LB As New Windows.Forms.ListBox
- #End Region
- #Region "Properties"
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _Items As String() = {""}
- <Category("Properties")>
- Public Property Items As String()
- Get
- Return _Items
- End Get
- Set(value As String())
- _Items = value
- LB.Items.Clear()
- LB.Items.AddRange(value)
- Invalidate()
- End Set
- End Property
- Sub AddItem(ByVal Item As Object)
- LB.Items.Remove("")
- LB.Items.Add(Item)
- End Sub
- Sub AddRange(ByVal Items As Object())
- LB.Items.Remove("")
- LB.Items.AddRange(Items)
- End Sub
- Public ReadOnly Property SelectedItem() As String
- Get
- Return CType(LB.SelectedItem, String)
- End Get
- End Property
- Public ReadOnly Property SelectedIndex() As Integer
- Get
- Return LB.SelectedIndex
- If LB.SelectedIndex < 0 Then Exit Property
- End Get
- End Property
- Public ReadOnly Property GetSelectedText() As String
- Get
- Return LB.Text
- End Get
- End Property
- Public Sub Clear()
- LB.Items.Clear()
- End Sub
- Public Sub ClearSelected()
- For i As Integer = (LB.SelectedItems.Count - 1) To 0 Step -1
- LB.Items.Remove(LB.SelectedItems(i))
- Next
- End Sub
- Sub Drawitem(ByVal sender As Object, ByVal e As DrawItemEventArgs) Handles LB.DrawItem
- If e.Index < 0 Then Exit Sub
- e.DrawBackground()
- e.DrawFocusRectangle()
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .InterpolationMode = InterpolationMode.HighQualityBicubic
- End With
- 'If Selected
- If InStr(e.State.ToString, "Selected,") > 0 Then
- 'Base
- e.Graphics.FillRectangle(New SolidBrush(SelectedColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
- 'Text
- e.Graphics.DrawString(" " & LB.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 4)
- Else
- 'Base
- e.Graphics.FillRectangle(New SolidBrush(UnselectedColor), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
- 'Text
- e.Graphics.DrawString(" " & LB.Items(e.Index).ToString(), New Font("Segoe UI", 8), Brushes.White, e.Bounds.X, e.Bounds.Y + 4)
- End If
- e.Graphics.Dispose()
- End Sub
- Protected Overrides Sub OnCreateControl()
- MyBase.OnCreateControl()
- If Not Controls.Contains(LB) Then
- Controls.Add(LB)
- End If
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property SelectedColor As Color
- Get
- Return _SelectedColor
- End Get
- Set(value As Color)
- _SelectedColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property UnselectedColor As Color
- Get
- Return _UnselectedColor
- End Get
- Set(value As Color)
- _UnselectedColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _BorderColor As Color = White
- Private _SelectedColor As Color = Gray
- Private _UnselectedColor As Color = Black
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- LB.BackColor = Black
- LB.Font = New Font("Segoe UI", 8)
- LB.ForeColor = Color.White
- LB.Location = New Point(3, 3)
- LB.BorderStyle = BorderStyle.None
- LB.DrawMode = DrawMode.OwnerDrawFixed
- LB.ScrollAlwaysVisible = False
- LB.HorizontalScrollbar = False
- LB.ItemHeight = 21
- LB.Items.Clear()
- LB.IntegralHeight = False
- Size = New Size(256, 320)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Size
- LB.Size = New Size(Width - 6, Height - 6)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Border
- If Border Then
- .DrawRectangle(New Pen(BorderColor), Base)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class StatusBar : Inherits Control
- #Region "Properties"
- Private _SecondText As String
- <Category("Properties")>
- Public Property SecondText As String
- Get
- Return _SecondText
- End Get
- Set(value As String)
- _SecondText = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = False
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- Dock = DockStyle.Bottom
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- MyBase.OnTextChanged(e) : Invalidate()
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property SecondTextColor As Color
- Get
- Return _SecondTextColor
- End Get
- Set(value As Color)
- _SecondTextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _BorderColor As Color = White
- Private _TextColor As Color = White
- Private _SecondTextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Font = New Font("Segoe UI", 8)
- Size = New Size(Width, 20)
- ForeColor = Color.White
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- 'Border
- If Border Then
- .DrawLine(New Pen(BorderColor), New Point(0, Height), New Point(Width, Height))
- .DrawLine(New Pen(BorderColor), New Point(0, 0), New Point(0, Height))
- .DrawLine(New Pen(BorderColor), New Point(Width, 0), New Point(Width, Height))
- End If
- 'Left Text
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(5, 5, Width, Height), Near)
- 'Right Text
- .DrawString(SecondText, Font, New SolidBrush(SecondTextColor), New Rectangle(-5, 2, Width, Height), New StringFormat() _
- With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Center})
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class GroupBox : Inherits ContainerControl
- #Region "Properties"
- <Flags()>
- Enum TP
- Left
- Center
- Right
- End Enum
- Private _TextPosition As TP
- <Category("Properties")>
- Public Property TextPosition As TP
- Get
- Return _TextPosition
- End Get
- Set(value As TP)
- _TextPosition = value
- Invalidate()
- End Set
- End Property
- Private _ShowText As Boolean = True
- <Category("Properties")>
- Public Property ShowText As Boolean
- Get
- Return _ShowText
- End Get
- Set(value As Boolean)
- _ShowText = value
- Invalidate()
- End Set
- End Property
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _TextColor As Color = White
- Private _BorderColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(240, 180)
- Font = New Font("Segoe UI", 12)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 24, Width, Height - 24)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- If ShowText Then
- 'Text
- Select Case TextPosition
- Case TP.Left
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(-2, 0, Width, Height), New StringFormat() With {.Alignment = StringAlignment.Near, .LineAlignment = StringAlignment.Near})
- Case TP.Center
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(0, 0, Width, Height), New StringFormat() With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Near})
- Case TP.Right
- .DrawString(Text, Font, New SolidBrush(TextColor), New Rectangle(5, 0, Width, Height), New StringFormat() With {.Alignment = StringAlignment.Far, .LineAlignment = StringAlignment.Near})
- End Select
- Else
- Base = New Rectangle(0, 0, Width, Height)
- End If
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- If Border Then
- 'Border
- .DrawRectangle(New Pen(BorderColor), Base)
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class TrackBar : Inherits Control
- #Region "Variables"
- Private v As Integer
- Private Bool As Boolean
- Private Track As Rectangle
- Private Border As Rectangle
- #End Region
- #Region "Mouse States"
- Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If e.Button = MouseButtons.Left Then
- Track = New Rectangle(v + 1, 1, 10, 20)
- Bool = Track.Contains(e.Location)
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
- MyBase.OnMouseUp(e) : Bool = False
- 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
- #End Region
- #Region "Properties"
- <Flags()>
- Enum S
- Normal
- ColorBlend
- End Enum
- <Flags()>
- Enum VP
- Left
- Center
- Right
- End Enum
- Private _Style As S
- <Category("Properties")>
- Public Property Style As S
- Get
- Return _Style
- End Get
- Set(value As S)
- _Style = value
- Invalidate()
- End Set
- End Property
- Private _ValuePosition As VP = VP.Center
- <Category("Properties")>
- Public Property ValuePosition As VP
- Get
- Return _ValuePosition
- End Get
- Set(value As VP)
- _ValuePosition = value
- Invalidate()
- End Set
- End Property
- Private _ShowValue As Boolean = False
- <Category("Properties")>
- Public Property ShowValue As Boolean
- Get
- Return _ShowValue
- End Get
- Set(value As Boolean)
- _ShowValue = value
- If ShowValue Then
- Size = New Size(Width, 34)
- Else
- Size = New Size(Width, 22)
- End If
- Invalidate()
- End Set
- End Property
- Private _ShowValuePercent As Boolean = False
- <Category("Properties")>
- Public Property ShowValuePercent As Boolean
- Get
- Return _ShowValuePercent
- End Get
- Set(value As Boolean)
- _ShowValuePercent = value
- Invalidate()
- End Set
- End Property
- <Category("Properties")>
- Event Scroll(ByVal sender As Object)
- 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 _Minimum As Integer = 0
- <Category("Properties")>
- 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 = 100
- <Category("Properties")>
- 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
- Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
- MyBase.OnKeyDown(e)
- If CBool(CType(e.KeyCode = Keys.Subtract, Keys) Or Keys.Right) Then
- If Value = 0 Then Exit Sub
- Value -= 1
- ElseIf CBool(CType(e.KeyCode = Keys.Add, Keys) Or Keys.Left) 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)
- If ShowValue Then
- Height = 34
- Else
- Height = 22
- End If
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TrackColor As Color
- Get
- Return _TrackColor
- End Get
- Set(value As Color)
- _TrackColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property SliderColor As Color
- Get
- Return _SliderColor
- End Get
- Set(value As Color)
- _SliderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ValueColor As Color
- Get
- Return _ValueColor
- End Get
- Set(value As Color)
- _ValueColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _TrackColor As Color = Green
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- Private _BorderColor As Color = Color.Black
- Private _SliderColor As Color = White
- Private _ValueColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer, True)
- DoubleBuffered = True
- BackColor = Gray
- Size = New Size(128, 22)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim TrackColorBlend As New ColorBlend(4), TrackBrush As New LinearGradientBrush(New Rectangle(0, 0, Width, Height), Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'ColorBlend
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- TrackColorBlend.Colors = Colors
- TrackColorBlend.Positions = ColorBlendPositions
- TrackBrush.InterpolationColors = TrackColorBlend
- 'Value
- v = CInt((Value - Minimum) / (Maximum - Minimum) * (Width - 12))
- 'Track
- Track = New Rectangle(v + 1, 1, 10, 20)
- 'Tracker
- .FillRectangle(New SolidBrush(BaseColor), New Rectangle(0, 7, Width, 8))
- Select Case Style
- Case S.Normal
- .FillRectangle(New SolidBrush(TrackColor), New Rectangle(0, 7, Track.X, 8))
- Case S.ColorBlend
- .FillRectangle(TrackBrush, New Rectangle(0, 7, Track.X, 8))
- End Select
- 'Slider
- .FillRectangle(New SolidBrush(BorderColor), v, 0, 12, 22)
- .FillRectangle(New SolidBrush(SliderColor), Track)
- 'Show Value
- If ShowValue Then
- Select Case ValuePosition
- Case VP.Left
- If ShowValuePercent Then
- .DrawString(Value & "%", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(-1, 22, 0, Height), Near)
- Else
- .DrawString(Value & "", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(-1, 22, 0, Height), Near)
- End If
- Case VP.Center
- If ShowValuePercent Then
- .DrawString(Value & "%", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(1, 13, Width, Height), Center)
- Else
- .DrawString(Value & "", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(1, 13, Width, Height), Center)
- End If
- Case VP.Right
- If ShowValuePercent Then
- .DrawString(Value & "%", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(2, 4, Width, Height), Far)
- Else
- .DrawString(Value & "", New Font("Segoe UI", 8), New SolidBrush(ValueColor), New Rectangle(2, 4, Width, Height), Far)
- End If
- End Select
- End If
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
- Public Class Seperator : Inherits Control
- #Region "Properties"
- Enum A
- Horizontal
- Vertical
- End Enum
- <Flags()>
- Enum S
- Normal
- ColorBlend
- End Enum
- Private _Alignment As A
- <Category("Properties")>
- Public Property Alignment As A
- Get
- Return _Alignment
- End Get
- Set(value As A)
- _Alignment = value
- Invalidate()
- End Set
- End Property
- Private _HorizontalStyle As S
- <Category("Properties")>
- Public Property HorizontalStyle As S
- Get
- Return _HorizontalStyle
- End Get
- Set(value As S)
- _HorizontalStyle = value
- Invalidate()
- End Set
- End Property
- Private _Thickness As Single = 2
- <Category("Properties")>
- Public Property Thickness As Single
- Get
- Return _Thickness
- End Get
- Set(value As Single)
- _Thickness = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property SeperatorColor As Color
- Get
- Return _SeperatorColor
- End Get
- Set(value As Color)
- _SeperatorColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend1 As Color
- Get
- Return _ColorBlend1
- End Get
- Set(value As Color)
- _ColorBlend1 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend2 As Color
- Get
- Return _ColorBlend2
- End Get
- Set(value As Color)
- _ColorBlend2 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend3 As Color
- Get
- Return _ColorBlend3
- End Get
- Set(value As Color)
- _ColorBlend3 = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ColorBlend4 As Color
- Get
- Return _ColorBlend4
- End Get
- Set(value As Color)
- _ColorBlend4 = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _SeperatorColor As Color = Black
- Private _ColorBlend1 As Color = Orange
- Private _ColorBlend2 As Color = Red
- Private _ColorBlend3 As Color = Green
- Private _ColorBlend4 As Color = Blue
- #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(128, 10)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- Dim G = e.Graphics
- Dim Base As New Rectangle(0, 0, Width, Height)
- Dim HorizontalColorBlend As New ColorBlend(4), SeperatorBrush As New LinearGradientBrush(Base, Color.Black, Color.Black, 0.0F)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- Dim Colors() As Color = {ColorBlend1, ColorBlend2, ColorBlend3, ColorBlend4}
- HorizontalColorBlend.Colors = Colors
- HorizontalColorBlend.Positions = ColorBlendPositions
- SeperatorBrush.InterpolationColors = HorizontalColorBlend
- Select Case Alignment
- Case A.Horizontal
- Select Case HorizontalStyle
- Case S.Normal
- .DrawLine(New Pen(SeperatorColor, Thickness), New Point(0, CInt(Height / 2)), New Point(Width, CInt(Height / 2)))
- Case S.ColorBlend
- .DrawLine(New Pen(SeperatorBrush, Thickness), New Point(0, CInt(Height / 2)), New Point(Width, CInt(Height / 2)))
- End Select
- Case A.Vertical
- .DrawLine(New Pen(SeperatorColor, Thickness), New Point(CInt(Width / 2), CInt(0)), New Point(CInt(Width / 2), CInt(Height)))
- End Select
- End With
- End Sub
- End Class
- Public Class Numeric : Inherits Control
- #Region "Variables"
- Private x, y As Integer
- Private Bool As Boolean
- #End Region
- #Region "Mouse States"
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- MyBase.OnMouseMove(e)
- x = e.Location.X
- y = e.Location.Y
- If e.X < Width - 26 Then Cursor = Cursors.IBeam Else Cursor = Cursors.Hand
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MyBase.OnMouseDown(e)
- If x > Width - 26 AndAlso x < Width Then
- If y < 15 Then
- If Value + 1 <= Maximum Then Value += 1
- Else
- If Value - 1 >= Minimum Then Value -= 1
- End If
- Else
- Bool = Not Bool
- Focus()
- End If
- Invalidate()
- End Sub
- #End Region
- #Region "Properties"
- Private _Border As Boolean = True
- <Category("Properties")>
- Public Property Border As Boolean
- Get
- Return _Border
- End Get
- Set(value As Boolean)
- _Border = value
- Invalidate()
- End Set
- End Property
- Private _Value As Long
- Public Property Value As Long
- Get
- Return _Value
- End Get
- Set(value As Long)
- If value <= Maximum And value >= Minimum Then _Value = value
- Invalidate()
- End Set
- End Property
- Private _Maximum As Long = 100
- Public Property Maximum As Long
- Get
- Return _Maximum
- End Get
- Set(value As Long)
- If value > Minimum Then _Maximum = value
- If _Value > Maximum Then _Value = Maximum
- Invalidate()
- End Set
- End Property
- Private _Minimum As Long = 0
- Public Property Minimum As Long
- Get
- Return _Minimum
- End Get
- Set(value As Long)
- If value < Maximum Then _Minimum = value
- If _Value < Minimum Then _Value = Minimum
- Invalidate()
- End Set
- End Property
- Protected Overrides Sub OnResize(e As EventArgs)
- MyBase.OnResize(e)
- Height = 30
- End Sub
- Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
- MyBase.OnKeyPress(e)
- Try
- If Bool Then Value = CLng(Value & e.KeyChar.ToString())
- If Value > Maximum Then Value = Maximum
- Invalidate()
- Catch : End Try
- End Sub
- Protected Overrides Sub OnKeyDown(e As KeyEventArgs)
- MyBase.OnKeyDown(e)
- If e.KeyCode = Keys.Back Then
- Value = 0
- End If
- End Sub
- #End Region
- #Region "Color Properties"
- <Category("Color Properties")>
- Public Property BaseColor As Color
- Get
- Return _BaseColor
- End Get
- Set(value As Color)
- _BaseColor = value
- End Set
- End Property
- <Category("Color Properties")>
- Public Property ButtonColor As Color
- Get
- Return _ButtonColor
- End Get
- Set(value As Color)
- _ButtonColor = value
- End Set
- End Property
- <Category("Color Properties")>
- Public Property BorderColor As Color
- Get
- Return _BorderColor
- End Get
- Set(value As Color)
- _BorderColor = value
- Invalidate()
- End Set
- End Property
- <Category("Color Properties")>
- Public Property TextColor As Color
- Get
- Return _TextColor
- End Get
- Set(value As Color)
- _TextColor = value
- Invalidate()
- End Set
- End Property
- #End Region
- #Region "Colors"
- Private _BaseColor As Color = Black
- Private _BorderColor As Color = White
- Private _ButtonColor As Color = Color.FromArgb(30, 30, 30)
- Private _TextColor As Color = White
- #End Region
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or
- ControlStyles.ResizeRedraw Or ControlStyles.OptimizedDoubleBuffer Or
- ControlStyles.SupportsTransparentBackColor, True)
- DoubleBuffered = True
- Font = New Font("Segoe UI", 10)
- BackColor = Gray
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- B = New Bitmap(Width, Height) : G = Graphics.FromImage(B)
- Dim Base As New Rectangle(0, 0, Width, Height)
- With G
- .SmoothingMode = SmoothingMode.HighQuality
- .PixelOffsetMode = PixelOffsetMode.HighQuality
- .TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- .Clear(BackColor)
- 'Base
- .FillRectangle(New SolidBrush(BaseColor), Base)
- .FillRectangle(New SolidBrush(ButtonColor), New Rectangle(Width - 24, 0, 24, Height))
- '+ & -
- 'Add
- .DrawString("+", New Font("Segoe UI", 10), New SolidBrush(White), New Point(Width - 12, 10), Center)
- 'Subtract
- .DrawString("-", New Font("Segoe UI", 10), New SolidBrush(White), New Point(Width - 12, 22), Center)
- If x > Width - 26 AndAlso x < Width Then
- If y < 15 Then
- 'Add
- .DrawString("+", New Font("Segoe UI", 10), New SolidBrush(Green), New Point(Width - 12, 10), Center)
- Else
- 'Subtract
- .DrawString("-", New Font("Segoe UI", 10), New SolidBrush(Red), New Point(Width - 12, 22), Center)
- End If
- End If
- 'BorderStyle
- If Border Then
- .DrawRectangle(New Pen(BorderColor), Base)
- .DrawLine(New Pen(BorderColor), Width - 25, 1, Width - 25, 29)
- End If
- 'Text
- .DrawString(Value & "", Font, New SolidBrush(TextColor), New Rectangle(5, 6, Width, Height), Near)
- End With
- MyBase.OnPaint(e)
- G.Dispose()
- e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic
- e.Graphics.DrawImageUnscaled(B, 0, 0)
- B.Dispose()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement