예제 #1
0
        private void RuleRibbonToggleButton_PressedButtonChanged(object sender, EventArgs e)
        {
            if (!(sender is RibbonToggleButton pressedRule))
            {
                return;
            }

            string ruleName = pressedRule.Text;
            bool   pressed  = pressedRule.Pressed;

            IRule newRule = _rules.Where(x => x.Name == ruleName).FirstOrDefault();

            newRule.AppliesTo.Add(new FieldRange(new string[] { "Product", "Country", "Color", "Discount" }));

            RuleCollection appliedRules = _rulesManager.Rules;
            IRule          existingRule = appliedRules.Where(x => x.Name == ruleName).FirstOrDefault();

            if (!pressed && appliedRules.Contains(existingRule))
            {
                appliedRules.Remove(existingRule);
            }
            if (pressed && existingRule is null)
            {
                appliedRules.Add(newRule);
            }
        }
예제 #2
0
 internal void ProcessRuleChange(SingleRule newRule, bool added)
 {
     if (added && !rules.Contains(newRule))
     {
         rules.Add(newRule);
     }
     else if (!added && rules.Contains(newRule))
     {
         rules.Remove(newRule);
     }
     gridController.ActiveRules = rules;
 }