MeterBar
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Displays read-only capacity usage with labels, semantic thresholds, and optional stacked segments.
- C#
- VB.NET
public class MeterBar : Control
Public Class MeterBar
Inherits 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
MeterBar()
Initializes an empty meter with a maximum of 100 and a six-pixel bar.
Properties
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.
BarHeight
Int32: Gets or sets the bar thickness in pixels. The default is 6. (Default: 6)
Throws:
- ArgumentOutOfRangeException The height is less than one.
CurrentTone
MeterTone: Gets the active threshold tone, or Primary when no threshold matches.
DefaultSize
Size: Gets the default meter size of 300 by 42 pixels.
Focusable
Boolean: Gets or sets whether the meter can receive focus. The default is false. (Default: False)
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:
- ArgumentNullException The format is null.
- FormatException The format is invalid or references an argument other than 0 or 1.
Example:
meter.Format = "{0:N1} / {1:N0} GB";
meter.ResetValueText(); // Re-enables formatted text after an explicit ValueText override.
Label
String: Gets or sets the label above the bar. The default is an empty string. (Default: "")
Maximum
Double: Gets or sets the positive capacity used to scale the bar. The default is 100. (Default: 100)
Throws:
- ArgumentOutOfRangeException The value is not finite or is not positive.
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.
TabStop
Boolean: Gets or sets whether the meter participates in tab navigation. The default is false. (Default: False)
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.
Value
Double: Gets or sets absolute usage. The default is 0. Usage may exceed Maximum. (Default: 0)
Throws:
- ArgumentOutOfRangeException The value is negative or not finite.
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
Dispose(disposing)
Detaches collection notifications before releasing the control.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Whether managed resources should be released. |
OnThresholdCrossed(e)
Raises ThresholdCrossed for one boundary.
| Parameter | Type | Description |
|---|---|---|
| e | MeterThresholdEventArgs | Snapshot of the crossed boundary and the old and new usage. |
OnValueChanged(e)
Raises ValueChanged.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Event data. |
OnWebRender(config)
Serializes the meter into properties consumed by wisej.web.MeterBar.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration, including inherited Wisej properties. |
ResetValueText()
Restores automatic value text generated from Format.
Events
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.
ValueChanged
EventHandler Occurs after Value changes, before ThresholdCrossed notifications.
Assigning the same value does not raise this event.
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |