Adding Commands to a DSL from a 10,000ft view
The DSL Tools are a huge improvement towards getting a VS designer up and running in no time.
They make a good job of keeping you abstracted at a 10,000ft view from the inner workings of a Visual Studio designer. You drag and drop shapes all around, defining your domain model and its graphical representation. You set properties here and there. And… you’re ready to go!
You now have thousands and thousands of automatically generated code implementing a VS designer which would have took you weeks to write if you went from scratch. That’s nice.
Now, let’s say you’re the kind of developer that likes to push the envelope and you come with the very wild idea of adding a menu command to the designer surface or a given shape of your DSL. Oh, yes, you’re wild.
At this point if you were an airplane you would have crashed. The nice 10,000ft altitude and the “I don’t have to worry about the dirty details” that you were used to while designing your domain model have changed for the feeling of hitting hard the ground.
You need to follow a several steps procedure which includes things as dealing with a C++ preprocessor and knowing in lots of detail one of the most arcane format that Microsoft may have invented, the obscure world of Command Table definitions.
So, you’re already thinking of hiring a skilled senior C++ developer so you can add your menu command? Well, that’s not required if you’re willing to put the time to learn lots of non-interesting stuff about how to define a command, but if you have the time, you will eventually make it work (and that’s because you’re a wild developer, remember that).
With SFT we try to keep you at the 10,000ft for adding commands too. And in our latest public drop we’ve included an enhanced DSL Recipe Binder Wizard that will do the magic for you.
It allows you to choose between binding a command to a built-in shape (the designer surface, a link, etc) or one of your custom shapes (your foo shape), and specifying on which kind of selection you want your command to appear: single, multiple or any? Moreover, you want your command to appear only for those Foo shapes whose Bar whose property start with a ‘C’? Easy enough, click a checkbox specifying you want to customize the selection logic and you will get a partial class with an override method taking a Foo shape where you can write the single line of code required to check the Bar property.
This is how it looks like: