Exemple #1
0
 public void RemSection(PySection sec)
 {
     _children.Remove(sec);
     Size -= sec.Size;
 }
Exemple #2
0
 public void AddSection(PySection sec)
 {
     _children.Add(sec);
     Size += sec.Size;
 }
Exemple #3
0
 public void RenderSection(StringCollection box, PySection section)
 {
     if (section.Name != "")
     {
         InsertToPos(box, section.Begin, "# --- " + section.Name + " : begin ---\n");
     }
     if (section.Children.Count == 0)
     {
         int cnt = 0;
         foreach (string it in section.Lines)
         {
             InsertToPos(box, section.Begin + cnt, it + "\n");
             cnt++;
         }
     } else {
         int cnt = 0;
         foreach (string it in section.Lines)
         {
             InsertToPos(box, section.Begin + cnt, it + "\n");
             cnt++;
         }
         foreach (PySection sec in section.Children)
         {
             RenderSection(box, sec);
         }
     }
     if (section.Name != "")
     {
         InsertToPos(box, section.Begin, "# --- " + section.Name + " : end ---\n");
     }
 }
Exemple #4
0
 public void ParseFile(string filename)
 {
     _t = File.OpenText(filename);
     StringCollection coll = new StringCollection();
     _main = new PySection("");
     while (!_t.EndOfStream)
     {
         coll.Add(_t.ReadLine());
     }
     ParseFileSection(coll, _main, 0);
 }
Exemple #5
0
 public int ParseFileSection(StringCollection sec, PySection section, int row)
 {
     // sec collection, doesn't contain # --- begin / # --- end
     int count = row;
     bool insection = false;
     StringCollection tempc = new StringCollection();
     foreach (string item in sec)
     {
         if (insection == true)
         {
             if (item.Contains("# ---") && item.Contains("end"))
             {
                 insection = false;
                 string nn = item.Substring(6, item.IndexOf(':') - 6);
                 section.Children.Add(new PySection(nn.Trim()));
                 PySection child = (PySection)section.Children[section.Children.Count - 1];
                 child.Begin = count;
                 int cnt = ParseFileSection(tempc, child, count);
                 child.Size = cnt - child.Begin;
             } else {
                 string debugstr = sec[count];
                 tempc.Add(debugstr);
             }
         }
         else if (item.Contains("# ---") && item.Contains("begin"))
         {
             // begin a new section
             insection = true;
             tempc.Clear();
         }
         else if (item.Contains("# ---") && item.Contains("end"))
         {
             // something to do here?
             insection = false;
         }
         else
         {
             section.Lines.Add(item);
         }
         count++;
     }
     return row;
 }