Add ReSharper_ToggleSuspended as toolbar button

你。 提交于 2019-12-03 01:26:49

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.

I think that the Resharper_ToggleSuspended command relates to the 'Suspend' button under Tools->Options...->Resharper->General. It seems you can't have items from the Options dialogue as commands. Possibly your only choice is to assign a keyboard shortcut to it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!