将图标添加到 Visual Studio 2017 中的现有菜单命令 [英] Add icon to existing menu command in Visual Studio 2017

查看:24
本文介绍了将图标添加到 Visual Studio 2017 中的现有菜单命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明:这是关于使用 Visual Studio 及其 GUI.它不是关于 VS 扩展.

Disclaimer: this is about using Visual Studio and its GUI. It is not about a VS extension.

上下文:

我喜欢使用工具栏按钮对 .cs 文件中的 using 指令进行排序和删除.在 VS 2015 中有两个专用命令(以及按钮)来执行此操作,每个命令都有自己的图标.现在在 VS 2017 中有一个命令可以做到这一点(Remove and Sort Usings),但它没有图标,只有文本.见下图,有命令,但只有文字:

I like to have toolbar buttons to sort and remove using directives in .cs files. In VS 2015 there were two dedicated commands (and hence buttons) to do this, each with their own icon. Now in VS 2017 there's a single command to do that (Remove and Sort Usings) but it has no icon, just text. See pciture below, command is there, but text only:

我记得很久以前,我相信在 VS 2010 中,您可以以某种方式破解 VS 现有命令以显示自定义图标.我认为这是在特殊位置添加图片文件的问题,并以特殊方式命名它们或从某些配置文件中引用它们.我完全忘了怎么做,但它是可行的.

I remember ages ago, with VS 2010 I believe, you could somehow hack VS existing commands so to show custom icons. I think it was a matter of adding picture files in a special location, and either name them in a special way or reference them from some configuration file. I totally forgot how, but it was doable.

问题:

有谁知道这在 VS 2017 中是否仍然可行?经过一番搜索,我无法找到答案.

Does anyone know if this is still possible with VS 2017 and how? After some search I was not able to find an answer.

顺便说一句,问题类似于这个未回答的问题,但就我而言,它是关于常规 VS 命令,而不是外部工具命令.

BTW question is similar to this unanswered one, but in my case it's about a regular VS command, not an external tool command.

TA

正如评论中所建议的,这个CommandingImage 扩展 曾经在 VS 2010 上工作.它没有更新,也没有开源,也没有移植.也许有人找到了它的继任者.

as suggested in comments, this CommandingImage extension used to work on VS 2010. It has not been updated, nor open-sourced, nor ported. Maybe someone as found its successor.

推荐答案

使用 Visual Studio 2017,可以使用 Visual Studio SDK,您可以在其中编写扩展或使用 .vsct 文件.可以在此处找到满足您需求的简单示例.

With Visual Studio 2017, it can be done using Visual Studio SDK where you can either write a extension or extend a existing menu command with a icon declared in the .vsct file. A simple example for the your need can be found here.

如果您想采用更简单的方法,我建议您使用 PowerCommands 或 Resharper 执行相同操作.请参阅此处.

If you want to go for a simpler way, I would suggest to either use PowerCommands or Resharper to do the same. See here.

这篇关于将图标添加到 Visual Studio 2017 中的现有菜单命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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