''' <summary>
''' A check box control that raises double-click events.
''' </summary>
Public Class DoubleClickableCheckBox
Inherits Wedderburn.Windows.Forms.UnselectableCheckBox
#Region " Variables "
''' <summary>
''' Indicates whether the <see cref="Click"/> event should be suppressed.
''' </summary>
Private suppressClick As Boolean = False
''' <summary>
''' Indicates whether the <see cref="MouseClick"/> event should be suppressed.
''' </summary>
Private suppressMouseClick As Boolean = False
#End Region 'Variables
#Region " Constructors "
''' <summary>
''' Initialises a new instance of the <see cref="DoubleClickableCheckBox"/> class.
''' </summary>
Public Sub New()
MyBase.New()
'The check box raises double-click events.
Me.SetStyle(ControlStyles.StandardClick, True)
Me.SetStyle(ControlStyles.StandardDoubleClick, True)
End Sub
#End Region 'Constructors
#Region " Methods "
''' <summary>
''' Overriden. Raises the <see cref="Click"/> event.
''' </summary>
''' <param name="e">
''' An <see cref="EventArgs"/> that contains the event data.
''' </param>
''' <remarks>
''' When the <see cref="ControlStyles">StandardClick</see> and <b>StandardDoubleClick</b> control styles are set the check box will, by default, raise two <b>Click</b> events each time it is clicked. This method suppresses the second event.
''' </remarks>
Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
If Not Me.suppressClick Then
MyBase.OnClick(e)
End If
Me.suppressClick = Not Me.suppressClick
End Sub
''' <summary>
''' Overriden. Raises the <see cref="DoubleClick"/> event.
''' </summary>
''' <param name="e">
''' An <see cref="EventArgs"/> that contains the event data.
''' </param>
''' <remarks>
''' When the <see cref="ControlStyles">StandardClick</see> and <b>StandardDoubleClick</b> control styles are set the check box will, by default, raise a <see cref="Click"/> event after each <b>DoubleClick</b> event. This method suppresses that <b>Click</b> event.
''' </remarks>
Protected Overrides Sub OnDoubleClick(ByVal e As System.EventArgs)
Me.suppressClick = True
MyBase.OnDoubleClick(e)
End Sub
''' <summary>
''' Overriden. Raises the <see cref="MouseClick"/> event.
''' </summary>
''' <param name="e">
''' An <see cref="MouseEventArgs"/> that contains the event data.
''' </param>
''' <remarks>
''' When the <see cref="ControlStyles">StandardClick</see> and <b>StandardDoubleClick</b> control styles are set the check box will, by default, raise two <b>MouseClick</b> events each time it is clicked. This method suppresses the second event.
''' </remarks>
Protected Overrides Sub OnMouseClick(ByVal e As System.Windows.Forms.MouseEventArgs)
If Not Me.suppressMouseClick Then
MyBase.OnMouseClick(e)
End If
Me.suppressMouseClick = Not Me.suppressMouseClick
End Sub
''' <summary>
''' Overriden. Raises the <see cref="MouseDoubleClick"/> event.
''' </summary>
''' <param name="e">
''' An <see cref="MouseEventArgs"/> that contains the event data.
''' </param>
''' <remarks>
''' When the <see cref="ControlStyles">StandardClick</see> and <b>StandardDoubleClick</b> control styles are set the check box will, by default, raise a <see cref="MouseClick"/> event after each <b>MouseDoubleClick</b> event. This method suppresses that <b>MouseClick</b> event.
''' </remarks>
Protected Overrides Sub OnMouseDoubleClick(ByVal e As System.Windows.Forms.MouseEventArgs)
Me.suppressMouseClick = True
MyBase.OnMouseDoubleClick(e)
End Sub
#End Region 'Methods
End Class