Back to Devexpress

StateIndicatorGauge Class

windowsforms-devexpress-dot-xtragauges-dot-win-dot-gauges-dot-state.md

latest5.4 KB
Original Source

StateIndicatorGauge Class

Imitates a static device or simple indicator that has a fixed set of states.

Namespace : DevExpress.XtraGauges.Win.Gauges.State

Assembly : DevExpress.XtraGauges.v25.2.Win.dll

NuGet Package : DevExpress.Win.Gauges

Declaration

csharp
public class StateIndicatorGauge :
    BaseGaugeWin,
    IStateIndicatorGauge,
    IWinGauge
vb
Public Class StateIndicatorGauge
    Inherits BaseGaugeWin
    Implements IStateIndicatorGauge,
               IWinGauge

The following members return StateIndicatorGauge objects:

Remarks

A state indicator gauge can be displayed as a part of a GaugeControl. The following image shows a set of state indicators painted using various paint styles:

A state indicator gauge can contain one or more state indicators, each of which is represented by the StateIndicatorComponent class.

See State Indicator Gauges to learn more.

Example

The following example shows how to create a state indicator gauge.

In the example a state indicator gauge is created using the GaugeControlBase.AddStateIndicatorGauge method. Then, a state indicator containing four states is added to this gauge. To set the initial state for the state indicator, the StateIndicator.StateIndex property is used.

The result is displayed below:

csharp
using DevExpress.XtraGauges.Win;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Base;
using DevExpress.XtraGauges.Win.Gauges.State;

GaugeControl gc = new GaugeControl();

// Add a state indicator gauge.
StateIndicatorGauge siGauge = gc.AddStateIndicatorGauge();

// Add a state indicator.
StateIndicatorComponent stateIndicator = siGauge.AddIndicator();

// Add states
StateIndicatorShapeType[] shapes = new StateIndicatorShapeType[] {
    StateIndicatorShapeType.TrafficLight1,
    StateIndicatorShapeType.TrafficLight2,
    StateIndicatorShapeType.TrafficLight3,
    StateIndicatorShapeType.TrafficLight4
};

stateIndicator.States.Clear();

foreach(StateIndicatorShapeType shape in shapes) {
    IndicatorState state = new IndicatorState();
    state.ShapeType = shape;
    stateIndicator.States.Add(state);
}

// Set the current state.
stateIndicator.StateIndex = 1;

// Set the indicator's size.
stateIndicator.Size = new SizeF(100, 200);

// Add the gauge control to the form.
gc.Size = new Size(250, 250);
gc.Parent = this;
vb
Imports DevExpress.XtraGauges.Win
Imports DevExpress.XtraGauges.Core.Model
Imports DevExpress.XtraGauges.Core.Base
Imports DevExpress.XtraGauges.Win.Gauges.State

Private gc As GaugeControl = New GaugeControl()

' Add a state indicator gauge.
Private siGauge As StateIndicatorGauge = gc.AddStateIndicatorGauge()

' Add a state indicator.
Private stateIndicator As StateIndicatorComponent = siGauge.AddIndicator()

' Add states
Private shapes As StateIndicatorShapeType() = New StateIndicatorShapeType() _
    { StateIndicatorShapeType.TrafficLight1, StateIndicatorShapeType.TrafficLight2, _
    StateIndicatorShapeType.TrafficLight3, StateIndicatorShapeType.TrafficLight4 }
stateIndicator.States.Clear()

For Each shape As StateIndicatorShapeType In shapes
    Dim state As IndicatorState = New IndicatorState()
    state.ShapeType = shape
    stateIndicator.States.Add(state)
Next shape

' Set the current state.
stateIndicator.StateIndex = 1

' Set the indicator's size.
stateIndicator.Size = New SizeF(100, 200)

' Add the gauge control to the form.
gc.Size = New Size(250, 250)
gc.Parent = Me

Inheritance

Object MarshalByRefObject Component BaseGauge BaseGaugeWin StateIndicatorGauge

See Also

StateIndicatorGauge Members

Gauge Types

State Indicator Gauges

DevExpress.XtraGauges.Win.Gauges.State Namespace