【发布时间】:2014-07-07 13:38:12
【问题描述】:
我正在为 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)
{
}
更新: 我别无选择。我必须使用插件
【问题讨论】:
-
(相关警告:Visual Studio 的下一个版本(目前称为 Visual Studio “14”)不支持加载项。您可能需要考虑编写扩展程序。)
-
@RichieHindle 我别无选择。我必须使用插件
标签: c# .net add-in visual-studio-addins