Professional Documents
Culture Documents
Visual Studio Aresio VB
Visual Studio Aresio VB
NET Theme
Imports System.Drawing.Drawing2D
Module DesignFunctions
Function ToBrush(ByVal A As Integer, ByVal R As Integer, ByVal G
As Integer, ByVal B As Integer) As Brush
Return ToBrush(Color.FromArgb(A, R, G, B))
End Function
Function ToBrush(ByVal R As Integer, ByVal G As Integer, ByVal B
As Integer) As Brush
Return ToBrush(Color.FromArgb(R, G, B))
End Function
Function ToBrush(ByVal A As Integer, ByVal C As Color) As Brush
Return ToBrush(Color.FromArgb(A, C))
End Function
Function ToBrush(ByVal Pen As Pen) As Brush
Return ToBrush(Pen.Color)
End Function
Function ToBrush(ByVal Color As Color) As Brush
Return New SolidBrush(Color)
End Function
Function ToPen(ByVal A As Integer, ByVal R As Integer, ByVal G As
Integer, ByVal B As Integer) As Pen
Return ToPen(Color.FromArgb(A, R, G, B))
End Function
Function ToPen(ByVal R As Integer, ByVal G As Integer, ByVal B As
Integer) As Pen
Return ToPen(Color.FromArgb(R, G, B))
End Function
Function ToPen(ByVal A As Integer, ByVal C As Color) As Pen
Return ToPen(Color.FromArgb(A, C))
End Function
Function ToPen(ByVal Color As Color) As Pen
Return ToPen(New SolidBrush(Color))
End Function
Function ToPen(ByVal Brush As SolidBrush) As Pen
Return New Pen(Brush)
End Function
Class CornerStyle
Public TopLeft As Boolean
Public TopRight As Boolean
Public BottomLeft As Boolean
Public BottomRight As Boolean
End Class
If CornerStyle.TopLeft Then
AdvRect.AddArc(New Rectangle(Rectangle.X, Rectangle.Y,
ArcRectangleWidth, ArcRectangleWidth), -180, 90)
Else
AdvRect.AddLine(Rectangle.X, Rectangle.Y, Rectangle.X +
ArcRectangleWidth, Rectangle.Y)
End If
If CornerStyle.TopRight Then
AdvRect.AddArc(New Rectangle(Rectangle.Width -
ArcRectangleWidth + Rectangle.X, Rectangle.Y, ArcRectangleWidth,
ArcRectangleWidth), -90, 90)
Else
AdvRect.AddLine(Rectangle.X + Rectangle.Width,
Rectangle.Y, Rectangle.X + Rectangle.Width, Rectangle.Y +
ArcRectangleWidth)
End If
If CornerStyle.BottomRight Then
AdvRect.AddArc(New Rectangle(Rectangle.Width -
ArcRectangleWidth + Rectangle.X, Rectangle.Height - ArcRectangleWidth
+ Rectangle.Y, ArcRectangleWidth, ArcRectangleWidth), 0, 90)
Else
AdvRect.AddLine(Rectangle.X + Rectangle.Width,
Rectangle.Y + Rectangle.Height, Rectangle.X + Rectangle.Width -
ArcRectangleWidth, Rectangle.Y + Rectangle.Height)
End If
If CornerStyle.BottomLeft Then
AdvRect.AddArc(New Rectangle(Rectangle.X,
Rectangle.Height - ArcRectangleWidth + Rectangle.Y,
ArcRectangleWidth, ArcRectangleWidth), 90, 90)
Else
AdvRect.AddLine(Rectangle.X, Rectangle.Y +
Rectangle.Height, Rectangle.X, Rectangle.Y + Rectangle.Height -
ArcRectangleWidth)
End If
AdvRect.CloseAllFigures()
Return AdvRect
End Function
Class PillStyle
Public Left As Boolean
Public Right As Boolean
End Class
If PillStyle.Left Then
Pill.AddArc(New Rectangle(Rectangle.X, Rectangle.Y,
Rectangle.Height, Rectangle.Height), -270, 180)
Else
Pill.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height,
Rectangle.X, Rectangle.Y)
End If
If PillStyle.Right Then
Pill.AddArc(New Rectangle(Rectangle.X + Rectangle.Width -
Rectangle.Height, Rectangle.Y, Rectangle.Height, Rectangle.Height),
-90, 180)
Else
Pill.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y,
Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height)
End If
Pill.CloseAllFigures()
Return Pill
End Function
End Module
Class AresioButton
Inherits Control
Enum MouseState
None
Over
Down
End Enum
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)
End Sub
G.SmoothingMode = SmoothingMode.HighQuality
'Background
G.FillPath(New LinearGradientBrush(New Point(0, 0), New
Point(0, Height), Color.FromArgb(250, 200, 70), Color.FromArgb(250,
160, 40)), _
RoundRect(0, 0, Width - 1, Height - 1, 4))
Class AresioTrackBar
Inherits Control
#Region "Properties"
Dim _Maximum As Integer = 10
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal value As Integer)
If value > 0 Then _Maximum = value
If value < _Value Then _Value = value
Invalidate()
End Set
End Property
Event ValueChanged()
Dim _Value As Integer = 0
Public Property Value() As Integer
Get
Return _Value
End Get
Set(ByVal value As Integer)
Invalidate()
RaiseEvent ValueChanged()
End Set
End Property
#End Region
Sub New()
Me.SetStyle(ControlStyles.DoubleBuffer Or _
ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.Selectable Or _
ControlStyles.SupportsTransparentBackColor, True)
End Sub
'Background
Dim BackLinear As LinearGradientBrush = New
LinearGradientBrush(New Point(0, CInt((Height / 2) - 4)), New
Point(0, CInt((Height / 2) + 4)), Color.FromArgb(50, Color.Black),
Color.Transparent)
G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4),
Width - 1, 8, 3))
G.DrawPath(ToPen(50, Color.Black), RoundRect(0,
CInt((Height / 2) - 4), Width - 1, 8, 3))
BackLinear.Dispose()
'Fill
G.FillPath(New LinearGradientBrush(New Point(1,
CInt((Height / 2) - 4)), New Point(1, CInt((Height / 2) + 4)),
Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)),
RoundRect(1, CInt((Height / 2) - 4), CInt(Bar.Width * (Value /
Maximum)) + CInt(Track.Width / 2), 8, 3))
G.DrawPath(ToPen(100, Color.White), RoundRect(2, CInt((Height
/ 2) - 2), CInt(Bar.Width * (Value / Maximum)) + CInt(Track.Width /
2), 4, 3))
G.SetClip(RoundRect(1, CInt((Height / 2) - 4), CInt(Bar.Width
* (Value / Maximum)) + CInt(Track.Width / 2), 8, 3))
For i = 0 To CInt(Bar.Width * (Value / Maximum)) +
CInt(Track.Width / 2) Step 10
G.DrawLine(New Pen(New SolidBrush(Color.FromArgb(20,
Color.Black)), 4), New Point(i, CInt((Height / 2) - 10)), New Point(i
- 10, CInt((Height / 2) + 10)))
Next
G.SetClip(New Rectangle(0, 0, Width, Height))
'Button
G.FillEllipse(Brushes.White, Bar.X + CInt(Bar.Width *
(Value / Maximum)) - CInt(Track.Width / 2), Bar.Y +
CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width,
Track.Height)
G.DrawEllipse(ToPen(50, Color.Black), Bar.X + CInt(Bar.Width
* (Value / Maximum)) - CInt(Track.Width / 2), Bar.Y +
CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width,
Track.Height)
G.FillEllipse(New LinearGradientBrush(New Point(0, Bar.Y +
CInt((Bar.Height / 2)) - CInt(Track.Height / 2)), New Point(0, Bar.Y
+ CInt((Bar.Height / 2)) - CInt(Track.Height / 2) + Track.Height),
Color.FromArgb(200, Color.Black), Color.FromArgb(100, Color.Black)),
New Rectangle(Bar.X + CInt(Bar.Width * (Value / Maximum)) -
CInt(Track.Width / 2) + 6, Bar.Y + CInt((Bar.Height / 2)) -
CInt(Track.Height / 2) + 6, Track.Width - 12, Track.Height - 12))
End Sub
MyBase.OnHandleCreated(e)
End Sub
End Class
Class AresioSwitch
Inherits Control
Event ToggledChanged()
Private _toggled As Boolean
Public Property Toggled() As Boolean
Get
Return _toggled
End Get
Set(ByVal value As Boolean)
_toggled = value
Invalidate()
RaiseEvent ToggledChanged()
End Set
End Property
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)
End Sub
Invalidate()
End Sub
'Background
Dim BackLinear As LinearGradientBrush = New
LinearGradientBrush(New Point(0, CInt((Height / 2) - (Track.Height /
2))), New Point(0, CInt((Height / 2) + (Track.Height / 2))),
Color.FromArgb(50, Color.Black), Color.Transparent)
'G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4),
Width - 1, 8, 3))
G.FillPath(BackLinear, Pill(0, CInt(Height / 2 - Track.Height
/ 2), Width - 1, Track.Height - 2, New PillStyle With {.Left =
True, .Right = True}))
G.DrawPath(ToPen(50, Color.Black), Pill(0, CInt(Height / 2 -
Track.Height / 2), Width - 1, Track.Height - 2, New PillStyle With
{.Left = True, .Right = True}))
BackLinear.Dispose()
'Fill
If ToggleLocation > 0 Then
G.FillPath(New LinearGradientBrush(New Point(0,
CInt((Height / 2) - Track.Height / 2)), New Point(1, CInt((Height /
2) + Track.Height / 2)), Color.FromArgb(250, 200, 70),
Color.FromArgb(250, 160, 40)), Pill(1, CInt((Height / 2) -
Track.Height / 2), CInt(Bar.Width * (ToggleLocation / 100)) +
CInt(Track.Width / 2), Track.Height - 3, New PillStyle With {.Left =
True, .Right = True}))
G.DrawPath(ToPen(100, Color.White), Pill(1,
CInt((Height / 2) - Track.Height / 2 + 1), CInt(Bar.Width *
(ToggleLocation / 100)) + CInt(Track.Width / 2), Track.Height - 5,
New PillStyle With {.Left = True, .Right = True}))
End If
If Toggled Then
G.DrawString("ON", New Font("Arial", 6, FontStyle.Bold),
ToBrush(150, Color.Black), New Rectangle(0, -1, Width - Track.Width +
Track.Width / 3, Height), New StringFormat() With {.Alignment =
StringAlignment.Center, .LineAlignment = StringAlignment.Center})
Else
G.DrawString("OFF", New Font("Arial", 6, FontStyle.Bold),
ToBrush(150, Color.Black), New Rectangle(Track.Width - Track.Width /
3, -1, Width - Track.Width + Track.Width / 3, Height), New
StringFormat() With {.Alignment = StringAlignment.Center,
.LineAlignment = StringAlignment.Center})
End If
'Button
G.FillEllipse(Brushes.White, Bar.X + CInt(Bar.Width *
(ToggleLocation / 100)) - CInt(Track.Width / 2), Bar.Y +
CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width,
Track.Height)
G.DrawEllipse(ToPen(50, Color.Black), Bar.X + CInt(Bar.Width
* (ToggleLocation / 100) - CInt(Track.Width / 2)), Bar.Y +
CInt((Bar.Height / 2)) - CInt(Track.Height / 2), Track.Width,
Track.Height)
End Sub
Class AresioTabControl
Inherits TabControl
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)
End Sub
Protected Overrides Sub CreateHandle()
MyBase.CreateHandle()
SizeMode = TabSizeMode.Normal
ItemSize = New Size(77, 31)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim G As Graphics = e.Graphics
Dim ItemBounds As Rectangle
Dim TextBrush As New SolidBrush(Color.Empty)
Dim SOFF As Integer = 0
G.Clear(Color.FromArgb(236, 237, 239))
End If
Next
End If
Next
End Sub
End Class
Class AresioProgressBar
Inherits Control
Invalidate()
End Set
End Property
Invalidate()
End Set
End Property
Event ValueChanged()
Private _value As Integer
Public Property Value() As Integer
Get
Return _value
End Get
Set(ByVal value As Integer)
If value < _minimum Then
_value = _minimum
ElseIf value > _maximum Then
_value = _maximum
Else
_value = value
End If
Invalidate()
RaiseEvent ValueChanged()
End Set
End Property
#End Region
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)
_maximum = 100
_minimum = 0
_value = 0
End Sub
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim G As Graphics = e.Graphics
G.Clear(Parent.FindForm.BackColor)
G.SmoothingMode = SmoothingMode.AntiAlias
'Background
Dim BackLinear As LinearGradientBrush = New
LinearGradientBrush(New Point(0, CInt((Height / 2) - 4)), New
Point(0, CInt((Height / 2) + 4)), Color.FromArgb(50, Color.Black),
Color.Transparent)
G.FillPath(BackLinear, RoundRect(0, CInt((Height / 2) - 4),
Width - 1, 8, 3))
G.DrawPath(ToPen(50, Color.Black), RoundRect(0,
CInt((Height / 2) - 4), Width - 1, 8, 3))
BackLinear.Dispose()
'Fill
If _value > 0 Then
G.FillPath(New LinearGradientBrush(New Point(1,
CInt((Height / 2) - 4)), New Point(1, CInt((Height / 2) + 4)),
Color.FromArgb(250, 200, 70), Color.FromArgb(250, 160, 40)),
RoundRect(1, CInt((Height / 2) - 4), CInt((Width - 2) * (Value /
Maximum)), 8, 3))
G.DrawPath(ToPen(100, Color.White), RoundRect(2,
CInt((Height / 2) - 2), CInt((Width - 4) * (Value / Maximum)), 4, 3))
End If
End Sub
End Class
Class AresioRadioButton
Inherits Control
Event CheckedChanged()
Private _checked As Boolean
Public Property Checked() As Boolean
Get
Return _checked
End Get
Set(ByVal value As Boolean)
_checked = value
Invalidate()
RaiseEvent CheckedChanged()
End Set
End Property
Sub New()
SetStyle(ControlStyles.AllPaintingInWmPaint Or _
ControlStyles.ResizeRedraw Or _
ControlStyles.UserPaint Or _
ControlStyles.DoubleBuffer, True)
End Sub
G.SmoothingMode = SmoothingMode.AntiAlias
If _checked Then
Dim MLG2 As LinearGradientBrush = New
LinearGradientBrush(New Point(Height / 2, 3), New Point(Height / 2,
Height - 6), Color.FromArgb(200, Color.White), Color.FromArgb(10,
Color.White))
G.FillEllipse(MLG2, New Rectangle(3, 3, Height - 7,
Height - 7))
G.DrawEllipse(ToPen(50, Color.Black), New Rectangle(3, 3,
Height - 7, Height - 7))
End If
End Sub