get_tree() public method

public get_tree ( ) : TreeView
return TreeView
Esempio n. 1
0
        public void load_dme()
        {
            if (dme_Loaded)
            {
                dirs       = new List <string>();
                dirsfull   = new Dictionary <string, string>();
                files      = new Dictionary <string, fileInfo>();
                root       = new TreeNode();
                dme_Loaded = false;
            }
            dir  = Path.GetDirectoryName(dme_path);
            root = new TreeNode(Path.GetFileNameWithoutExtension(dme_path));
            string[]    test    = File.ReadAllLines(dme_path);
            int         t_lines = test.Length;
            int         d_lines = 0;
            ProgressBar bar     = (ProgressBar)mainWindow.Controls["work_bar"];

            test = null;
            StreamReader tr = new StreamReader(dme_path);

            bar.Visible = true;
            while (tr.EndOfStream == false)
            {
                string   temp  = tr.ReadLine();
                string[] lines = temp.Split(' ');
                d_lines++;
                bar.Value = (d_lines / t_lines);
                if (lines[0] == "#include")
                {
                    string line = lines[1];
                    if (lines.Length > 2)
                    {
                        for (int i = 2; i < lines.Length; i++)
                        {
                            line += " " + lines[i];
                        }
                    }
                    line = line.Substring(1, line.Length - 2);
                    files[dir + "\\" + line] = new fileInfo(dir + '\\' + line, line);
                    System.Console.WriteLine(dir + '\\' + line);
                }
                else if (lines.Length - 1 >= 1 && lines[1] == "FILE_DIR")
                {
                    string line = lines[2];
                    if (line == ".")
                    {
                        continue;
                    }
                    if (lines.Length > 3)
                    {
                        for (int i = 3; i < lines.Length; i++)
                        {
                            line += " " + lines[i];
                        }
                    }
                    line = line.Substring(1, line.Length - 2);
                    if (line.IndexOf('/') == -1)
                    {
                        dirs.Add(line);
                        dirsfull[line] = line;
                    }
                    else
                    {
                        lines = line.Split('/');
                        dirs.Add(lines[lines.Length - 1]);
                        dirsfull[line] = lines[lines.Length - 1];
                    }
                }
            }
            popTree(dir, root);
            TreeView T = mainWindow.get_tree();

            T.Nodes.Add(root);
            dme_Loaded = true;
            tr.Close();
            save_dme();
            bar.Visible = false;
        }