When I started creating my project, it made sense to separate the Goxam data from our Entity Framework database. Thus, I designed a system that would have a parallel list of our Entity Framework Objects (Arcs and Nodes), and a Goxam list of Links and Nodes. When I save the Diagram, I create an XML representation of our GraphLinksModel. When I restore the Diagram, I go through all of our EntityFramework Objects, create a new
Now that the project has matured, I would like to use proper databinding, and bind our Entity Object’s data directly to the Goxam data. Maintaining the 2 lists of a nightmare, and an easy vector to introducing bugs (bye-bye last Friday!)
So far, it’s going pretty well, in that I figured out how to extend our Entity model to provide things like a Category (for Node Template selection). I can also restore the positions of the Nodes via setting the Location of each Goxam Node’s Location field.
The problems I’m having now are:
1. The Link arrows don’t end at the same place as before the Diagram was saved, and I’m not sure how to set it (see attached pic). If I drag the Node in the Diagram, the links will return to their desired locations. What am I forgetting to set? Do I need to add a Node and a Link to the PartManager via the .AddLinkForData and .AddNodeForData calls for each Node and Link I add to the LinksSource and NodesSource?
2. I can’t get the Node location properties until well after the Diagram is loaded into the Prism view because the Diagram.PartManager.Nodes is not filled until then. Is there a way to get the PartManager to detect changes in the Diagram.Model and create the PartManager properties before the control is finished loading?
3. For Simple models I can load, but for larger (200 – 300 nodes), when I restore using my Bound method, it hands when I add it to my Prism View. I’m not sure how to debug this, but I assume that since I’m likely restoring the model incorrectly, the hang is associate with that. (Update: It doesn’t hang, it just takes a REALLY, REALLY long time to create all the default Node locations, I suppose!)
Is there a better approach to Saving and then Re-loading the Diagram? Can I just Serialize the PartManager, save it, and then Restore it? I don’t want to add any location properties to my Entity Model, as we’re trying to make the Diagram aspect optional if possible.
Thanks!
-Dan
Attachments:
Default positioning (no setting of PartManager properties, because the PartManager isn't created until Control is finished and presented to the user:
Diagram after calling UpdatePositions() via an arbitrary Node_DoubleClick event from the UI
After dragging each of the Nodes, the Arrows re-flow to their proper positions on the Nodes.