public virtual DocumentItem FindHierarchy(string fileName, string hierarchy) { foreach (ProjectItem item in mItems) { string newHierarchy = hierarchy; newHierarchy += item.Label; if (item.mItems.Count > 0) { newHierarchy += "/"; } if (fileName.StartsWith(newHierarchy, true, null)) { DocumentItem result = item.FindHierarchy(fileName, newHierarchy); if (result != null) { return(result); } } } return(null); }
public DocumentView ShowDocument(DocumentItem docItem) { return ShowDocument(docItem.AbsoluteFileName); }
public Document OpenDocument(DocumentItem docItem) { return OpenDocument(docItem.AbsoluteFileName, docItem.DocumentType); }
private void LoadFilesFromVCProj(XmlElement rootNode, ProjectItem rootItem) { foreach (XmlElement element in rootNode.SelectNodes("Filter|File")) { if (element.Name == "Filter") { Folder folder = new Folder(element.GetAttribute("Name")); folder.ProjectTag = element; rootItem.Items.Add(folder); LoadFilesFromVCProj(element, folder); } else if (element.Name == "File") { string fileName = element.GetAttribute("RelativePath"); DocumentItem doc = new DocumentItem(PathUtils.NormaliseFileName(fileName, BaseDirectory), Manager.FindFileDocumentType(fileName)); doc.ProjectTag = element; rootItem.Items.Add(doc); } } }
public override void RemoveDocument(DocumentItem doc) { XmlElement folderElement = (XmlElement)((XmlElement)doc.ProjectTag).ParentNode; folderElement.RemoveChild((XmlElement)doc.ProjectTag); }
public override void AddDocument(ProjectItem folder, DocumentItem fileItem) { XmlElement folderElement = (XmlElement)folder.ProjectTag; XmlElement fileElement = folderElement.OwnerDocument.CreateElement("File"); fileElement.SetAttribute("RelativePath", ".\\" + fileItem.RelativeFileName.Replace('/', '\\')); fileItem.ProjectTag = fileElement; folderElement.AppendChild(fileElement); }
public void RenameDocument(DocumentItem doc, string fileName) { Folder folder = (Folder) doc.Parent; ProjectDocument projDoc = doc.ProjectDocument; RemoveDocument(doc); doc.RelativeFileName = PathUtils.NormaliseFileName(fileName, projDoc.BaseDirectory); AddDocument(folder, doc); }
public void RemoveDocument(DocumentItem doc) { ProjectDocument projDoc = doc.ProjectDocument; if (projDoc.ReadOnly) throw new ReadOnlyDocumentException(projDoc); // Remove from the tree doc.Parent.Items.Remove(doc); // Remove from project file projDoc.RemoveDocument(doc); projDoc.Modified = true; }
public void AddDocument(ProjectItem folder, DocumentItem fileItem) { ProjectDocument projDoc = folder.ProjectDocument; if (projDoc.ReadOnly) throw new ReadOnlyDocumentException(projDoc); // Insert it into the tree folder.Items.InsertSorted(fileItem, delegate(ProjectItem lhs, ProjectItem rhs) { string lhsName = lhs is DocumentItem ? (lhs as DocumentItem).RelativeFileName : lhs.Label; string rhsName = rhs is DocumentItem ? (rhs as DocumentItem).RelativeFileName : rhs.Label; return String.Compare(lhsName, rhsName, true); }); // Add to project file projDoc.AddDocument(folder, fileItem); projDoc.Modified = true; }
/// <summary> /// Creates a DocumentItem node in the project tree. /// </summary> /// <param name="folder">ProjectItem to insert the document under.</param> /// <param name="fileName">Path to file; either absolute or relative to the folder's ProjectDocument.</param> /// <param name="fileType"></param> /// <returns></returns> public DocumentItem AddDocument(ProjectItem folder, string fileName, Type fileType) { ProjectDocument projDoc = folder.ProjectDocument; string normName = PathUtils.NormaliseFileName(fileName, projDoc.BaseDirectory); DocumentItem fileItem = new DocumentItem(normName, fileType); AddDocument(folder, fileItem); return fileItem; }
private void AddFile(Project project, DocumentItem documentItem) { ListViewItem listItem = new ListViewItem(Path.GetFileName(documentItem.RelativeFileName)); listItem.Tag = documentItem; listItem.SubItems.Add(documentItem.AbsoluteFileName); mFileItems.Add(listItem); }
public abstract void RemoveDocument(DocumentItem doc);
public abstract void AddDocument(ProjectItem folder, DocumentItem doc);