Пример #1
0
        internal double?CalcuteMinValue(ICalcEvaluator evaluator, int baseRow, int baseColumn, int index, IActualValue actual)
        {
            ScaleValue value2 = base.scales[index];
            CellRange  range  = null;

            if (value2 != null)
            {
                if ((value2.Type != ScaleValueType.Formula) && (value2.Type != ScaleValueType.Percentile))
                {
                    return(base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual));
                }
                for (int i = 0; i < base.Ranges.Length; i++)
                {
                    if (base.Ranges[i].IntersectRow(baseRow))
                    {
                        range = base.Ranges[i];
                        break;
                    }
                }
                if (range != null)
                {
                    return(base.GetActualValue(evaluator, range.Row, range.Column, 0, actual));
                }
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Calculates the actual value for a specified <see cref="T:Dt.Cells.Data.ScaleRule" />.
        /// </summary>
        /// <returns>Returns the actual value of a specified <see cref="T:Dt.Cells.Data.ScaleRule" /> value.</returns>
        internal double?GetActualValue(ICalcEvaluator evaluator, int baseRow, int baseColumn, int index, IActualValue actual)
        {
            ScaleValue value2 = this.scales[index];

            if (value2 != null)
            {
                switch (value2.Type)
                {
                case ScaleValueType.Number:
                    return(this.CalculateValue(evaluator, baseRow, baseColumn, value2.Value));

                case ScaleValueType.LowestValue:
                    return(this.GetLowestValue(actual));

                case ScaleValueType.HighestValue:
                    return(this.GetHighestValue(actual));

                case ScaleValueType.Percent:
                    return(this.CalculatePercent(evaluator, baseRow, baseColumn, value2.Value, actual));

                case ScaleValueType.Percentile:
                    return(this.CalculatePercentile(evaluator, baseRow, baseColumn, value2.Value));

                case ScaleValueType.Automin:
                {
                    double?lowestValue = this.GetLowestValue(actual);
                    if (!lowestValue.HasValue || (lowestValue.Value <= 0.0))
                    {
                        return(lowestValue);
                    }
                    return(0.0);
                }

                case ScaleValueType.Formula:
                    return(this.CalculateValue(evaluator, baseRow, baseColumn, value2.Value));

                case ScaleValueType.Automax:
                {
                    double?highestValue = this.GetHighestValue(actual);
                    if (!highestValue.HasValue || (highestValue.Value >= 0.0))
                    {
                        return(highestValue);
                    }
                    return(0.0);
                }
                }
            }
            return(null);
        }
Пример #3
0
 void AddScaleRuleCondition(ScaleRule scaleRule)
 {
     if (scaleRule != null)
     {
         List <DummyScaleValue> list = new List <DummyScaleValue>();
         for (int i = 0; i < 3; i++)
         {
             ScaleValue value2 = scaleRule.Scales[i];
             if (((value2 != null) && (value2.Type == ScaleValueType.Formula)) && !string.IsNullOrEmpty((string)(value2.Value as string)))
             {
                 list.Add(new DummyScaleValue(scaleRule, i));
             }
             else if (((value2 != null) && !string.IsNullOrEmpty((string)(value2.Value as string))) && (value2.Value as string).StartsWith("="))
             {
                 list.Add(new DummyScaleValue(scaleRule, i));
             }
         }
         if (list.Count > 0)
         {
             this.scaleRules.Add(scaleRule, list);
             this.AddConditionsByRange(scaleRule.Ranges, list.ToArray());
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Creates a new scale rule.
 /// </summary>
 protected ScaleRule(ScaleValue s1, ScaleValue s2, ScaleValue s3) : base(null)
 {
     this.scales   = new ScaleValue[] { s1, s2, s3 };
     this.expected = new object[3];
 }