#Region " Option Statements "
Option Strict On
Option Explicit On
Option Infer Off
#End Region
#Region " Imports "
Imports System
Imports System.Diagnostics
Imports System.Linq
Imports System.Windows.Forms
#End Region
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' An extended <see cref="ProgressBar"/>.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Public Class ProgressBarExtended : Inherits ProgressBar
#Region " Events "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Occurs when the progress value changes.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Public Custom Event ValueChanged As EventHandler(Of ValueChangedEventArgs)
<DebuggerNonUserCode>
<DebuggerStepThrough>
AddHandler(ByVal value As EventHandler(Of ValueChangedEventArgs))
MyBase.Events.AddHandler("ValueChangedEvent", value)
End AddHandler
<DebuggerNonUserCode>
<DebuggerStepThrough>
RemoveHandler(ByVal value As EventHandler(Of ValueChangedEventArgs))
MyBase.Events.RemoveHandler("ValueChangedEvent", value)
End RemoveHandler
<DebuggerNonUserCode>
<DebuggerStepThrough>
RaiseEvent(ByVal sender As Object, ByVal e As ValueChangedEventArgs)
Dim handler As EventHandler(Of ValueChangedEventArgs) =
DirectCast(MyBase.Events("ValueChangedEvent"), EventHandler(Of ValueChangedEventArgs))
If (handler IsNot Nothing) Then
handler.Invoke(sender, e)
End If
End RaiseEvent
End Event
#End Region
#Region " Events Data "
#Region " ValueChangedEventArgs "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Contains the event-data of a <see cref="ValueChanged"/> event.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Public Class ValueChangedEventArgs : Inherits EventArgs
#Region " Properties "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Gets the value.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <value>
''' The value.
''' </value>
''' ----------------------------------------------------------------------------------------------------
Public Overridable ReadOnly Property Value() As Integer
<DebuggerStepThrough>
Get
Return Me.valueB
End Get
End Property
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' ( Backing field )
''' The value.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private ReadOnly valueB As Integer
#End Region
#Region " Constructors "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Prevents a default instance of the <see cref="ValueChangedEventArgs"/> class from being created.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<DebuggerNonUserCode>
Private Sub New()
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Initializes a new instance of the <see cref="ValueChangedEventArgs"/> class.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="value">
''' The value.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub New(ByVal value As Integer)
Me.valueB = value
End Sub
#End Region
End Class
#End Region
#End Region
#Region " Event Invocators "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Raises <see cref="ValueChanged"/> event.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="e">
''' The <see cref="ValueChangedEventArgs"/> instance containing the event data.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Protected Overridable Sub OnValueChanged(ByVal e As ValueChangedEventArgs)
RaiseEvent ValueChanged(Me, e)
End Sub
#End Region
#Region " Constructors "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Initializes a new instance of the <see cref="ProgressBarExtended"/> class.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub New()
MyBase.New()
End Sub
#End Region
#Region " Properties "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Gets or sets the current position of the progress bar.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <value>
''' The value.
''' </value>
''' ----------------------------------------------------------------------------------------------------
Public Overridable Shadows Property Value As Integer
<DebuggerStepThrough>
Get
Return MyBase.Value
End Get
<DebuggerStepThrough>
Set(ByVal value As Integer)
Dim oldValue As Integer = MyBase.Value
MyBase.Value = value
If (value <> oldValue) Then
Me.OnValueChanged(New ValueChangedEventArgs(value))
End If
End Set
End Property
#End Region
#Region " Public Methods "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Advances the current position of the progress bar by the specified amount.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="value">
''' The amount by which to increment the progress bar's current position.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Overridable Shadows Sub Increment(ByVal value As Integer)
Dim oldValue As Integer = MyBase.Value
MyBase.Increment(value)
If (oldValue <> MyBase.Maximum) Then
Me.OnValueChanged(New ValueChangedEventArgs(MyBase.Value))
End If
End Sub
#End Region
End Class