添加 ReSharper_ToggleSuspended 作为工具栏按钮 [英] Add ReSharper_ToggleSuspended as toolbar button

查看:25
本文介绍了添加 ReSharper_ToggleSuspended 作为工具栏按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 ReSharper_ToggleSuspended 命令映射到 VS 2012 中工具栏上的按钮,但该命令未列在自定义 > 命令对话框中可用的命令的 ReSharper 类别中.>

有没有办法做到这一点?

解决方案

借用 R# 问题跟踪器上的建议,用于此

您可以使用任何现有的工具栏,也可以从头开始创建一个.我最初使用 UI 添加了一个新工具栏,但更新了它以包括如何创建一个工具栏,以及更新按钮文本以使用 $cmdText.

Rick Strahl 有一个不错的 如果您有兴趣,请在命令栏上写.

I'd like to map the ReSharper_ToggleSuspended command to a button on a toolbar in VS 2012, but the command is not listed in the ReSharper category of Commands availabe in Customize > Commands dialog.

Is there a way to do this?

解决方案

Borrowed from the suggestion on the R# issue tracker for this issue.

In the VS Package Manager Console, you can run these commands to add the ReSharper_ToggleSuspended command to an existing toolbar named "R#".

$cmdBarName = "R#"
$cmdName = "ReSharper_ToggleSuspended"
$cmdText = "R# Active"
$toolbarType = [EnvDTE.vsCommandBarType]::vsCommandBarTypeToolbar

#----If you have a command bar you want to use---
#$cmdBar =  $dte.CommandBars.Item($cmdBarName)
# - or you can create one -
$cmdBar = $dte.Commands.AddCommandBar($cmdBarName, $toolbarType)
#------

$cmdItem = $dte.Commands.Item($cmdName).AddControl($cmdBar, 1)
$cmdItem.Caption = $cmdText

You can use any existing toolbar, or create one from scratch. I had originally added a new toolbar using the UI but updated this to include how to create one, as well as to update the Button text to use $cmdText.

Rick Strahl has a decent writeup on the command bars, if you are interested.

这篇关于添加 ReSharper_ToggleSuspended 作为工具栏按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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