MouseStick Control in VB.NET

MouseStick-VB.NET.gif

The MouseStick control gets its name from the fusion of a joystick with a mouse. Think of the line in the MouseStick as a joystick that is controlled with your computer's mouse. The MouseStick fires events when the mouse is moved while over the MouseStick. These events report the Distance that the mouse is from the center of the control (on a scale of 0 -15), and the Direction that the line is pointing in from the center (strings referencing "north", "northeast", "east", "southeast", "south", "southwest", "west", "northwest", "north"). This is much like an analog joystick where the further that the joystick is pushed the greater the magnitude that is reported by the joystick.

The MouseStick has the following customizable Properties.

  • BackColor -- Color of background.
  • LineColor -- Color of the line inside of the MouseStick.
  • Cursor -- Cursor type while the mouse is over the MouseStick.
  • LineTip -- Shape of the tip of the Line.
  • LineWidth -- Width of the Line.
  • OutlineColor -- Color of the outline of the MouseStick.
  • Diameter -- The MouseStick's diameter

The events that are fired are:

  • MouseStickDirectionChanged(object sender, MouseStickEventArgs mse)
  • MouseStickDirectionChanged(object sender, MouseStickEventArgs mse)

MouseStickEventArgs have two properties that report the corresponding properties of the MouseStick. These are:

  • Distance
  • Direction

There is a MouseStickDemo project included in the same solution as the MouseStick Control project in the attached download. This demo makes use of a MouseStick by controlling a small airplane. The direction of the airplane changes in accordance with the direction that the line of the MouseStick points and changes speed in accordance with how far from the center of the MouseStick the line is drawn. There is also a statusBar at the bottom of the application that will display these values.

MouseSticks-in-vb.net.gif
MouseStick Demo

Up Next
    Ebook Download
    View all
    Learn
    View all