如何添加额外的工具窗口,一个Visual Studio扩展? [英] How to add additional tool windows to a Visual Studio Extension?

查看:284
本文介绍了如何添加额外的工具窗口,一个Visual Studio扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建扩展为Visual Studio 2013 工具窗口被默认​​设置。不过,我想有一个的第二的工具窗口,看不出人都应该去有关。

When creating an Extension for Visual Studio 2013 a tool window gets set up by default. However, I'd like to have a second tool window and can't see how one is supposed to go about that.

推荐答案

好吧,我只是发现了一些东西 - 所以我会回答我的问题,使得具有相同问题的其他人可能会利用它的优势:

Well I just found a few things - so I'm gonna answer my own question so that other people having the same problem may take advantage of it:


  1. 设置您的分机作为的本教程但检查的工具窗口

创建的工具窗口一个新的用户控件的 ToolWindow2Control 的复制粘贴的 ToolWindowControl.xaml 的&含量;的 ToolWindowControl.xaml.cs 的相应

Create a new UserControl for the ToolWindow "ToolWindow2Control" and copy paste the contents of ToolWindowControl.xaml & ToolWindowControl.xaml.cs accordingly

添加一个类的 ToolWindow2 的复制和粘贴,从内容的 ToolWindow.cs 的。更改GUID到一个新的(工具 - >创建GUID)

Add a class "ToolWindow2" and copy paste the contents from ToolWindow.cs. Change the GUID to a new one (Tools->Create GUID)

NameOfYou​​rProject.vsct 的添加代码用于显示第二在入门的查看 - >其他窗口的通过复制在按钮部分中找到的按钮。更改ButtonText,优先级,按钮的ID和图标的ID。

In NameOfYourProject.vsct add the code for displaying a second entry in View->Other Windows by duplicating the Button found in the Buttons section. Change the ButtonText, the priority, the id of the Button and the id of the Icon.

按钮的ID添加到项下的符号页面底部。它应该是在第三项的 guidNameOfYou​​rProjectCmdSet

Add the id of the Button to the entries under Symbols on the bottom of the page. It should be a third entry under guidNameOfYourProjectCmdSet.

开放的 PkgCmdID.cs 的(或 PkgCmdIDList.cs 的),并添加按钮的ID有作为,如结果
公共常量UINT cmdidMyTool2 = 0x102;

Open PkgCmdID.cs (or PkgCmdIDList.cs) and add the id of the Button there as well, e.g.
public const uint cmdidMyTool2 = 0x102;

添加其他图标到您的项目/资源。在随后的 NameOfYou​​rProject.vsct 的的位图部分添加另一个位图条目以您先前给的图标GUID-ID。像这样:结果
<位图GUID =guidImages2的href =Images\test.icousedList =testIcon/> < BR>
和创建新的GUID,并具有相同的名称为您在使用usedList,像这样的一个单一的IDSymbol条目的符号部的另一GuidSymbol项:结果
< GuidSymbol NAME =guidImages2VALUE ={7BC1F97F-2693-4186-91CC-A35AE95886CE}>
< IDSymbol NAME =testIcon值=1/>
< / GuidSymbol>

Add another icon to your project / resources. Then add another Bitmap entry in the Bitmaps section of NameOfYourProject.vsct with the GUID-id that you previously gave the Icon. Like so:
<Bitmap guid="guidImages2" href="Images\test.ico" usedList="testIcon"/>
And create another GuidSymbol entry in the Symbols section with a new GUID and a single IDSymbol entry which has the same name as the one you used in the usedList, like so:
<GuidSymbol name="guidImages2" value="{7BC1F97F-2693-4186-91CC-A35AE95886CE}" > <IDSymbol name="testIcon" value="1" /> </GuidSymbol>

这行添加到的 NameOfYou​​rProjectPackage.cs 的< BR>
[ProvideToolWindow(typeof运算(ToolWindow2))]

NameOfYou​​rProjectPackage.cs 的编辑通过复制粘贴的初始化方法在 //创建工具窗口它下面的命令3行。在第一行我们使用步骤#6给了ID( cmdidMyTool2 的)。在第二行中使用了新的MenuCommand事件处理的 ShowToolWindow2 的。并更改变量名。

In NameOfYourProjectPackage.cs edit the Initialize method by copy-pasting the 3 lines under // Create the command for the tool window beneath it. In the first line use the id we gave in step #6 (cmdidMyTool2). In the 2nd line use a new MenuCommand Event handler ShowToolWindow2. And change the variable names.

创建一个新的方法的 ShowToolWindow2 的。从 ShowToolWindow 的复制粘贴方法,并在第一行改变的typeof来的 ToolWindow2

Create a new method ShowToolWindow2. Copy paste from the ShowToolWindow method and change the typeof in the first line to ToolWindow2

这应该是它。我希望我没有忘记什么。然后,您可以打开下的视图 - >其他的Windows

This should be it. I hope I haven't forgot anything. You can then open the two windows under Views->Other Windows

这篇关于如何添加额外的工具窗口,一个Visual Studio扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆