My second How do I is up.
Scenario
Let's say that we want to synchronize the DSL model explorer with the DSL designer. Somehow we need to select a particular shape every time a node in the tree is selected. The focus of this How do I tackles this scenario.
Interfaces and classes needed
Code snippet
public void SelectShape(ModelElement modelElement)
{
ShapeElement modelElementShape = PresentationViewsSubject.GetPresentation(modelElement).FirstOrDefault() as ShapeElement;
Diagram diagram = modelElement.Store.ElementDirectory.AllElements.OfType<Diagram>().FirstOrDefault();
DiagramItem diagramItem = new DiagramItem(modelElementShape);
diagram.ActiveDiagramView.Selection.Set(diagramItem);
}
Assemblies needed
- Microsoft.VisualStudio.Modeling.Sdk
- Microsoft.VisualStudio.Modeling.Sdk.Diagrams
Stay tuned,
Pablo