I would like to write a plugin for Visual Studio 2010 but in fact I face some problems. What I want to do seems easy, I would like that a little toolbox appears when selecting t
I can answer two parts of that question:
AdornmentLayerDefinition
for the visual manager (the most important thing to change, from the default you get with the project template, is the Order
attribute, to make sure your adornment is displayed on top of any text).UIElement
, but past that it is really up to you.From an ITextView
, which you'll have as a part of the IWpfTextViewCreationListener
implemented as part of the sample (it is passed to the AgentBadgeVisualManager
), you can subscribe to the SelectionChanged event like this:
view.Selection.SelectionChanged += (sender, args) => /* call methods to update your adornment here */;
Note that the event won't be fired when the selection is empty and follows the caret around, so if you want to track that, you'll also need to listen to caret changed events. However, if you just care about a) when the selection is non-empty, or b) when the selection is changing between empty and non-empty, that event will be enough.
For more general information about extensibility, you can check out the other extensions I've written on my github page, read about how I wrote them on my blog, check out the VSX samples page, or the editor samples page on codeplex.