Grouping & Transactions
Group the selected nodes into a container and dissolve it again without anything moving on screen, change the stacking order, and make several changes as one edit with EditAsync. Every edit is one labelled undo step and one OnGraphChanged event, logged under the canvas with its kind, origin and label.
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Parse and Check start selected: press Group and they are wrapped in a group that is selected in their place - nothing moves. Drag the group and they go with it.
- With the group selected, press Ungroup: the group goes and its nodes stay exactly where they are.
- Click the background to clear the selection, drag Parse on top of Check and press Send to back. Parse stays on top while it is selected; click the background again and it is drawn beneath Check. Select it and press Bring to front to put it back above.
- Add a chain (one step) adds three nodes and two edges in one edit: one line in the log, and one Undo takes all of it back.
- Simulate a remote edit moves Store as another user's change would: it is logged with the origin Remote, and undo never takes it back - with nothing else done, Undo stays disabled.
- The Undo and Redo buttons name the step they would take back or bring back - group, order, add chain, move. Ctrl/Cmd+Z and Ctrl/Cmd+Shift+Z do the same, and Ctrl/Cmd+C, V, X and D copy, paste, cut and duplicate - groups and all.
How it works
GroupSelectionAsync(padding: 24)creates a node of typegroupsized to enclose the selected nodes with 24 units to spare, makes it their parent - turning each position into one relative to the group - and selects it. It returns null and does nothing when nothing is selected or the selected nodes have different parents.UngroupAsync(group)hands the children to the group's own parent, again without moving them on screen, and removes the group as a deletion:DeletableandOnBeforeDeleteapply to it.BringToFrontAsync()andSendToBackAsync()move the selection, with everything nested in it, to the end or the start ofNodes- within its parent, so a child never goes behind its own group.ZIndexMode="BlowZIndexMode.Basic"draws nodes in list order, so that order is the stacking order - except that a selected or dragged node is lifted above the rest while it is, which is why the change shows once Parse is deselected. An explicitZIndexstill wins.EditAsync(action, label: "add chain")makes everything inside the action one edit, however many nodes and edges it adds: one undo step under that label, oneOnGraphChanged, oneNodesChangedandEdgesChanged, and one render.- The remote edit passes
origin: BlowChangeOrigin.RemoteandrecordHistory: false: a change listener can tell not to send it back to the server, and instead of becoming a step it is written into every step the history holds (BlowHistory.Rebase). OnGraphChangedreceives aBlowGraphChangeper completed edit - itsKind(Moved,Connected,Edited,Replaced, ...),Origin(User,Api,History,Remote),Label, and theNodes,Edges,RemovedNodesandRemovedEdgesit touched - which the log prints. Undo and redo arrive asReplacedchanges fromHistory.HistoryEnabledkeeps the undo stack andOnHistoryChangedreports its state to the toolbar;OnSelectionChangekeeps the page's copy of the selection, which enables the selection buttons.