Introduction
When you use the DSL SDK, you can create a tool with which you draw out your domain and it is subsequently turned into code with the T4 templates and code generation. However, the diagram can be quite busy so by having a tool tip on your connector classes, you can create it.
Background
Creating a domain specific language model requires the Visual Studio Modelling SDK.
1. Make Your Connector Use a Custom Tool Tip
To do this, find the ConnectorShape
you have in your DSL definition diagram and at the very bottom of the list of properties for it, you will find Tooltip Type. Set this to "Variable
".
2. Hooking Up the Code to Create the Tooltip
The DSL model is turned into code by text templates. You need to create a matching partial class of your own so that your changes don't get overwritten every time the DSL is compiled.
In that partial class, override the HasTooltip
property to indicate to the designer that your connector has a tool tip:
public override bool HasToolTip
{
get
{
return true;
}
}
Then, you need to override the GetTooltipText
method to return the actual text to go into the tooltip:
public override string GetToolTipText(DiagramItem item)
{
string fromName = this.FromShape.AccessibleName;
string toName = this.ToShape.AccessibleName;
return string.Format("Projection {0} handles the event {1}", fromName, toName);
}
The resulting tooltip will show what the connector connects thus:
History