public sealed class RunicHostedRegion A region of a host page that shows a guest application's Window (the Runic host protocol, region/1): the page's <runic-hosted-region name="…"> shows the guest's page in a frame from the guest's own loopback origin, as part of the host's window.
Remarks
A policy's RunicHostedWindowDecision.Embed creates it with its RunicHostedWindow. The window is open from then on, whether or not a region shows it: it waits until a host page declares a region of its name, loads the guest's page there, and is attached once that page connected. When the page removes the region, reloads or navigates, the window is detached and stays open; it attaches again when a region of the same name appears in the same host window (RunicHostedRegionOptions.ReattachOnReload). When the guest closes its Window or goes away, the region is ended, and the page shows its own content for it.
A departure the host decides, such as a wizard's Back or Next, asks the guest first: register RunicHostedRegion.AsDepartureGuard with the step, or call RunicHostedRegion.RequestCloseAsync. The region's dialogs are owned by its host window. Its events are raised on a thread-pool thread, one at a time.
Experimental; see docs/experimental.md.
Properties
Appearance
public RunicHostedAppearance? Appearance { get; } The appearance override of the region's window (RunicHostedRegionOptions.Appearance, RunicHostedRegion.SetAppearanceAsync), or null for none. It belongs to the window: it stays across a detach, a re-attach and RunicHostedRegion.MoveToAsync.
CanSetAppearance
public bool CanSetAppearance { get; } Whether the guest applies an appearance override: it implements region-appearance/1 (RunicHostedWindowRequest.CanOverrideAppearance). A guest of an older release shows the desktop's appearance.
HostWindow
public IRunicWindow? HostWindow { get; } The host's Window whose page shows the region, or showed it last; null before a page declared it, or for a page of no Runic Window.
IsComponent
public bool IsComponent { get; } Whether the region shows the window as a component in the host page's own document (RunicHostedWindowDecision.EmbedComponent), not in a frame.
IsDocumentEdited
public bool IsDocumentEdited { get; } Whether the guest marks its Window's document as edited (set-document-edited).
IsFocused
public bool IsFocused { get; } Whether the keyboard focus is in the region, as the host page reported it last.
Name
public string Name { get; } The name of the region that shows the window, or that it waits for.
Options
public RunicHostedRegionOptions Options { get; } How the region shows the window, as the policy decided.
PreferredHeight
public int? PreferredHeight { get; } The height the guest asked for last (resize), in CSS pixels, or null; a region whose page declares sizing="content-height" takes it, within RunicHostedRegionOptions.MinimumHeight and RunicHostedRegionOptions.MaximumHeight.
PreferredWidth
public int? PreferredWidth { get; } The width the guest asked for last (resize), in CSS pixels, or null.
Size
public RunicHostedRegionSize? Size { get; } The region's size and scale as the host page reported it last, or null before its first report.
State
public RunicHostedRegionState State { get; } Where the window is: waiting for a region, loading, attached, detached or ended.
Title
public string? Title { get; } The title of the guest's page (set-title), the frame's accessible name, or null.
Methods
AsDepartureGuard
public INavigationDepartureGuard AsDepartureGuard() A departure guard (INavigationDepartureGuard) that asks the guest's close guard first, such as for a wizard step that shows the region: the departure goes ahead only when the guest allowed the close and its Window closed, or the region has ended.
Returns
The guard; it may run again for the same departure.
DetachAsync
public ValueTask DetachAsync(CancellationToken cancellationToken = default) Detaches the window from its region; it stays open and detached, the region shows another window that waits for it or its page's fallback content, and RunicHostedRegion.MoveToAsync attaches it again.
Parameters
cancellationTokenCancels the wait; the detach still happens.
Returns
A task that completes when the guest was told.
MoveToAsync
public ValueTask MoveToAsync(IRunicWindow window, string region, CancellationToken cancellationToken = default) Shows the window in the region region of the page of window, such as another step of a wizard: a window that a region shows now is detached first. It attaches once the page declares the region and no other window shows there.
Parameters
windowThe host's Window whose page declares the region.
regionThe region's name.
cancellationTokenCancels the wait; the move still happens.
Returns
A task that completes when the move started: the window is detached, and attaches when the region takes it.
Exceptions
ArgumentExceptionregionis not a region name.
RequestCloseAsync
public ValueTask<bool> RequestCloseAsync(bool force = false, CancellationToken cancellationToken = default) Asks the guest to close its window, as a departure the host decides does: a Window that guards its close decides first (RunicHostedWindow.RequestCloseAsync).
Parameters
forceWhether the window closes whatever the guest decides.
cancellationTokenCancels the wait for the guest's decision.
Returns
Whether the guest allowed the close; true for an ended region.
SetAppearanceAsync
public ValueTask<bool> SetAppearanceAsync(RunicHostedAppearance? appearance, CancellationToken cancellationToken = default) Sets the appearance override of the region's window, or removes it (null), whether a region shows the window now or not: its pages receive the host's desktop appearance with the override's members in place of the desktop's, and a page that connects later receives it first. The host page sets the override's RunicHostedAppearance.ColorScheme as the CSS color-scheme of the region's frame or component.
Parameters
appearanceThe override; it replaces the previous one as a whole.
cancellationTokenCancels the wait; the override still applies.
Returns
true once the guest was told, or when the override did not change; false when the region has ended, or when the guest does not apply overrides (RunicHostedRegion.CanSetAppearance), which then logs a warning once for the window. RunicHostedRegion.Appearance records the override in that case too.
Remarks
It can be called from any thread. Overrides that the guest has not read yet are coalesced: the guest receives the latest. It does not wait for an attach or a detach in progress.
Events
Attached
public event EventHandler<RunicHostedRegionEventArgs>? Attached Raised when a region of a host page starts to show the window, which then loads the guest's page.
Detached
public event EventHandler<RunicHostedRegionEventArgs>? Detached Raised when the region no longer shows the window, with the reason (RunicHostedRegionEventArgs.Reason).
DocumentEditedChanged
public event EventHandler<RunicHostedRegionEventArgs>? DocumentEditedChanged Raised when RunicHostedRegion.IsDocumentEdited changed.
PreferredSizeChanged
public event EventHandler<RunicHostedRegionEventArgs>? PreferredSizeChanged Raised when RunicHostedRegion.PreferredWidth or RunicHostedRegion.PreferredHeight changed.
StateChanged
public event EventHandler<RunicHostedRegionEventArgs>? StateChanged Raised when RunicHostedRegion.State changed.
TitleChanged
public event EventHandler<RunicHostedRegionEventArgs>? TitleChanged Raised when RunicHostedRegion.Title changed.