C# 获取项目表单“;项目“;命令栏按钮

C# 获取项目表单“;项目“;命令栏按钮,c#,.net,add-in,visual-studio-addins,C#,.net,Add In,Visual Studio Addins,我正在为VS 2012开发一个插件。我在项目命令栏中添加了一个按钮和命令 现在,在点击Project之后,我在右键菜单中有了一个按钮 现在我只想列出单击该按钮的项目中的所有*.cs文件,并有权编辑它们 我需要在“Exec”函数中“捕获”我的命令的信息 怎么做 我的代码片段: _CommandBars cmdBars = (_CommandBars)_applicationObject.CommandBars; CommandBar vsBarProject = cmdBars["Project

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

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

现在我只想列出单击该按钮的项目中的所有
*.cs
文件,并有权编辑它们

我需要在“Exec”函数中“捕获”我的命令的信息

怎么做

我的代码片段:

_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看看这个问题的答案:

确定要选择的项目后(请参见

)

您可以使用ProjectKinds.vsProjectKindSolutionFolder获取项目文件夹(请参阅 )


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

(切线警告:VisualStudio的下一个版本(当前称为VisualStudio”14)不支持加载项。您可能需要考虑编写扩展名。)@ RigieHeunle,我没有选择。我必须使用addins
_applicationObject.SelectedItems.Item(1).Project