-
I'm drawing my diagram from information from an external source (including coordinates), is it possible to make the nodes snap the the nearest snapping point on/after drawing? |
Beta Was this translation helpful? Give feedback.
Answered by
zHaytam
Sep 25, 2023
Replies: 1 comment 1 reply
-
Currently, there is no out of the box to do that, however you can just re-set the position of all your nodes while while snapping it with the following snippet of code: yourNode.SetPosition(new Point(ApplyGridSize(yourNode.Position.X), ApplyGridSize(yourNode.Position.Y));
private double ApplyGridSize(double n)
{
if (Diagram.Options.GridSize == null)
return n;
var gridSize = Diagram.Options.GridSize.Value;
return gridSize * Math.Floor((n + gridSize / 2.0) / gridSize);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
rjtwins
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, there is no out of the box to do that, however you can just re-set the position of all your nodes while while snapping it with the following snippet of code: