private void OnRuleAdded(object sender, MatchingRuleEventArgs e)
        {
            MatchingRule rule     = e.Rule;
            var          flatList = (ObservableCollection <MatchingRule>) this.FlatListBox.ItemsSource;

            if (flatList.All(r => r.RuleId != rule.RuleId))
            {
                flatList.Add(rule);
            }

            var groupedList            = (ObservableCollection <RulesGroupedByBucket>) this.GroupedByListBox.ItemsSource;
            RulesGroupedByBucket group = groupedList.SingleOrDefault(g => g.Bucket == rule.Bucket);

            if (group == null)
            {
                group = new RulesGroupedByBucket(rule.Bucket, new[] { rule });
                groupedList.Add(group);
            }

            if (group.Rules.All(r => r.RuleId != rule.RuleId))
            {
                group.Rules.Add(rule);
            }
        }
        private void OnRuleAdded(object sender, MatchingRuleEventArgs e)
        {
            MatchingRule rule = e.Rule;
            var flatList = (ObservableCollection<MatchingRule>)this.FlatListBox.ItemsSource;
            if (flatList.All(r => r.RuleId != rule.RuleId))
            {
                flatList.Add(rule);
            }

            var groupedList = (ObservableCollection<RulesGroupedByBucket>)this.GroupedByListBox.ItemsSource;
            RulesGroupedByBucket group = groupedList.SingleOrDefault(g => g.Bucket == rule.Bucket);
            if (group == null)
            {
                group = new RulesGroupedByBucket(rule.Bucket, new[] { rule });
                groupedList.Add(group);
            }

            if (group.Rules.All(r => r.RuleId != rule.RuleId))
            {
                group.Rules.Add(rule);
            }
        }