Issue
When we load diagram, CompoundEdits count must be zero so that undo will not be triggered. However, sometimes CoumpoundEdits are not being cleared due to which we are able to undo as soon as the diagram is rendered.
Investigation
As a process of investigation, we found that in the below code LayoutCompleted property is being set to true at some unknown point. As a result, clear method in UndoManager is not getting invoked.
Code (in DiagramPanel)
private void DoUpdateDiagramBounds() {
VerifyAccess();
// in case some are left over or because of undo/redo
UpdateRouteGeometries();
if (this.SkipsNextUpdateDiagramBounds) {
this.SkipsNextUpdateDiagramBounds = false;
Diagram.InvokeLater(this, DoUpdateDiagramBounds);
return;
}
try {
this.DiagramBounds = ComputeDiagramBounds();
} catch (Exception) {
}
//Diagram.Debug(this.UpdateDiagramBoundsReason + " " + Diagram.Str(this.DiagramBounds) + this.LayoutCompleted.ToString() + " " + this.InitialLayoutCompleted.ToString());
this.UpdateDiagramBoundsReason = null;
// if LayoutCompleted is true, this is the first time we've computed the diagram bounds since finishing a layout;
// only raise the Diagram.InitialLayoutCompleted and Diagram.LayoutCompleted events after computing new diagram bounds
if (this.LayoutCompleted && this.Diagram != null) {
if (!this.InitialLayoutCompleted) {
this.InitialLayoutCompleted = true;
this.IsVirtualizing = true;
OnInitialLayoutCompleted();
}
OnLayoutCompleted();
}
this.LayoutCompleted = false;
}