Documente Academic
Documente Profesional
Documente Cultură
txt
Imports System.ComponentModel, System.Drawing, System.Drawing.Drawing2D
Enum MouseState As Byte
None = 0
Over = 1
Down = 2
Block = 3
End Enum
Class SharpButton
Inherits Control
#Region " Control Help - MouseState & Flicker Control"
Private State As MouseState = MouseState.None
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseDown(e)
State = MouseState.Down
Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
State = MouseState.None
Invalidate()
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs
)
MyBase.OnMouseUp(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
#End Region
Public Property Color2() As Boolean
Get
Return _Color2
End Get
Set(ByVal value As Boolean)
_Color2 = value
Me.Refresh()
End Set
End Property
Private _Color2 As Boolean = False
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor,
True)
ForeColor = Color.FromArgb(210, 220, 230)
DoubleBuffered = True
Font = New Font("Verdana", 8.5F, FontStyle.Regular)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim bmp As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(bmp)
MyBase.OnPaint(e)
Select Case State
Case MouseState.None
If _Color2 Then
G.Clear(Color.FromArgb(43, 53, 63))
Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height
/ 2 - 2), Color.FromArgb(37, 47, 57), Color.FromArgb(140, 149, 155), 180)
G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2
- 2), Color.FromArgb(140, 149, 155), Color.FromArgb(37, 47, 57), 180)
G.FillRectangle(BTNLGB1, New Rectangle(1, 1, Width / 2, Height / 2 - 2))
G.SmoothingMode = SmoothingMode.HighQuality
'----- Borders ----G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(23, 33, 43))), New Rectang
le(0, 0, Width - 1, Height - 1))
Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height 2), Color.FromArgb(113, 123, 133), Color.FromArgb(50, 50, 50), 90)
G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(63, 73, 83))), 2, Height - 2, W
idth - 2, Height - 2)
G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, -1, Width 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center,
.Alignment = StringAlignment.Center})
Else
G.Clear(Color.FromArgb(43, 53, 63))
Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height
/ 2 - 2), Color.FromArgb(37, 47, 57), Color.FromArgb(140, 149, 155), LinearGradi
entMode.Horizontal)
G.FillRectangle(BTNLGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height / 2
- 2), Color.FromArgb(140, 149, 155), Color.FromArgb(37, 47, 57), LinearGradient
Mode.Horizontal)
G.FillRectangle(BTNLGB1, New Rectangle(1, 1, Width / 2, Height / 2 - 2))
G.SmoothingMode = SmoothingMode.HighQuality
'----- Borders ----G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(33, 43, 53))), New Rectang
le(0, 0, Width - 1, Height - 1))
Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height 2), Color.FromArgb(153, 163, 173), Color.FromArgb(50, 50, 50), 90)
G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(73, 83, 93))), 1, Height - 2, W
idth - 2, Height - 2)
G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(0, -1, Width 1, Height - 1), New StringFormat With {.LineAlignment = StringAlignment.Center,
.Alignment = StringAlignment.Center})
End If
Case MouseState.Over
If _Color2 Then
+ h)
rr5.AddLine(x + w - r3, y + h, x + r4, y + h)
rr5.AddBezier(x + r4, y + h, x, y + h, x, y + h - r4, x, y + h - r4)
rr5.AddLine(x, y + h - r4, x, y + r1)
Return rr5
End Function
#Region " Control Help - Movement & Flicker Control "
Protected Overrides Sub OnInvalidated(ByVal e As System.Windows.Forms.Invalidate
EventArgs)
MyBase.OnInvalidated(e)
ParentForm.FindForm.Text = Text
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
Me.ParentForm.FormBorderStyle = FormBorderStyle.None
Me.ParentForm.TransparencyKey = Color.Fuchsia
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseDown(e)
If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Width, Hea
der).Contains(e.Location) Then
Cap = True : MouseP = e.Location
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs
)
MyBase.OnMouseUp(e) : Cap = False
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseMove(e)
If Cap Then
Parent.Location = MousePosition - MouseP
End If
End Sub
Private Sub minimBtnClick() Handles minimBtn.Click
ParentForm.FindForm.WindowState = FormWindowState.Minimized
End Sub
Private Sub closeBtnClick() Handles closeBtn.Click
If CloseButtonExitsApp Then
System.Environment.Exit(0)
Else
ParentForm.FindForm.Close()
End If
End Sub
Private _closesEnv As Boolean = False
Public Property CloseButtonExitsApp() As Boolean
Get
Return _closesEnv
End Get
Set(ByVal v As Boolean)
_closesEnv = v
Invalidate()
End Set
End Property
Private _minimBool As Boolean = True
Public Property MinimizeButton() As Boolean
Get
Return _minimBool
End Get
Set(ByVal v As Boolean)
_minimBool = v
Invalidate()
End Set
End Property
#End Region
Dim WithEvents minimBtn As New
on.TxtState.Minim, .Location =
Dim WithEvents closeBtn As New
on.TxtState.Close, .Location =
Dim InerRecLGB As Rectangle = New Rectangle(11, 28, Width - 22, Height - 37)
Dim InnerRecLGB As New LinearGradientBrush(InerRecLGB, Color.FromArgb(57, 67, 77
), Color.FromArgb(60, 69, 75), 90)
G.FillRectangle(InnerRecLGB, InerRecLGB)
'----- InnerRect
Dim P1 As Pen = New
G.DrawRectangle(P1,
Dim P2 As Pen = New
G.DrawRectangle(P2,
Pen(New
12, 29,
Pen(New
11, 28,
, Height)
G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(137, 147, 157))), 1, 1, Wi
dth - 3, Height - 3)
Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
G.DrawPath(Pens.Black, RoundRect(ClientRectangle, 0, 0, 0, 0))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(163, 173, 183))), 2, 1, Width 3, 1)
e.Graphics.DrawImage(bmp.Clone, 0, 0)
bmp.Dispose()
G.Dispose()
End Sub
End Class
Class SharpTopButton
Inherits Control
#Region " Control Help - MouseState & Flicker Control"
Enum MouseState As Byte
None = 0
Over = 1
Down = 2
Block = 3
End Enum
Private State As MouseState
Dim X As Integer
Protected Overrides Sub
MyBase.OnMouseEnter(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub
gs)
MyBase.OnMouseDown(e)
State = MouseState.Down
Invalidate()
End Sub
Protected Overrides Sub
MyBase.OnMouseLeave(e)
State = MouseState.None
Invalidate()
End Sub
Protected Overrides Sub
)
MyBase.OnMouseUp(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub
aintEventArgs)
End Sub
Protected Overrides Sub
MyBase.OnTextChanged(e)
Invalidate()
End Sub
Protected Overrides Sub
OnMouseEnter(ByVal e As System.EventArgs)
OnMouseDown(ByVal e As System.Windows.Forms.MouseEventAr
OnMouseLeave(ByVal e As System.EventArgs)
OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs
OnMouseMove(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseMove(e)
X = e.X
Invalidate()
End Sub
#End Region
Enum TxtState As Byte
Close = 1
Minim = 2
End Enum
Private BtnTxt As TxtState
Public Property TopButtonTXT() As TxtState
Get
Return BtnTxt
End Get
Set(ByVal v As TxtState)
BtnTxt = v
Invalidate()
End Set
End Property
Sub New()
MyBase.New()
BackColor = Color.FromArgb(38, 38, 38)
Font = New Font("Verdana", 8.25F)
Size = New Size(30, 20)
DoubleBuffered = True
Focus()
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim bmp As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(bmp)
MyBase.OnPaint(e)
Select Case State
Case MouseState.Over
If BtnTxt = TxtState.Close Then
G.Clear(Color.FromArgb(170, 18, 32))
Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, Width - 3, Height / 2
- 2), Color.FromArgb(170, 18, 32), Color.FromArgb(147, 156, 162), 360)
G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Height / 2 - 2))
Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1, Width - 2, Height /
2 - 2), Color.FromArgb(147, 156, 162), Color.FromArgb(170, 18, 32), 360)
G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Height / 2 - 2))
G.SmoothingMode = SmoothingMode.HighQuality
'----- Borders ----G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(39, 49, 59))), New Rectang
le(0, 0, Width - 1, Height - 1))
Dim InnerRect As New LinearGradientBrush(New Rectangle(1, 1, Width - 3, Height 2), Color.FromArgb(159, 169, 179), Color.FromArgb(90, 90, 90), 90)
G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Width - 3, Height - 3))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(123, 133, 143))), 1, Height - 2
, Width - 2, Height - 2)
19)
e.Graphics.DrawImage(bmp.Clone(), 0, 0)
G.Dispose() : bmp.Dispose()
End Sub
End Class
Class SharpGroupBOx
Inherits ContainerControl
#Region " Control Help - Properties & Flicker Control"
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
#End Region
Sub New()
MyBase.New()
Size = New Size(200, 100)
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBackColor,
True)
'BackColor = Color.Transparent
DoubleBuffered = True
ForeColor = Color.FromArgb(210, 220, 230)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim bmp As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(bmp)
MyBase.OnPaint(e)
G.SmoothingMode = SmoothingMode.HighQuality
G.Clear(Color.FromArgb(43, 53, 63))
Dim s2 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 25), Color.From
Argb(35, 45, 55), Color.FromArgb(50, Color.White), 90S)
G.FillRectangle(s2, New Rectangle(1, 14, Width - 3, 13))
Dim s1 As New LinearGradientBrush(New Rectangle(0, 2, Width - 3, 25), Color.From
Argb(90, Color.White), Color.FromArgb(35, 45, 55), 90S)
G.FillRectangle(s1, New Rectangle(1, 1, Width - 3, 13))
G.DrawRectangle(New
- 1, 28)
G.DrawRectangle(New
dth - 3, 26)
G.DrawRectangle(New
h - 1, Height - 31)
G.DrawRectangle(New
h - 3, Height - 33)
e.Graphics.DrawImage(bmp.Clone(), 0, 0)
G.Dispose() : bmp.Dispose()
End Sub
End Class
Class SharpProgreSsBar
Inherits Control
Private GlowAnimation As Timer = New Timer
'Private _GlowColor As Color = Color.FromArgb(55, 65, 75)
Private _GlowColor As Color = Color.FromArgb(50, 255, 255, 255)
Private _Animate As Boolean = True
Private _Value As Int32 = 0
Private _HighlightColor As Color = Color.Silver
Private _BackgroundColor As Color = Color.FromArgb(150, 150, 150)
Private _StartColor As Color = Color.FromArgb(110, 110, 110)
#Region "Properties"
Public Property Color() As Color
Get
Return _StartColor
End Get
Set(ByVal value As Color)
_StartColor = value
Me.Invalidate()
End Set
End Property
Public Property Animate() As Boolean
Get
Return _Animate
End Get
Set(ByVal value As Boolean)
_Animate = value
If value = True Then
GlowAnimation.Start()
Else
GlowAnimation.Stop()
End If
Me.Invalidate()
End Set
End Property
Public Property GlowColor() As Color
Get
Return _GlowColor
End Get
Set(ByVal value As Color)
_GlowColor = value
Me.Invalidate()
End Set
End Property
Public Property Value() As Int32
Get
Return _Value
End Get
Set(ByVal value As Int32)
If value < 0 Then Return
_Value = value
If value < 100 Then GlowAnimation.Start()
Me.Invalidate()
End Set
End Property
Me.Invalidate()
End If
Else
GlowAnimation.Stop()
_mGlowPosition = -50
End If
End Sub
End Class
Class SharpTextBox : Inherits Control
Dim WithEvents txtbox As New TextBox
#Region " Control Help - Properties & Flicker Control "
Private _passmask As Boolean = False
Public Shadows Property UseSystemPasswordChar() As Boolean
Get
Return _passmask
End Get
Set(ByVal v As Boolean)
txtbox.UseSystemPasswordChar = UseSystemPasswordChar
_passmask = v
Invalidate()
End Set
End Property
Private _maxchars As Integer = 32767
Public Shadows Property MaxLength() As Integer
Get
Return _maxchars
End Get
Set(ByVal v As Integer)
_maxchars = v
txtbox.MaxLength = MaxLength
Invalidate()
End Set
End Property
Private _align As HorizontalAlignment
Public Shadows Property TextAlignment() As HorizontalAlignment
Get
Return _align
End Get
Set(ByVal v As HorizontalAlignment)
_align = v
Invalidate()
End Set
End Property
Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.P
aintEventArgs)
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
MyBase.OnBackColorChanged(e)
txtbox.BackColor = BackColor
Invalidate()
End Sub
Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
MyBase.OnForeColorChanged(e)
txtbox.ForeColor = ForeColor
Invalidate()
End Sub
Protected Overrides Sub OnFontChanged(ByVal e As System.EventArgs)
MyBase.OnFontChanged(e)
txtbox.Font = Font
End Sub
Protected Overrides Sub OnGotFocus(ByVal e As System.EventArgs)
MyBase.OnGotFocus(e)
txtbox.Focus()
End Sub
Sub TextChngTxtBox() Handles txtbox.TextChanged
Text = txtbox.Text
End Sub
Sub TextChng() Handles MyBase.TextChanged
txtbox.Text = Text
End Sub
Sub NewTextBox()
With txtbox
.Multiline = False
.BackColor = Color.FromArgb(43, 43, 43)
.ForeColor = ForeColor
.Text = String.Empty
.TextAlign = HorizontalAlignment.Center
.BorderStyle = BorderStyle.None
.Location = New Point(5, 5)
.Font = New Font("Verdana", 8)
.Size = New Size(Width - 10, Height - 11)
.UseSystemPasswordChar = UseSystemPasswordChar
End With
End Sub
#End Region
Sub New()
MyBase.New()
NewTextBox()
Controls.Add(txtbox)
Text = ""
BackColor = Color.FromArgb(35, 45, 55)
ForeColor = Color.FromArgb(162, 172, 182)
Size = New Size(135, 35)
DoubleBuffered = True
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim B As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(B)
G.SmoothingMode = SmoothingMode.HighQuality
MyBase.OnPaint(e)
Height = txtbox.Height + 11
With txtbox
.Width = Width - 10
.TextAlign = TextAlignment
.UseSystemPasswordChar = UseSystemPasswordChar
End With
G.Clear(Color.FromArgb(35, 45, 55))
Dim txtRect As New Rectangle(0, 0, Width - 1, Height - 1)
Dim InnerRect As New LinearGradientBrush(txtRect, Color.FromArgb(74, 84, 94), Co
lor.FromArgb(94, 104, 114), 90S)
G.DrawRectangle(New Pen(Color.FromArgb(12, 22, 32), 2), txtRect)
G.DrawLine(New Pen(InnerRect), Width - 1, 0, Width - 1, Height)
G.DrawLine(New Pen(InnerRect), 0, Height - 1, Width - 1, Height - 1)
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
Class SharpCheckBox : Inherits Control
#Region " Control Help - MouseState & Flicker Control"
Private State As MouseState = MouseState.None
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseDown(e)
State = MouseState.Down
Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
State = MouseState.None
Invalidate()
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs
)
MyBase.OnMouseUp(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
Private _Checked As Boolean
Property Checked() As Boolean
Get
Return _Checked
End Get
Set(ByVal value As Boolean)
_Checked = value
Invalidate()
End Set
End Property
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
G.DrawString(Text, Font, txtbrush, New Point(18, 2), New StringFormat With {.Lin
eAlignment = StringAlignment.Near, .Alignment = StringAlignment.Near})
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
Class SharpRadioButton : Inherits Control
#Region " Control Help - MouseState & Flicker Control"
Enum MouseState As Byte
None = 0
Over = 1
Down = 2
Block = 3
End Enum
Private State As MouseState = MouseState.None
Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs)
MyBase.OnMouseEnter(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventAr
gs)
MyBase.OnMouseDown(e)
State = MouseState.Down
Invalidate()
End Sub
Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs)
MyBase.OnMouseLeave(e)
State = MouseState.None
Invalidate()
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs
)
MyBase.OnMouseUp(e)
State = MouseState.Over
Invalidate()
End Sub
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Height = 16
End Sub
Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
MyBase.OnTextChanged(e)
Invalidate()
End Sub
Private _Checked As Boolean
Property Checked() As Boolean
Get
Return _Checked
End Get
Set(ByVal value As Boolean)
_Checked = value
InvalidateControls()
RaiseEvent CheckedChanged(Me)
Invalidate()
End Set
End Property