简体   繁体   English

默认情况下如何激活Visual Studio扩展VSIX C#项目的工具栏

[英]How to activate by default the toolbar for a Visual Studio extension VSIX C# project

When I install for the first time the extension I want to see my toolbar without to activate it manually by right clicking on Visual Studio toolbar section and select my toolbar. 第一次安装扩展程序时,我想看到我的工具栏而无需手动激活它,方法是右键单击Visual Studio工具栏部分并选择我的工具栏。 I want to activate the toolbar just once, to inform the users about it's existence, but if it is manually disabled from VS then I want to keep it disable and use VS user settings. 我只想激活一次工具栏,以通知用户它的存在,但是如果从VS中手动禁用了它,那么我想使其保持禁用状态并使用VS用户设置。

My code from .vsct file is : 我从.vsct文件中的代码是:

<Menu guid="guidPackageCmdSet" id="Toolbar" type="Toolbar">
  <CommandFlag>DefaultDocked</CommandFlag>
  <Strings>
    <ButtonText>My Toolbar</ButtonText>
    <CommandName>My Toolbar</CommandName>
  </Strings>
</Menu>

<Group guid="guidPackageCmdSet" id="ToolbarGroup" priority="0x0000">
  <Parent guid="guidPackageCmdSet" id="Toolbar" />
</Group>

<GuidSymbol name="guidPackageCmdSet" value="{498fdff5-5217-4da9-88d2-edad44ba3874}">
  <IDSymbol name="Toolbar" value="0x1000" />
  <IDSymbol name="ToolbarGroup" value="0x1050" />
</GuidSymbol>

What I did in the end was to store a hidden property using the attribute [Browsable(false)] , with a default value set to true, in one of my Dialog Pages from extension and after the extension was installed for the first time I checked the property and I showed the toolbar as vorou's suggested in this link Showing a toolbar at Visual Studio startup and after that I changed the value for my property to false. 最后,我要做的是使用扩展名[Browsable(false)]将隐藏属性存储为默认值,该默认值设置为true,该扩展名在我的扩展中的一个对话框页面中,并且在首次安装扩展后进行检查属性,并在此链接中按照vorou的建议显示工具栏。在Visual Studio启动时显示工具栏,然后将属性的值更改为false。 Once the property was changed every time when a new instance of Visual Studio is started I checked the property but now nothing happens and Visual Studio will handle the toolbar just like the others. 每次启动Visual Studio的新实例时,更改属性后,我都会检查该属性,但现在什么也没有发生,Visual Studio会像处理其他工具栏一样处理该工具栏。 The bool property will be automatically preserved and it will never lose it's value. bool属性将被自动保留,并且永远不会失去其价值。 In this way the toolbar will appear after the installation but after that you can disable it and enable it again and the user setting will be preserved. 这样,工具栏将在安装后出现,但之后您可以禁用它并再次启用它,并且用户设置将被保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM