protected virtual void RenameChildNodes(FileNode parentNode)
{
foreach(HierarchyNode child in Children)
{
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));
}
}
}