void Project_ItemRemoved(Project sender, ProjectItem removedItem, ProjectItem itemParent) { TreeNode node = FindItem(delegate(ProjectItem item) { return item == removedItem; }); if (node != null) node.Parent.Nodes.Remove(node); }
void Project_ItemRenamed(Project sender, ProjectItem changedItem) { TreeNode node = FindItem( delegate(ProjectItem item) { return item == changedItem; } ); if (node != null) UpdateNode(node); }
public ProjectItem() { mProjectTag = null; mParent = null; mItems = new ProjectItemCollection(this); }
void Project_ItemAdded(Project sender, ProjectItem addedItem) { TreeNode parent = FindItem(delegate(ProjectItem item) { return item == addedItem.Parent; }); if (parent != null) { TreeNode newNode = CreateNode(addedItem); UpdateNodeImage(newNode); int index = addedItem.Parent.Items.IndexOf(addedItem); parent.Nodes.Insert(index, newNode); UpdateTree(newNode, addedItem); projectView.SelectedNode = newNode; newNode.EnsureVisible(); } }
void Project_ItemRemoved(Project sender, ProjectItem removedItem, ProjectItem itemParent) { UpdateFileList(sender); }
internal void OnItemRenamed(ProjectItem item) { if (ItemRenamed != null) ItemRenamed(this, item); }
private void AddProjectDocument(ProjectDocument doc, ProjectDocument parentDoc, ProjectItem parentItem) { doc.PropertyChange += new PropertyChangeEventHandler(ProjectDocument_PropertyChange); doc.Loading += new DocumentLoadingEventHandler(ProjectDocument_Loading); doc.Loaded += new DocumentLoadedEventHandler(ProjectDocument_Loaded); if (parentDoc == null) mRootDocument = doc; else parentDoc.Imports.Add(doc); parentItem.Items.Add(doc.Root); }
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); }
/// <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; }
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; }
private Folder FindFolderRecursive(ProjectItem root, string label) { if (root is Folder && ((Folder)root).Label == label) return (Folder) root; else { foreach(ProjectItem item in root.Items) { Folder result = FindFolderRecursive(item, label); if (result != null) return result; } } return null; }
private void UpdateFileList(Project project, ProjectItem root) { foreach(ProjectItem item in root.Items) { if(item is DocumentItem) { AddFile(project, item as DocumentItem); } UpdateFileList(project, item); } }
void Project_ItemAdded(Project sender, ProjectItem addedItem) { UpdateFileList(sender); }
private TreeNode CreateNode(ProjectItem item) { TreeNode node = new TreeNode(item.Label); node.Tag = item; node.ImageIndex = -1; UpdateNode(node); return node; }
private void SaveProjectTree(XmlElement rootElement, ProjectItem rootItem) { foreach (ProjectItem item in rootItem.Items) { XmlElement element = rootElement.OwnerDocument.CreateElement("Item"); element.SetAttribute("type", item.GetType().Name); rootElement.AppendChild(element); SaveProjectTree(element, item); } }
private void UpdateTree(TreeNode rootnode, ProjectItem rootitem) { foreach (ProjectItem item in rootitem.Items) { TreeNode node = CreateNode(item); if (rootnode == null) projectView.Nodes.Add(node); else rootnode.Nodes.Add(node); UpdateTree(node, item); } }
internal void OnItemRemoved(ProjectItem item, ProjectItem parent) { if (Loading) return; ProjectDocument projDoc = parent.ProjectDocument; if (projDoc != null && projDoc.ReadOnly) throw new ReadOnlyDocumentException(projDoc); if (ItemRemoved != null) ItemRemoved(this, item, parent); if (projDoc != null) projDoc.Modified = true; }
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 abstract void AddDocument(ProjectItem folder, DocumentItem doc);