获取项目表单"项目"CommandBar按钮

本文关键字:quot 项目 CommandBar 按钮 项目表 获取 表单 | 更新日期: 2023-09-27 18:11:41

我正在为VS 2012开发一个插件。我在Project命令栏中添加了一个按钮和命令。

现在我在点击Project后右键菜单中有一个按钮。

我现在想做的就是列出所有的*.cs文件从该按钮被点击的项目,并有权编辑它们。

我需要的信息在"执行"功能,是"捕捉"我的命令。

怎么做?

我的代码片段:

_CommandBars cmdBars = (_CommandBars)_applicationObject.CommandBars;
CommandBar vsBarProject = cmdBars["Project"];
CommandBarPopup pluginProjectFolderPopup = (CommandBarPopup)vsBarProject.Controls.Add(MsoControlType.msoControlPopup, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);
pluginProjectFolderPopup.Caption = "Plugin";
try
{
    Command command = commands.AddNamedCommand2(_addInInstance, "TestRightClickProject", "Plugin test", "Testing right click command on code window", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
    if ((commands != null) && (pluginProjectFolderPopup != null))
    {
        command.AddControl(pluginProjectFolderPopup.CommandBar, 1);
    }
}
catch (System.ArgumentException)
{
}

更新:我没有选择。我必须使用addins

获取项目表单"项目"CommandBar按钮

看看这个问题的答案:

Visual Studio 2010插件-向解决方案资源管理器添加上下文菜单

一旦确定要选择的项目(参见

)
_applicationObject.SelectedItems.Item(1).Project

)

你可以使用projecttypes。vsProjectKindSolutionFolder获取项目文件夹(参见如何在项目下获取文件夹?)

然后遍历所需的文件夹和子文件夹。

相关文章: