Modes

FormCallMode is Modal, Modeless or Replace. Manager methods: CallFormAsync(name, parameters, mode, ct), OpenFormModelessAsync, NewFormAsync, ReturnToCallerAsync(returnData), GetFormParameter(name), GetCallStack.

Shared state and messaging: SetGlobalVariable, GetGlobalVariable, SendParameterToForm, PostMessage(targetForm, messageType, payload), BroadcastMessage, SubscribeToMessage and UnsubscribeFromMessage.

Register the target form

A form can only be called when it is in the engine form registry. FormRegistry is on the concrete DMEEditor, not on IDMEEditor.

((TheTechIdea.Beep.DMEEditor)editor).FormRegistry.RegisterForm("OrderDetail", manager);
manager.CurrentFormName = "OrderEntry";

When the target is not registered, CallFormAsync returns false and the WinForms host shows an error saying the form is not registered in the engine's form registry, or that its WHEN-NEW-FORM-INSTANCE trigger declined it.

Form factory

The host needs a FormFactory that creates the window.

  • WinForms: an IWinFormFormsFactory with ShowModalAsync, ShowModelessAsync, ReplaceCurrentAsync (each takes the form name, a read only dictionary of parameters and a cancellation token) and ReturnToCallerAsync(returnData, ct).
  • WPF: a function from the form name and an optional parameter dictionary to a Window. The host shows and closes the window.
_masterHost.FormFactory = (_, parameters) => new OrderDetailWindow(manager, parameters);

Without a factory the host throws "A WinForms form factory must be assigned before opening another form." or the WPF equivalent.

Example flow

The end to end example calls CallFormAsync("OrderDetail", parameters, FormCallMode.Modal) with the parameters OrderId and Qty. The called form's host calls ReturnToCallerAsync() when it is done.