C# 如何在“工具”菜单中的一个菜单项中设置多个命令?
我试图在工具菜单中添加一个菜单项(使用C# 如何在“工具”菜单中的一个菜单项中设置多个命令?,c#,plugins,menu,vsix,extensibility,C#,Plugins,Menu,Vsix,Extensibility,我试图在工具菜单中添加一个菜单项(使用IDM\u VS\u menu\u Tools),该菜单项有两个子菜单按钮。但我做不到。但是,如果我将IDG_VS_MM_TOOLSADDINS添加为顶级菜单,那么我可以在扩展菜单中看到它,这很好(遵循img-1) img-1 如图所示,我想将我的顶部菜单(及其子命令)添加到工具菜单中。 我该怎么做?我尝试了以下代码,但没有任何变化,但我的顶部菜单也被删除 <?xml version="1.0" encoding="utf-8"?> <C
IDM\u VS\u menu\u Tools
),该菜单项有两个子菜单按钮。但我做不到。但是,如果我将IDG_VS_MM_TOOLSADDINS添加为顶级菜单,那么我可以在扩展菜单中看到它,这很好(遵循img-1)
img-1
如图所示,我想将我的顶部菜单(及其子命令)添加到工具菜单中。
我该怎么做?我尝试了以下代码,但没有任何变化,但我的顶部菜单也被删除
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidMultipleMenuCmdTestPackage">
<Groups>
<Group guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop" priority="0x0600">
</Group>
</Groups>
<Menus>
<Menu guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroup" type="Menu" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
<Strings>
<ButtonText>My Top Menu</ButtonText>
</Strings>
</Menu>
</Menus>
<Buttons>
<Button guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command1Id" type="Button">
<Strings>
<ButtonText>Changed 2</ButtonText>
</Strings>
</Button>
<Button guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command2Id" type="Button">
<Strings>
<ButtonText>Command 2</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\Ext1.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
</Bitmaps>
</Commands>
<CommandPlacements>
<CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop" priority="0x0601">
<Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroup"/>
</CommandPlacement>
<CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command1Id" priority="0x0601" >
<Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop"/>
</CommandPlacement>
<CommandPlacement guid="guidMultipleMenuCmdTestPackageCmdSet" id="Command2Id" priority="0x0602" >
<Parent guid="guidMultipleMenuCmdTestPackageCmdSet" id="MyMenuGroupTop"/>
</CommandPlacement>
</CommandPlacements>
<Symbols>
<GuidSymbol name="guidMultipleMenuCmdTestPackage" value="{5f20b1ae-835b-423f-89e1-a33f2e20a715}" />
<GuidSymbol name="guidMultipleMenuCmdTestPackageCmdSet" value="{2e60374a-c4f8-4d96-9bb6-301ab412846f}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="MyMenuGroupTop" value="0x1021" />
<IDSymbol name="Command1Id" value="0x0101" />
<IDSymbol name="Command2Id" value="0x0102" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{512d3770-bde4-4353-a6c0-7138bbfffebe}" >
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
</Symbols>
</CommandTable>
我的顶级菜单
改变2
命令2
更多信息(已编辑):-
当我将
从菜单标签替换为组标签然后运行时,我只能在工具菜单下看到子命令。(请参考img-2)
img-2这是Visual Studio 2019的新行为。您不能再在该菜单的扩展部分之外插入自定义选项。如果您也为VS 2015和2017构建了扩展,那么您可以在工具部分添加新选项,或者可以在顶部菜单中工具附近创建一个新条目
请记住,扩展部分在VS 2015和2017中不存在这是Visual Studio 2019的新行为。您不能再在该菜单的扩展部分之外插入自定义选项。如果您也为VS 2015和2017构建了扩展,那么您可以在工具部分添加新选项,或者可以在顶部菜单中工具附近创建一个新条目 请记住,VS 2015和2017中不存在扩展部分。在这里,我找到了解决问题的线索。我只是添加了另一个组,并根据需要进行了一些更改,以添加对该组的引用。以下是为我提供完美解决方案的代码:
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidCodeReviewMainPackage">
<Groups>
<Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
<Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" priority="0x0600">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem"/>
</Group>
</Groups>
<Menus>
<Menu guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem" type="Menu" priority="0x0600">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup"/>
<Strings>
<ButtonText>Caladrius</ButtonText>
</Strings>
</Menu>
</Menus>
<Buttons>
<Button guid="guidCodeReviewMainPackageCmdSet" id="Ext1Id" priority="0x0100" type="Button">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
<Strings>
<ButtonText>Select Directories</ButtonText>
</Strings>
</Button>
<Button guid="guidCodeReviewMainPackageCmdSet" id="Ext2Id" priority="0x0101" type="Button">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Load Recent</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\Ext1.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
</Bitmaps>
</Commands>
<Symbols>
<GuidSymbol name="guidCodeReviewMainPackage" value="{-----}" />
<GuidSymbol name="guidCodeReviewMainPackageCmdSet" value="{-----}">
<IDSymbol name="MyMenuGroup" value="0x1021" />
<IDSymbol name="MyMenuItem" value="0x1020" />
<IDSymbol name="MyMenuSubGroup" value="0x1022" />
<IDSymbol name="Ext1Id" value="0x0100" />
<IDSymbol name="Ext2Id" value="0x0101" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{a0eaa6e3-70cc-45c8-9300-1bedd0871fe6}" >
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
</Symbols>
</CommandTable>
卡拉德里厄斯
选择目录
最近加载
我提到了答案。在这里,我找到了解决问题的线索。我只是添加了另一个组,并根据需要进行了一些更改,以添加对该组的引用。以下是为我提供完美解决方案的代码:
<?xml version="1.0" encoding="utf-8"?>
<CommandTable xmlns="http://schemas.microsoft.com/VisualStudio/2005-10-18/CommandTable" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<Extern href="stdidcmd.h"/>
<Extern href="vsshlids.h"/>
<Commands package="guidCodeReviewMainPackage">
<Groups>
<Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_MENU_TOOLS"/>
</Group>
<Group guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" priority="0x0600">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem"/>
</Group>
</Groups>
<Menus>
<Menu guid="guidCodeReviewMainPackageCmdSet" id="MyMenuItem" type="Menu" priority="0x0600">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuGroup"/>
<Strings>
<ButtonText>Caladrius</ButtonText>
</Strings>
</Menu>
</Menus>
<Buttons>
<Button guid="guidCodeReviewMainPackageCmdSet" id="Ext1Id" priority="0x0100" type="Button">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
<Strings>
<ButtonText>Select Directories</ButtonText>
</Strings>
</Button>
<Button guid="guidCodeReviewMainPackageCmdSet" id="Ext2Id" priority="0x0101" type="Button">
<Parent guid="guidCodeReviewMainPackageCmdSet" id="MyMenuSubGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Load Recent</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\Ext1.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough"/>
</Bitmaps>
</Commands>
<Symbols>
<GuidSymbol name="guidCodeReviewMainPackage" value="{-----}" />
<GuidSymbol name="guidCodeReviewMainPackageCmdSet" value="{-----}">
<IDSymbol name="MyMenuGroup" value="0x1021" />
<IDSymbol name="MyMenuItem" value="0x1020" />
<IDSymbol name="MyMenuSubGroup" value="0x1022" />
<IDSymbol name="Ext1Id" value="0x0100" />
<IDSymbol name="Ext2Id" value="0x0101" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{a0eaa6e3-70cc-45c8-9300-1bedd0871fe6}" >
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
</Symbols>
</CommandTable>
卡拉德里厄斯
选择目录
最近加载
我编辑了问题(通过更多信息(已编辑))。请再看一遍。我编辑了这个问题(通过更多信息(编辑))。请再检查一遍。