private void AddDiscountRule(Worksheet sheet)
        {
            ConditionalFormattingDxfRule discountRule = null;

            switch (this.SelectedDiscountComparison)
            {
            case DiscountComparison.GreaterThan:
                discountRule = new GreaterThanRule(this.discountThreshold.ToString());
                break;

            case DiscountComparison.GreaterThanOrEqual:
                discountRule = new GreaterThanOrEqualToRule(this.discountThreshold.ToString());
                break;

            case DiscountComparison.LessThan:
                discountRule = new LessThanRule(this.discountThreshold.ToString());
                break;

            case DiscountComparison.LessThanOrEqual:
                discountRule = new LessThanOrEqualToRule(this.discountThreshold.ToString());
                break;
            }

            discountRule.Formatting = new DifferentialFormatting();
            ThemableColor fillColor = new ThemableColor(Telerik.Documents.Media.Color.FromArgb(255, 198, 239, 206));
            ThemableColor foreColor = new ThemableColor(Telerik.Documents.Media.Color.FromArgb(255, 0, 97, 0));

            discountRule.Formatting.ForeColor = foreColor;
            discountRule.Formatting.Fill      = new PatternFill(PatternType.Solid, fillColor, fillColor);

            sheet.Cells[3, 5, 48, 5].AddConditionalFormatting(new Telerik.Windows.Documents.Spreadsheet.Model.ConditionalFormatting(discountRule));
        }
示例#2
0
        public void BetweenValueUnderLowEndReturnsFalse()
        {
            var rule = new LessThanRule(1, 0, 3);

            JsonAssert.IsFalse(rule.Apply());
        }
示例#3
0
        public void BetweenValueAtHighEndReturnsFalse()
        {
            var rule = new LessThanRule(1, 3, 3);

            JsonAssert.IsFalse(rule.Apply());
        }
示例#4
0
        public void LessThanNullThrowsError()
        {
            var rule = new LessThanRule(LiteralRule.Null, 2);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }
示例#5
0
        public void BetweenValueInRangeReturnsTrue()
        {
            var rule = new LessThanRule(1, 2, 3);

            JsonAssert.IsTrue(rule.Apply());
        }
示例#6
0
        public void LessThanArrayThrowsError()
        {
            var rule = new LessThanRule(new JsonElement[] {}.AsJsonElement(), 2);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }
示例#7
0
        public void LessThanObjectThrowsError()
        {
            var rule = new LessThanRule(JsonDocument.Parse("{}").RootElement, 2);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }
示例#8
0
        public void LessThanBooleanThrowsError()
        {
            var rule = new LessThanRule(false, 2);

            JsonAssert.IsTrue(rule.Apply());
        }
示例#9
0
        public void LessThanStringThrowsError()
        {
            var rule = new LessThanRule("foo", 2);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }
示例#10
0
        public void LessThanTwoNumbersReturnsFalse()
        {
            var rule = new LessThanRule(3, 2);

            JsonAssert.IsFalse(rule.Apply());
        }
示例#11
0
        public void EqualTwoNumbersReturnsFalse()
        {
            var rule = new LessThanRule(1, 1);

            JsonAssert.IsFalse(rule.Apply());
        }
示例#12
0
        public void BetweenHighEndNotNumberThrowsError()
        {
            var rule = new LessThanRule(1, 2, false);

            Assert.Throws <JsonLogicException>(() => rule.Apply());
        }