Search Results for

    Show / Hide Table of Contents

    Class RangeExtension

    Inheritance
    System.Object
    RangeExtension
    Namespace: IronPPT.Models.Extensions
    Assembly: IronPPT.dll
    Syntax
    public static class RangeExtension : Object

    Clamping a numeric value into a fixed band runs through RangeExtension. The static helper adds one extension method that takes a value and a lower and upper bound, returning a double constrained to that span, which is handy for keeping a size, opacity, or percentage within the limits a slide property accepts.

    The method is ToRange<T>, a generic extension called on the value itself, taking a double minimum and a double maximum. It returns the value as a double brought inside [min, max], so a figure below the floor comes back as the floor and a figure above the ceiling comes back as the ceiling. Because the receiver is generic, it works across the numeric types a presentation model uses without a separate overload per type. Reach for it when assigning a computed measurement to a property that has a valid range, rather than writing the same min and max guard inline each time.

    double opacity = rawValue.ToRange(0, 1);

    The paragraph style example sets sized style values, and the add shape example positions and sizes a shape where bounded values apply.

    Methods

    ToRange<T>(T, Double, Double)

    Declaration
    public static double ToRange<T>(this T value, double min, double max)
        where T : struct, ValueType
    Parameters
    Type Name Description
    T value
    System.Double min
    System.Double max
    Returns
    Type Description
    System.Double
    Type Parameters
    Name Description
    T
    ☀
    ☾
    Downloads
    • Download with NuGet
    • Start for Free
    In This Article
    Back to top
    Install with NuGet