Example #1
0
        /// <summary>
        /// Recursive function to traverse the virtual directory of
        /// a flat git response files and build a visual tree component.
        /// </summary>
        /// <param name="tnRoot">Root node to base the tree on</param>
        /// <param name="list">List of files in git format</param>
        /// <param name="sortBy">File sorting order</param>
        private static void BuildTreeRecurse(TreeNode tnRoot, List <string> list, GitDirectoryInfo.SortBy sortBy)
        {
            string           rootPath = tnRoot.Tag.ToString();
            GitDirectoryInfo dir      = new GitDirectoryInfo(rootPath, list);

            GitDirectoryInfo[] dirs = dir.GetDirectories();

            foreach (GitDirectoryInfo d in dirs)
            {
                TreeNode tn = new TreeNode(d.Name);
                tn.Tag = d.FullName + Path.DirectorySeparatorChar;
                tnRoot.Nodes.Add(tn);
                BuildTreeRecurse(tn, d.List, sortBy);
            }

            GitFileInfo[] files = dir.GetFiles(sortBy);

            foreach (GitFileInfo file in files)
            {
                TreeNode tn = new TreeNode(file.Name);
                tn.Tag = file.FullName;
                tnRoot.Nodes.Add(tn);
            }
        }
Example #2
0
        /// <summary>
        /// Builds a flat list of tree nodes based on a given list of files
        /// </summary>
        /// <param name="tnRoot">Root node to build the list on</param>
        /// <param name="list">List of relative path file names</param>
        public static void BuildFileList(TreeNode tnRoot, List <string> list, GitDirectoryInfo.SortBy sortBy)
        {
            // Sort the list according to the sorting rule
            if (sortBy == GitDirectoryInfo.SortBy.Name)
            {
                list.Sort();
            }
            else
            {
                var vSort = from s in list
                            orderby Path.GetExtension(s), s ascending
                select s;

                list = vSort.ToList();
            }

            // Build a list view);
            foreach (string s in list)
            {
                TreeNode tn = new TreeNode(s);
                tn.Tag = s;
                tnRoot.Nodes.Add(tn);
            }
        }
Example #3
0
 /// <summary>
 /// Build a tree view given the list of files
 /// </summary>
 /// <param name="tnRoot">Root node to base the tree on</param>
 /// <param name="list">List of files in git format</param>
 /// <param name="sortBy">File sorting order</param>
 public static void BuildTree(TreeNode tnRoot, List <string> list, GitDirectoryInfo.SortBy sortBy)
 {
     BuildTreeRecurse(tnRoot, list, sortBy);
 }