360 Degree Wheel Control

webbiz

Member
Joined
Oct 15, 2011
Messages
21
Programming Experience
10+
Does anyone know if there is a control available for VS2010 that would be like a wheel knob?

In other words, you would have this round DIAL like control that you can move around clock-wise or counter-clockwise to represent values of 0 to 360 degree.

I'm having trouble finding such a control and would prefer it over typing in degrees.

For example, if the user wants to tell the application to do something based on winds moving SE at approximately 255 degrees, he would just turn this dial to point SE and adjust to 255 rather than type it in.

Anything out there?

Thanks.
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
898
Location
Norway
Programming Experience
10+
Ordinal point SE centers at 135°, Boxing the compass - Wikipedia, the free encyclopedia

I had a look around, and while there were a few knob controls that may or may not been usable, and some professional instrumentation products to be found, I decided to write a basic one myself. The idea is simple, you have a square control, the angle (degree) can be calculated from its center for any place mouse points to (Atan2 function). Now some visual representation of the angle can be given, this control uses an image of a compass that is rotated to that degree (Graphics.Transform using Matrix.RotateAt), so it points 'north' of image to that angle. Any square image can be used, the demo uses one picked up from the Wiki article "compass rose". I included functions to expose the angle as point strings in both short and long form. Runtime interaction can be done by clicking the control or moving mouse with left button pressed. It could be applied differently perhaps, by that's how I did it. Feel free to use it any way you want.

Attached is demo project that includes the Compass.cs control class, here's a screen shot:
compass demo.png
 

Attachments

  • CompassDemo-C#Net4.zip
    97.4 KB · Views: 70
Top Bottom