Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
		public DocumentView ShowDocument(DocumentItem docItem)
		{
			return ShowDocument(docItem.AbsoluteFileName);
		}
Exemplo n.º 3
0
		public Document OpenDocument(DocumentItem docItem)
		{
			return OpenDocument(docItem.AbsoluteFileName, docItem.DocumentType);
		}
Exemplo n.º 4
0
		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);
				}
			}
		}
Exemplo n.º 5
0
		public override void RemoveDocument(DocumentItem doc)
		{
			XmlElement folderElement = (XmlElement)((XmlElement)doc.ProjectTag).ParentNode;
			folderElement.RemoveChild((XmlElement)doc.ProjectTag);
		}
Exemplo n.º 6
0
		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);
		}
Exemplo n.º 7
0
		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);
		}
Exemplo n.º 8
0
		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;
		}
Exemplo n.º 9
0
		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;
		}
Exemplo n.º 10
0
		/// <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;
		}
Exemplo n.º 11
0
		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);
		}
Exemplo n.º 12
0
		public abstract void RemoveDocument(DocumentItem doc);
Exemplo n.º 13
0
		public abstract void AddDocument(ProjectItem folder, DocumentItem doc);