Class EditorFrame
The design-time editor overlay for a live page: click to select, drag to move, drag the handles to resize, and use the editor's key bindings, with every gesture recorded as an undoable markup edit.
public sealed class EditorFrame : IDisposable
- Inheritance
-
EditorFrame
- Implements
- Inherited Members
- Extension Methods
Remarks
The frame adds two overlays to the canvas: a capture layer over the editor's scope (the whole surface when there is none) that takes the pointer in Edit and draws the adorners, and a small toolbar with the mode toggle, the selection, and why editing is blocked when it is. In Interact the capture layer lets the pointer through, so the page and the game work normally while the selection stays visible.
The logic lives in Session; the frame only shows it and feeds it pointer gestures. Detaching keeps every edit; save the documents through Save().
Typical in-game use:
EditorFrame editor = EditorFrame.Attach(canvas, designSession);
// ... edit, playtest in Interact mode, edit more ...
foreach (DesignDocument document in designSession.Documents)
document.Save();
editor.Dispose();
Scoped to one part of the UI, for example a tool's content area next to its own sidebar:
EditorFrame editor = EditorFrame.Attach(canvas, designSession, contentArea);
The sidebar keeps working with the pointer, the wheel and the middle button scroll the content area, and the keyboard stays with the editor in Edit. A canvas takes one editor at a time (see FindAttached(Canvas)).
Properties
GhostColor
Gets or sets the color of the dragged element's ghost outline.
public Color GhostColor { get; set; }
Property Value
HandleSize
Gets or sets the side of the square resize handles, in surface units. Defaults to 7.
public float HandleSize { get; set; }
Property Value
HoverColor
Gets or sets the color of the hover outline.
public Color HoverColor { get; set; }
Property Value
IndicatorColor
Gets or sets the color of the drop indicator.
public Color IndicatorColor { get; set; }
Property Value
SelectionColor
Gets or sets the color of the selection outline and handles.
public Color SelectionColor { get; set; }
Property Value
Session
Gets the session the frame shows; share it with other tools to share the selection.
public EditorSession Session { get; }
Property Value
ToolbarPlacement
Gets or sets the corner the toolbar sits in. Defaults to TopLeft.
public EditorToolbarPlacement ToolbarPlacement { get; set; }
Property Value
Methods
Attach(Canvas, DesignSession)
Attaches an editor to the whole of canvas, in Edit.
public static EditorFrame Attach(Canvas canvas, DesignSession design)
Parameters
canvasCanvasThe canvas whose pages to edit.
designDesignSessionThe design session tracking those pages.
Returns
- EditorFrame
The frame; dispose it to detach.
Exceptions
- ArgumentNullException
An argument is null.
- InvalidOperationException
Another editor session is attached to
canvas.
Attach(Canvas, DesignSession, UIElement?)
Attaches an editor to canvas, limited to scope, in Edit.
public static EditorFrame Attach(Canvas canvas, DesignSession design, UIElement? scope)
Parameters
canvasCanvasThe canvas whose pages to edit.
designDesignSessionThe design session tracking those pages.
scopeUIElementThe subtree to edit (see Scope), or null for the whole canvas. The capture layer, the toolbar and the adorners keep to the scope's visible area, so the rest of the canvas stays usable with the pointer.
Returns
- EditorFrame
The frame; dispose it to detach.
Exceptions
- ArgumentNullException
canvasordesignis null.- ArgumentException
scopeis not oncanvas.- InvalidOperationException
Another editor session is attached to
canvas.
Dispose()
Detaches the editor: removes its overlays and key bindings, and gives the canvas its focus and navigation back. Every edit stays.
public void Dispose()