private void DeleteRuleControl(SmartRuleControl rule) { int index = rule.Index; _rulePanel.Controls.Remove(rule); foreach (SmartRuleControl control in _rulePanel.Controls) { if (control.Index > index) { control.Index--; } } LayoutRuleControls(); }
private void InsertRuleControl(SmartRuleControl afterRule) { int num = afterRule.Index + 1; foreach (SmartRuleControl control in _rulePanel.Controls) { if (control.Index >= num) { control.Index++; } } SmartRuleControl value = CreateRuleControl(null, num); _rulePanel.Controls.Add(value); LayoutRuleControls(); }
private SmartRuleControl CreateRuleControl(Rule rule, int index) { SmartRuleControl newRule = new SmartRuleControl(rule, ref _nextRuleTabIndex) { Index = index }; newRule.AddButton.Click += delegate { InsertRuleControl(newRule); }; newRule.DeleteButton.Click += delegate { DeleteRuleControl(newRule); }; return(newRule); }
private void AddRuleControl(Rule rule) { SmartRuleControl value = CreateRuleControl(rule, _rulePanel.Controls.Count); _rulePanel.Controls.Add(value); }