My application includes a GoView with GoIconicNodes and a DataGridView which contains a row for each node in the view.
The application also supports forming GoSubGraphs. When a node is added to a GoSubGraph or removed, its corresponding row needs to be updated with the GoSubGraph.Text.
The problem is with undo/redo:
when a node is deleted its row must be removed, and on undo - readded. when a new node is added a row has to be added, and on undo - removed. (same for redo)
when a node is inserted to a group and then undo is invoked - its row should be updated that it is no longer in the group, and when a removal from a group is being undone, the row should be updated that the node is in the group.
The way this is implemented today is probably not very good, and causes many bugs when undoing/redoing node deletions, insert/removal from groups and such.
Inside GraphView.OnDocumentChanged I have no way of knowing when a node is being moved to a group and when it is being deleted completely.
I would like some assistance in using GoDiagram’s events and hints in order to do this right.
to see the object inserted into the subgraph, look for DocumentChanged event:
hint = GoLayer.ChangedObject
subhint = GoGroup.InsertedObject (e.NewValue is GoObject, e.Object is SubGraph)
you should see this series of events to insert a node “3” with a self-link into a subgraph.
Inserted Object: CustomSubGraph 6
Removed Object: GoBasicNode 3
GoLayer.ChangedObject/GoGroup.InsertedObject: GoBasicNode 3 into CustomSubGraph 6
Removed Object: GoLink ?
GoLayer.ChangedObject/GoGroup.InsertedObject: GoLink ? into CustomSubGraph 6
Finished Transaction: grouped subgraph