【问题标题】:How to create custom extension for .sql file in visual studio 2017如何在 Visual Studio 2017 中为 .sql 文件创建自定义扩展名
【发布时间】:2018-07-24 15:07:57
【问题描述】:

我对 Visual Studio 扩展非常陌生。我需要为 Visual Studio 2017 创建一个新的扩展名,这个扩展名适用于 .sql 文件。如果一个解决方案有 .sql 文件,并且如果用户右键单击 .sql 文件,那么我需要有新的自定义选项来在 word pad 中打开文件。

任何帮助或指导将不胜感激。

【问题讨论】:

  • 我很确定如果您右键单击任何 sql 文件,已经有一个选项可以在 word pad 中打开。您是否遗漏了部分问题?
  • 这个问题有什么更新吗?你解决了这个问题吗?如果没有,请告诉我有关此问题的最新信息吗?

标签: c# editor visual-studio-extensions


【解决方案1】:

只需右键单击解决方案资源管理器中的文件 > 打开方式。然后简单地配置它:

Visual Studio 是最好的 IDE 之一,即使不是最好的,也不知道为什么要使用写字板,但至少这可以让你免于制作扩展。


如果你真的想做,这里有一个例子,说明如何将菜单项添加到上下文菜单中,它会为你提供谷歌的关键字:

Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;


Command command = commands.AddNamedCommand2(_addInInstance, "AddinMultiLineWatch", "AddinMultiLineWatch", "Executes the command for AddinMultiLineWatch", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

if((command != null) && (toolsPopup != null))
{
    command.AddControl(toolsPopup.CommandBar, 1);
}

参考:https://stackoverflow.com/a/38500621/495455

【讨论】:

    【解决方案2】:

    这里有一些你可以开始的资源。

    我认为您想将命令添加到上下文菜单(文本编辑器解决方案资源管理器

    【讨论】:

      猜你喜欢
      • 2021-07-09
      • 2018-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 2018-05-15
      • 2021-06-18
      • 1970-01-01
      相关资源
      最近更新 更多