// Get Node using CotnentElement addressing public ArchiveNode GetNode(string contentElement) // String inclue [] so strip it first { string address = contentElement.Substring(1, contentElement.Length - 2); // Get actual address string[] nodeNames = address.Split(new char[] { '/' }); // Get name of each node // Iterate to find node List <ArchiveNode> children = Roots; ArchiveNode node = null; foreach (string name in nodeNames) { bool bFound = false; foreach (ArchiveNode child in children) { if (child.Name == name) { node = child; bFound = true; break; } } if (bFound == true) { children = node.Children; } else { return(null); } } return(node); }
public string GetNodeCEA(ArchiveNode node) { if (node.Parent != null) { return(GetNodeCEA(node.Parent) + '/'); // Notice CEA is in linux format } else { return(node.Name); } }
public ArchiveNode AddRootNode(string nodeName) { ArchiveNode newNode = new ArchiveNode(nodeName, this); Roots.Add(newNode); // Request saving bDirty = true; return(newNode); }
/// <summary> /// Generate a new ArchiveNode, optionally with a parent and a Document reference to establish a link /// An ArchiveNode can represent both a file and a folder, if it doesn't have any children then it's a file /// </summary> /// <param name="name"></param> /// <param name="parent"></param> /// <param name="docRef"></param> public ArchiveNode(string name, Archive owner, ArchiveNode parent = null) { Owner = owner; _Name = name; Parent = parent; if (owner.IsReal == false) { _Children = new List <ArchiveNode>(); } else { _Children = null; } _Text = string.Empty; }
public ArchiveNode AddNode(string name = DefaultArchiveNodeName, Document docRef = null) { ArchiveNode newNode = new ArchiveNode(name, Owner, this); // If it's real we add a new folder bearing the node's name, otherwise we just create a virtual node if (_Children == null) { System.IO.Directory.CreateDirectory(newNode.GetPath()); } else { if (docRef != null) { newNode.Link = "ID" + docRef.GUID; // Owner.AddLink(this); // Record an external ref; Not used } Children.Add(newNode); } return(newNode); }
// Create VA from VW public Archive(VirtualWorkspace vw) : base(DocumentType.VirtualArchive, null, vw.Name, vw.CreationDate) { IsReal = false; Roots = new List <ArchiveNode>(); ArchiveNode rootNode = new ArchiveNode(vw.Name, this); Roots.Add(rootNode); // Populate contents Home home = (App.Current as App).CurrentHome; for (int i = 0; i < vw.Pages.Count; i++) { ArchiveNode child = rootNode.AddNode("Page " + i); foreach (DocumentIcon docIcon in vw.Pages[i].Documents) { Document doc = home.GetDocument(docIcon.DocumentID); child.AddNode(doc.Name, doc); } } // Request saving bDirty = true; }