Tapping Into The "Projects" Pad
After yesterday’s adventure of adding buttons to Visual Studio’s Solution Explorer, I just had to post a short follow-up that shows how easily the same task can be done in #develop’s Projects pad. To remind you, what I wanted to do was add two buttons - one for the project context menu and one for the solution context menu.
While the Solution Explorer adventure required some coding, the Projects pad one is almost nothing but XML.
Simply open up your .addin file and add two Path elements under your AddIn element.
1: <AddIn name = “My Add-in”
2: author = “Omer Rauchwerger (rauchy)”
3: url = “http://blog.rauchy.net”
4: description = “Does stuff.”>
5:
6: …
7:
8: <Path name=”/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectNode”>
9: <MenuItem id = “DoStuffOnProject”
10: label = “Do stuff on this project”
11: class = “MyNamespace.ProjectCommand”/>
12: </Path>
13: <Path name=”/SharpDevelop/Pads/ProjectBrowser/ContextMenu/SolutionNode”>
14: <MenuItem id = “DoStuffOnSolution”
15: label = “Do stuff on this solution”
16: class = “MyNamespace.SolutionCommand”/>
17: </Path>
18: </AddIn>
The first Path element creates a button labeled “Do stuff on this project” and places it on the context menu that pops up when your right-click a project in the Projects pad. It also hooks it up with the “MyNamespace.ProjectCommand” class. The second Path element does the same but for solutions, and hooks it up with the “MyNameSpace.SolutionCommand” class.
ProjectCommand and SolutionCommand are two classes you should create which inherit from AbstractMenuCommand. All you need to implement in these classes is the Run method. The Run method will run whenever someone clicks on the button.
1: using ICSharpCode.Core;
2:
3: namespace MyNamespace
4: {
5: public class SolutionCommand : AbstractMenuCommand
6: {
7: public override void Run()
8: {
9: // TODO: Handle the Click event.
10: }
11: }
12: }
Gosh I love #develop extensibility