Exemplo n.º 1
0
        private bool InsertCommandIntoPropertyNode(TreeNodeData currentNodeData, PropertyInfo property, Command newCommand)
        {
            if (IsEmptyProperty(currentNodeData, property))
            {
                return(ReplaceCommandIntoProperty(currentNodeData, newCommand));
            }
            if (IsEnumerableProperty(currentNodeData, property))
            {
                CommandTreeNode node = currentNodeData.Node;
                if (currentNodeData.Property == null || currentNodeData.Property != property)
                {
                    IEnumerable <CommandTreeNode> childs = currentNodeData.Node.Childs;
                    node = childs.Where(c => c.Data.Property == property).FirstOrDefault();
                }
                AppendCommandAfter(node, newCommand, null);
                return(true);
            }
            else
            {
                AppendNodeType appendType = AskUserToDo();
                switch (appendType)
                {
                case AppendNodeType.Append:
                    CommandTreeNode sequenceTreeNode = IntermediateWithSequence(currentNodeData);
                    AppendCommandAfter(sequenceTreeNode, newCommand, null);
                    return(true);

                case AppendNodeType.Replace:
                    return(ReplaceCommandIntoProperty(currentNodeData, newCommand));
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private AppendNodeType AskUserToDo()
        {
            AppendNodeType         appendType = AppendNodeType.Nothing;
            AppendTreeViewNodeForm form       = new AppendTreeViewNodeForm();

            if (form.ShowDialog() == DialogResult.OK)
            {
                appendType = form.CustomDialogResult;
            }
            return(appendType);
        }