Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Imports System.Drawing.Drawing2D
- Imports System.Drawing.Text
- Imports System.ComponentModel
- Module AnimationManager
- Interface IAnimatable
- Property IsAnimating As Boolean
- Sub Animate()
- End Interface
- Private WithEvents animTimer As New Timer
- Private animControls As New List(Of Control)
- Private childControls As New List(Of Control)
- Public Property Interval As Integer
- Get
- Return animTimer.Interval
- End Get
- Set(value As Integer)
- animTimer.Interval = If(value >= 10, value, 10)
- End Set
- End Property
- Sub New()
- Interval = 20
- animTimer.Enabled = True
- End Sub
- Private Sub animTimer_Tick(sender As Object, e As EventArgs) Handles animTimer.Tick
- For Each animCtrl As IAnimatable In animControls
- If animCtrl.IsAnimating Then animCtrl.Animate()
- Next
- End Sub
- Public Sub Add(ByVal animCtrl As Control)
- If TypeOf animCtrl Is IAnimatable AndAlso Not animControls.Contains(animCtrl) Then
- animControls.Add(animCtrl)
- End If
- End Sub
- Public Sub AddAllFromContainer(ByVal container As ContainerControl)
- childControls.Clear()
- For Each animCtrl As Control In GetAllChildren(container)
- Add(animCtrl)
- Next
- End Sub
- Public Sub AddRange(ByVal animCtrls As Control())
- For Each animCtrl As Control In animCtrls
- Add(animCtrl)
- Next
- End Sub
- Public Sub Clear()
- animControls.Clear()
- End Sub
- Public Sub Remove(ByVal animCtrl As Control)
- If animControls.Contains(animCtrl) Then animControls.Remove(animCtrl)
- End Sub
- Public Sub RemoveAllFromContainer(container As ContainerControl)
- childControls.Clear()
- For Each animCtrl As Control In GetAllChildren(container)
- Remove(animCtrl)
- Next
- End Sub
- Public Sub RemoveRange(ByVal animates As IAnimatable())
- For Each animCtrl As Control In animates
- Remove(animCtrl)
- Next
- End Sub
- Private Function GetAllChildren(control As Control) As Control()
- For Each ctrl As Control In control.Controls
- GetAllChildren(ctrl)
- childControls.Add(ctrl)
- Next
- Return childControls.ToArray()
- End Function
- End Module
- Module EndeavourHelper
- Enum MouseState
- None
- Over
- Down
- End Enum
- Public Function AlterColor(originalColor As Color, difference As Integer, Optional keepAlpha As Boolean = True) As Color
- With originalColor
- Dim a, r, g, b As Integer
- a = If(keepAlpha, .A, 255)
- r = SetInteger(.R + difference)
- g = SetInteger(.G + difference)
- b = SetInteger(.B + difference)
- Return Color.FromArgb(a, r, g, b)
- End With
- End Function
- Public Function SetInteger(intendedValue As Integer, Optional minimum As Integer = 0, Optional maximum As Integer = 255) As Integer
- If intendedValue < minimum Then
- Return minimum
- ElseIf intendedValue > maximum Then
- Return maximum
- Else
- Return intendedValue
- End If
- End Function
- Public Function CreateRound(rect As Rectangle, slope As Integer, topLeft As Boolean, topRight As Boolean, bottomRight As Boolean, bottomLeft As Boolean) As GraphicsPath
- Dim gp As New GraphicsPath()
- gp.StartFigure()
- If slope <= 0 Then
- gp.AddRectangle(rect)
- gp.CloseFigure()
- Return gp
- End If
- Dim arcWidth As Integer = slope * 2
- If topLeft Then
- gp.AddArc(New Rectangle(rect.X, rect.Y, arcWidth, arcWidth), -180, 90)
- Else
- gp.AddLine(rect.X, rect.Y, rect.X + 1, rect.Y)
- End If
- If topRight Then
- gp.AddArc(New Rectangle(rect.Width - arcWidth + rect.X, rect.Y, arcWidth, arcWidth), -90, 90)
- Else
- gp.AddLine(rect.X + rect.Width, rect.Y, rect.X + rect.Width, rect.Y + 1)
- End If
- If bottomRight Then
- gp.AddArc(New Rectangle(rect.Width - arcWidth + rect.X, rect.Height - arcWidth + rect.Y, arcWidth, arcWidth), 0, 90)
- Else
- gp.AddLine(rect.X + rect.Width, rect.Y + rect.Height, rect.X + rect.Width - 1, rect.Y + rect.Height)
- End If
- If bottomLeft Then
- gp.AddArc(New Rectangle(rect.X, rect.Height - arcWidth + rect.Y, arcWidth, arcWidth), 90, 90)
- Else
- gp.AddLine(rect.X, rect.Y + rect.Height, rect.X, rect.Y + rect.Height - 1)
- End If
- gp.CloseFigure()
- Return gp
- End Function
- Public Function CreateRound(rect As Rectangle, slope As Integer) As GraphicsPath
- Return CreateRound(rect, slope, True, True, True, True)
- End Function
- Class RelationalColorSwitcher
- Private _currentColor As Color
- Private _transitions As Integer
- Private _transitionsLapsed As Integer
- Private currentValues(3) As Double
- Private increments(3) As Double
- Public Property OriginalColor As Color
- Public Property NewColor As Color
- Public ReadOnly Property CurrentColor As Color
- Get
- Return _currentColor
- End Get
- End Property
- Public ReadOnly Property Transitions As Integer
- Get
- Return _transitions
- End Get
- End Property
- Public ReadOnly Property TransitionsLapsed As Integer
- Get
- Return _transitionsLapsed
- End Get
- End Property
- Sub New(originalColor As Color, newColor As Color, Optional transitions As Integer = 10)
- Me.OriginalColor = originalColor
- Me.NewColor = newColor
- _transitions = transitions
- _transitionsLapsed = 0
- currentValues = GetValues(originalColor)
- GetIncrements(GetValues(originalColor), GetValues(newColor))
- End Sub
- Public Sub Transition()
- For i As Integer = 0 To 3
- currentValues(i) += increments(i)
- Next
- _currentColor = Color.FromArgb(
- SetInteger(CInt(currentValues(0))), _
- SetInteger(CInt(currentValues(1))), _
- SetInteger(CInt(currentValues(2))), _
- SetInteger(CInt(currentValues(3))))
- _transitionsLapsed += 1
- End Sub
- Private Sub GetIncrements(originalValues As Double(), newValues As Double())
- For i As Integer = 0 To 3
- increments(i) = (newValues(i) - originalValues(i)) / _transitions
- Next
- End Sub
- Private Function GetValues(color As Color) As Double()
- Return New Double() {CDbl(color.A), CDbl(color.R), CDbl(color.G), CDbl(color.B)}
- End Function
- End Class
- End Module
- MustInherit Class EndeavourControl
- Inherits Control
- Private _borderRectangle As Rectangle
- Protected g As Graphics
- Public Shadows Property BackColor As Color
- Get
- Return Color.Transparent
- End Get
- Set(value As Color)
- If Not value = Color.Transparent Then
- Throw New Exception("BackColor must be transparent.")
- End If
- End Set
- End Property
- Protected ReadOnly Property BorderRectangle As Rectangle
- Get
- Return _borderRectangle
- End Get
- End Property
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or _
- ControlStyles.UserPaint, True)
- BackColor = Color.Transparent
- End Sub
- Protected MustOverride Overrides Sub OnPaint(e As PaintEventArgs)
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- _borderRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- Invalidate()
- End Sub
- End Class
- MustInherit Class EndeavourContainer
- Inherits ContainerControl
- Private _borderRectangle As Rectangle
- Protected g As Graphics
- Public Shadows Property BackColor As Color
- Get
- Return Color.Transparent
- End Get
- Set(value As Color)
- If Not value = Color.Transparent Then
- Throw New Exception("BackColor must be transparent.")
- End If
- End Set
- End Property
- Protected ReadOnly Property BorderRectangle As Rectangle
- Get
- Return _borderRectangle
- End Get
- End Property
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor Or _
- ControlStyles.UserPaint, True)
- BackColor = Color.Transparent
- End Sub
- Protected MustOverride Overrides Sub OnPaint(e As PaintEventArgs)
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- _borderRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- Invalidate()
- End Sub
- End Class
- Class eFormSkin
- Inherits ContainerControl
- Private Const HEADER_HEIGHT As Integer = 40
- Private Const FOOTER_HEIGHT As Integer = 26
- Protected g As Graphics
- Private _headerFont As Font
- Public Property HeaderFont As Font
- Get
- Return _headerFont
- End Get
- Set(value As Font)
- _headerFont = value
- Invalidate()
- End Set
- End Property
- Public Overrides Property BackColor As Color
- Get
- Return MyBase.BackColor
- End Get
- Set(value As Color)
- If value <> Color.FromArgb(220, 220, 220) Then
- Throw New Exception("The BackColor of this control may not be changed.")
- End If
- MyBase.BackColor = Color.FromArgb(220, 220, 220)
- End Set
- End Property
- Private formCanMove As Boolean
- Private mouseX, mouseY As Integer
- Private borderRectangle As Rectangle
- Private borderPath As GraphicsPath
- Private backBrush As SolidBrush
- Private headerRectangle As Rectangle
- Private headerPath As GraphicsPath
- Private headerGradientBrush As LinearGradientBrush
- Private footerRectangle As Rectangle
- Private footerPath As GraphicsPath
- Private footerGradientBrush As LinearGradientBrush
- Private borderPen As Pen
- Private borderHighlightPen As Pen
- Private textSize As Size
- Private textX, textY As Integer
- Sub New()
- SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.OptimizedDoubleBuffer Or _
- ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
- BackColor = Color.FromArgb(220, 220, 220)
- Padding = New Padding(6, 46, 6, 32)
- HeaderFont = New Font("Segoe UI", 11)
- backBrush = New SolidBrush(Color.FromArgb(220, 220, 220))
- borderPen = New Pen(Color.FromArgb(45, 45, 45))
- borderHighlightPen = New Pen(Color.FromArgb(80, Color.White), 2)
- End Sub
- Protected Overrides Sub CreateHandle()
- MyBase.CreateHandle()
- FindForm().BackColor = Color.Fuchsia
- FindForm().TransparencyKey = Color.Fuchsia
- FindForm().FormBorderStyle = FormBorderStyle.None
- Dock = DockStyle.Fill
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.Clear(Color.Fuchsia)
- g.SmoothingMode = SmoothingMode.HighQuality
- g.FillPath(backBrush, borderPath)
- g.FillPath(headerGradientBrush, headerPath)
- g.DrawArc(borderHighlightPen, 0, 1, 12, 12, -180, 90)
- g.DrawLine(borderHighlightPen, 6, 1, Width - 7, 1)
- g.DrawArc(borderHighlightPen, Width - 1 - 12, 1, 12, 12, -90, 90)
- g.FillPath(footerGradientBrush, footerPath)
- g.DrawLine(borderHighlightPen, 0, footerRectangle.Y + 1, Width - 1, footerRectangle.Y)
- g.DrawLine(borderPen, 0, HEADER_HEIGHT, Width - 1, HEADER_HEIGHT)
- g.DrawLine(borderPen, 0, Height - 1 - FOOTER_HEIGHT, Width - 1, Height - 1 - FOOTER_HEIGHT)
- g.SmoothingMode = SmoothingMode.None
- For i As Integer = 10 To 12
- g.DrawArc(Pens.Fuchsia, 0, 0, i, i, -180, 90)
- g.DrawArc(Pens.Fuchsia, Width - 1 - i, 0, i, i, -90, 90)
- g.DrawArc(Pens.Fuchsia, Width - 1 - i, Height - 1 - i, i, i, 0, 90)
- g.DrawArc(Pens.Fuchsia, 0, Height - 1 - i, i, i, 90, 90)
- Next
- g.DrawPath(borderPen, borderPath)
- textSize = g.MeasureString(Text, HeaderFont).ToSize()
- textX = CInt((Width / 2) - (textSize.Width / 2) + 1)
- textY = CInt((headerRectangle.Height / 2) - (textSize.Height / 2))
- g.DrawString(Text, HeaderFont, Brushes.White, textX, textY)
- End Sub
- Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
- mouseX = e.X
- mouseY = e.Y
- formCanMove = e.Y <= HEADER_HEIGHT
- End Sub
- Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
- If e.Y <= HEADER_HEIGHT Then
- If formCanMove = True Then
- FindForm().Location = New Point(MousePosition.X - mouseX, MousePosition.Y - mouseY)
- End If
- End If
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- formCanMove = False
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- borderRectangle = New Rectangle(0, 0, Width - 1, Height - 1)
- borderPath = CreateRound(borderRectangle, 8)
- headerRectangle = New Rectangle(0, 0, Width - 1, HEADER_HEIGHT)
- headerPath = CreateRound(headerRectangle, 8, True, True, False, False)
- headerGradientBrush = New LinearGradientBrush(headerRectangle, Color.FromArgb(65, 65, 65), Color.FromArgb(30, 30, 30), 90.0F)
- footerRectangle = New Rectangle(0, Height - 1 - FOOTER_HEIGHT, Width - 1, FOOTER_HEIGHT)
- footerPath = CreateRound(footerRectangle, 8, False, False, True, True)
- footerGradientBrush = New LinearGradientBrush(footerRectangle, Color.FromArgb(65, 65, 65), Color.FromArgb(30, 30, 30), 90.0F)
- End Sub
- Protected Overrides Sub OnTextChanged(e As EventArgs)
- Invalidate()
- End Sub
- End Class
- Class eControlButton
- Inherits EndeavourControl
- Implements IAnimatable
- Public Enum ControlAction
- Minimize
- None
- Close
- End Enum
- Private _mouseState As MouseState
- Public Property Action As ControlAction
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Protected Property MouseState As MouseState
- Private Set(value As MouseState)
- If _mouseState <> value Then
- _mouseState = value
- SetSwitchers()
- IsAnimating = True
- End If
- End Set
- Get
- Return _mouseState
- End Get
- End Property
- Private borderPath As GraphicsPath
- Private defaultColors(1), overColors(1) As Color
- Private topSwitcher, bottomSwitcher As RelationalColorSwitcher
- Private topColor, bottomColor As Color
- Private backGradientBrush As LinearGradientBrush
- Private borderPen As Pen
- Sub New()
- Size = New Size(10, 10)
- Action = ControlAction.None
- defaultColors = New Color() {Color.FromArgb(240, 235, 230), Color.FromArgb(185, 180, 170)}
- overColors = New Color() {Color.FromArgb(125, 200, 230), Color.FromArgb(45, 130, 195)}
- topColor = defaultColors(0)
- bottomColor = defaultColors(1)
- borderPen = New Pen(Color.FromArgb(25, 25, 25))
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.Clear(Color.FromArgb(46, 46, 46))
- g.SmoothingMode = SmoothingMode.HighQuality
- backGradientBrush = New LinearGradientBrush(BorderRectangle, topColor, bottomColor, 90.0F)
- g.FillPath(backGradientBrush, borderPath)
- g.DrawPath(borderPen, borderPath)
- End Sub
- Public Sub Animate() Implements IAnimatable.Animate
- topSwitcher.Transition()
- topColor = topSwitcher.CurrentColor
- bottomSwitcher.Transition()
- bottomColor = bottomSwitcher.CurrentColor
- If topSwitcher.TransitionsLapsed = topSwitcher.Transitions Then IsAnimating = False
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- With FindForm()
- Select Case Action
- Case ControlAction.Close
- .Close()
- Case ControlAction.Minimize
- .WindowState = FormWindowState.Minimized
- topColor = defaultColors(0)
- bottomColor = defaultColors(1)
- Invalidate()
- End Select
- End With
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MouseState = EndeavourHelper.MouseState.Over
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MouseState = EndeavourHelper.MouseState.None
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- borderPath = CreateRound(BorderRectangle, 2)
- End Sub
- Private Sub SetSwitchers()
- Dim newColors() As Color = GetNewColors()
- Dim newTopColor, newBottomColor As Color
- newTopColor = newColors(0)
- newBottomColor = newColors(1)
- topSwitcher = New RelationalColorSwitcher(topColor, newTopColor)
- bottomSwitcher = New RelationalColorSwitcher(bottomColor, newBottomColor)
- End Sub
- Private Function GetNewColors() As Color()
- Select Case MouseState
- Case EndeavourHelper.MouseState.Over
- Return New Color() {overColors(0), overColors(1)}
- Case Else
- Return New Color() {defaultColors(0), defaultColors(1)}
- End Select
- End Function
- End Class
- Class eButton
- Inherits EndeavourControl
- Implements IAnimatable
- Private topSwitcher, bottomSwitcher As RelationalColorSwitcher
- Private borderSwitcher As RelationalColorSwitcher
- Private _mouseState As MouseState
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Protected Property MouseState As MouseState
- Private Set(value As MouseState)
- If _mouseState <> value Then
- _mouseState = value
- SetSwitchers()
- IsAnimating = True
- End If
- End Set
- Get
- Return _mouseState
- End Get
- End Property
- Private topColor, bottomColor As Color
- Private borderColor As Color
- Private defaultColors(2), overColors(2), downColors(2) As Color
- Private borderPath As GraphicsPath
- Private borderPen As Pen
- Private borderHighlightPen As Pen
- Private backGradientBrush As LinearGradientBrush
- Private textSize As Size
- Private textX, textY As Integer
- Sub New()
- Cursor = Cursors.Hand
- Font = New Font("Segoe UI", 10)
- Size = New Size(86, 36)
- _mouseState = EndeavourHelper.MouseState.None
- defaultColors = New Color() {Color.FromArgb(75, 75, 75), Color.FromArgb(45, 45, 45), Color.FromArgb(25, 25, 25)}
- overColors = New Color() {Color.FromArgb(85, 165, 215), Color.FromArgb(45, 125, 185), Color.FromArgb(80, 80, 80)}
- downColors = New Color() {Color.FromArgb(40, 105, 160), Color.FromArgb(75, 150, 195), Color.FromArgb(80, 80, 80)}
- borderPath = CreateRound(New Rectangle(0, 0, Width - 1, Height - 1), 6)
- borderHighlightPen = New Pen(Color.FromArgb(80, Color.White), 2)
- topColor = defaultColors(0)
- bottomColor = defaultColors(1)
- borderColor = defaultColors(2)
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- backGradientBrush = New LinearGradientBrush(BorderRectangle, topColor, bottomColor, 90.0F)
- g.FillPath(backGradientBrush, borderPath)
- g.DrawArc(borderHighlightPen, 0, 1, 12, 12, -180, 90)
- g.DrawLine(borderHighlightPen, 6, 1, Width - 7, 1)
- g.DrawArc(borderHighlightPen, Width - 1 - 12, 1, 12, 12, -90, 90)
- borderPen = New Pen(borderColor)
- g.DrawPath(borderPen, borderPath)
- textSize = g.MeasureString(Text, Font).ToSize
- textX = CInt((Width / 2) - (textSize.Width / 2) + 1)
- textY = CInt((Height / 2) - (textSize.Height / 2))
- g.DrawString(Text, Font, Brushes.White, textX, textY)
- End Sub
- Protected Sub Animate() Implements IAnimatable.Animate
- topSwitcher.Transition()
- topColor = topSwitcher.CurrentColor
- bottomSwitcher.Transition()
- bottomColor = bottomSwitcher.CurrentColor
- borderSwitcher.Transition()
- borderColor = borderSwitcher.CurrentColor
- If topSwitcher.TransitionsLapsed = topSwitcher.Transitions Then IsAnimating = False
- Invalidate()
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- MouseState = EndeavourHelper.MouseState.Down
- End Sub
- Protected Overrides Sub OnMouseEnter(e As EventArgs)
- MouseState = EndeavourHelper.MouseState.Over
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- MouseState = EndeavourHelper.MouseState.None
- End Sub
- Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
- MouseState = EndeavourHelper.MouseState.Over
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- borderPath = CreateRound(BorderRectangle, 6)
- End Sub
- Private Sub SetSwitchers()
- Dim newColors() As Color = GetNewColors()
- Dim newTopColor, newBottomColor As Color
- Dim newBorderColor As Color
- Dim transitions As Integer
- newTopColor = newColors(0)
- newBottomColor = newColors(1)
- newBorderColor = newColors(2)
- transitions = If(MouseState <> EndeavourHelper.MouseState.Down, 10, 2)
- topSwitcher = New RelationalColorSwitcher(topColor, newTopColor, transitions)
- bottomSwitcher = New RelationalColorSwitcher(bottomColor, newBottomColor, transitions)
- borderSwitcher = New RelationalColorSwitcher(borderColor, newBorderColor, transitions)
- End Sub
- Private Function GetNewColors() As Color()
- Select Case MouseState
- Case EndeavourHelper.MouseState.Over
- Return overColors
- Case EndeavourHelper.MouseState.Down
- Return downColors
- Case Else
- Return defaultColors
- End Select
- End Function
- End Class
- <DefaultEvent("ValueChanged")> Class eProgressBar
- Inherits EndeavourControl
- Event ValueChanged(sender As Object)
- Private _maximum As Integer
- Private _value As Integer
- Public Property Maximum As Integer
- Get
- Return _maximum
- End Get
- Set(value As Integer)
- If value > 0 Then
- _maximum = value
- If _value > _maximum Then _value = _maximum
- Invalidate()
- Else
- Throw New Exception("Maximum must be great than 0.")
- End If
- End Set
- End Property
- Public Property Value As Integer
- Get
- Return _value
- End Get
- Set(value As Integer)
- If value <> _value Then
- If value >= 0 Then
- _value = value
- If _value > _maximum Then _value = _maximum
- Invalidate()
- Else
- Throw New Exception("Value must be greater than or equal to 0.")
- End If
- RaiseEvent ValueChanged(Me)
- End If
- End Set
- End Property
- Private borderPath As GraphicsPath
- Private backGradientBrush As LinearGradientBrush
- Private borderPen As Pen
- Private barWidth As Integer
- Private barPath, innerBarPath As GraphicsPath
- Private barGradientBrush As LinearGradientBrush
- Private barBorderPen As Pen
- Sub New()
- MyBase.New()
- Size = New Size(300, 14)
- _maximum = 100
- backGradientBrush = New LinearGradientBrush(BorderRectangle, Color.FromArgb(220, 225, 240), Color.FromArgb(160, 165, 175), 90.0F)
- borderPen = New Pen(Color.FromArgb(115, 115, 115))
- barGradientBrush = New LinearGradientBrush(BorderRectangle, Color.FromArgb(85, 165, 215), Color.FromArgb(35, 100, 150), 90.0F)
- barBorderPen = New Pen(Color.FromArgb(50, Color.White))
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- g.FillPath(backGradientBrush, borderPath)
- If _value > 0 Then
- barWidth = CInt((Width / _maximum) * _value)
- If barWidth <= 12 Then
- barPath = CreateRound(New Rectangle(0, 0, 10, Height - 1), 6)
- innerBarPath = CreateRound(New Rectangle(1, 1, 8, Height - 3), 6)
- Else
- barPath = CreateRound(New Rectangle(0, 0, barWidth - 1, Height - 1), 6)
- innerBarPath = CreateRound(New Rectangle(1, 1, barWidth - 3, Height - 3), 6)
- End If
- g.FillPath(barGradientBrush, barPath)
- g.DrawPath(barBorderPen, innerBarPath)
- g.DrawPath(borderPen, barPath)
- End If
- g.DrawPath(borderPen, borderPath)
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- borderPath = CreateRound(BorderRectangle, 6)
- End Sub
- End Class
- Class eSpinner
- Inherits EndeavourControl
- Implements IAnimatable
- Class Spinner
- Public Property Rectangle As Rectangle
- Public Property Angle As Integer
- Sub New()
- Angle = 180
- End Sub
- End Class
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Private spinners(3) As Spinner
- Private spinnerPen As Pen
- Sub New()
- For i As Integer = 0 To spinners.Count - 1
- spinners(i) = New Spinner
- Dim m As Integer = i Mod 4
- With spinners(i)
- Select Case m
- Case 0
- .Angle = 0
- Case 1
- .Angle = 90
- Case 2
- .Angle = 180
- Case 3
- .Angle = 270
- End Select
- End With
- spinners(i).Angle = If(i Mod 2 = 0, 90, 270)
- Next
- PlaceSpinners()
- Size = New Size(40, 40)
- spinnerPen = New Pen(Color.FromArgb(65, 145, 200), 2)
- IsAnimating = False
- End Sub
- Public Sub Animate() Implements IAnimatable.Animate
- For i As Integer = 0 To spinners.Count - 1
- Dim m As Integer = i Mod 4
- With spinners(i)
- Select Case m
- Case 0
- .Angle = If(.Angle <> 360, .Angle + 4, 4)
- Case 1
- .Angle = If(.Angle <> 360, .Angle - 5, 5)
- Case 2
- .Angle = If(.Angle <> 0, .Angle + 6, 354)
- Case 3
- .Angle = If(.Angle <> 0, .Angle - 8, 352)
- End Select
- End With
- Next
- Invalidate()
- End Sub
- Protected Overrides Sub OnCreateControl()
- IsAnimating = True
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- e.Graphics.Clear(Parent.BackColor)
- e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
- For Each s As Spinner In spinners
- e.Graphics.DrawArc(spinnerPen, s.Rectangle, s.Angle, 180)
- Next
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- PlaceSpinners()
- End Sub
- Private Sub PlaceSpinners()
- Dim padding As Integer = 3
- For Each s As Spinner In spinners
- s.Rectangle = New Rectangle(padding, padding, Width - (padding * 2) - 1, Height - (padding * 2) - 1)
- padding += 4
- Next
- End Sub
- End Class
- <DefaultEvent("CheckedChanged")> Class eCheckBox
- Inherits EndeavourControl
- Implements IAnimatable
- Event CheckedChanged(sender As Object)
- Private _checked As Boolean
- Private _overBox As Boolean
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Public Property Checked As Boolean
- Get
- Return _checked
- End Get
- Set(value As Boolean)
- If _checked <> value Then
- _checked = value
- SetSwitchers()
- IsAnimating = True
- RaiseEvent CheckedChanged(Me)
- End If
- End Set
- End Property
- Private Property OverBox As Boolean
- Get
- Return _overBox
- End Get
- Set(value As Boolean)
- If _overBox <> value Then
- _overBox = value
- SetSwitchers()
- IsAnimating = True
- Cursor = If(_overBox, Cursors.Hand, Cursors.Default)
- End If
- End Set
- End Property
- Private boxBorderRect As Rectangle
- Private checkBorderRect As Rectangle
- Private boxBorderPath As GraphicsPath
- Private checkBorderPath As GraphicsPath
- Private boxBorderPen As Pen
- Private checkBorderPen As Pen
- Private boxDefaultColors(1), boxOverColors(1) As Color
- Private uncheckedColors(2), checkedColors(2) As Color
- Private boxTopSwitcher, boxBottomSwitcher As RelationalColorSwitcher
- Private checkTopSwitcher, checkBottomSwitcher As RelationalColorSwitcher
- Private checkBorderSwitcher As RelationalColorSwitcher
- Private boxTopColor, boxBottomColor As Color
- Private checkTopColor, checkBottomColor As Color
- Private checkBorderColor As Color
- Private boxGradientBrush As LinearGradientBrush
- Private checkGradientBrush As LinearGradientBrush
- Private textY As Integer
- Private textBrush As SolidBrush
- Sub New()
- Font = New Font("Segoe UI", 10)
- Size = New Size(120, 24)
- boxDefaultColors = New Color() {Color.FromArgb(235, 230, 220), Color.FromArgb(185, 180, 170)}
- boxOverColors = New Color() {Color.FromArgb(125, 200, 235), Color.FromArgb(50, 130, 195)}
- uncheckedColors = New Color() {Color.Transparent, Color.Transparent, Color.Transparent}
- checkedColors = New Color() {Color.FromArgb(180, Color.White), Color.FromArgb(150, Color.White), Color.FromArgb(80, Color.Black)}
- boxTopColor = boxDefaultColors(0)
- boxBottomColor = boxDefaultColors(1)
- checkTopColor = uncheckedColors(0)
- checkBottomColor = uncheckedColors(1)
- checkBorderColor = uncheckedColors(2)
- boxBorderPen = New Pen(Color.FromArgb(120, 120, 120))
- textBrush = New SolidBrush(Color.FromArgb(25, 25, 25))
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- boxGradientBrush = New LinearGradientBrush(boxBorderRect, boxTopColor, boxBottomColor, 90.0F)
- g.FillPath(boxGradientBrush, boxBorderPath)
- checkGradientBrush = New LinearGradientBrush(checkBorderRect, checkTopColor, checkBottomColor, 90.0F)
- g.FillPath(checkGradientBrush, checkBorderPath)
- checkBorderPen = New Pen(checkBorderColor)
- g.DrawPath(checkBorderPen, checkBorderPath)
- g.DrawPath(boxBorderPen, boxBorderPath)
- textY = CInt((Height / 2) - (g.MeasureString(Text, Font).Height / 2))
- g.DrawString(Text, Font, textBrush, 23, textY)
- End Sub
- Public Sub Animate() Implements IAnimatable.Animate
- Dim boxAnimating, checkAnimating As Boolean
- If boxTopSwitcher.TransitionsLapsed <> boxTopSwitcher.Transitions Then
- boxAnimating = True
- boxTopSwitcher.Transition()
- boxTopColor = boxTopSwitcher.CurrentColor
- boxBottomSwitcher.Transition()
- boxBottomColor = boxBottomSwitcher.CurrentColor
- Else
- boxAnimating = False
- End If
- If checkTopSwitcher.TransitionsLapsed <> checkTopSwitcher.Transitions Then
- checkAnimating = True
- checkTopSwitcher.Transition()
- checkTopColor = checkTopSwitcher.CurrentColor
- checkBottomSwitcher.Transition()
- checkBottomColor = checkBottomSwitcher.CurrentColor
- checkBorderSwitcher.Transition()
- checkBorderColor = checkBorderSwitcher.CurrentColor
- Else
- checkAnimating = False
- End If
- If Not boxAnimating AndAlso Not checkAnimating Then
- IsAnimating = False
- Else
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- If OverBox Then Checked = Not Checked
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- OverBox = boxBorderRect.Contains(e.Location)
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- OverBox = False
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- boxBorderRect = New Rectangle(0, CInt((Height / 2) - 9), 20, 20)
- boxBorderPath = CreateRound(boxBorderRect, 6)
- checkBorderRect = New Rectangle(boxBorderRect.X + 5, boxBorderRect.Y + 5, 10, 10)
- checkBorderPath = CreateRound(checkBorderRect, 4)
- End Sub
- Private Sub SetSwitchers()
- Dim newBackColors() As Color = GetNewBackColors()
- Dim backTransitions As Integer = If(boxTopColor <> newBackColors(0), 10, 0)
- boxTopSwitcher = New RelationalColorSwitcher(boxTopColor, newBackColors(0), backTransitions)
- boxBottomSwitcher = New RelationalColorSwitcher(boxBottomColor, newBackColors(1), backTransitions)
- Dim newCheckColors() As Color = GetNewCheckColors()
- Dim checkTransitions As Integer = If(checkTopColor <> newCheckColors(0), 6, 0)
- checkTopSwitcher = New RelationalColorSwitcher(checkTopColor, newCheckColors(0), checkTransitions)
- checkBottomSwitcher = New RelationalColorSwitcher(checkBottomColor, newCheckColors(1), checkTransitions)
- checkBorderSwitcher = New RelationalColorSwitcher(checkBorderColor, newCheckColors(2), checkTransitions)
- End Sub
- Private Function GetNewBackColors() As Color()
- Return If(OverBox OrElse Checked, boxOverColors, boxDefaultColors)
- End Function
- Private Function GetNewCheckColors() As Color()
- Return If(Checked, checkedColors, uncheckedColors)
- End Function
- End Class
- <DefaultEvent("CheckedChanged")> Class eRadioButton
- Inherits EndeavourControl
- Implements IAnimatable
- Event CheckedChanged(sender As Object)
- Private _checked As Boolean
- Private _overBox As Boolean
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Public Property Checked As Boolean
- Get
- Return _checked
- End Get
- Set(value As Boolean)
- If _checked <> value Then
- _checked = value
- SetSwitchers()
- IsAnimating = True
- RaiseEvent CheckedChanged(Me)
- End If
- End Set
- End Property
- Private Property OverBox As Boolean
- Get
- Return _overBox
- End Get
- Set(value As Boolean)
- If _overBox <> value Then
- _overBox = value
- SetSwitchers()
- IsAnimating = True
- Cursor = If(_overBox, Cursors.Hand, Cursors.Default)
- End If
- End Set
- End Property
- Private boxBorderRect As Rectangle
- Private checkBorderRect As Rectangle
- Private boxBorderPen As Pen
- Private checkBorderPen As Pen
- Private boxDefaultColors(1), boxOverColors(1) As Color
- Private uncheckedColors(2), checkedColors(2) As Color
- Private boxTopSwitcher, boxBottomSwitcher As RelationalColorSwitcher
- Private checkTopSwitcher, checkBottomSwitcher As RelationalColorSwitcher
- Private checkBorderSwitcher As RelationalColorSwitcher
- Private boxTopColor, boxBottomColor As Color
- Private checkTopColor, checkBottomColor As Color
- Private checkBorderColor As Color
- Private boxGradientBrush As LinearGradientBrush
- Private checkGradientBrush As LinearGradientBrush
- Private textY As Integer
- Private textBrush As SolidBrush
- Sub New()
- Font = New Font("Segoe UI", 10)
- Size = New Size(120, 24)
- boxDefaultColors = New Color() {Color.FromArgb(235, 230, 220), Color.FromArgb(185, 180, 170)}
- boxOverColors = New Color() {Color.FromArgb(125, 200, 235), Color.FromArgb(50, 130, 195)}
- uncheckedColors = New Color() {Color.Transparent, Color.Transparent, Color.Transparent}
- checkedColors = New Color() {Color.FromArgb(180, Color.White), Color.FromArgb(150, Color.White), Color.FromArgb(80, Color.Black)}
- boxTopColor = boxDefaultColors(0)
- boxBottomColor = boxDefaultColors(1)
- checkTopColor = uncheckedColors(0)
- checkBottomColor = uncheckedColors(1)
- checkBorderColor = uncheckedColors(2)
- boxBorderPen = New Pen(Color.FromArgb(120, 120, 120))
- textBrush = New SolidBrush(Color.FromArgb(25, 25, 25))
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit
- boxGradientBrush = New LinearGradientBrush(boxBorderRect, boxTopColor, boxBottomColor, 90.0F)
- g.FillEllipse(boxGradientBrush, boxBorderRect)
- checkGradientBrush = New LinearGradientBrush(checkBorderRect, checkTopColor, checkBottomColor, 90.0F)
- g.FillEllipse(checkGradientBrush, checkBorderRect)
- checkBorderPen = New Pen(checkBorderColor)
- g.DrawEllipse(checkBorderPen, checkBorderRect)
- g.DrawEllipse(boxBorderPen, boxBorderRect)
- textY = CInt((Height / 2) - (g.MeasureString(Text, Font).Height / 2) + 2)
- g.DrawString(Text, Font, textBrush, 23, textY)
- End Sub
- Public Sub Animate() Implements IAnimatable.Animate
- Dim boxAnimating, checkAnimating As Boolean
- If boxTopSwitcher.TransitionsLapsed <> boxTopSwitcher.Transitions Then
- boxAnimating = True
- boxTopSwitcher.Transition()
- boxTopColor = boxTopSwitcher.CurrentColor
- boxBottomSwitcher.Transition()
- boxBottomColor = boxBottomSwitcher.CurrentColor
- Else
- boxAnimating = False
- End If
- If checkTopSwitcher.TransitionsLapsed <> checkTopSwitcher.Transitions Then
- checkAnimating = True
- checkTopSwitcher.Transition()
- checkTopColor = checkTopSwitcher.CurrentColor
- checkBottomSwitcher.Transition()
- checkBottomColor = checkBottomSwitcher.CurrentColor
- checkBorderSwitcher.Transition()
- checkBorderColor = checkBorderSwitcher.CurrentColor
- Else
- checkAnimating = False
- End If
- If Not boxAnimating AndAlso Not checkAnimating Then
- IsAnimating = False
- Else
- Invalidate()
- End If
- End Sub
- Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
- If OverBox And Not Checked Then
- For Each c As Control In Parent.Controls
- If TypeOf c Is eRadioButton Then DirectCast(c, eRadioButton).Checked = False
- Next
- Checked = True
- End If
- End Sub
- Protected Overrides Sub OnMouseMove(e As MouseEventArgs)
- OverBox = boxBorderRect.Contains(e.Location)
- End Sub
- Protected Overrides Sub OnMouseLeave(e As EventArgs)
- OverBox = False
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- boxBorderRect = New Rectangle(0, CInt((Height / 2) - 9), 20, 20)
- checkBorderRect = New Rectangle(boxBorderRect.X + 6, boxBorderRect.Y + 6, 8, 8)
- End Sub
- Private Sub SetSwitchers()
- Dim newBackColors() As Color = GetNewBackColors()
- Dim backTransitions As Integer = If(boxTopColor <> newBackColors(0), 10, 0)
- boxTopSwitcher = New RelationalColorSwitcher(boxTopColor, newBackColors(0), backTransitions)
- boxBottomSwitcher = New RelationalColorSwitcher(boxBottomColor, newBackColors(1), backTransitions)
- Dim newCheckColors() As Color = GetNewCheckColors()
- Dim checkTransitions As Integer = If(checkTopColor <> newCheckColors(0), 6, 0)
- checkTopSwitcher = New RelationalColorSwitcher(checkTopColor, newCheckColors(0), checkTransitions)
- checkBottomSwitcher = New RelationalColorSwitcher(checkBottomColor, newCheckColors(1), checkTransitions)
- checkBorderSwitcher = New RelationalColorSwitcher(checkBorderColor, newCheckColors(2), checkTransitions)
- End Sub
- Private Function GetNewBackColors() As Color()
- Return If(OverBox OrElse Checked, boxOverColors, boxDefaultColors)
- End Function
- Private Function GetNewCheckColors() As Color()
- Return If(Checked, checkedColors, uncheckedColors)
- End Function
- End Class
- Class eSplitter
- Inherits EndeavourControl
- Implements IAnimatable
- Private animX As Integer
- Private animWidth As Integer
- Public Property IsAnimating As Boolean Implements IAnimatable.IsAnimating
- Private baseLineColors(2), animLineColors(4) As Color
- Private baseLineGradientBrush As LinearGradientBrush
- Private baseLineBlend As ColorBlend
- Private baseLinePen As Pen
- Private animLineGradientBrush As LinearGradientBrush
- Private animLineBlend As ColorBlend
- Private animLinePen As Pen
- Sub New()
- baseLineColors = New Color() {Color.FromArgb(45, 45, 45), Color.FromArgb(75, 75, 75), Color.FromArgb(45, 45, 45)}
- animLineColors = New Color() {Color.Transparent, Color.FromArgb(45, 125, 185), Color.FromArgb(85, 165, 215), _
- Color.FromArgb(45, 125, 185), Color.Transparent}
- baseLineBlend = New ColorBlend(3)
- baseLineBlend.Colors = baseLineColors
- baseLineBlend.Positions = New Single() {0.0F, 0.5F, 1.0F}
- animLineBlend = New ColorBlend(5)
- animLineBlend.Colors = animLineColors
- animLineBlend.Positions = New Single() {0.0F, 0.2F, 0.5F, 0.8F, 1.0F}
- Size = New Size(300, 14)
- IsAnimating = True
- End Sub
- Protected Overrides Sub OnPaint(e As PaintEventArgs)
- g = e.Graphics
- g.SmoothingMode = SmoothingMode.HighQuality
- Dim halfHeight As Integer = CInt(Height / 2)
- g.DrawLine(baseLinePen, 0, halfHeight, Width, halfHeight)
- g.DrawLine(animLinePen, animX, halfHeight, animX + animWidth, halfHeight)
- End Sub
- Public Sub Animate() Implements IAnimatable.Animate
- animX = If(animX < Width + animWidth, animX + 2, animWidth * -1)
- animLineGradientBrush = New LinearGradientBrush(New Rectangle(animX, Height, animWidth, Height), Color.Transparent, Color.Transparent, 0.0F)
- animLineGradientBrush.InterpolationColors = animLineBlend
- animLinePen = New Pen(animLineGradientBrush)
- Invalidate()
- End Sub
- Protected Overrides Sub OnSizeChanged(e As EventArgs)
- MyBase.OnSizeChanged(e)
- baseLineGradientBrush = New LinearGradientBrush(BorderRectangle, Color.Transparent, Color.Transparent, 0.0F)
- baseLineGradientBrush.InterpolationColors = baseLineBlend
- baseLinePen = New Pen(baseLineGradientBrush)
- animX = animWidth * -1
- animWidth = CInt(Width / 3)
- animLineGradientBrush = New LinearGradientBrush(New Rectangle(animX, Height, animWidth, Height), Color.Transparent, Color.Transparent, 0.0F)
- animLineGradientBrush.InterpolationColors = animLineBlend
- animLinePen = New Pen(animLineGradientBrush)
- End Sub
- End Class
- Class eLabel
- Inherits Label
- Sub New()
- ForeColor = Color.FromArgb(25, 25, 25)
- Font = New Font("Segoe UI", 9)
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment