Class Wizard | Terminal.Gui v2 (original) (raw)
Namespace
Assembly
Terminal.Gui.dll
Provides navigation and a user interface (UI) to collect related data across multiple steps. Each step (WizardStep) can host arbitrary Views, much like a Dialog. Each step also has a pane for help text. Along the bottom of the Wizard view are customizable buttons enabling the user to navigate forward and backward through the Wizard.
public class Wizard : Dialog, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
Wizard
Implements
Inherited Members
Examples
using Terminal.Gui;
using System.Text;
Application.Init();
var wizard = new Wizard ($"Setup Wizard");
// Add 1st step
var firstStep = new WizardStep ("End User License Agreement");
wizard.AddStep(firstStep);
firstStep.NextButtonText = "Accept!";
firstStep.HelpText = "This is the End User License Agreement.";
// Add 2nd step
var secondStep = new WizardStep ("Second Step");
wizard.AddStep(secondStep);
secondStep.HelpText = "This is the help text for the Second Step.";
var lbl = new Label () { Text = "Name:" };
secondStep.Add(lbl);
var name = new TextField { X = Pos.Right (lbl) + 1, Width = Dim.Fill () - 1 };
secondStep.Add(name);
wizard.Finished += (args) =>
{
MessageBox.Query("Wizard", $"Finished. The Name entered is '{name.Text}'", "Ok");
Application.RequestStop();
};
Application.Top.Add (wizard);
Application.Run ();
Application.Shutdown ();
Constructors
Initializes a new instance of the Wizard class.
Properties
If the CurrentStep is not the first step in the wizard, this button causes theMovingBack event to be fired and the wizard moves to the previous step.
Gets or sets the currently active WizardStep.
Determines whether the Wizard is displayed as modal pop-up or not. The default istrue. The Wizard will be shown with a frame and title and will behave like anyToplevel window. If set to false
the Wizard will have no frame and will behave like any embedded View. To use Wizard as an embedded View
- Set Modal to
false
. - Add the Wizard to a containing view with Add(View?). If a non-Modal Wizard is added to the application afterRun(Toplevel, Func<Exception, bool>?) has been called the first step must be explicitly set by setting CurrentStep toGetNextStep():
wizard.CurrentStep = wizard.GetNextStep();
If the CurrentStep is the last step in the wizard, this button causes the Finishedevent to be fired and the wizard to close. If the step is not the last step, the MovingNext event will be fired and the wizard will move next step.
Methods
Adds a step to the wizard. The Next and Back buttons navigate through the added steps in the order they were added.
Returns the first enabled step in the Wizard
Returns the last enabled step in the Wizard
Returns the next enabled WizardStep after the current step. Takes into account steps which are disabled. If CurrentStep is null
returns the first enabled step.
Returns the first enabled WizardStep before the current step. Takes into account steps which are disabled. If CurrentStep is null
returns the last enabled step.
Causes the wizard to move to the previous enabled step (or first step if CurrentStep is not set). If there is no previous step, does nothing.
Causes the wizard to move to the next enabled step (or last step if CurrentStep is not set). If there is no previous step, does nothing.
Changes to the specified WizardStep.
Wizard is derived from Dialog and Dialog causes Esc
to callRequestStop(Toplevel?), closing the Dialog. Wizard overridesOnKeyDownNotHandled(Key) to instead fire the Cancelled event when Wizard is being used as a non-modal (see Modal).
OnStepChanged(WizardStep?, WizardStep?)
Called when the Wizard has completed transition to a new WizardStep. Fires theStepChanged event.
OnStepChanging(WizardStep?, WizardStep?)
Called when the Wizard is about to transition to another WizardStep. Fires theStepChanging event.
Events
Raised when the user has cancelled the Wizard by pressing the Esc key. To prevent a modal (Modal is true
) Wizard from closing, cancel the event by settingCancel to true
before returning from the event handler.
Raised when the Next/Finish button in the Wizard is clicked. The Next/Finish button is always the last button in the array of Buttons passed to the Wizard constructor, if any. This event is only raised if the CurrentStep is the last Step in the Wizard flow (otherwise the Finishedevent is raised).
Raised when the Back button in the Wizard is clicked. The Back button is always the first button in the array of Buttons passed to the Wizard constructor, if any.
Raised when the Next/Finish button in the Wizard is clicked (or the user presses Enter). The Next/Finish button is always the last button in the array of Buttons passed to the Wizardconstructor, if any. This event is only raised if the CurrentStep is the last Step in the Wizard flow (otherwise the Finished event is raised).
This event is raised after the Wizard has changed the CurrentStep.
This event is raised when the current CurrentStep) is about to change. UseCancel to abort the transition.