private void UpdateBackupView() { if (_selectedBackupIndex > -1 && _backupList.Count > 0) { //Update Log display XElement backup = XElement.Load(_backupList[_selectedBackupIndex].Path); Log = (string)backup.Attribute("Log"); //Update Backup Tree View _backupTreeView.Clear(); BackupVM backupTreeItem = new BackupVM(new Backup((string)backup.Attribute("Title"))); _backupTreeView.Add(backupTreeItem); foreach (XElement dir in backup.Elements("Directory")) { DirVM dirTreeItem = new DirVM(new BackupDir((string)dir.Attribute("Name"))); backupTreeItem.Add(dirTreeItem); foreach (XElement file in dir.Elements("File")) { FileVM fileTreeItem = new FileVM(new BackupFile((string)file.Attribute("Name"),"")); dirTreeItem.Add(fileTreeItem); } } } }
public bool Remove(FileVM node) { if (node.Parent == this) { if (BackupPanelVM.curVM != null) BackupPanelVM.curVM.UpdateTrackTree(); return this.Children.Remove(node); } else return false; }
private void LoadTrackTree() { if (!File.Exists(TRACKTREE_PATH)) { XElement emptyTrackTree = new XElement("TrackTree", new XAttribute("Title", "Track Tree")); emptyTrackTree.Save(TRACKTREE_PATH); } _treeRoot = XElement.Load(TRACKTREE_PATH); _backupRoot.Children.Clear(); _backupRoot.Title = (string)_treeRoot.Attribute("Title"); foreach (XElement dir in _treeRoot.Elements("Directory")) { DirVM dirVM = new DirVM(new BackupDir((string)dir.Attribute("Name"))); _backupRoot.Add(dirVM); foreach (XElement file in dir.Elements("File")) { FileVM fileVM; if (File.Exists((string)file.Attribute("Path"))) { fileVM = new FileVM(new BackupFile((string)file.Attribute("Name"), (string)file.Attribute("Path"))); dirVM.Add(fileVM); } else { MessageBox.Show("Tracked file " + (string)file.Attribute("Path") + " can't be found!", "BackendGUI"); } } } }
public void Add(FileVM node) { this.Children.Add(node); node.Parent = this; if (BackupPanelVM.curVM != null) BackupPanelVM.curVM.UpdateTrackTree(); }