Professional Documents
Culture Documents
Drawing2D
Imports System.ComponentModel
Sub New()
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw, True)
BackColor = Color.FromArgb(50, 50, 50)
ForeColor = Color.White
Dock = DockStyle.Fill
End Sub
MyBase.OnPaint(e)
End Sub
End Class
Sub New()
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
Dock = DockStyle.Bottom
Height = 27
End Sub
End Class
Sub New()
ForeColor = Color.White
BackColor = Color.Transparent
Font = New Font("Segoe UI", 9)
End Sub
End Class
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
Sub New()
Size = New Size(75, 37)
Text = "Button"
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw, True)
Font = New Font("Segoe UI", 9)
End Sub
MyBase.OnPaint(e)
End Sub
End Class
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
#Region "Properties"
Enum ImageAlignments
Left = 0
Center = 1
Right = 2
End Enum
#End Region
Sub New()
Size = New Size(120, 31)
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw Or
ControlStyles.SupportsTransparentBackColor, True)
BackColor = Color.Transparent
Font = New Font("Segoe UI", 9)
End Sub
If IsNothing(_Image) Then
e.Graphics.DrawString(Text, Font, Brushes.White, New
Rectangle(3, 2, Width - 7, Height - 5), New StringFormat With
{.Alignment = StringAlignment.Center, .LineAlignment =
StringAlignment.Center, .Trimming =
StringTrimming.EllipsisCharacter})
Else
e.Graphics.InterpolationMode =
InterpolationMode.HighQualityBicubic
Select Case _ImageAlignment
Case ImageAlignments.Left
Dim ImageRect As New Rectangle(9, 6, Height - 13,
Height - 13)
e.Graphics.DrawImage(_Image, ImageRect)
e.Graphics.DrawString(Text, Font, Brushes.White,
New Rectangle(ImageRect.X + ImageRect.Width + 6, 2, Width -
ImageRect.Width - 22, Height - 5), New StringFormat With {.Alignment
= StringAlignment.Center, .LineAlignment = StringAlignment.Center,
.Trimming = StringTrimming.EllipsisCharacter})
Case ImageAlignments.Center
Dim ImageRect As New Rectangle(((Width - 1) / 2)
- (Height - 13) / 2, 6, Height - 13, Height - 13)
e.Graphics.DrawImage(_Image, ImageRect)
Case ImageAlignments.Right
Dim ImageRect As New Rectangle(Width - Height +
3, 6, Height - 13, Height - 13)
e.Graphics.DrawImage(_Image, ImageRect)
e.Graphics.DrawString(Text, Font, Brushes.White,
New Rectangle(3, 2, Width - ImageRect.Width - 22, Height - 5), New
StringFormat With {.Alignment = StringAlignment.Center,
.LineAlignment = StringAlignment.Center, .Trimming =
StringTrimming.EllipsisCharacter})
End Select
End If
MyBase.OnPaint(e)
End Sub
End Class
<DefaultEvent("CheckedChanged")> _
Public Class TheEmpireCheckbox
Inherits Control
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
Function CreateRound(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal slope As
Integer) As GraphicsPath
CreateRoundRectangle = New Rectangle(x, y, width, height)
Return CreateRound(CreateRoundRectangle, slope)
End Function
MyBase.OnMouseDown(e)
End Sub
#Region "Properties"
Enum SliderLocations
Left = 0
Right = 1
End Enum
#End Region
Sub New()
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw Or
ControlStyles.SupportsTransparentBackColor, True)
Font = New Font("Segoe UI", 9)
ForeColor = Color.Black
BackColor = Color.Transparent
Size = New Size(150, 21)
End Sub
If _Checked Then
e.Graphics.DrawString("a", New Font("Marlett", 13),
Brushes.White, New Point(-2, 1))
End If
e.Graphics.DrawString(Text, Font, New SolidBrush(ForeColor),
New Rectangle(20, 0, Width - 21, Height - 1), New StringFormat With
{.Alignment = StringAlignment.Near, .LineAlignment =
StringAlignment.Center, .Trimming =
StringTrimming.EllipsisCharacter})
MyBase.OnPaint(e)
End Sub
End Class
<DefaultEvent("CheckedChanged")> _
Public Class TheEmpireRadioButton
Inherits Control
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
#Region "Properties"
#End Region
Sub New()
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw Or
ControlStyles.SupportsTransparentBackColor, True)
Font = New Font("Segoe UI", 9)
ForeColor = Color.Black
BackColor = Color.Transparent
Size = New Size(150, 21)
End Sub
If _Checked Then
LGB = New LinearGradientBrush(New Rectangle(5, 6, 7, 7),
Color.White, Color.Gainsboro, 90.0F)
e.Graphics.FillEllipse(LGB, LGB.Rectangle)
End If
End Class
Sub New()
Font = New Font("Segoe UI", 9)
ForeColor = Color.Black
DoubleBuffered = True
SetStyle(ControlStyles.OptimizedDoubleBuffer Or
ControlStyles.ResizeRedraw Or
ControlStyles.SupportsTransparentBackColor, True)
BackColor = Color.Transparent
End Sub
MyBase.OnPaint(e)
End Sub
End Class
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
Function CreateRound(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal slope As
Integer) As GraphicsPath
CreateRoundRectangle = New Rectangle(x, y, width, height)
Return CreateRound(CreateRoundRectangle, slope)
End Function
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or
ControlStyles.DoubleBuffer, True)
DoubleBuffered = True
ForeColor = Color.White
DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
ItemHeight = 23
Size = New Size(144, 30)
Font = New Font("Segoe UI", 9)
ForeColor = Color.White
BackColor = Color.FromArgb(200, 200, 200)
DropDownStyle = ComboBoxStyle.DropDownList
End Sub
e.DrawBackground()
If e.State > 0 Then
e.Graphics.FillRectangle(New
SolidBrush(Color.FromArgb(70, 70, 70)), e.Bounds)
e.Graphics.DrawString(Me.Items(e.Index).ToString(), New
Font(Font.FontFamily, 8), Brushes.White, e.Bounds, New StringFormat
With {.Alignment = StringAlignment.Center, .LineAlignment =
StringAlignment.Center, .Trimming =
StringTrimming.EllipsisCharacter})
Else
e.Graphics.FillRectangle(New
SolidBrush(Color.FromArgb(36, 36, 36)), e.Bounds)
e.Graphics.DrawString(Me.Items(e.Index).ToString(), New
Font(Font.FontFamily, 8), Brushes.White, e.Bounds, New StringFormat
With {.Alignment = StringAlignment.Center, .LineAlignment =
StringAlignment.Center, .Trimming =
StringTrimming.EllipsisCharacter})
End If
e.Graphics.DrawLine(New Pen(Color.FromArgb(55, Color.Black)),
New Point(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 1), New
Point(e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height - 1))
MyBase.OnDrawItem(e)
End Sub
#Region "CreateRound"
#End Region
Sub New()
SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
DoubleBuffered = True
BorderStyle = Windows.Forms.BorderStyle.None
DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
ItemHeight = 24
ForeColor = Color.Black
BackColor = Color.FromArgb(200, 200, 200)
IntegralHeight = False
End Sub
e.Graphics.FillRectangle(New SolidBrush(BackColor),
ItemRectangle)
e.Graphics.FillRectangle(New SolidBrush(BackColor), e.Bounds)
If e.State > 0 Then
Dim LGB As New LinearGradientBrush(ItemRectangle,
Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
e.Graphics.FillPath(LGB, CreateRound(ItemRectangle, 4))
e.Graphics.SmoothingMode = SmoothingMode.None
e.Graphics.DrawString(Items(e.Index).ToString(), Font,
Brushes.White, 7, e.Bounds.Y + 4)
Else
e.Graphics.FillRectangle(New SolidBrush(BackColor),
e.Bounds)
e.Graphics.DrawString(Items(e.Index).ToString(), Font,
Brushes.Black, 7, e.Bounds.Y + 4)
End If
MyBase.OnDrawItem(e)
<DefaultEvent("TextChanged")> _
Public Class TheEmpireTextBox
Inherits Control
#Region "CreateRound"
Private CreateRoundPath As GraphicsPath
Private CreateRoundRectangle As Rectangle
Function CreateRound(ByVal x As Integer, ByVal y As Integer,
ByVal width As Integer, ByVal height As Integer, ByVal slope As
Integer) As GraphicsPath
CreateRoundRectangle = New Rectangle(x, y, width, height)
Return CreateRound(CreateRoundRectangle, slope)
End Function
#Region "Properties"
Private _TextAlign As HorizontalAlignment =
HorizontalAlignment.Left
Property TextAlign() As HorizontalAlignment
Get
Return _TextAlign
End Get
Set(ByVal value As HorizontalAlignment)
_TextAlign = value
If Base IsNot Nothing Then
Base.TextAlign = value
End If
End Set
End Property
Private _MaxLength As Integer = 32767
Property MaxLength() As Integer
Get
Return _MaxLength
End Get
Set(ByVal value As Integer)
_MaxLength = value
If Base IsNot Nothing Then
Base.MaxLength = value
End If
End Set
End Property
Private _ReadOnly As Boolean
Property [ReadOnly]() As Boolean
Get
Return _ReadOnly
End Get
Set(ByVal value As Boolean)
_ReadOnly = value
If Base IsNot Nothing Then
Base.ReadOnly = value
End If
End Set
End Property
Private _UseSystemPasswordChar As Boolean
Property UseSystemPasswordChar() As Boolean
Get
Return _UseSystemPasswordChar
End Get
Set(ByVal value As Boolean)
_UseSystemPasswordChar = value
If Base IsNot Nothing Then
Base.UseSystemPasswordChar = value
End If
End Set
End Property
Private _Multiline As Boolean
Property Multiline() As Boolean
Get
Return _Multiline
End Get
Set(ByVal value As Boolean)
_Multiline = value
If Base IsNot Nothing Then
Base.Multiline = value
If value Then
Base.Height = Height - 7
Base.Location = New Point(3, 3)
Else
Height = Base.Height + 7
Base.Location = New Point(6, 3)
End If
End If
End Set
End Property
Overrides Property Text As String
Get
Return MyBase.Text
End Get
Set(ByVal value As String)
MyBase.Text = value
If Base IsNot Nothing Then
Base.Text = value
End If
End Set
End Property
Overrides Property Font As Font
Get
Return MyBase.Font
End Get
Set(ByVal value As Font)
MyBase.Font = value
If Base IsNot Nothing Then
Base.Font = value
Base.Location = New Point(6, 3)
Base.Width = Width - 12
#End Region
#End Region
Base.Font = Font
Base.Text = Text
Base.ForeColor = Color.Black
Base.BackColor = Color.LightGray
Base.MaxLength = _MaxLength
Base.Multiline = _Multiline
Base.ReadOnly = _ReadOnly
Base.UseSystemPasswordChar = _UseSystemPasswordChar
Base.BorderStyle = BorderStyle.None
Base.Location = New Point(6, 3)
Base.Width = Width - 12
If _Multiline Then
Base.Height = Height - 7
Else
Height = Base.Height + 7
End If
MyBase.OnPaint(e)
End Sub
If _Multiline Then
Base.Height = Height - 7
Base.Location = New Point(3, 3)
Else
Base.Location = New Point(6, 3)
End If
MyBase.OnResize(e)
End Sub
End Class
#Region "Initialization"
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or
ControlStyles.ResizeRedraw Or ControlStyles.UserPaint Or
ControlStyles.DoubleBuffer, True)
DoubleBuffered = True
SizeMode = TabSizeMode.Fixed
ItemSize = New Size(37, 120)
End Sub
_OldIndexOver = _IndexOver
MyBase.OnMouseMove(e)
End Sub
Protected Overrides Sub OnMouseLeave(e As EventArgs)
_IndexOver = -1
Invalidate()
MyBase.OnMouseLeave(e)
End Sub
#End Region
e.Graphics.FillRectangle(Brushes.Gainsboro, New
Rectangle(ItemSize.Height, 0, Width - ItemSize.Height, Height))
Dim LinearGB As New LinearGradientBrush(New
Rectangle(ItemSize.Height, 0, Width - ItemSize.Height, 4),
Color.FromArgb(90, Color.Black), Color.Transparent, 90.0F)
e.Graphics.FillRectangle(LinearGB, LinearGB.Rectangle)
e.Graphics.DrawLine(Pens.Black, New Point(ItemSize.Height,
0), New Point(ItemSize.Height, Height))
For i = 0 To TabCount - 1
Dim x2 As Rectangle = New Rectangle(New
Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2),
New Size(GetTabRect(i).Width, GetTabRect(i).Height))
Dim textrectangle As New Rectangle(x2.Location.X + 34,
x2.Location.Y, x2.Width - 34, x2.Height)
If i = SelectedIndex Then
Dim LGB As New LinearGradientBrush(x2,
Color.FromArgb(36, 36, 36), Color.FromArgb(25, 25, 25), 90.0F)
e.Graphics.FillRectangle(LGB, LGB.Rectangle)
'e.Graphics.FillRectangle(New
SolidBrush(EmpirePurple), New Rectangle(x2.Location, New Size(6,
x2.Height)))
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(51,
51, 51)), x2)
e.Graphics.DrawLine(New Pen(Color.FromArgb(17, 17,
17)), New Point(x2.Location.X + 1, x2.Location.Y + x2.Height - 1),
New Point(x2.Location.X + x2.Width, x2.Location.Y + x2.Height - 1))
e.Graphics.DrawString(TabPages(i).Text, Font,
Brushes.Gainsboro, textrectangle, New StringFormat With
{.LineAlignment = StringAlignment.Center, .Alignment =
StringAlignment.Near})
Else
e.Graphics.DrawString(TabPages(i).Text, Font,
Brushes.Gray, textrectangle, New StringFormat With {.LineAlignment =
StringAlignment.Center, .Alignment = StringAlignment.Near})
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(51,
51, 51)), x2)
e.Graphics.DrawLine(New Pen(Color.FromArgb(17, 17,
17)), New Point(x2.Location.X + 1, x2.Location.Y + x2.Height - 1),
New Point(x2.Location.X + x2.Width, x2.Location.Y + x2.Height - 1))
End If
End Class