This project is read-only.

Save the disposition of the grpah

Sep 7, 2012 at 1:10 PM

Hi everybody!

I would like to know if there is any way to save the location of the nodes in the graph after generating it, so you can load it when starting the program again in order to maintain the disposition of the nodes.

Thanks in advance!

Mar 22, 2013 at 8:49 PM
Ever figure this out?
Mar 26, 2013 at 3:09 PM
I'm using the following method to serialize each node and their position to a string. ComponentVertex is the class of the vertices that I add to my graph.

Hope you can use it.
    public string SaveDiagramToString()
        var sb = new StringBuilder();

        foreach (var vertex in graphControl.Children.OfType<VertexControl>())
            double? x = vertex.GetValue(GraphCanvas.XProperty) as double?;
            double? y = vertex.GetValue(GraphCanvas.YProperty) as double?;

            if (x == null || y == null) continue;

            var obj = vertex.Vertex as ComponentVertex;

            if (sb.Length > 0) sb.AppendLine();

            sb.AppendFormat("{0}|{1}|{2}", obj.Id, Math.Round(x ?? 0), Math.Round(y ?? 0));

        return sb.ToString();