/// <summary>Initializes a new instance of the <see cref="ChangeableRelativeUnit"/> class.</summary> /// <param name="name">The full name of the unit (e.g. 'percent of page with').</param> /// <param name="shortcut">The shortcut of the unit (e.g. %PW).</param> /// <param name="divider">Used to calculate the relative value from the numeric value of the quantity. In the above example (percent of page width), the divider is 100.</param> /// <param name="referenceQuantity">The reference quantity.</param> public ChangeableRelativeUnit(string name, string shortcut, double divider, DimensionfulQuantity referenceQuantity) { _name = name; _shortCut = shortcut; _divider = divider; _referenceQuantity = referenceQuantity; }
private static ValidationResult EhValidateQuantity(Altaxo.Units.DimensionfulQuantity quantity) { string error = null; double val = quantity.AsValueInSIUnits; if (double.IsInfinity(val)) { error = "Value must not be infinity"; } else if (double.IsNaN(val)) { error = "Value must be a valid number"; } return(error == null ? ValidationResult.ValidResult : new ValidationResult(false, error)); }
/// <summary>Initializes a new instance of the <see cref="ChangeableRelativePercentUnit"/> class.</summary> /// <param name="name">The full name of the unit (e.g. 'percent of page with').</param> /// <param name="shortcut">The shortcut of the unit (e.g. %PW).</param> /// <param name="valueForHundredPercent">The quantity that corresponds to a value of hundred percent.</param> public ChangeableRelativePercentUnit(string name, string shortcut, DimensionfulQuantity valueForHundredPercent) : base(name, shortcut, 100, valueForHundredPercent) { }