Sometimes when defining a property for a domain model element you may need to use a complex type that has more than one property or can’t easily be displayed using a single text field or drop down in the property editor. A good example might be a class that holds a list of strings for a GUI interface or a Rich Text editor for a custom text field required by your framework.
To resolve this you can create a custom editor and hook it into your domain model that will provide a proper user interface to specify information for your property.
There are three steps you need to take in order to wire your domain property to display a custom editor:
1. Create a class derived from System.Drawing.Design.UITypeEditor that will launch the custom dialog box as below:
2. Create a Windows Form dialog that will be displayed when the editor is invoked, such as the one below:
3. Set the Custom Attributes for the Domain Property to reference the UITypeEditor class you have created.
The text is as follows: [System.ComponentModel.Editor(typeof(XXX.UIProcessDesigner.UIEditors.FormActionTypeUITypeEditor),typeof(System.Drawing.Design.UITypeEditor))]
The bold faced text is the full namespace of your class that derives from UITypeEditor.
I normally store all code that I add to a DSL Designer in various folders such as; CustomCode, UIEditors, Validators, etc. That way it is easy to find when I am trying to reference it.
Also, you can debug the UITypeEditor and Dialog by setting breakpoints in the code before you start debugging.