''' <summary>
''' Flag that determines whether the user made a single click.
''' </summary>
Private DidSingleClick As Boolean = False
''' <summary>
''' Flag that determines whether the user made a double click.
''' </summary>
Private DidDoubleClick As Boolean = False
''' <summary>
''' Flag that determines whether the user made a triple click.
''' </summary>
Private DidTripleclick As Boolean = False
''' <summary>
''' Timer that resets the click-count after an inactivity period.
''' </summary>
Private WithEvents ClickInactivity_Timer As New Timer With
{
.Interval = SystemInformation.DoubleClickTime,
.Enabled = False
}
''' <summary>
''' Handles the MouseClick event of the TextBox1 control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles TextBox1.MouseClick
If Me.ClickInactivity_Timer.Enabled Then
Me.ClickInactivity_Timer.Enabled = False
End If
Me.DidSingleClick = True
End Sub
''' <summary>
''' Handles the MouseDoubleClick event of the TextBox1 control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
Private Sub TextBox1_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles TextBox1.MouseDoubleClick
If Me.ClickInactivity_Timer.Enabled Then
Me.ClickInactivity_Timer.Enabled = False
End If
Me.DidDoubleClick = True
End Sub
''' <summary>
''' Handles the MouseUp event of the TextBox1 control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
Private Sub TextBox1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles TextBox1.MouseUp
If Not Me.ClickInactivity_Timer.Enabled Then
Me.ClickInactivity_Timer.Enabled = True
Me.ClickInactivity_Timer.Start()
End If
End Sub
''' <summary>
''' Handles the MouseDown event of the TextBox1 control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
Private Sub TextBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles TextBox1.MouseDown
Me.DidTripleclick = (Me.DidDoubleClick AndAlso Me.DidSingleClick)
If Me.DidTripleclick Then
Me.DidSingleClick = False
Me.DidDoubleClick = False
Me.DidTripleclick = False
sender.SelectAll()
End If
End Sub
''' <summary>
''' Handles the Tick event of the ClickInactivity_Timer control.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
Private Sub ClickInactivity_Timer_Tick(ByVal sender As Object, ByVal e As EventArgs) _
Handles ClickInactivity_Timer.Tick
Me.DidSingleClick = False
Me.DidDoubleClick = False
Me.DidTripleclick = False
sender.Enabled = False
End Sub