Vixen
feb85697
csharp
public sealed class LevelIndicator

Where a reading sits between two thresholds, and whether that is a problem.

Read the guide page for this →

Remarks

⚠ Not a ProgressBar with colours, and the difference is what the reading means rather than how it is drawn. A progress bar is about a job: it starts empty, only ever goes up, and being full is the good outcome. A level indicator is about a capacity — a disk, a battery, a budget, a memory pool — which goes both ways, never finishes, and where full may be exactly the thing you are worried about. Doc 49 § 7.1 ranks this sixth of the missing controls because ProgressBar was the only readout in the set and every panel wanting a capacity had to misuse it.

⚠ Which direction is bad is inferred from the order of the two thresholds whenever there are two. Warning = 0.7, Critical = 0.9 is a disk filling up and Warning = 0.3, Critical = 0.1 is a battery running down, with nothing else to set. See Level.

⚠ And stated by Direction when there is one line, because one line has no order. This type used to refuse any such property, arguing that a flag beside two numbers can contradict them and leave a control "silently wrong and looking configured". Both halves of that were wrong. A contradiction is not silent: a falling direction over a disk's rising pair reads Critical at every ordinary reading, which is the first thing anybody sees. What was silent was the case the refusal created — a battery with only Critical = 0.1 set had no way to say it falls, was inferred rising, and read critical at a full charge with nothing to show it was a guess (#1353). Inferred is still the default and still reads a lone line as a ceiling, so no existing indicator moves.

⚠ The level is a class rather than a colour. level-indicator.warning and .critical are what the theme selects on, exactly as .indeterminate is for a progress bar, so which hues mean "nearly full" stays a decision of the stylesheet and one palette answers for the whole interface. A Color4 property here would be a second palette that the theme cannot see.

Segmented and continuous are one control: Segments at zero draws a bar and above zero draws that many blocks of which the filled fraction is lit, which is what a signal strength or a rating is. Splitting them would be two controls with one arithmetic problem and two chances to round the boundary differently.

Fields and properties (15)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • protected override bool AcceptsFocus
  • protected override AccessibleRole NativeRole

    The role this kind of element has when nobody says otherwise.

  • protected override string? NativeAccessibleValue
  • public float Value
  • public float Warning
  • public float Critical
  • public LevelDirection Direction
  • public int Segments
  • public LevelReading Level

    What the reading currently amounts to.

  • public static readonly UiPropertyKey ValueProperty

    Identity for Value.

  • public static readonly UiPropertyKey WarningProperty

    Identity for Warning.

  • public static readonly UiPropertyKey CriticalProperty

    Identity for Critical.

  • public static readonly UiPropertyKey DirectionProperty

    Identity for Direction.

  • public static readonly UiPropertyKey SegmentsProperty

    Identity for Segments.

Methods (7)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • protected override void OnDraw(DrawContext context)

    Draws whatever this element is, beyond what a stylesheet can describe.

  • public void ClearValue()

    Unsets Value, so it takes its default or its ancestor's value again.

  • public void ClearWarning()

    Unsets Warning, so it takes its default or its ancestor's value again.

  • public void ClearCritical()

    Unsets Critical, so it takes its default or its ancestor's value again.

  • public void ClearDirection()

    Unsets Direction, so it takes its default or its ancestor's value again.

  • public void ClearSegments()

    Unsets Segments, so it takes its default or its ancestor's value again.

Used by (5)

  • GalleryHelloUi
  • GaugeTestsVixen.Ui.Controls.Tests
  • LevelIndicatorImageTestsVixen.Graphics.Golden.Tests
  • LevelIndicatorTestsVixen.Ui.Controls.Tests
  • RangeFillEdgeTestsVixen.Ui.Controls.Tests