【问题标题】:How to get EnvDTE.Command from CommandBarButton in Visual Studio 2012如何从 Visual Studio 2012 中的 CommandBarButton 获取 EnvDTE.Command
【发布时间】:2013-06-04 21:32:44
【问题描述】:

我正在尝试通过菜单查找所有启用的 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,
        };  
    }
}

我应该使用什么属性来查找命令(上面的???)?

谢谢, 埃里克

【问题讨论】:

    标签: visual-studio visual-studio-2012 visual-studio-extensions


    【解决方案1】:

    你想使用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,
    };  
    

    【讨论】:

      猜你喜欢
      • 2013-12-07
      • 1970-01-01
      • 2013-11-30
      • 1970-01-01
      • 2017-06-12
      • 1970-01-01
      • 2014-05-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多