示例#1
0
		/// <summary>
		/// Update the ChildNodes after the parent node has been renamed
		/// </summary>
		/// <param name="newFileNode">The new FileNode created as part of the rename of this node</param>
		private void SetNewParentOnChildNodes(FileNode newFileNode)
		{
			foreach(HierarchyNode childNode in GetChildNodes())
			{
				childNode.Parent = newFileNode;
			}
		}
示例#2
0
		/// <summary>
		/// Rename all childnodes
		/// </summary>
		/// <param name="newFileNode">The newly added Parent node.</param>
		protected virtual void RenameChildNodes(FileNode parentNode)
		{
			foreach(HierarchyNode child in GetChildNodes())
			{
				FileNode childNode = child as FileNode;
				if(null == childNode)
				{
					continue;
				}
				string newfilename;
				if(childNode.HasParentNodeNameRelation)
				{
					string relationalName = childNode.Parent.GetRelationalName();
					string extension = childNode.GetRelationNameExtension();
					newfilename = relationalName + extension;
					newfilename = Path.Combine(Path.GetDirectoryName(childNode.Parent.GetMkDocument()), newfilename);
				}
				else
				{
					newfilename = Path.Combine(Path.GetDirectoryName(childNode.Parent.GetMkDocument()), childNode.Caption);
				}

				childNode.RenameDocument(childNode.GetMkDocument(), newfilename);

				//We must update the DependsUpon property since the rename operation will not do it if the childNode is not renamed
				//which happens if the is no name relation between the parent and the child
				string dependentOf = childNode.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon);
				if(!string.IsNullOrEmpty(dependentOf))
				{
					childNode.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, childNode.Parent.ItemNode.GetMetadata(ProjectFileConstants.Include));
				}
			}
		}
		public FileDocumentManager(FileNode node)
			: base(node)
		{
		}