void RemoveScaleRuleCondition(ScaleRule scaleRule)
 {
     if (this.scaleRules.ContainsKey(scaleRule))
     {
         this.RemoveConditionsByRange(scaleRule.Ranges, this.scaleRules[scaleRule].ToArray());
     }
 }
Exemple #2
0
        /// <summary>
        /// Returns a specified value of the rule if the cell satisfies the condition.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The row index.</param>
        /// <param name="baseColumn">The column index.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>Returns the conditional number value.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 != null)
            {
                double num;
                try
                {
                    num = ConditionValueConverter.ToDouble(obj2);
                }
                catch (InvalidCastException)
                {
                    return(null);
                }
                double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                if (nullable.HasValue && nullable2.HasValue)
                {
                    return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value), this.MinimumColor, this.MaximumColor));
                }
            }
            return(null);
        }
Exemple #3
0
        /// <summary>
        /// Creates a new object that is a copy of the current instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public override object Clone()
        {
            ScaleRule rule = base.Clone() as ScaleRule;

            rule.scales = new ScaleValue[3];
            this.scales.CopyTo(rule.scales, 0);
            return(rule);
        }
Exemple #4
0
 internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
 {
     if (base.condition != null)
     {
         this.lastActualValue = actual;
         object obj2 = actual.GetValue(baseRow, baseColumn);
         if (obj2 != null)
         {
             double num;
             try
             {
                 num = ConditionValueConverter.ToDouble(obj2);
             }
             catch (InvalidCastException)
             {
                 return(false);
             }
             double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
             double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
             double?nullable3 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
             if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
             {
                 double?nullable4 = nullable;
                 double?nullable5 = nullable3;
                 if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                 {
                     return(false);
                 }
                 double num2      = num;
                 double?nullable6 = nullable;
                 if ((num2 >= ((double)nullable6.GetValueOrDefault())) || !nullable6.HasValue)
                 {
                     double num3      = num;
                     double?nullable7 = nullable3;
                     if ((num3 >= ((double)nullable7.GetValueOrDefault())) && nullable7.HasValue)
                     {
                         return(true);
                     }
                     if ((nullable.Value <= num) && (num <= nullable2.Value))
                     {
                         ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value);
                         return(true);
                     }
                     ScaleRule.Evaluate2Scale(num, nullable2.Value, nullable3.Value);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #5
0
        /// <summary>
        /// Returns the specified value of the rule if the cell meets the condition.
        /// </summary>
        /// <param name="evaluator">The evaluator.</param>
        /// <param name="baseRow">The row index.</param>
        /// <param name="baseColumn">The column index.</param>
        /// <param name="actual">The current value.</param>
        /// <returns>Returns the conditional number value.</returns>
        public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual)
        {
            this.lastActualValue = actual;
            object obj2 = actual.GetValue(baseRow, baseColumn);

            if (obj2 != null)
            {
                double num;
                try
                {
                    num = ConditionValueConverter.ToDouble(obj2);
                }
                catch (InvalidCastException)
                {
                    return(null);
                }
                double?nullable  = base.GetActualValue(evaluator, baseRow, baseColumn, 0, actual);
                double?nullable2 = base.GetActualValue(evaluator, baseRow, baseColumn, 1, actual);
                double?nullable3 = base.GetActualValue(evaluator, baseRow, baseColumn, 2, actual);
                if ((nullable.HasValue && nullable3.HasValue) && nullable2.HasValue)
                {
                    double?nullable4 = nullable;
                    double?nullable5 = nullable3;
                    if ((((double)nullable4.GetValueOrDefault()) > ((double)nullable5.GetValueOrDefault())) && (nullable4.HasValue & nullable5.HasValue))
                    {
                        return(null);
                    }
                    double num4      = num;
                    double?nullable6 = nullable;
                    if ((num4 < ((double)nullable6.GetValueOrDefault())) && nullable6.HasValue)
                    {
                        return(this.MinimumColor);
                    }
                    double num5      = num;
                    double?nullable7 = nullable3;
                    if ((num5 >= ((double)nullable7.GetValueOrDefault())) && nullable7.HasValue)
                    {
                        return(this.MaximumColor);
                    }
                    if ((nullable.Value <= num) && (num <= nullable2.Value))
                    {
                        return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable.Value, nullable2.Value), this.MinimumColor, this.MidpointColor));
                    }
                    return(ScaleRule.EvaluateColor(ScaleRule.Evaluate2Scale(num, nullable2.Value, nullable3.Value), this.MidpointColor, this.MaximumColor));
                }
            }
            return(null);
        }
 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());
         }
     }
 }
Exemple #7
0
 public DummyScaleValue(ScaleRule rule, int index)
 {
     this.scaleRule  = rule;
     this.valueIndex = index;
 }