That happens because when you call Arrange, SpringLayout calculates initial layout area based on number and size of nodes, and pulls all nodes inside it. After a few hundred Arrange calls the rightmost node gets outside the calculated area and you see it pulled back in.
You could use the built-in animation methods of SpringLayout (BeginArrange, Iterate, EndArrange), and the layout area check will be done only in the beginning:
this.diagram1.LoadFromFile("test.diag");
var sl = new SpringLayout
{
Anchoring = Anchoring.Ignore,
IterationCount = 5,
NodeDistance = 50,
MinimizeCrossings = false,
GrowToFit = false,
EnableClusters = false,
LinkType = SpringLayoutLinkType.Straight,
//EnableParallelism = false,
Randomize = false // nicht random, sondern die initiale Partitionierung (s.o.) beachten!
};
sl.BeginArrange(diagram1, null);
this.layout = sl;
private void HandlesAnimTimerTick(object sender, EventArgs args)
{
var sl = this.layout as SpringLayout;
if (sl != null)
sl.Iterate(0, 5); // this won't pull back nodes anymore
}
Alternatively keep using Arrange, but set SpringLayout.LayoutArea to the GetContentBounds() rectangle inflated by some margin area before each Arrange call.
I hope that helps,
Stoyan