Table of Contents

Class EditorWorkspace

Namespace
Icy.Design.Editor
Assembly
IcyUI.Design.dll

The complete editor as a page: a document picker, Outline and Toolbox on the left, a preview of the open document in the middle, Properties on the right and the command bar on top. Put it on a game's debug or settings page.

public class EditorWorkspace : ContentControl, INotifyPropertyChanging, IBindingTarget, INotifyPropertyChanged, INotifyFocusChanged, IContainerLayout
Inheritance
EditorWorkspace
Implements
Inherited Members
Extension Methods

Remarks

Using it in your game:

#if DEBUG
DesignSession design = DesignSession.Attach(configuration);           // before loading any screen
if (DesignSession.FindSourceRoot("MyGame.csproj", "Assets/UI") is { } root)
    design.UseSourceRoot(root);
debugPage.Content = new EditorWorkspace { Design = design };
#endif

Reference IcyUI.Design from the game only in Debug builds, so release builds don't carry it: <ProjectReference Include="..\IcyUI.Design\IcyUI.Design.csproj" Condition="'$(Configuration)' == 'Debug'" />.

  • The picker lists the documents Design tracks, with "●" on unsaved ones. "Open file" loads a markup file the game hasn't loaded yet; the session tracks it from then on.
  • Opening a document loads its current text again into the preview, under the same source path. The session joins that copy to the same DesignDocument, so every edit made here also reaches the game's live screen, and both share one undo history. Opening another document releases the previous preview.
  • The editor attaches to the canvas, scoped to the preview, while a document is open and the workspace is on a canvas. A canvas takes one editor at a time: while the EditorOverlay is shown, the workspace waits with a notice and attaches once the overlay is hidden.

Constructors

EditorWorkspace()

Initializes a new instance of the EditorWorkspace class.

public EditorWorkspace()

Properties

CurrentDocument

Gets the document shown in the preview, or null.

public DesignDocument? CurrentDocument { get; }

Property Value

DesignDocument

Design

Gets or sets the design session whose documents the workspace edits, or null for an empty workspace.

public DesignSession? Design { get; set; }

Property Value

DesignSession

IsEditing

Gets a value indicating whether the editor is attached to the preview.

public bool IsEditing { get; }

Property Value

bool

Preview

Gets the preview's root element: a second live copy of CurrentDocument, or null.

public UIElement? Preview { get; }

Property Value

UIElement

StatusText

Gets the workspace's notice: why the editor is waiting, or why opening a document failed. Save outcomes are on the command bar.

public string StatusText { get; }

Property Value

string

Methods

OnAttached()

Raises the Attached event.

protected override void OnAttached()

Remarks

Propagates Canvas to every element in GetVisualChildren() - this is what makes attaching a whole pre-built subtree (the common pattern: build children, then attach the root once via Add(UIElement)) reach every descendant, not just the immediate root. Each child's own Canvas setter recurses into its children the same way, so this walks the full subtree regardless of depth. Container-specific child-add paths (e.g. OnChildAdded(object?, GenericEventArgs<UIElement>)) still assign Canvas directly for children added after the parent is already attached - this cascade is what covers everything built beforehand.

OnDetached()

Raises the Detached event.

protected override void OnDetached()

Remarks

Propagates null to every element in GetVisualChildren(), mirroring OnAttached() - see its remarks.

OnRender(IRenderContext)

Handles custom render logic when overridden in any UIElement instance.

protected override void OnRender(IRenderContext context)

Parameters

context IRenderContext

The context to render with.

Open(DesignDocument)

Opens document: loads its current text into the preview and attaches the editor to it.

public void Open(DesignDocument document)

Parameters

document DesignDocument

A document of Design.

Exceptions

ArgumentNullException

document is null.

InvalidOperationException

Design isn't set.

OpenFile(string)

Loads a markup file the game hasn't loaded yet, and opens the document the session tracks for it.

public bool OpenFile(string path)

Parameters

path string

The file's path.

Returns

bool

false when the file doesn't exist or doesn't load; StatusText says why.

Exceptions

InvalidOperationException

Design isn't set.

RefreshDocuments()

Re-reads the documents Design tracks into the picker.

public void RefreshDocuments()