Skip to main content
Version: 4.2

MeterBar

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

Displays read-only capacity usage with labels, semantic thresholds, and optional stacked segments.

public class MeterBar : Control

Value and all threshold and segment amounts use absolute units. Maximum determines the fill scale only. Values above Maximum remain available as data and text, while the fill is capped at 100 percent. Segments partition Value in collection order; any remainder uses the active threshold tone.

Example:

var meter = new MeterBar { Label = "Memory", Maximum = 384, Value = 312.3, Format = "{0:N1} / {1:N0} GB" };
meter.Thresholds.Add(new MeterThreshold(300, MeterTone.Warning));
meter.Thresholds.Add(new MeterThreshold(360, MeterTone.Danger));
this.Controls.Add(meter);

Constructors​

Instance member MeterBar()​

Initializes an empty meter with a maximum of 100 and a six-pixel bar.

Properties​

Instance member Animated​

Boolean: Gets or sets whether fill changes animate. The default is false. (Default: False)

Animation is disabled in the designer and when the browser requests reduced motion.

Instance member BarHeight​

Int32: Gets or sets the bar thickness in pixels. The default is 6. (Default: 6)

Throws:

Instance member CurrentTone​

MeterTone: Gets the active threshold tone, or Primary when no threshold matches.

Protected member DefaultSize​

Size: Gets the default meter size of 300 by 42 pixels.

Instance member Focusable​

Boolean: Gets or sets whether the meter can receive focus. The default is false. (Default: False)

Instance member Format​

String: Gets or sets the composite format for automatic value text. The default is "{0:N0} / {1:N0}". (Default: "{0:N0} / {1:N0}")

Argument 0 is Value and argument 1 is Maximum; formatting uses the current culture.

Throws:

Example:

meter.Format = "{0:N1} / {1:N0} GB";
meter.ResetValueText(); // Re-enables formatted text after an explicit ValueText override.

Instance member Label​

String: Gets or sets the label above the bar. The default is an empty string. (Default: "")

Instance member Maximum​

Double: Gets or sets the positive capacity used to scale the bar. The default is 100. (Default: 100)

Throws:

Instance member Segments​

MeterSegmentCollection: Gets the named, colored portions stacked within Value, in collection order.

Excess amounts are clipped; unallocated usage uses CurrentTone. Editing segments does not change Value.

Example:

meter.Value = 80;
meter.Segments.Add(new MeterSegment("Applications", 50, MeterTone.Primary));
meter.Segments.Add(new MeterSegment("Cache", 20, MeterTone.Success));
// The remaining 10 units use CurrentTone; adding segments does not change Value.

Instance member TabStop​

Boolean: Gets or sets whether the meter participates in tab navigation. The default is false. (Default: False)

Instance member Thresholds​

MeterThresholdCollection: Gets absolute tone boundaries. The highest matching From wins; equal boundaries use the last item.

Editing thresholds refreshes the appearance without raising ThresholdCrossed.

Example:

meter.Maximum = 200;
meter.Thresholds.Add(new MeterThreshold(150, MeterTone.Warning));
meter.Thresholds.Add(new MeterThreshold(180, MeterTone.Danger));
meter.Value = 190; // Crosses 150, then 180; CurrentTone becomes Danger.

Instance member Value​

Double: Gets or sets absolute usage. The default is 0. Usage may exceed Maximum. (Default: 0)

Throws:

Instance member ValueText​

String: Gets the displayed value text, or sets an explicit override.

Assign null or an empty string, or call ResetValueText, to generate text using Format.

Methods​

Protected member Dispose(disposing)​

Detaches collection notifications before releasing the control.

ParameterTypeDescription
disposingBooleanWhether managed resources should be released.

Protected member OnThresholdCrossed(e)​

Raises ThresholdCrossed for one boundary.

ParameterTypeDescription
eMeterThresholdEventArgsSnapshot of the crossed boundary and the old and new usage.

Protected member OnValueChanged(e)​

Raises ValueChanged.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnWebRender(config)​

Serializes the meter into properties consumed by wisej.web.MeterBar.

ParameterTypeDescription
configObjectClient configuration, including inherited Wisej properties.

Instance member ResetValueText()​

Restores automatic value text generated from Format.

Events​

Instance member ThresholdCrossed​

EventHandler<MeterThresholdEventArgs> Occurs once for each absolute threshold crossed in either direction by a Value change.

Boundaries are inclusive on entry: old < From <= new upward, new < From <= old downward. Multiple crossings are reported in traversal order. Maximum and collection edits do not raise this event.

Instance member ValueChanged​

EventHandler Occurs after Value changes, before ThresholdCrossed notifications.

Assigning the same value does not raise this event.

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IBindableComponentBindable components implement this interface.
IDropTargetControls that support drag & drop operations implement this interface.
IWisejComponentAll wisej components implement this interface.
IWisejControlAll wisej controls derived from the Control class must implement this interface.
IWisejSerializableAllows an object to serialize itself.