The Jog buttons: jog motion

Two jog buttons are used for jog motion: one for jog forward and another for jog backward. The behavior of the buttons can be customized. In this sample, the buttons are used this way:

Because we don't use the click behavior, the code is not written in the Button_Click method. Instead, we use the MouseDown event. When the left mouse button is pressed and held, JogAxis moves the axis forward or backward. When the button is released, HaltAxis stops jogging. Because MouseDown is applied to the Jog buttons, the methods for these buttons are btnJOG_F_MouseDown, btnJOG_F_MouseUp, btnJOG_B_MouseDown, and btnJOG_B_MouseUp. F is Jog Forward and B is Jog Backward. The command velocity is received from tbCMD_VEL.Text, which is converted to a double-precision floating-point number using Convert.ToDouble.

Jog Forward

Private Sub btnJOG_F_MouseDown(sender As Object, e As MouseEventArgs) Handles btnJOG_F.MouseDown
   Dim Mindex As Integer = lbMList.SelectedIndex

   'Commands a never-ending controlled motion at a specified velocity.
   motion.JogAxis(Mindex, Convert.ToDouble(tbCMD_VEL.Text), 3600, 3600, 360000, McDirection.mcPositiveDirection)
End Sub
Private Sub btnJOG_F_MouseUp(sender As Object, e As MouseEventArgs) Handles btnJOG_F.MouseUp
   Dim Mindex As Integer = lbMList.SelectedIndex

   'Commands a controlled motion stop.
   motion.HaltAxis(Mindex, 3600, 360000, McBufferMode.mcAborting) 
End Sub

Jog Backward

Private Sub btnJOG_B_MouseDown(sender As Object, e As MouseEventArgs) Handles btnJOG_B.MouseDown
   Dim Mindex As Integer = lbMList.SelectedIndex

   'Commands a never-ending controlled motion at a specified velocity.
   motion.JogAxis(Mindex, Convert.ToDouble(tbCMD_VEL.Text), 3600, 3600, 360000, McDirection.mcNegativeDirection)
End Sub
Private Sub btnJOG_B_MouseUp(sender As Object, e As MouseEventArgs) Handles btnJOG_B.MouseUp
   Dim Mindex As Integer = lbMList.SelectedIndex

   'Commands a controlled motion stop.
   motion.HaltAxis(Mindex, 3600, 360000, McBufferMode.mcAborting)
End Sub