Exemplo n.º 1
0
        private void LoadModules()
        {
            string MainPath = Path.GetFullPath(Path.Combine(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), ".."), ".."));

            MainNode = new TTreeNode(Text, Path.Combine(MainPath, "MainDemo"));

            string[] subdirectoryEntries = Directory.GetDirectories(Path.Combine(MainPath, "Modules"));
            foreach (string subdirectory in subdirectoryEntries)
            {
                LoadModule(Path.Combine(MainPath, "Modules"), subdirectory, MainNode);
            }
        }
Exemplo n.º 2
0
 private void FilterTree(Dictionary <string, string> FoundModules, TTreeNode ParentNode, TreeNode ParentTreeNode, string OldSelectedPath, ref TreeNode NewSelected)
 {
     foreach (TTreeNode node in ParentNode.Children)
     {
         if (FoundModules == null || HasKey(FoundModules, Path.GetDirectoryName(node.NodePath)))
         {
             TreeNode NewNode = new TreeNode(node.NodeName);
             NewNode.Tag = node.NodePath;
             ParentTreeNode.Nodes.Add(NewNode);
             FilterTree(FoundModules, node, NewNode, OldSelectedPath, ref NewSelected);
             if (node.NodePath == OldSelectedPath)
             {
                 NewSelected = NewNode;
             }
         }
     }
 }
Exemplo n.º 3
0
        private void LoadModule(string MainPath, string modulePath, TTreeNode node)
        {
            string LinkFile = Path.Combine(modulePath, "link.txt");

            if (File.Exists(LinkFile))
            {
                using (StreamReader sr = new StreamReader(LinkFile))
                {
                    string RelPath = sr.ReadLine().Replace('\\', Path.DirectorySeparatorChar);
                    modulePath = Path.GetFullPath(Path.Combine(MainPath, RelPath));
                }
            }

            string moduleName  = Path.GetFileName(modulePath);
            string shortModule = moduleName.Substring(moduleName.IndexOf(".") + 1);

            if (moduleName.Length < 1 || moduleName[0] == '.')
            {
                return;                                                //Do not process hidden folders.
            }
            if (moduleName.IndexOf('.') < 1)
            {
                return;                              //Do not process folders without the convention xx.name
            }
            string NodePath = null;

            if (File.Exists(Path.Combine(modulePath, shortModule + ".rtf")))
            {
                NodePath = Path.Combine(modulePath, shortModule);
            }

            TTreeNode NewNode = new TTreeNode(shortModule, NodePath);

            node.Children.Add(NewNode);


            string[] subdirectoryEntries = Directory.GetDirectories(modulePath);
            foreach (string subdirectory in subdirectoryEntries)
            {
                LoadModule(MainPath, subdirectory, NewNode);
            }
        }