Class FlowControl
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A container control that renders a single flow step inline — a banner band on top, a scrollable body in the middle, and a button toolbar at the bottom — instead of opening a modal window per step. It is the in-control counterpart to ModalWindowHost / SwapContentHost: drive it via AsHost() to present flow steps that live inside an existing window's layout.
public class FlowControl : GridControl, IDOMPaintable, INotifyPropertyChanged, IContainer, IContainerControl, IControlHost, IColorRoleableControl, IGridSource, IFillReportsMinimumHeight, IInteractiveControl, IFocusableControl, IMouseAwareControl, IWindowControl, IDisposable, IFocusScope, ILogicalCursorProvider, ICursorShapeProvider
- Inheritance
-
FlowControl
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Composition. A FlowControl is a three-row GridControl
(Auto top band / Star body / Auto bottom band) with a flow-presentation API.
It subclasses GridControl rather than wrapping one, so it inherits — for free and
without any change to the layout/focus/mouse core — full child hosting: cell children participate
in the layout tree, take focus and Tab order, route mouse clicks, and report a cursor. This is why
a button rendered into the bottom band is reachable and clickable inside the control.
Threading. ShowStep(IReadOnlyList<IWindowControl>, IWindowControl, IReadOnlyList<IWindowControl>, string) mutates the grid and so must run on the UI thread; the
inline host marshals its call via ConsoleWindowSystem.EnqueueOnUIThread.
Constructors
FlowControl()
Initializes a new, empty FlowControl. The control shows nothing until a step is
presented through AsHost() or one of the Run overloads.
public FlowControl()
Properties
Container
Overrides the Container setter to detect removal from the parent
while a flow is running. When the control is detached (value is
null) and a flow is in progress, the per-run cancellation token is cancelled
so the flow observes OperationCanceledException and resolves as
Cancelled instead of hanging indefinitely. The inline host's
in-flight step is also resolved promptly (with Cancel) so the
pending await unblocks immediately rather than only on the next token-observing await.
public override IContainer? Container { get; set; }
Property Value
Placeholder
Gets or sets the control displayed when the FlowControl is idle (before any
Run call) and after a flow has ended. When null the control renders
empty in those states. Setting this property while the control is idle immediately updates the
displayed content; setting it during a running flow stores the value for restoration when the
flow ends.
public IWindowControl? Placeholder { get; set; }
Property Value
Methods
AsHost()
Returns the IFlowHost that presents flow steps inside this control. The same host instance is returned on every call, so steps presented through it share this one control.
public IFlowHost AsHost()
Returns
- IFlowHost
The control's inline flow host.
Run(Func<FlowContext, Task>)
Runs an imperative flow body that produces no payload inline inside this control.
The returned FlowResult<T> carries bool with
Value set to true on completion.
public Task<FlowResult<bool>> Run(Func<FlowContext, Task> body)
Parameters
bodyFunc<FlowContext, Task>The flow body; receives a FlowContext.
Returns
- Task<FlowResult<bool>>
A FlowResult<T> of
bool, withValue == trueon completion.
Exceptions
- InvalidOperationException
Thrown synchronously when a flow is already running on this control (re-entrancy guard), or when the control has not yet been added to a window in a ConsoleWindowSystem.
Run<TState>(FlowWizardBuilder<TState>)
Runs a declarative wizard inline inside this control. Every step is presented inside this control instead of opening a modal window per step.
public Task<FlowResult<TState>> Run<TState>(FlowWizardBuilder<TState> wizard) where TState : new()
Parameters
wizardFlowWizardBuilder<TState>The configured FlowWizardBuilder<TState> to run.
Returns
- Task<FlowResult<TState>>
The wizard outcome carrying the final state on completion.
Type Parameters
TStateThe mutable wizard state type.
Exceptions
- InvalidOperationException
Thrown synchronously when a flow is already running on this control (re-entrancy guard), or when the control has not yet been added to a window in a ConsoleWindowSystem.
Run<T>(Func<FlowContext, Task<T>>)
Runs an imperative flow body that produces a typed value inline inside this control. The body receives a FlowContext and returns the flow's value; each step is presented inside this control (no modal window is opened).
public Task<FlowResult<T>> Run<T>(Func<FlowContext, Task<T>> body)
Parameters
bodyFunc<FlowContext, Task<T>>The flow body; receives a FlowContext and returns the flow's value.
Returns
- Task<FlowResult<T>>
A FlowResult<T> carrying the body's value on completion, cancelled when the body throws OperationCanceledException, or faulted for any other exception.
Type Parameters
TThe value type produced by the flow body on completion.
Exceptions
- InvalidOperationException
Thrown synchronously when a flow is already running on this control (re-entrancy guard), or when the control has not yet been added to a window in a ConsoleWindowSystem.