Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

GLUI-style Spinner

0.00/5 (No votes)
20 Jun 2005 1  
Creating an OpenGL GLUI-style spinner.

Sample Image - spinner.jpg

Introduction

Having had loads of fun working with OpenGL, I decided to try my hand at DirectX. I thought what better way to start than to take my OpenGL projects and see how they work in DirectX. I ran into a barrier when the original project used various GLUI objects which are not available in .NET. This is my first GLUI-style control.

Using the code

As this is a beginner control, there is not much difference between this and a Microsoft control. The control is derived from a System.Windows.Forms.Panel as I needed something to contain the System.Windows.Forms.TextBox and two System.Windows.Forms.Button objects. This has allowed me to keep the usability of a single control (i.e., you cannot tab to each button, instead to each spinner as a while).

Each Spinner has the following properties for setting the behavior to the user's liking:

  • The 'Minimum' and 'Maximum' properties to set the range of the Spinner.
  • A 'Value' property to set the original value of the Spinner.
  • A 'Theta' property to set the step value for the Spinner.

Using this control should be as simple as using any other Panel; just drop it on a form and set the listed properties to your desire.

Points of Interest

This is not exactly a final release. I am still relatively new to .NET development, so there are a few features I plan to add just as soon as I learn how. As it stands, you can change the Spinner value in three ways:

  1. Input the value by using the numeric keypad found on your keyboard.
  2. Use the buttons on the right side of the control.
  3. Use the Up and Down arrow keys on your keyboard while the control has focus.

Currently, there is no code in place to stop the user from inputting a value outside the range, but the next click of the button or press of the arrow keys will set the value to the range minimum or maximum, whichever applies.

History

As this is the first draft, there aren't any updates.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here