private void BuildTagDataDict(FileSystemTreeNode node, Dictionary <string, FileSystemTreeNodeData> dict) { // Skip over loading nodes and nodes without a tag. if (node == null || node.Data.Type == TypeEnum.LOADING) { return; } CheckState state = GetCheckState(node); switch (state) { case CheckState.Unchecked: // If it's unchecked, ignore it and its child nodes. return; case CheckState.Checked: // If it's checked, add it and ignore its child nodes. // This means the entire folder is checked - regardless of what it contains. if (CheckedDataSource != null) { string path = node.Data.Path; FileSystemTreeNodeData match; bool found = dict.TryGetValue(path, out match); match = found ? match : node.Data; match.State = CheckState.Checked; node.Data = match; if (!dict.ContainsKey(match.Path)) { dict.Add(match.Path, match); } } else { FileSystemTreeNodeData tag = node.Data; tag.State = CheckState.Checked; if (!dict.ContainsKey(tag.Path)) { dict.Add(tag.Path, tag); } } break; case CheckState.Mixed: // Ignore it, but verify its child nodes. foreach (FileSystemTreeNode child in node.Nodes) { BuildTagDataDict(child, dict); } break; } }
private void ExpandCheckedDataSourceAddParents(Dictionary <string, FileSystemTreeNodeData> expandedDict, string path) { PathNodes nodes = new PathNodes(path); PathNode nodeParent = nodes.ParentNode; while (nodeParent != null) { EntryTreeNodeData newTag = null; switch (nodeParent.Type) { case PathNode.TypeEnum.FILE: { EntryInfo info = new EntryInfo(TypeEnum.FILE, nodeParent.Name, nodeParent.Path); newTag = new FileSystemTreeNodeData(info); newTag.State = CheckState.Mixed; break; } case PathNode.TypeEnum.FOLDER: { EntryInfo info = new EntryInfo(TypeEnum.FOLDER, nodeParent.Name, nodeParent.Path); newTag = new FileSystemTreeNodeData(info); newTag.State = CheckState.Mixed; break; } case PathNode.TypeEnum.DRIVE: { EntryInfo info = new EntryInfo(TypeEnum.DRIVE, nodeParent.Name, nodeParent.Path); newTag = new FileSystemTreeNodeData(info); newTag.State = CheckState.Mixed; break; } } if (newTag != null) { if (!expandedDict.ContainsKey(nodeParent.Path)) { expandedDict.Add(nodeParent.Path, newTag as FileSystemTreeNodeData); } } nodeParent = nodeParent.Parent; } }
// Convert collection of `FileSystemTreeView.TreeNodeTag` to `BackupPlanSourceEntry`. public static List <BackupPlanSourceEntry> ToBackupPlanSourceEntry( this Dictionary <string, FileSystemTreeNodeData> dataDict, BackupPlan plan, BackupPlanSourceEntryRepository dao) { List <BackupPlanSourceEntry> sources = new List <BackupPlanSourceEntry>(dataDict.Count); foreach (var entry in dataDict) { FileSystemTreeNodeData data = entry.Value; BackupPlanSourceEntry source = null; if (data.Id != null) { source = dao.Get(data.Id as long?); } else { source = new BackupPlanSourceEntry(); } source.BackupPlan = plan; source.Type = data.ToEntryType(); source.Path = data.Path; sources.Add(source); } return(sources); }