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:
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.