/// <summary> /// Formats the specified value. /// </summary> /// <param name="obj">The object.</param> /// <returns> /// Returns the string of the formatted value. /// </returns> public override string Format(object obj) { string str = string.Empty; if (FormatConverter.IsNumber(obj)) { bool flag = (base.PartLocaleID == null) || base.PartLocaleID.AllowScience; double?nullable = FormatConverter.TryDouble(obj, true); if (!nullable.HasValue) { return(""); } double num = nullable.Value; if (((Math.Abs(num) <= 99999999999) || !flag) && ((Math.Abs(num) >= 1E-11) || (num == 0.0))) { return(this.DigitalFormat.Format(obj)); } return(this.ExponentialDigitalFormat.Format(obj)); } if (obj is string) { string newValue = FormatConverter.ToString(obj, true); string str3 = DefaultTokens.TrimEscape(this.FormatString.Replace("\"", "")); if (str3 != null) { newValue = str3.Replace("General", newValue); } return(newValue); } if (obj is bool) { bool flag2 = (bool)((bool)obj); str = flag2.ToString().ToUpper(); } return(str); }
internal override bool IsConditionEvaluateToTrue(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual) { if (base.condition == null) { return(false); } object obj2 = actual.GetValue(baseRow, baseColumn); if (obj2 == null) { return(false); } double num = 0.0; if (!FormatConverter.IsNumber(obj2)) { return(false); } double?nullable = FormatConverter.TryDouble(obj2, false); if (!nullable.HasValue) { return(false); } num = nullable.Value; int num2 = 0; if ((this.iconSetType >= Dt.Cells.Data.IconSetType.ThreeArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.ThreeSymbolsUncircled)) { num2 = 3; } else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FourArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FourTrafficLights)) { num2 = 4; } else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FiveArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FiveBoxes)) { num2 = 5; } if (this.iconCriteria != null) { double maxValue = double.MaxValue; for (int i = num2 - 1; i > 0; i--) { if (i >= (this.iconCriteria.Length + 1)) { return(true); } IconCriterion criterion = this.iconCriteria[i - 1]; if ((criterion == null) || (criterion.Value == null)) { return(true); } double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, i - 1, actual); if (!nullable2.HasValue) { return(true); } if (criterion.IsGreaterThanOrEqualTo) { if ((num < maxValue) && (num >= nullable2.Value)) { return(true); } } else if ((num < maxValue) && (num > nullable2.Value)) { return(true); } } } return(true); }
internal virtual void UpdateCollection() { List <T> list = new List <T>(); if ((this._dataProviders != null) && (this._dataProviders.Count > 0)) { bool flag = true; foreach (ISeriesDataProvider provider in this._dataProviders) { int valuesCount = provider.ValuesCount; int seriesCount = provider.SeriesCount; for (int i = 0; i < valuesCount; i++) { object obj2 = null; string str = null; bool flag2 = true; for (int j = 0; j < seriesCount; j++) { flag2 = this.DataSeries.DisplayHiddenData || provider.IsValueVisible(j, i); if (flag2) { object obj3 = provider.GetValue(j, i); string text = provider.GetText(j, i); if (j == 0) { obj2 = obj3; str = text; } else { string str3 = (obj2 != null) ? obj2.ToString() : ""; string str4 = (obj3 != null) ? obj3.ToString() : ""; if (!string.IsNullOrEmpty(str4)) { obj2 = str3 + this.ValuesSeperator + str4; } else { obj2 = str3; } flag = false; } } } if (flag2) { if (!(obj2 is DateTime)) { if (FormatConverter.IsNumber(obj2)) { DateTime time; if (!string.IsNullOrEmpty(str) && !DateTime.TryParse(str, (IFormatProvider)CultureInfo.CurrentCulture, (DateTimeStyles)DateTimeStyles.None, out time)) { flag = false; } } else { flag = false; } } T local = this.ConvertValue(i, obj2); list.Add(local); } } } base.items.Clear(); base.items.AddRange((IEnumerable <T>)list); if ((flag != this.IsDateTimeSeries) && (base.items.Count > 0)) { this.IsDateTimeSeries = flag; } } else if ((this.DataSeries != null) && (this.DataSeries.DataReference is CalcArrayExpression)) { bool flag3 = true; CalcArrayExpression dataReference = this.DataSeries.DataReference as CalcArrayExpression; if (dataReference.ArrayValue != null) { int length = dataReference.ArrayValue.Length; for (int k = 0; k < length; k++) { T local2 = this.ConvertValue(k, dataReference.ArrayValue.GetValue(k)); if (flag3 && !(local2 is DateTime)) { flag3 = false; } list.Add(local2); } } base.items.Clear(); base.items.AddRange((IEnumerable <T>)list); if ((flag3 != this.IsDateTimeSeries) && (base.items.Count > 0)) { this.IsDateTimeSeries = flag3; } } else if ((this.DataSeries != null) && (this.DataSeries.DataReference is CalcConstantExpression)) { CalcConstantExpression expression2 = this.DataSeries.DataReference as CalcConstantExpression; T local3 = this.ConvertValue(0, expression2.Value); base.items.Clear(); base.items.Add(local3); bool flag4 = local3 is DateTime; if (flag4 != this.IsDateTimeSeries) { this.IsDateTimeSeries = flag4; } } else { base.items.Clear(); this.IsDateTimeSeries = false; } }
/// <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 object.</param> /// <returns>Returns an icon object.</returns> public override object Evaluate(ICalcEvaluator evaluator, int baseRow, int baseColumn, IActualValue actual) { object obj2 = actual.GetValue(baseRow, baseColumn); if (obj2 == null) { return(null); } double num = 0.0; if (!FormatConverter.IsNumber(obj2)) { return(null); } double?nullable = FormatConverter.TryDouble(obj2, false); if (!nullable.HasValue) { return(null); } num = nullable.Value; int num2 = 0; if ((this.iconSetType >= Dt.Cells.Data.IconSetType.ThreeArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.ThreeSymbolsUncircled)) { num2 = 3; } else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FourArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FourTrafficLights)) { num2 = 4; } else if ((this.iconSetType >= Dt.Cells.Data.IconSetType.FiveArrowsColored) && (this.iconSetType <= Dt.Cells.Data.IconSetType.FiveBoxes)) { num2 = 5; } if (this.iconCriteria == null) { return((int)0); } double maxValue = double.MaxValue; for (int i = num2 - 1; i > 0; i--) { if (i >= (this.iconCriteria.Length + 1)) { return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly)); } IconCriterion criterion = this.iconCriteria[i - 1]; if ((criterion == null) || (criterion.Value == null)) { return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly)); } double?nullable2 = this.GetActualValue(evaluator, baseRow, baseColumn, i - 1, actual); if (!nullable2.HasValue) { return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly)); } if (criterion.IsGreaterThanOrEqualTo) { if ((num < maxValue) && (num >= nullable2.Value)) { return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(i), this.showIconOnly)); } } else if ((num < maxValue) && (num > nullable2.Value)) { return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(i), this.showIconOnly)); } } return(new IconDrawingObject(baseRow, baseColumn, this.iconSetType, this.modifyIconIndex(0), this.showIconOnly)); }