Class HudThresholdRules
Canonical, engine-agnostic rules for a HUD element's threshold colour ramp: which representations can be coloured by a value band, and which band a value falls into.
Inherited Members
Namespace: Serenity.GameUi.Application.Validation
Assembly: Serenity.GameUi.Application.dll
Syntax
public static class HudThresholdRules
Remarks
Defined once here so the builder tool, the runtime and the validator agree — the same reason HudRepresentationRules exists. The model is deliberately narrow: ascending upper bounds, first-match-wins, no base colour. A value at or below a bound belongs to it; a value above every bound belongs to no band at all, and the representation keeps whatever colour it already had rather than falling back to some default the author never chose.
Methods
AreBoundsStrictlyAscending(IReadOnlyList<double>)
Whether a list of upper bounds is strictly ascending, so every band is actually reachable.
Declaration
public static bool AreBoundsStrictlyAscending(IReadOnlyList<double> bounds)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<double> | bounds | The authored upper bounds, in authoring order. |
Returns
| Type | Description |
|---|---|
| bool | True when every bound is strictly greater than the one before it. |
Remarks
A bound that is not strictly greater than the one before it makes every later band unreachable: SelectBandIndex(double, IReadOnlyList<double>) always returns the earlier, lower-or-equal bound first. An empty or single-band list is trivially ascending — there is nothing to compare it against.
SelectBandIndex(double, IReadOnlyList<double>)
Selects the band a value falls into.
Declaration
public static int SelectBandIndex(double value, IReadOnlyList<double> ascendingUpperBounds)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value to classify — already the transformed value a representation draws. |
| IReadOnlyList<double> | ascendingUpperBounds | The band upper bounds, in ascending order. |
Returns
| Type | Description |
|---|---|
| int | The index of the matching band, or -1 when the value is above every bound or the list is empty. |
Remarks
Bounds are read in list order and are expected ascending (see AreBoundsStrictlyAscending(IReadOnlyList<double>)) — the first bound at or above the value wins. A value above every bound matches no band; there is deliberately no "last band catches everything above it" rule, because that would make the highest band a base colour by another name.
SupportsThresholdColors(HudRepresentationKind)
Whether a representation kind can be coloured by a threshold band at all.
Declaration
public static bool SupportsThresholdColors(HudRepresentationKind kind)
Parameters
| Type | Name | Description |
|---|---|---|
| HudRepresentationKind | kind | The representation kind to check. |
Returns
| Type | Description |
|---|---|
| bool | True when the kind supports threshold colour. |
Remarks
TEXT, NUMBER, TIME, INTEGER_PART and FRACTION_PART share one renderer; GAUGE tints its fill; STACK and SEGMENTED share a renderer that tints filled slots. Every one of these eight kinds is wired to threshold colour. ICON_SET is excluded on purpose: its own per-entry tint already owns colour, and a second colour source would fight it. SPRITE and LABEL read no bound value, so there is nothing to band.