DevExpress the creator of Refactor and CodeRush two great visual studio productivity tools provide a free library called DXCore that can be used to create rich plug-ins that can extend visual studio the same way their commercial products do. Until visual studio 2010 will be widely developers can use DXCore to extend visual studio and provide integration functionality without messing around with DTE and GUIDs.
In this tutorial I will explain what is needed to write your first DXCore plug-in
When running visual studio you will be prompted to choose the location of your community plug-ins. this is where your plug-ins will be placed.
Now we can write our first DXCore plug-in.
Notice that a new tool menu named DevExpress was added to VS, click on it and choose New Plug-in, or create a new project of type DXCore (using File –> new project).
Choose your language of choice (C#), standard plug-in and the plug-in name.
Select a name and check “Load Manually”, This tells DXCore not to load the plug-in automatically to Visual Studio, this option is only relevant to the development phase.
Now we have a new plug-in that does absolutely nothing, it’s time to add some functionality.
DXCore adds a few new tools to VS toolbox, in this tutorial we’re going to use the “Action”.
Simply drag a new action into the designer.
Add name and description in the action property page:
Double click on the action or create an “Execute” event handler and paste this code inside:
The first line we get the position of the caret on the screen. Then we get the active element and use it to receive the current opened document which we use to write text of the screen.
Pressing F5 (Run Debug) will open a new instance of VS, open or create a new C# project so we’ll have some where to try our new plug-in.
Open the Plug-in manager and double click the Plug-In to enable it (remember the “Load manually” checkbox).
Lastly we want to bind a new keyboard shortcut that will invoke our code. Inside DevExpress –> options choose Shortcuts (under IDE)
Select a proper shortcut and bind it to the action’s name:
That’s now we can run our code, each time I press the key combination a remark is written in my code:
You can learn (much) more about DXCore in the following places:
Rory Becker has posted several tutorials about DXCore on his blog.
Travis Illig also written a few tutorials and how-tos on his blog.
DXCore community plugins on Google Code.
If you’re stuck with a tough problem DevExpress Forums is the place to ask DXCore related questions.