我正在尝试通过菜单查找所有已启用的 resharper 命令。我可以使用以下代码找到所有菜单项。但是我找不到如何从 DTE 命令集合中获取实际命令。
var resharper = ((CommandBars)_dte.Application.CommandBars)["RESHARPER"];
var refactor = (CommandBarPopup)resharper.Controls["&Refactor"].Control;
foreach (var c in refactor.Controls)
{
var cbb = c as CommandBarButtonClass;
if (cbb != null)
{
yield return new VoiceCommand
{
Command = _dte.Commands.Item(???),
Key = cbb.accName,
};
}
}
我应该使用什么属性来查找命令(??? 上面)?
谢谢, 埃里克
最佳答案
您想使用 CommandInfo method ,像这样:
Guid guid;
int id;
_dte.Commands.CommandInfo(cbb, out guid, out id);
yield return new VoiceCommand
{
Command = _dte.Commands.Item(guid, id),
Key = cbb.accName,
};
关于visual-studio - 如何从 Visual Studio 2012 中的 CommandBarButton 获取 EnvDTE.Command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17003364/