Add ReSharper_ToggleSuspended as toolbar button

丶灬走出姿态 提交于 2019-12-03 09:47:22

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/19048489/add-resharper-togglesuspended-as-toolbar-button

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