Charting for WinForms Programmer's Guide
Indicators

The indicator is a gauge element, which changes its appearance based on its Value property and its defined states. The states of the indicator are specified as CustomInterval objects and are located in the States collection. When the value of the indicator falls within one of its defined states, this state becomes active and its Fill and Stroke properties are applied to the indicator automatically. If the value of the indicator does not fall in any of the defined states, then the DefaultState becomes active.

A common scenario is to synchronize the Value property of the indicator with the Value of a Pointer object, thus when the value of the pointer is modified, the state of the indicator changes to reflect this.

Usage

The sample code below illustrates how to define and add indicators to an existing scale:

C#  Copy Code

var indicator = new Indicator();
indicator.States.Add(new CustomInterval()
{
    MinValue = 80,
    MaxValue = 100,
    Fill = new MindFusion.Drawing.SolidBrush(Color.Red)
});

const float shapeSize = 24;
var scaleWidth = ovalGauge.Width * (1 - ovalScale.Margin.Left - ovalScale.Margin.Right);
var scaleHeight = ovalGauge.Height * (1 - ovalScale.Margin.Top - ovalScale.Margin.Bottom);
indicator.Bounds = new RectangleF(scaleWidth / 2 - shapeSize / 2, 3 * scaleHeight / 4, shapeSize, shapeSize);

ovalScale.ScaleChildren.Add(indicator);

// Synchronize the value of the indicator with the value of the first pointer in the scale
ovalScale.Pointers[0].ValueChanging += (s, e) =>
{
    indicator.Value = ((Pointer)s).Value;
};

The oval gauge defined above will look like this: