Exemple #1
0
            // -------------------------------------------------------------------
            // CopyTreeNode
            // -------------------------------------------------------------------

            public void CopyTreeNode(NTree <EventCommand> tree, NTree <EventCommand> treeToCopy)
            {
                foreach (NTree <EventCommand> childToCopy in treeToCopy.Children)
                {
                    CopyTreeNode(tree.AddChildData(childToCopy.Data.CreateCopy()), childToCopy);
                }
            }
        // -------------------------------------------------------------------
        // GetDefaultTreeConditions
        // -------------------------------------------------------------------

        public static NTree <List <object> > GetDefaultTreeConditions()
        {
            NTree <List <object> > tree = new NTree <List <object> >(new List <object>(new object[] { "" }));

            tree.AddChildData(null);

            return(tree);
        }
Exemple #3
0
            // -------------------------------------------------------------------
            // GetDefaultTreeCommands
            // -------------------------------------------------------------------

            public static NTree <EventCommand> GetDefaultTreeCommands()
            {
                NTree <EventCommand> tree = new NTree <EventCommand>(null);

                tree.AddChildData(new EventCommandOther());

                return(tree);
            }
        // -------------------------------------------------------------------
        // CopyTreeNode
        // -------------------------------------------------------------------

        public void CopyTreeNode(NTree <List <object> > tree, NTree <List <object> > treeToCopy)
        {
            foreach (NTree <List <object> > childToCopy in treeToCopy.Children)
            {
                List <object> command = null;
                if (childToCopy.Data != null)
                {
                    command = new List <object>();
                    for (int i = 0; i < childToCopy.Data.Count; i++)
                    {
                        command.Add(childToCopy.Data[i]);
                    }
                }
                CopyTreeNode(tree.AddChildData(command), childToCopy);
            }
        }
        private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string previousSelecteIndex = ((ComboBoxCondition)sender).Index;
            string newSelectedIndex     = ((ComboBox)sender).SelectedItem.ToString();

            if (previousSelecteIndex != newSelectedIndex)
            {
                if ((string)Tree.Data[0] == newSelectedIndex)
                {
                    Tree.AddChildData(null);
                }
                else if ((string)Tree.Data[0] == "")
                {
                    ((ComboBoxCondition)sender).ParentNode.Data = new List <object>(new object[] { newSelectedIndex });
                    ((ComboBoxCondition)sender).ParentNode.AddChildData(null);
                }
                else
                {
                    if (TreeContainsAndOr(Tree, newSelectedIndex))
                    {
                        if (((ComboBoxCondition)sender).ParentNode.Data.Count == 1 && (string)((ComboBoxCondition)sender).ParentNode.Data[0] == newSelectedIndex)
                        {
                            ((ComboBoxCondition)sender).ParentNode.AddChildData(null);
                        }
                        else
                        {
                            List <object> previousData = ((ComboBoxCondition)sender).Node.Data;
                            ((ComboBoxCondition)sender).Node.Data = new List <object>(new object[] { newSelectedIndex });
                            ((ComboBoxCondition)sender).Node.AddChildData(previousData);
                            ((ComboBoxCondition)sender).Node.AddChildData(null);
                        }
                    }
                    else
                    {
                        NTree <List <object> > previousTree = Tree;
                        Tree = new NTree <List <object> >(new List <object>(new object[] { newSelectedIndex }));
                        Tree.AddChild(previousTree);
                        Tree.AddChildData(null);
                    }
                }

                GeneratePanel();
            }
        }