Maybe we should add a DiagramPanel.ZoomToFit method as a convenience.
I haven’t tried this, but it might be implemented as:
public void ZoomToFit() {
Rect b = this.DiagramBounds;
double xscale = this.ViewportWidth/Math.Max(b.Width, 1);
double yscale = this.ViewportHeight/Math.Max(b.Height, 1);
this.Scale = Math.Min(xscale, Math.Min(yscale, 1));
}
To be clear, “this” in the above code is a DiagramPanel, the value of Diagram.Panel.