Beispiel #1
0
 public void AddListToTree(TreeNode treeNode, BenList list)
 {
     if (list.isPathList_)
     {
         BenFilePath p = new BenFilePath(list);
         fileList_.Add(p);
         checkedListBox1.Items.Add(p.fileNameFull_);
     }
     foreach (IBenNode node in list.list_)
     {
         TreeNode childNode = new TreeNode();
         string noteString = string.Empty;
         if (node is BenString)
         {
             noteString = (node as BenString).value_;
             childNode.Text = noteString;
         }
         else if (node is BenInt)
         {
             noteString = (node as BenInt).value_.ToString();
             childNode.Text = noteString;
         }
         else if (node is BenDictionary)
         {
             childNode.Text = "item(d)";
             AddDictToTree(childNode, (node as BenDictionary));
         }
         else if (node is BenList)
         {
             childNode.Text = "item(l)";
             AddListToTree(childNode, (node as BenList));
         }
         treeNode.Nodes.Add(childNode);
     }
 }
Beispiel #2
0
        public BenFilePath(BenList list)
        {
            ref_ = list;
            if (!list.isPathList_)
            {
                return;
            }
            foreach (IBenNode node in list.list_)
            {
                if (node is BenString)
                {
                    fileNameFull_ += (node as BenString).value_;
                    fileNameFull_ += @"\";
                }
            }
            if (fileNameFull_ != string.Empty)
            {
                try
                {
                    fileNameFull_ = fileNameFull_.Remove(fileNameFull_.Length - 1);
                    int pos = fileNameFull_.LastIndexOf('.');
                    extName_ = fileNameFull_.Substring(pos, fileNameFull_.Length - pos);
                }
                catch (System.Exception ex)
                {

                }

            }
        }
Beispiel #3
0
 public static IBenNode NextNote(Bencoder file)
 {
     IBenNode node = null;
     char key = file.ReadChar();
     switch (key)
     {
         case '0':
         case '1':
         case '2':
         case '3':
         case '4':
         case '5':
         case '6':
         case '7':
         case '8':
         case '9':
             string stringLen = string.Empty;
             char c = key;
             while (c != ':')
             {
                 stringLen += c.ToString();
                 c = file.ReadChar();
             }
             BenString benString = new BenString(System.Int32.Parse(stringLen));
             benString.Decode(file);
             node = benString;
             break;
         case 'i':
             BenInt i = new BenInt();
             i.Decode(file);
             node = i;
             break;
         case 'd':
             BenDictionary dict = new BenDictionary();
             dict.Decode(file);
             node = dict;
             break;
         case 'l':
             BenList list = new BenList();
             list.Decode(file);
             node = list;
             break;
     }
     return node;
 }