Hi Will,
The standard way to do this is to create the domain elements and relationships that the shapes and connectors depict. So for example, starting from the "Minimal Language" solution template, you can write things like:
Suppose you add a command to create a new object for each selected object, and a relationship between them. (To see how to create a command, see the examples in Program Files\Visual Studio 2005 SDK\2006.06\VisualStudioIntegration\Samples\DslTools\Example.Customization\Example.ClassDesigner, and look in DslPackage\CtcComponents\ChangeAssociationSort)
internal void OnMenuChangeAssociationSort(object sender, EventArgs e) {
foreach (object selectedObject in this.CurrentSelection) {
ExampleElement e1 = object as ExampleElement; if (e1 == null) continue;
// All updates must be done inside a transaction using (Transaction t = e1.Store.TransactionManager.BeginTransaction()) {
// create new elements ExampleElement e2 = new Component(e1.Store);
// add them to the tree e1.ExampleModel = myModel; // same effect as myModel.Elements.Add(e1) e2.ExampleModel = myModel;
// add a relationship link e1.Targets.Add(e2);
t.Commit(); // creates the shapes and connectors and displays them } } }
- Alan [Microsoft] |