コード例 #1
0
        private void GetDirectories(DirectoryInfo[] subDirs, ProjectFolderNode nodeToAddTo, FitProj p)
        {
            ProjectFolderNode aNode;

            DirectoryInfo[] subSubDirs;
            foreach (DirectoryInfo subDir in subDirs)
            {
                aNode = new ProjectFolderNode()
                {
                    Text = subDir.Name
                };
                aNode.Tag  = subDir;
                subSubDirs = subDir.GetDirectories();
                if (subSubDirs.Length != 0)
                {
                    GetDirectories(subSubDirs, aNode, p);
                }
                GetFiles(subDir, aNode, p);
                nodeToAddTo.Nodes.Add(aNode);
            }
        }
コード例 #2
0
ファイル: ProjectNode.cs プロジェクト: soneek/Smash-Forge
        public void AddFolder()
        {
            int i = 0;

            foreach (TreeNode n in this.Nodes)
            {
                if (n.Text == $"NewFolder{i}")
                {
                    i++;
                }
                else
                {
                    break;
                }
            }

            string path = "";

            if (this is ProjectNode)
            {
                path = Path.Combine(Path.GetDirectoryName((((FileInfo)this.Tag).FullName)), $"NewFolder{i}");
            }
            else
            {
                path = Path.Combine((((DirectoryInfo)this.Tag).FullName), $"NewFolder{i}");
            }

            ProjectNode.Project.AddFolder(path);
            Directory.CreateDirectory(path);
            var node = new ProjectFolderNode()
            {
                Tag = new DirectoryInfo(path)
            };

            node.Text = $"NewFolder{i}";
            Nodes.Add(node);
            node.EnsureVisible();
            node.BeginEdit();
        }
コード例 #3
0
        private void GetFiles(DirectoryInfo dir, ProjectFolderNode nodeToAddTo, FitProj p)
        {
            foreach (var fileinfo in dir.GetFiles())
            {
                if (fileinfo.Name.EndsWith(".fitproj", StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }

                var child = new ProjectFileNode()
                {
                    Text = fileinfo.Name
                };
                child.Tag = fileinfo;
                foreach (var f in p.IncludedFiles)
                {
                    if (fileinfo.FullName.Contains(f.RelativePath))
                    {
                        nodeToAddTo.Nodes.Add(child);
                        break;
                    }
                }
            }
        }