Monday, April 27, 2009

CR_HelloWorld – Your first DXCore plugin

So for your first DXCore Plugin, we’ll show you the traditional “Hello World” program…plugin style.

We’ll show you how you can execute any managed code from a plugin – Fun stuff

First up you’ll need to Create a Vanilla plugin. From here you’ll be able to add all the relevant pieces to create CR_HelloWorld.

 

Ok first Step… ensure you’re looking at the designer view of your plugin. If you’ve not renamed it this will be the “Plugin1” (cs or vb) file.

DXCoreDesignSurfaceSmall

Next locate the ‘Action’ component in your toolbox and place one on the designer surface.

DXCoreControls

The set an appropriate name and a few properties:

actSayHelloWorld

Finally handle the “Execute” Action and do something within it.

This seems appropriate:

-------------------------------------------------------------
Private Sub actSayHelloWorld_Execute(ByVal ea As ExecuteEventArgs) Handles actSayHelloWorld.Execute
    MessageBox.Show("Hello World")
End Sub
-------------------------------------------------------------

Ok well that’s the majority of the work done.

However you’re going to need some way to activate this action…

So hit F5 to run up a new instance of studio to debug your new plugin.

Once this new copy of studio is running, be sure to ensure your plugin is actually running in memory.

Next we will attach your new action to a shortcut….

Open up the DXCore options screen (DevExpress\Options) Note – You may need to use the previously mentioned 'registry hack' to get the DevExpress menu to show up, if you’re running one of the Free DXCore based products.

Next select the IDE\Shortcuts page from the left hand side and you should see something like the following.

DXCoreOptionsShortcuts

In the shot you can see (Click to view full image) I have created a new ‘keyboard shortcut’ ( which I did via a context menu within the shortcut tree) and then I have filled out the Key1 and command options.

Now you can have your copy of Studio say “Hello World” whenever you choose :)

Obviously this is a something of a contrived example but, as you can see, it would be easy to have studio execute any managed code you care to dream up in a similar way.


5 comments:

BenAlabaster said...

Very amusing... I'm almost tempted to plug this into one of my colleagues systems and replace a common shortcut key...let's say F5

Rory said...

I was thinking that later on we might implement CR_CodeGoggles.

Perhaps lock down the IDE unless simple mathematics could be answered when loading projects outside specific hours :)

Carl Weis said...

I have downloaded some plugins from your site and now all my method names are pink?

Is there any way I can change this color?

Please help!!!
carl@codelogix.com
carlweis@live.com

Thanks
Carl Weis

Rory said...

Hi Carl.. you've likely installed the CR_ColorizeMember which was just a demo really to show someone how it was done... either disable in the plugin manager options or just delete from your plugin folder :)

Sorry no color picking on that one at the moment. might add it later though.

Anonymous said...

I've looked at writing DXCore plugins in the past but didn't really know where to start. This series looks really promising, hope you keep it up!