コード例 #1
0
    /// <summary>
    /// Adds a clause according to selected item.
    /// </summary>
    private void AddClause()
    {
        MacroRuleInfo rule = MacroRuleInfo.Provider.Get(ValidationHelper.GetInteger(lstRules.SelectedValue, 0));

        if (rule != null)
        {
            List <MacroRuleTree> selected = GetSelected();
            if (selected.Count == 1)
            {
                MacroRuleTree item = selected[0];
                if (item?.Parent != null)
                {
                    item.Parent.AddRule(rule, item.Position + 1);
                    return;
                }
            }

            // Add the rule at the root level, when no selected item
            RuleTree.AddRule(rule, RuleTree.Children.Count);
        }
    }