Example #1
0
 public void _print(ProtocolNode_old node)
 {
     foreach (ProtocolNode_old n in node.NodeList)
     {
         print(n);
         _print(n);
     }
 }
Example #2
0
        public ProtocolNode_old getNode(int id)
        {
            ProtocolNode_old node = null;

            _getNode(mNode, id);
            node      = foundNode;
            foundNode = null;
            return(node);
        }
Example #3
0
 public bool deleteNode(ProtocolNode_old childNode)
 {
     if (childNode == null || !childNode.IsLeaf || childNode.Equals(mNode))
     {
         System.Console.WriteLine("Cant delete a nonLeaf node or root node");
         return(false);
     }
     _deleteNode(mNode, childNode);
     return(true);
 }
Example #4
0
 private void _getNode(ProtocolNode_old node, int id)
 {
     foreach (ProtocolNode_old n in node.NodeList)
     {
         if (n.Id == id)
         {
             foundNode = n;
             break;
         }
         _getNode(n, id);
     }
 }
Example #5
0
 private void _deleteNode(ProtocolNode_old parentNode, ProtocolNode_old childNode)
 {
     foreach (ProtocolNode_old n in parentNode.NodeList)
     {
         if (parentNode.NodeList.Contains(childNode))
         {
             parentNode.NodeList.Remove(childNode);
             break;
         }
         _deleteNode(n, childNode);
     }
 }
Example #6
0
 private void _insertChild(ProtocolNode_old parentNode, ProtocolNode_old childNode)
 {
     foreach (ProtocolNode_old n in parentNode.NodeList)
     {
         if (n.Equals(childNode))
         {
             childNode.NodeList.Add(mNewNode);
             break;
         }
         _insertChild(n, childNode);
     }
 }
Example #7
0
        public void addSection(string text)
        {
            ProtocolNode_old sectionNode = new ProtocolNode_old(new Element());

/*            sectionNode.Element.GotoSection = "0";*/
            sectionNode.Element.Text = text;
            sectionNode.IsSection    = true;
            mNode.NodeList.Add(sectionNode);
            ProtocolNode_old newNode = new ProtocolNode_old(new Element());

            newNode.Element.Text = "New Node";
            sectionNode.NodeList.Add(newNode);
        }
Example #8
0
        private static void processNewNode(string nodeText, string gotoSection, List <string> subTextList, ProtocolNode_old node)
        {
            if (node == null)
            {
                node = new ProtocolNode_old(new Element());
            }
            node.Element.Text = nodeText;
/*	            node.Element.GotoSection = gotoSection;*/

            if (subTextList != null)
            {
                node.Element.SubTextList = subTextList;
            }
        }
Example #9
0
        private void print(ProtocolNode_old node)
        {
            string str = node.Id.ToString() + " ";
            string tab = "";

            for (int i = 0; i < node.Depth; i++)
            {
                tab += "\t";
            }
            System.Console.WriteLine(str + tab + node.Element.Text);
//             foreach(string gotostr in node.Element.GotoList)
//             {
//                 System.Console.WriteLine(tab + gotostr);
//             }
            foreach (string subString in node.Element.SubTextList)
            {
                System.Console.WriteLine(tab + subString);
            }
        }
Example #10
0
 private void _insertSibling(ProtocolNode_old siblingNode, ProtocolNode_old curNode)
 {
     foreach (ProtocolNode_old n in siblingNode.NodeList)
     {
         if (n.NodeList.Contains(curNode))
         {
             int index = n.NodeList.IndexOf(curNode);
             if (index == n.NodeList.Count - 1)
             {
                 n.NodeList.Add(mNewNode);
             }
             else
             {
                 n.NodeList.Insert(index + 1, mNewNode);
             }
             break;
         }
         _insertSibling(n, curNode);
     }
 }
Example #11
0
        public bool insertChild(ProtocolNode_old node, string nodeText, string gotoSection, List <string> subTextList)
        {
            if (node == null)
            {
                System.Console.WriteLine("Cant add to a null node");
                return(false);
            }
            processNewNode(nodeText, gotoSection, subTextList, mNewNode);

            if (node.Equals(mNode))
            {
                mNode.NodeList.Add(node);
            }
            else
            {
                _insertChild(mNode, node);
            }

            return(true);
        }
Example #12
0
 public bool removeSection(ProtocolNode_old sectionNode)
 {
     return(mNewNode.NodeList.Remove(sectionNode));
 }
Example #13
0
 public void insertSibling(ProtocolNode_old node, string nodeText, string gotoSection, List <string> subTextList)
 {
     processNewNode(nodeText, gotoSection, subTextList, mNewNode);
     _insertSibling(mNode, node);
 }