public static string GetRangeStr(double min, double max) { if (double.IsNaN(min) && double.IsNaN(max)) { return(string.Empty); } return(ALCore.GetDecimalStr(min) + " - " + ALCore.GetDecimalStr(max)); }
private void PrepareValue(IList <MeasureValue> measures, double mVal, string sign, string uom, ValueRange[] ranges) { string strVal = !double.IsNaN(mVal) ? ALCore.GetDecimalStr(mVal) : string.Empty; string text = string.Format("{0}={1} {2}", sign, strVal, uom); Color color = Color.Black; ValueRange bounds = CheckValue(mVal, ranges); if (bounds != null) { color = bounds.Color; } var tval = new MeasureValue(sign, mVal, uom, strVal, text, color, ranges); measures.Add(tval); }
public static string CastStr(double value, MeasurementType measurementType, int decimalDigits = 2, bool hideZero = false) { // sourceUoM = always only SI MeasurementUnit targetUnit = MeasurementUnit.Unknown; switch (measurementType) { case MeasurementType.Length: targetUnit = ALSettings.Instance.LengthUoM; break; case MeasurementType.Volume: targetUnit = ALSettings.Instance.VolumeUoM; break; case MeasurementType.Mass: targetUnit = ALSettings.Instance.MassUoM; break; case MeasurementType.Temperature: targetUnit = ALSettings.Instance.TemperatureUoM; break; } switch (targetUnit) { case MeasurementUnit.Centimeter: break; case MeasurementUnit.Inch: value = UnitConverter.cm2inch(value); break; case MeasurementUnit.Litre: break; case MeasurementUnit.UKGallon: break; case MeasurementUnit.USGallon: value = UnitConverter.l2gal(value); break; case MeasurementUnit.Kilogram: break; case MeasurementUnit.Pound: value = UnitConverter.kg2lb(value); break; case MeasurementUnit.DegreeCelsius: break; case MeasurementUnit.DegreeFahrenheit: value = UnitConverter.C2F(value); break; case MeasurementUnit.DegreeKelvin: value = UnitConverter.C2K(value); break; case MeasurementUnit.Unknown: default: break; } return(ALCore.GetDecimalStr(value, decimalDigits, hideZero)); }