Click here to Skip to main content
15,902,636 members
Articles / Desktop Programming / Windows Forms
Article

TomOMeter

Rate me:
Please Sign up or sign in to vote.
2.05/5 (9 votes)
25 May 20051 min read 43.7K   1.6K   27   7
A meter control.

Sample Image

Introduction

This control allows the user to display values using a meter style reminiscent of the classic audio dB meters. It provides a pleasant visual representation of values between two user assignable values. In addition, the user may specify the range of a "red zone" to indicate high levels.

Background

TomOMeter is a custom Windows control library made using .NET and C#. It utilizes the rotation of Matrix objects to draw "circular" things.

Using the code

Upon adding the TomOMeter to your form, you will probably want to change some of its properties, notably:

  • End_Value: specifies maximum value of meter.
  • Start_Value: specifies starting value of meter.
  • Hash_Mark_Color: specifies color of non-"red zone" graduations.
  • Hash_Mark_Width: specifies width of all graduations.
  • Label: specifies top level (big) label.
  • Needle_Color: specifies needle color.
  • Number_Font: specifies font to be used for numbers.
  • Red_Zone: specifies value at which graduations will be drawn in "Red Zone" color.
  • Red_Zone_Color: specifies which color to use for "Red Zone".
  • Text_Color: specifies color of numbers and labels.
  • Units: specifies units (small) label.

The control is resizable, but care must be taken to avoid clipping the display. When the value of what you are measuring changes, simply set the TomOMeter's Deflection property to this new value.

For example, in my demonstration program, I want to change the needle's deflection when the value of the TrackBar changes. I do this in the main form's trackBar1.ValueChanged event handler:

C#
private void trackBar1_ValueChanged(object sender, System.EventArgs e) 
{
    this.userControl11.Deflection = this.trackBar1.Value;
}

Points of Interest

Sadly, this control does not work well for smaller values. As there are only 10 graduations on the control, and I am rounding values to the nearest whole number, ranges less than 10 or not multiples of 10 for relatively small values produce some rather undesirable results.

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralRebuild of control Pin
Arith0n31-Dec-05 16:13
Arith0n31-Dec-05 16:13 
GeneralRe: Rebuild of control Pin
vaibhav_patel5-Mar-07 3:38
vaibhav_patel5-Mar-07 3:38 
GeneralRe: Rebuild of control Pin
Mountazar Abou Chrouche20-Jul-07 5:00
Mountazar Abou Chrouche20-Jul-07 5:00 
GeneralRe: Rebuild of control Pin
Dieter6821-Jan-09 8:06
Dieter6821-Jan-09 8:06 
Hi Jon,
I'm also interested in your changes, could you please e-mail me your version.
Thanks and regards,
Dieter

...

QuestionRe: Rebuild of control Pin
Horscht200514-Apr-11 11:14
Horscht200514-Apr-11 11:14 
GeneralAnitAlias Pin
Einar Kvandahl20-Sep-05 5:22
Einar Kvandahl20-Sep-05 5:22 
GeneralFlickering Pin
Robert M. Bouwens1-Apr-05 8:19
Robert M. Bouwens1-Apr-05 8:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.