public override UndoObject Redo() { if (graph != null && !string.IsNullOrEmpty(json)) { UINode n = graph.AddNodeFromJson(json, point); if (n != null) { foreach (var p in parents) { var id = p.Item1; var cons = p.Item2; UINode unode = graph.GetNode(id); if (unode != null) { unode.Node.SetConnection(graph.Graph.NodeLookup, cons, n.Id); unode.LoadConnection(n.Id); } } return(new UndoCreateNode(StackId, n.Id, graph)); } } return(null); }
public async override Task Undo(Action <UndoObject> cb) { if (graph != null && !string.IsNullOrEmpty(json)) { graph.TryAndLoadGraphStack(stack); await Task.Delay(25); App.Current.Dispatcher.Invoke(() => { UI.IUIGraphNode n = graph.AddNodeFromJson(json, point); if (n != null && parents.Count > 0) { Task.Delay(100).ContinueWith(t => { App.Current.Dispatcher.Invoke(() => { foreach (var p in parents) { UI.IUIGraphNode unode = graph.GetNode(p.parent); if (unode != null) { unode.Node.SetConnection(n.Node, p); unode.LoadConnection(n.Id); } } //update the graph after reconnections graph.Graph.TryAndProcess(); }); }); } if (cb != null) { cb.Invoke(new CreateNode(StackId, nid, graph, stack)); } }); return; } if (cb != null) { cb.Invoke(null); } }