Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
InteropSer
vices, System.ComponentModel
Imports System.Drawing, System.Drawing.Drawing2D, System.Drawing.Imaging, System
.Windows.Forms
'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
'--------------------- [ Credits ] -------------------'Creator: Recuperare
'Contact: cschaefer2183 (Skype)
'Created: 10.11.2012
'Changed: 10.11.2012
'-------------------- [ /Credits ] --------------------'PLEASE LEAVE CREDITS IN SOURCE, DO NOT REDISTRIBUTE!
Enum MouseState As Byte
None = 0
Over = 1
Down = 2
Block = 3
End Enum
#Region " GLOBAL FUNCTIONS "
Class Draw
Public Function RoundRect(ByVal Rectangle As Rectangle, ByVal Curve As Integ
er) As GraphicsPath
Dim P As GraphicsPath = New GraphicsPath()
Dim ArcRectangleWidth As Integer = Curve * 2
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcR
ectangleWidth), -180, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X
, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X
, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRect
angleWidth), 0, 90)
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth
+ Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth +
Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
Return P
End Function
Public Function RoundRect(ByVal X As Integer, ByVal Y As Integer, ByVal Widt
h As Integer, ByVal Height As Integer, ByVal Curve As Integer) As GraphicsPath
Dim Rectangle As Rectangle = New Rectangle(X, Y, Width, Height)
Dim P As GraphicsPath = New GraphicsPath()
Dim ArcRectangleWidth As Integer = Curve * 2
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Y, ArcRectangleWidth, ArcR
ectangleWidth), -180, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X
, Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), -90, 90)
P.AddArc(New Rectangle(Rectangle.Width - ArcRectangleWidth + Rectangle.X
, Rectangle.Height - ArcRectangleWidth + Rectangle.Y, ArcRectangleWidth, ArcRect
angleWidth), 0, 90)
P.AddArc(New Rectangle(Rectangle.X, Rectangle.Height - ArcRectangleWidth
+ Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 90, 90)
P.AddLine(New Point(Rectangle.X, Rectangle.Height - ArcRectangleWidth +
Rectangle.Y), New Point(Rectangle.X, Curve + Rectangle.Y))
Return P
End Function
End Class
#End Region
Public Class InfluenceTheme : Inherits ContainerControl
#Region " Control Help - Movement & Flicker Control "
Private MouseP As Point = New Point(0, 0)
Private Cap As Boolean = False
Private MoveHeight As Integer
Private pos As Integer = 0
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEve
ntArgs)
MyBase.OnMouseDown(e)
If e.Button = Windows.Forms.MouseButtons.Left And New Rectangle(0, 0, Wi
dth, MoveHeight).Contains(e.Location) Then
Cap = True : MouseP = e.Location
End If
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEvent
Args)
MyBase.OnMouseUp(e) : Cap = False
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEve
ntArgs)
MyBase.OnMouseMove(e)
If Cap Then
Parent.Location = MousePosition - MouseP
End If
End Sub
Protected Overrides Sub OnInvalidated(ByVal e As System.Windows.Forms.Invali
dateEventArgs)
MyBase.OnInvalidated(e)
ParentForm.FindForm.Text = Text
End Sub
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.Pa
intEventArgs)
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
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
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
{.ButtonIcon = Influe
= New Point(Width - 8
{.ButtonIcon = Influe
= New Point(Width - 5
Sub New()
MyBase.New()
Dock = DockStyle.Fill
MoveHeight = 25
Font = New Font("Verdana", 8.25F)
DoubleBuffered = True
Controls.Add(closeBtn)
closeBtn.Refresh() : minimBtn.Refresh()
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
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)
If _minimBool Then
Controls.Add(minimBtn)
Else
Controls.Remove(minimBtn)
End If
minimBtn.Location = New Point(Width - 81, 0)
closeBtn.Location = New Point(Width - 52, 0)
G.SmoothingMode = SmoothingMode.HighSpeed
Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
Dim TransparencyKey As Color = Me.ParentForm.TransparencyKey
Dim d As New Draw()
MyBase.OnPaint(e)
G.Clear(TransparencyKey)
G.FillPath(New SolidBrush(Color.FromArgb(20, 20, 20)), d.RoundRect(Clien
tRectangle, 2))
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(1
00, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
Dim g1 As New LinearGradientBrush(New Rectangle(0, 2, Width - 1, 25), Co
lor.FromArgb(40, 40, 40), Color.FromArgb(29, 29, 29), 90S)
G.FillPath(g1, d.RoundRect(New Rectangle(0, 2, Width - 1, 25), 2))
G.FillPath(h1, d.RoundRect(New Rectangle(0, 2, Width - 1, 25), 2))
Dim s1 As New LinearGradientBrush(g1.Rectangle, Color.FromArgb(15, Color
.White), Color.FromArgb(0, Color.White), 90S)
G.FillRectangle(s1, New Rectangle(1, 1, Width - 1, 13))
G.DrawLine(New Pen(Color.FromArgb(75, Color.White)), 1, 1, Width - 1, 1)
G.DrawLine(New Pen(Color.FromArgb(18, 18, 18)), 1, 26, Width - 1, 26)
G.DrawRectangle(New Pen(Color.FromArgb(37, 37, 37)), New Rectangle(1, 27
, Width - 3, Height - 29))
G.DrawPath(Pens.Black, d.RoundRect(ClientRectangle, 2))
G.DrawString(Text, Font, Brushes.Black, New Rectangle(8, 8,
0), New StringFormat With {.LineAlignment = StringAlignment.Center,
StringAlignment.Near})
G.DrawString(Text, Font, Brushes.White, New Rectangle(8, 9,
1), New StringFormat With {.LineAlignment = StringAlignment.Center,
StringAlignment.Near})
Width - 1, 1
.Alignment =
Width - 1, 1
.Alignment =
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
Public Class InfluenceButton : 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
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
Font = New Font("Verdana", 8.25F)
Size = New Size(43, 21)
DoubleBuffered = True
Focus()
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)
Dim d As New Draw()
Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
G.Clear(BackColor)
Select Case State
Case MouseState.None 'Mouse None
Dim g1 As New LinearGradientBrush(ClientRectangle, Color.FromArg
b(125, 78, 75, 73), Color.FromArgb(125, 61, 59, 55), 90S)
G.FillRectangle(g1, g1.Rectangle)
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.Fr
omArgb(100, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillRectangle(h1, g1.Rectangle)
Dim s1 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1,
Height / 2), Color.FromArgb(35, Color.White), Color.FromArgb(0, Color.White), 9
0S)
G.FillRectangle(s1, s1.Rectangle)
G.DrawRectangle(New Pen(Color.FromArgb(150, 97, 94, 90)), New Re
ctangle(0, 1, Width - 1, Height - 3))
G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), New Rectang
le(0, 0, Width - 1, Height - 1))
Case MouseState.Over
Dim g1 As New LinearGradientBrush(ClientRectangle, Color.FromArg
b(125, 78, 75, 73), Color.FromArgb(125, 61, 59, 55), 90S)
G.FillRectangle(g1, g1.Rectangle)
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.Fr
omArgb(100, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillRectangle(h1, g1.Rectangle)
Dim s1 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1,
Height / 2), Color.FromArgb(35, Color.White), Color.FromArgb(0, Color.White), 9
0S)
G.FillRectangle(s1, s1.Rectangle)
G.FillRectangle(New SolidBrush(Color.FromArgb(15, Color.White)),
New Rectangle(0, 0, Width - 1, Height - 1))
G.DrawRectangle(New Pen(Color.FromArgb(150, 97, 94, 90)), New Re
ctangle(0, 1, Width - 1, Height - 3))
G.DrawRectangle(New Pen(Color.FromArgb(20, 20, 20)), New Rectang
le(0, 0, Width - 1, Height - 1))
Case MouseState.Down
Dim g1 As New LinearGradientBrush(ClientRectangle, Color.FromArg
b(125, 78, 75, 73), Color.FromArgb(125, 61, 59, 55), 90S)
G.FillRectangle(g1, g1.Rectangle)
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.Fr
omArgb(100, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillRectangle(h1, g1.Rectangle)
End Get
Set(ByVal v As Integer)
Select Case v
Case Is > _Maximum
v = _Maximum
End Select
_Value = v
Invalidate()
End Set
End Property
Private _ShowPercentage As Boolean = False
Public Property ShowPercentage() As Boolean
Get
Return _ShowPercentage
End Get
Set(ByVal v As Boolean)
_ShowPercentage = v
Invalidate()
End Set
End Property
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
' Dim tmr As New Timer With {.Interval = Speed}
' AddHandler tmr.Tick, AddressOf Animate
' tmr.Start()
Dim T As New Threading.Thread(AddressOf Animate)
T.IsBackground = True
'T.Start()
End Sub
Sub Animate()
While True
If OFS <= Width Then : OFS += 1
Else : OFS = 0
End If
Invalidate()
Threading.Thread.Sleep(Speed)
End While
End Sub
#End Region
Sub New()
MyBase.New()
DoubleBuffered = True
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
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
Dim d As New Draw()
Dim intValue As Integer = CInt(_Value / _Maximum * Width)
G.Clear(BackColor)
Dim gB As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height
End Property
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 = Color.FromArgb(43, 43, 43)
Invalidate()
End Sub
Protected Overrides Sub OnForeColorChanged(ByVal e As System.EventArgs)
MyBase.OnForeColorChanged(e)
txtbox.ForeColor = ForeColor
Invalidate()
End Sub
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)
txtbox.Size = New Size(Width - 10, Height - 11)
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 = True
.BackColor = BackColor
.ForeColor = ForeColor
.Text = String.Empty
.TextAlign = HorizontalAlignment.Center
.BorderStyle = BorderStyle.None
.Location = New Point(3, 4)
.Font = New Font("Verdana", 8.25)
.Size = New Size(Width - 10, Height - 10)
End With
txtbox.Font = New Font("Verdana", 8.25)
End Sub
#End Region
Sub New()
MyBase.New()
NewTextBox()
Controls.Add(txtbox)
Text = String.Empty
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
ForeColor = Color.White
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 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 = Color.FromArgb(43, 43, 43)
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.25)
.Size = New Size(Width - 10, Height - 11)
.UseSystemPasswordChar = UseSystemPasswordChar
End With
End Sub
#End Region
Sub New()
MyBase.New()
NewTextBox()
Controls.Add(txtbox)
Text = ""
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
ForeColor = Color.White
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
Dim d As New Draw()
Dim ClientRectangle As New Rectangle(0, 0, Width - 1, Height - 1)
Height = txtbox.Height + 11
With txtbox
.Width = Width - 10
.TextAlign = TextAlignment
.UseSystemPasswordChar = UseSystemPasswordChar
End With
G.Clear(BackColor)
Dim g1 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height
/ 2), Color.FromArgb(40, 40, 40), Color.FromArgb(45, 45, 45), 90S)
G.FillPath(g1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2), 2
))
Dim g2 As New LinearGradientBrush(New Rectangle(0, Height / 2, Width - 1
, Height / 2), Color.FromArgb(45, 45, 45), Color.FromArgb(40, 40, 40), 90S)
G.FillPath(g2, d.RoundRect(New Rectangle(0, Height / 2 - 3, Width - 1, H
eight / 2 + 2), 2))
G.DrawPath(New Pen(Color.FromArgb(150, 97, 94, 90)), d.RoundRect(New Rec
tangle(0, 1, Width - 1, Height - 3), 2))
G.DrawPath(New Pen(Color.FromArgb(10, 10, 10)), d.RoundRect(ClientRectan
gle, 2))
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
Public Class InfluenceListBox : Inherits Control
Public WithEvents lstbox As New ListBox
Private __Items As String() = {""}
#Region " Control Help - Properties & Flicker Control "
Protected Overrides Sub OnSizeChanged(ByVal e As System.EventArgs)
MyBase.OnSizeChanged(e)
lstbox.Size = New Size(Width - 6, Height - 6)
Invalidate()
End Sub
Protected Overrides Sub OnBackColorChanged(ByVal e As System.EventArgs)
MyBase.OnBackColorChanged(e)
End Get
Set(ByVal value As Integer)
_StartIndex = value
Try
MyBase.SelectedIndex = value
Catch
End Try
Invalidate()
End Set
End Property
Sub ReplaceItem(ByVal sender As System.Object, ByVal e As System.Windows.For
ms.DrawItemEventArgs) Handles Me.DrawItem
e.DrawBackground()
Try
If (e.State And DrawItemState.Selected) = DrawItemState.Selected The
n
e.Graphics.FillRectangle(New SolidBrush(_highlightColor), e.Boun
ds) '37 37 37
End If
Using b As New SolidBrush(e.ForeColor)
e.Graphics.DrawString(MyBase.GetItemText(MyBase.Items(e.Index)),
e.Font, b, e.Bounds)
End Using
Catch
End Try
e.DrawFocusRectangle()
Invalidate()
End Sub
Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, By
Val SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
Dim points As New List(Of Point)()
points.Add(FirstPoint)
points.Add(SecondPoint)
points.Add(ThirdPoint)
G.FillPolygon(New SolidBrush(Clr), points.ToArray)
End Sub
Private _highlightColor As Color = Color.FromArgb(128, 128, 128)
Public Property ItemHighlightColor() As Color
Get
Return _highlightColor
End Get
Set(ByVal v As Color)
_highlightColor = v
Invalidate()
End Set
End Property
#End Region
Sub New()
MyBase.New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer Or _
ControlStyles.SupportsTransparentBackColor, True)
DrawMode = Windows.Forms.DrawMode.OwnerDrawFixed
BackColor = Color.Transparent
ForeColor = Color.White
DropDownStyle = ComboBoxStyle.DropDownList
DoubleBuffered = True
Invalidate()
End Sub
Protected
Dim B
Dim G
Dim d
G.SmoothingMode = SmoothingMode.HighQuality
G.Clear(BackColor)
Dim g1 As New LinearGradientBrush(ClientRectangle, Color.FromArgb(125, 7
8, 75, 73), Color.FromArgb(125, 61, 59, 55), 90S)
G.FillPath(g1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2
))
'G.FillRectangle(g1, ClientRectangle)
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(1
00, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillPath(h1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2
))
'G.FillRectangle(h1, New Rectangle(0, 0, Width - 1, Height - 2))
Dim s1 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height
/ 2), Color.FromArgb(35, Color.White), Color.FromArgb(0, Color.White), 90S)
G.FillPath(s1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2 - 1
), 2))
G.DrawLine(New Pen(Color.FromArgb(85, 83, 80)), Width - 18, 0, Width - 1
8, Height - 1)
G.DrawLine(New Pen(Color.FromArgb(15, 13, 10)), Width - 19, 0, Width - 1
9, Height - 1)
G.DrawPath(New Pen(Color.FromArgb(150, 97, 94, 90)), d.RoundRect(New Rec
tangle(0, 1, Width - 1, Height - 3), 2))
G.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), d.RoundRect(New Rectangle(0
, 0, Width - 1, Height - 1), 2))
'
Far Point
Near Poi
nt
Middle Point
DrawTriangle(Color.White, New Point(Width - 14, 12), New Point(Width - 7
, 12), New Point(Width - 11, 15), G)
DrawTriangle(Color.White, New Point(Width - 14, 9), New Point(Width - 7,
9), New Point(Width - 11, 6), G)
Try
G.DrawString(Text, Font, Brushes.White, New Rectangle(3, 0, Width 20, Height), New StringFormat With {.LineAlignment = StringAlignment.Center, .Al
ignment = StringAlignment.Near})
Catch
End Try
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
<DefaultEvent("CheckedChanged")> Public Class InfluenceCheckBox : Inherits Contr
ol
#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 OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Height = 16
End Sub
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)
#End Region
Sub New()
MyBase.New()
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
ForeColor = Color.White
Size = New Size(145, 16)
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
G.Clear(BackColor)
Select Case Checked
Case False
Dim g1 As New LinearGradientBrush(radioBtnRectangle, Color.FromA
rgb(10, 10, 10), Color.FromArgb(16, 16, 16), 90S)
G.FillEllipse(g1, radioBtnRectangle)
G.DrawEllipse(New Pen(Color.FromArgb(80, 97, 94, 90)), New Recta
ngle(1, 1, Height - 3, Height - 3))
G.DrawEllipse(Pens.Black, radioBtnRectangle)
Case True
Dim g1 As New LinearGradientBrush(radioBtnRectangle, Color.FromA
rgb(10, 10, 10), Color.FromArgb(16, 16, 16), 90S)
G.FillEllipse(g1, radioBtnRectangle)
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.Fr
omArgb(100, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillEllipse(h1, radioBtnRectangle)
Dim s1 As New LinearGradientBrush(New Rectangle(0, 1, Height - 1
, Height / 2 - 1), Color.FromArgb(35, Color.White), Color.FromArgb(0, Color.Whit
e), 90S)
G.FillEllipse(s1, s1.Rectangle)
G.FillEllipse(New SolidBrush(Color.FromArgb(15, 15, 15)), New Re
ctangle(4, 4, Height - 9, Height - 9))
G.FillEllipse(New SolidBrush(Color.FromArgb(250, 255, 255, 255))
, New Rectangle(5, 5, Height - 11, Height - 11))
G.DrawEllipse(New Pen(Color.FromArgb(80, 97, 94, 90)), New Recta
ngle(1, 1, Height - 3, Height - 3))
G.DrawEllipse(Pens.Black, radioBtnRectangle)
End Select
Width - 1, 1
.Alignment =
Width - 1, 1
.Alignment =
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class
Public Class InfluenceNumericUpDown : Inherits Control
#Region " Properties & Flicker Control "
Private State As New MouseState
Private X As Integer
Private Y As Integer
Private _Value As Long
Private _Max As Long
Private _Min As Long
Private Typing As Boolean
Public Property Value As Long
Get
Return _Value
End Get
Set(ByVal V As Long)
If V <= _Max And V >= _Min Then _Value = V
Invalidate()
End Set
End Property
Public Property Maximum As Long
Get
Return _Max
End Get
Set(ByVal V As Long)
If V > _Min Then _Max = V
If _Value > _Max Then _Value = _Max
Invalidate()
End Set
End Property
Public Property Minimum As Long
Get
Return _Min
End Get
Set(ByVal V As Long)
If V < _Max Then _Min = V
If _Value < _Min Then _Value = _Min
Invalidate()
End Set
End Property
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEve
ntArgs)
MyBase.OnMouseMove(e)
X = e.Location.X
Y = e.Location.Y
Invalidate()
If e.X < Width - 23 Then Cursor = Cursors.IBeam Else Cursor = Cursors.De
fault
End Sub
Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
MyBase.OnResize(e)
Me.Height = 22
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEve
ntArgs)
MyBase.OnMouseClick(e)
If X > Me.Width - 21 Then
If Y < 10 Then
If (Value + 1) <= _Max Then _Value += 1
Else
If (Value - 1) >= _Min Then _Value -= 1
End If
Else
Typing = Not Typing
Focus()
End If
Invalidate()
End Sub
Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressE
ventArgs)
MyBase.OnKeyPress(e)
Try
If Typing Then _Value = CStr(CStr(_Value) & e.KeyChar.ToString)
Catch ex As Exception : End Try
End Sub
Protected Overrides Sub OnKeyup(ByVal e As System.Windows.Forms.KeyEventArgs
)
MyBase.OnKeyUp(e)
If e.KeyCode = Keys.Up Then
If (Value + 1) <= _Max Then _Value += 1
Invalidate()
ElseIf e.KeyCode = Keys.Down Then
If (Value - 1) >= _Min Then _Value -= 1
End If
Invalidate()
End Sub
Protected Sub DrawTriangle(ByVal Clr As Color, ByVal FirstPoint As Point, By
Val SecondPoint As Point, ByVal ThirdPoint As Point, ByVal G As Graphics)
Dim points As New List(Of Point)()
points.Add(FirstPoint)
points.Add(SecondPoint)
points.Add(ThirdPoint)
G.FillPolygon(New SolidBrush(Clr), points.ToArray)
End Sub
#End Region
Sub New()
_Max = 9999999
_Min = 0
Cursor = Cursors.IBeam
SetStyle(ControlStyles.UserPaint Or ControlStyles.SupportsTransparentBac
kColor, True)
BackColor = Color.Transparent
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.Clear(BackColor)
Dim d As New Draw()
G.SmoothingMode = SmoothingMode.HighQuality
G.Clear(Color.FromArgb(20, 20, 20))
Dim g1 As New LinearGradientBrush(ClientRectangle, Color.FromArgb(125, 7
8, 75, 73), Color.FromArgb(125, 61, 59, 55), 90S)
G.FillPath(g1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2
))
Dim h1 As New HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(1
00, 31, 31, 31), Color.FromArgb(100, 36, 36, 36))
G.FillPath(h1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height - 2), 2
))
Dim s1 As New LinearGradientBrush(New Rectangle(0, 0, Width - 1, Height
/ 2), Color.FromArgb(35, Color.White), Color.FromArgb(0, Color.White), 90S)
G.FillPath(s1, d.RoundRect(New Rectangle(0, 0, Width - 1, Height / 2 - 1
), 2))
G.DrawPath(New Pen(Color.FromArgb(150, 97, 94, 90)), d.RoundRect(New Rec
tangle(0, 1, Width - 1, Height - 3), 2))
G.DrawPath(New Pen(Color.FromArgb(0, 0, 0)), d.RoundRect(New Rectangle(0
, 0, Width - 1, Height - 1), 2))
''Separator Lines
G.DrawLine(New Pen(Color.FromArgb(10,
, New Point(Width - 21, Height))
G.DrawLine(New Pen(Color.FromArgb(70,
, New Point(Width - 20, Height - 3))
G.DrawLine(New Pen(Color.FromArgb(10,
), New Point(Width, 10))
G.DrawLine(New Pen(Color.FromArgb(70,
), New Point(Width - 3, 11))
'Top Triangle
DrawTriangle(Color.White, New Point(Width - 14, 14), New Point(Width - 7
, 14), New Point(Width - 11, 17.5), G)
'Bottom Triangle
DrawTriangle(Color.White, New Point(Width - 14, 7), New Point(Width - 7,
7), New Point(Width - 11, 3), G)
G.DrawString(Value, Font, Brushes.White, New Point(5, 4))
'G.DrawRectangle(New Pen(Color.FromArgb(70, 70, 70)), New Rectangle(1, 1
, Width - 3, Height - 3))
'G.DrawRectangle(New Pen(Color.FromArgb(30, 30, 30)), New Rectangle(0, 0
, Width - 1, Height - 1))
e.Graphics.DrawImage(B.Clone(), 0, 0)
G.Dispose() : B.Dispose()
End Sub
End Class