protected override int QueryStatusOnNode(Guid cmdGroup, uint cmd, IntPtr pCmdText, ref vsCommandStatus result)
{
if(cmdGroup == VsMenus.guidStandardCommandSet97)
{
switch((VsCommands)cmd)
{
case VsCommands.Copy:
case VsCommands.Paste:
case VsCommands.Cut:
case VsCommands.Rename:
string linkPath = this.ItemNode.GetMetadata(ProjectFileConstants.Link);
if (string.IsNullOrEmpty(linkPath))
{
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
}
else
{
// disable these commands on linked items
result = vsCommandStatus.vsCommandStatusUnsupported;
return VSConstants.S_OK;
}
case VsCommands.ViewCode:
if (this.IsNonmemberItem)
result = vsCommandStatus.vsCommandStatusUnsupported;
else
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
//case VsCommands.Delete: goto case VsCommands.OpenWith;
case VsCommands.Open:
case VsCommands.OpenWith:
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
}
}
else if(cmdGroup == VsMenus.guidStandardCommandSet2K)
{
if ((VsCommands2K)cmd == VsCommands2K.INCLUDEINPROJECT)
{
// if it is a non member item node, the we support "Include In Project" command
if (IsNonmemberItem)
{
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
}
}
else if((VsCommands2K)cmd == VsCommands2K.EXCLUDEFROMPROJECT)
{
// if it is a non member item node, then we don't support "Exclude From Project" command
if (IsNonmemberItem)
{
result = vsCommandStatus.vsCommandStatusUnsupported;
return VSConstants.S_OK;
}
string linkPath = this.ItemNode.GetMetadata(ProjectFileConstants.Link);
if (string.IsNullOrEmpty(linkPath))
{
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
}
else
{
result = vsCommandStatus.vsCommandStatusUnsupported;
return VSConstants.S_OK;
}
}
if((VsCommands2K)cmd == VsCommands2K.RUNCUSTOMTOOL)
{
if(string.IsNullOrEmpty(this.ItemNode.GetMetadata(ProjectFileConstants.DependentUpon)))
{
IEnumerable<string> extenderNames = this.NodeProperties.ExtenderNames() as IEnumerable<string>;
if (extenderNames != null && extenderNames.Contains(SingleFileGeneratorNodeExtenderProvider.Name)
&& this.NodeProperties.Extender(SingleFileGeneratorNodeExtenderProvider.Name) != null)
{
result |= vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
return VSConstants.S_OK;
}
}
}
}
else
{
return (int)OleConstants.OLECMDERR_E_UNKNOWNGROUP;
}
return base.QueryStatusOnNode(cmdGroup, cmd, pCmdText, ref result);
}