Exemplo n.º 1
0
        void AddColorScaleFormatCondition()
        {
            ColorScaleFormatCondition condition = new ColorScaleFormatCondition();

            condition.FieldName            = "Total";
            condition.PredefinedFormatName = "RedYellowGreenColorScale";
            formats.Add("Totals Color Scale", condition);
        }
 void AddColorScaleFormatCondition() {
     ColorScaleFormatCondition condition = new ColorScaleFormatCondition();
     condition.FieldName = "Total";
     condition.PredefinedFormatName = "RedYellowGreenColorScale";
     formats.Add("Totals Color Scale", condition);
 }
        private void CollectionModify(StyleOption styleOption)
        {
            if (styleOption == null)
            {
                return;
            }

            FormatConditionBase formatCondition = null;

            Func <TopBottomRule, FormatConditionBase> createTopBottomRuleFormatConditionHandler = rule =>
            {
                var result = new TopBottomRuleFormatCondition();
                var format = CreateFormat(styleOption);
                if (format != null)
                {
                    result.Format = format;
                }

                result.Rule      = rule;
                result.Threshold = styleOption.Threshold;


                if (styleOption.ApplyToRow)
                {
                    result.Expression = string.Format("[{0}]", styleOption.FieldName);
                }
                else
                {
                    result.FieldName = styleOption.FieldName;
                }

                return(result);
            };

            Action <FormatConditionBase> setAnimatedFormatConditionHandler = fc =>
            {
                formatCondition                      = fc;
                formatCondition.FieldName            = styleOption.FieldName;
                formatCondition.PredefinedFormatName = styleOption.PredefinedFormatName;
            };

            switch (styleOption.FormatConditionType)
            {
            case FormatConditionType.Default:
                var condition = new FormatCondition();
                var format    = CreateFormat(styleOption);
                if (format != null)
                {
                    condition.Format = format;
                }

                formatCondition            = condition;
                formatCondition.FieldName  = styleOption.ApplyToRow ? null : styleOption.FieldName;
                formatCondition.Expression = styleOption.ExpressionString;
                break;

            case FormatConditionType.TopItemsRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.TopItems);
                break;

            case FormatConditionType.TopPersentRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.TopPercent);
                break;

            case FormatConditionType.BottomItemsRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.BottomItems);
                break;

            case FormatConditionType.BottomPercentRule:
                formatCondition = createTopBottomRuleFormatConditionHandler(TopBottomRule.BottomPercent);
                break;

            case FormatConditionType.AboveAverageRule:
                //Не работает
                styleOption.ApplyToRow = false;
                formatCondition        = createTopBottomRuleFormatConditionHandler(TopBottomRule.AboveAverage);
                break;

            case FormatConditionType.BelowAverageRule:
                //Не работает
                styleOption.ApplyToRow = false;
                formatCondition        = createTopBottomRuleFormatConditionHandler(TopBottomRule.BelowAverage);
                break;

            case FormatConditionType.DataBar:
                var dataBarCondition = new DataBarFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(dataBarCondition);
                break;

            case FormatConditionType.ColorScale:
                var colorScaleCondition = new ColorScaleFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(colorScaleCondition);
                break;

            case FormatConditionType.IconSet:
                var iconSetCondition = new IconSetFormatCondition();
                //Необходимо специальное форматирование для этого свойства.
                setAnimatedFormatConditionHandler(iconSetCondition);
                break;

            default:
                throw new DeveloperException("Undefined FormatConditionType '{0}'.", styleOption.FormatConditionType);
            }

            if (formatCondition != null)
            {
                View.AddFormatCondition(formatCondition);
            }
        }