Skip to content

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.

Selection Edit
Fetch
Parse
Check
Store
bit Blow

Try 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 type group sized 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: Deletable and OnBeforeDelete apply to it.
  • BringToFrontAsync() and SendToBackAsync() move the selection, with everything nested in it, to the end or the start of Nodes - 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 explicit ZIndex still 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, one OnGraphChanged, one NodesChanged and EdgesChanged, and one render.
  • The remote edit passes origin: BlowChangeOrigin.Remote and recordHistory: 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).
  • OnGraphChanged receives a BlowGraphChange per completed edit - its Kind (Moved, Connected, Edited, Replaced, ...), Origin (User, Api, History, Remote), Label, and the Nodes, Edges, RemovedNodes and RemovedEdges it touched - which the log prints. Undo and redo arrive as Replaced changes from History.
  • HistoryEnabled keeps the undo stack and OnHistoryChanged reports its state to the toolbar; OnSelectionChange keeps the page's copy of the selection, which enables the selection buttons.
An unhandled error has occurred. Reload 🗙