Skip to content

When things happen

Ambit is quiet until you do something. Here's what fires and when.

Controller events

EventWhen it firesWhat to do with it
RegionsChangedUser finishes a drag, finishes drawing, or clicks a toggle decoration. Never during the drag, only on mouse up.Save to your database or config. This is the only one you need for persistence.
RenderStateChangedHover changes, selection changes, or anything that needs a redraw. Can fire a lot while moving the mouse.Just redraw. The sample listens and calls InvalidateVisual().
CellsChangedUser paints grid cells.Update your cell selection storage.
CursorChangedHover moves from a handle to a body to background. Returns a name like Hand, Cross, SizeAll.Set the cursor. RegionDrawingLayer already does this.
PanZoomChangedUser pans (right-drag) or zooms (wheel).Sync a video player or update an overlay if you keep your own transform.

Clicking outside to deselect

If you click empty canvas and no shape is under the cursor, Ambit clears SelectedRegionId and fires RenderStateChanged, not RegionsChanged. That's intentional: selection is UI state, not saved data. The sample's sidebar updates on RenderStateChanged so it clears right away.

csharp
controller.RegionsChanged += (_, _) => Save(controller.Regions); // save
controller.RenderStateChanged += (_, _) => UpdateUi(controller.SelectedRegionId); // select
controller.CellsChanged += (_, _) => SaveGrid(controller.SelectedCells);

Viewer events

AmbitViewer.PanZoomChanged also fires on zoom/pan. The controller's CoordinateTransform is updated automatically, you usually don't need to set it yourself.

Released under the MIT License.