Пример #1
0
 private static void ChangeState(bool isChecked, DirectoryEntry dir)
 {
     dir.IsIncluded = !dir.IsDirectory && isChecked;
     foreach (var subDirectory in dir.Entries) {
         var subDir = subDirectory as DirectoryEntry;
         if(subDir != null)
             ChangeState(isChecked, subDir);
     }
 }
Пример #2
0
        public static DirectoryEntry BuildHeirarchy(string startingDirectory, IDictionary<string, Directory> directories)
        {
            var directory = new DirectoryInfo(startingDirectory);
            var myEntry = new DirectoryEntry
            {
                Name = directory.Name,
                Path = directory.FullName
            };
            if (directories.ContainsKey(startingDirectory))
                foreach (var entry in directories[startingDirectory].Entries)
                    myEntry.Entries.Add(entry);

            foreach (var subdir in directory.GetDirectories()) {
                if (directories.ContainsKey(subdir.FullName)) {
                    myEntry.Entries.Add(directories[subdir.FullName]);
                }
                else if (directories.ContainsKey(subdir.FullName.Substring(subdir.FullName.IndexOf(':') + 1))) {
                    myEntry.Entries.Add(directories[subdir.FullName.Substring(subdir.FullName.IndexOf(':') + 1)]);
                }
            }
            return myEntry;
        }