ARTICLE

MouseStick Control in VB.NET

Posted by Ben Simmons Articles | Visual Basic 2010 May 13, 2005
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.
Download Files:
 
Reader Level:

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.


MouseStick Demo

share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor