How to move nodes in GoDocument?

I want to move nodes and links contained in a rectangle by code in derived GoDocument class.
But I found that after I move all the nodes and links in a rectangle (from PickObjectsInRectangle) by an offset, the links are recalculated. And even worse, links end points are not on the port as they were. Maybe it’s worth mentioning that in the GoView that displays this GoDocument, there is a grid and objects are snapped to this grid.
Basically, the question is how can I get exactly the same effect by moving nodes and links in code as users drag a selection in GoView?
Or how can I move links without recalculating their paths only when they are totally in the rectangle?

GoToolDragging calls GoView.MoveSelection. So if you know exactly what links and nodes you want to move, create a new GoSelection(null), add all of the links and nodes to move, and then call GoView.MoveSelection.
You can find all of the links and nodes that are within a rectangle by calling GoDocument.PickObjectsInRectangle, or depending on what sets of objects you want to consider, maybe the GoLayer or GoView methods by that same name.

OK, that’s one solution, but with the overhead of creating a GoSelection. Is it possible for me to define a function similiar to GoView.MoveSelection in a derived GoDocument class, since I’m moving objects in document coordinates without GoView necessarily inolved? I even want to control what types of objects can be moved. Thanks.

You could try moving all the links first, and then moving everything else.

Thanks. I will check if it works.
When I programmly moved a number of GoObjects from one GoDocument to another GoDocument, I found that links should be moved first since moving node will lose all the links.