The attached source code is a MouseStick control written in C# and Windows Forms. 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 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.
The events that are fired are:
MouseStickEventArgs have two properties that report the corresponding properties of the MouseStick. These are:
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.
MouseStick Demo
Pro WPF: Windows Presentation Foundation in .NET 3.0