int IProjectSourceNode.ExcludeFromProject()
{
if (ProjectManager == null || ProjectManager.IsClosed)
{
return (int)OleConstants.OLECMDERR_E_NOTSUPPORTED;
}
else if (this.IsNonmemberItem)
{
return VSConstants.S_OK; // do nothing, just ignore it.
}
//using ( WixHelperMethods.NewWaitCursor() )
//{
// Check out the project file.
if (!ProjectManager.QueryEditProjectFile(false))
{
throw Marshal.GetExceptionForHR(VSConstants.OLE_E_PROMPTSAVECANCELLED);
}
// remove children, if any, before removing from the hierarchy
for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
{
IProjectSourceNode node = child as IProjectSourceNode;
if (node != null)
{
int result = node.ExcludeFromProject();
if (result != VSConstants.S_OK)
{
return result;
}
}
}
if (ProjectManager != null && ProjectManager.ShowAllFilesEnabled && Directory.Exists(this.Url))
{
string url = this.Url;
this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true);
this.ItemNode.RemoveFromProjectFile();
this.ItemNode = new ProjectElement(this.ProjectManager, null, true); // now we have to create a new ItemNode to indicate that this is virtual node.
this.ItemNode.Rename(url);
this.ItemNode.SetMetadata(ProjectFileConstants.Name, this.Url);
this.Redraw(UIHierarchyElements.Icon); // we have to redraw the icon of the node as it is now not a member of the project and shoul be drawn using a different icon.
}
else if (this.Parent != null) // the project node has no parentNode
{
// this is important to make it non member item. otherwise, the multi-selection scenario would
// not work if it has any parent child relation.
this.SetProperty((int)__VSHPROPID.VSHPROPID_IsNonMemberItem, true);
// remove from the hierarchy
this.OnItemDeleted();
this.Parent.RemoveChild(this);
this.ItemNode.RemoveFromProjectFile();
}
// refresh property browser...
ProjectNode.RefreshPropertyBrowser();
//}
return VSConstants.S_OK;
}