Exemplo n.º 1
0
 public AFPTreeView(List <AFPDataLine> dl)
 {
     Nodes = new List <AFPNode>();
     for (int j = 0; j < dl.Count;)
     {
         // Skip all No Operations
         if (dl[j].SFICode == "NOP")
         {
             j++;
             continue;
         }
         // If current line SFI matches a start tag, build into interior list
         if (AFPFile.StandardFieldElementPairs.ContainsKey(dl[j].SFICode))
         {
             // Add Current line as Node
             AFPNode newNode = new AFPNode(dl[j]);
             // Pass in list and index for next creation as children
             int index;
             newNode.Children = AFPNode.BuildChildGroup(dl, j + 1, dl[j].SFICode, out index);
             Nodes.Add(newNode);
             j = index;
         }
         else
         {
             Nodes.Add(new AFPNode(dl[j]));
             j++;
         }
     }
 }
Exemplo n.º 2
0
        private TreeNode AddChildNodes(TreeNode tn, AFPNode child)
        {
            TreeNode tnx = tn.Nodes.Add(child.Name);

            tnx.Tag = child.Data;
            if (child.Children != null)
            {
                foreach (AFPNode ch in child.Children)
                {
                    tnx = AddChildNodes(tnx, ch);
                }
            }

            return(tn);
        }
Exemplo n.º 3
0
        public static List <AFPNode> BuildChildGroup(List <AFPDataLine> dl, int sIndex, string SFI, out int index)
        {
            index = 0;
            string         EndKey = AFPFile.StandardFieldElementPairs[SFI];
            List <AFPNode> Nodes  = new List <AFPNode>();

            for (int i = sIndex; i < dl.Count;)
            {
                // Skip all No Operations
                if (dl[i].SFICode == "NOP")
                {
                    i++;
                    continue;
                }

                if (dl[i].SFICode == EndKey)
                {
                    Nodes.Add(new AFPNode(dl[i]));
                    i++;
                    index = i;
                    break;
                }
                // If current line SFI matches a start tag, build into interior list
                else if (AFPFile.StandardFieldElementPairs.ContainsKey(dl[i].SFICode))
                {
                    // Add Current line as Node
                    AFPNode newNode = new AFPNode(dl[i]);
                    // Pass in list and index for next creation as children
                    newNode.Children = BuildChildGroup(dl, i + 1, dl[i].SFICode, out index);
                    Nodes.Add(newNode);
                    i = index;
                }
                else
                {
                    Nodes.Add(new AFPNode(dl[i]));
                    i++;
                }
            }

            return(Nodes);
        }