Esempio n. 1
0
        public override double ConvertToPercent(object value)
        {
            if (value == null)
            {
                return(double.NaN);
            }
            double         num        = Convert.ToDouble(value, (IFormatProvider)CultureInfo.InvariantCulture);
            Range <double> fromRange  = new Range <double>(this.ActualMinimum, this.ActualMaximum);
            double         precision1 = DoubleHelper.GetPrecision(num, fromRange.Minimum, fromRange.Maximum);

            if (DoubleHelper.LessWithPrecision(num, fromRange.Minimum, precision1) || DoubleHelper.GreaterWithPrecision(num, fromRange.Maximum, precision1))
            {
                return(double.NaN);
            }
            double precision2 = DoubleHelper.GetPrecision(1, new double[0]);

            return(DoubleHelper.RoundWithPrecision(RangeHelper.Project(fromRange, num, Scale.PercentRange), precision2));
        }