Beruflich Dokumente
Kultur Dokumente
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.MouseEve
ntArgs)
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.MouseEvent
Args)
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.SupportsTransparentBac
kColor, True)
ForeColor = Color.FromArgb(210, 220, 230)
DoubleBuffered = True
Font = New Font("Verdana", 8.5F, FontStyle.Regular)
End Sub
2))
Dim BTNLGB1 As New LinearGradientBrush(New Rectangle(-1, 1, Width, H
eader / 2), Color.FromArgb(120, Color.White), Color.FromArgb(35, 45, 55), 180)
G.FillRectangle(BTNLGB1, New Rectangle(-1, 1, Width / 2, Header / 2)
)
Dim txtbrush As Brush = New SolidBrush(Color.FromArgb(210, 220, 230)
)
G.DrawString(Text, Font, txtbrush, New Rectangle(16, 7, Width - 1, 2
2), New StringFormat With {.LineAlignment = StringAlignment.Near, .Alignment = S
tringAlignment.Near})
End If
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,
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.PaintEventAr
gs)
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, W
idth - 3, Height / 2 - 2), Color.FromArgb(170, 18, 32), Color.FromArgb(147, 156,
162), 360)
G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Heig
ht / 2 - 2))
Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1,
Width - 2, Height / 2 - 2), Color.FromArgb(147, 156, 162), Color.FromArgb(170, 1
8, 32), 360)
G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Hei
ght / 2 - 2))
G.SmoothingMode = SmoothingMode.HighQuality
'----- Borders ----G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(39, 49
, 59))), New Rectangle(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, 9
0), 90)
G.DrawRectangle(New Pen(InnerRect), New Rectangle(1, 1, Widt
h - 3, Height - 3))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(123, 133, 1
43))), 1, Height - 2, Width - 2, Height - 2)
ElseIf BtnTxt = TxtState.Minim Then
G.Clear(Color.FromArgb(0, 102, 175))
Dim LGBOver As New LinearGradientBrush(New Rectangle(2, 1, W
idth - 3, Height / 2 - 2), Color.FromArgb(0, 102, 175), Color.FromArgb(157, 166,
172), 360)
G.FillRectangle(LGBOver, New Rectangle(2, 1, Width - 3, Heig
ht / 2 - 2))
Dim LGBOver1 As New LinearGradientBrush(New Rectangle(0, 1,
Width - 2, Height / 2 - 2), Color.FromArgb(157, 166, 172), Color.FromArgb(0, 102
, 175), 360)
G.FillRectangle(LGBOver1, New Rectangle(0, 1, Width / 2, Hei
ght / 2 - 2))
G.SmoothingMode = SmoothingMode.HighQuality
0, Width - 1, 28)
G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(111, 121, 131))),
1, 1, Width - 3, 26)
G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 40, 50))), 0,
30, Width - 1, Height - 31)
G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(60, 70, 80))), 1,
31, Width - 3, Height - 33)
G.DrawRectangle(New Pen(New SolidBrush(Color.FromArgb(30, 30, 30))), New
Rectangle(0, 0, Width - 1, Height - 1))
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(20, 30, 40))), 1, 29, W
idth - 2, 29)
G.DrawString(Text, Font, New SolidBrush(ForeColor), New Rectangle(1, 4,
Width, 20), New StringFormat With {.LineAlignment = StringAlignment.Center, .Ali
gnment = StringAlignment.Center})
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
G.FillRectangle(GlowLGBS, GlowRect)
G.ResetClip()
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
Private Function RoundRect(ByVal r As RectangleF, ByVal r1 As Single, ByVal
r2 As Single, ByVal r3 As Single, ByVal r4 As Single) As GraphicsPath
Dim x As Single = r.X, y As Single = r.Y, w As Single = r.Width, h As Si
ngle = r.Height
Dim rr5 As GraphicsPath = New GraphicsPath
rr5.AddBezier(x, y + r1, x, y, x + r1, y, x + r1, y)
rr5.AddLine(x + r1, y, x + w - r2, y)
rr5.AddBezier(x + w - r2, y, x + w, y, x + w, y + r2, x + w, y + r2)
rr5.AddLine(x + w, y + r2, x + w, y + h - r3)
rr5.AddBezier(x + w, y + h - r3, x + w, y + h, x + w - r3, y + h, x + w
- r3, y + 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
Private Sub GlowAnimation_Tick(ByVal sender As Object, ByVal e As EventArgs)
If Me.Animate Then
_mGlowPosition += 4
If _mGlowPosition > Me.Width Then
_mGlowPosition = -10
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.For
ms.PaintEventArgs)
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.PaintEventAr
gs)
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), Color.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.MouseEve
ntArgs)
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.MouseEvent
Args)
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)
_Checked = Not _Checked
RaiseEvent CheckedChanged(Me)
MyBase.OnClick(e)
End Sub
Event CheckedChanged(ByVal sender As Object)
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Height = 18
End Sub
#End Region
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
Size = New Size(145, 16)
ForeColor = Color.FromArgb(210, 210, 222)
DoubleBuffered = True
Font = New Font("Verdana", 8)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventAr
gs)
Dim B As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(B)
MyBase.OnPaint(e)
G.SmoothingMode = SmoothingMode.HighQuality
G.Clear(BackColor)
If Checked = False Then
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.MouseEvent
Args)
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
Protected Overrides Sub OnClick(ByVal e As EventArgs)
If Not _Checked Then Checked = True
MyBase.OnClick(e)
End Sub
Event CheckedChanged(ByVal sender As Object)
Protected Overrides Sub OnCreateControl()
MyBase.OnCreateControl()
InvalidateControls()
End Sub
Private Sub InvalidateControls()
If Not IsHandleCreated OrElse Not _Checked Then Return
For Each C As Control In Parent.Controls
If C IsNot Me AndAlso TypeOf C Is SharpRadioButton Then
DirectCast(C, SharpRadioButton).Checked = False
End If
Next
End Sub
#End Region
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
Size = New Size(150, 16)
ForeColor = Color.FromArgb(210, 210, 222)
DoubleBuffered = True
Font = New Font("Verdana", 8)
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventAr
gs)
Dim B As New Bitmap(Width, Height)
Dim G As Graphics = Graphics.FromImage(B)
G.SmoothingMode = SmoothingMode.HighQuality
MyBase.OnPaint(e)
G.Clear(BackColor)
If Checked = False Then
Dim BTNLGBOver As New LinearGradientBrush(New Rectangle(3, 3, 12, 11
), Color.FromArgb(37, 47, 57), Color.FromArgb(62, 68, 74), 90)
G.FillEllipse(BTNLGBOver, New Rectangle(3, 3, 12, 11))
G.DrawEllipse(New Pen(Color.FromArgb(0, 0, 0)), 2, 2, 14, 13)
Else
Dim CKelGrd As New LinearGradientBrush(New Rectangle(3, 3, 12, 11),
Color.FromArgb(65, 71, 77), Color.FromArgb(0, 0, 0), 90)
G.FillEllipse(CKelGrd, New Rectangle(3, 3, 12, 11))
G.DrawEllipse(New Pen(Color.FromArgb(13, 23, 33)), 2, 2, 14, 13)
End If