First, sorry my english.
I'm developing a DSL. In the main window I have two panels: a list of shapes and the diagram itself. I would like, when clicking on an item in the list, to center its shape on the screen (diagram panel).
I don't want to move the shape to the center of the diagram. I want to scroll the diagram to center the shape.
Another way to explain: When a validation error occurs (Error List window on bottom), and when clicking on the error, it centers the invalid shape on the screen, right? That's what I want.
Start point:
private void symbolsListBox_SelectedIndexChanged(object sender, EventArgs e)
{
var listBox = sender as ListBox;
var symbol = listBox.SelectedItem as Symbol;
var compartment = PresentationViewsSubject.GetPresentation(symbol)
.FirstOrDefault() as SymbolCompartmentShape;
var diagram = docView.CurrentDiagram;
//Next step, center the shape
//How? God please help me!!!
}
Image example is always better!! So...
HERE, AN EXAMPLE IMAGE OF THAT I WANT
HERE, AN EXAMPLE IMAGE OF THE EXPECTED RESULT
What you can do is locate the shape in the diagram and select it. The diagram will automatically make it visible if necessary.
Here's the code I use for that. Note that this starts from the ModelElement (not the shape).
Now the extension methods:
Notice that this last method has a "trick" to deal with shapes that have compartments (IModelElementCompartmented). You can omit this part if your shapes don't have compartments.