Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add ReSharper_ToggleSuspended as toolbar button

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?

like image 452
Faust Avatar asked Sep 27 '13 10:09

Faust


2 Answers

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

enter image description here

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.

like image 70
StingyJack Avatar answered Nov 11 '22 07:11

StingyJack


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.

like image 21
Piers Myers Avatar answered Nov 11 '22 08:11

Piers Myers