Skip to content

Getting Started with Wizards

Craftplacer edited this page May 6, 2021 · 7 revisions

Make sure you referenced Craftplacer.ClassicSuite.Wizards in your project

Adding a new page

  1. Create a new UserControl
  2. View the control's code by pressing F7, or right-clicking and selecting "View Code"
  3. Change the base type from UserControl to WizardPage.
- public partial class MyCoolPage : UserControl
+ public partial class MyCoolPage : WizardPage
  1. Start adding controls to the page.

How to consruct the WizardForm

The WizardForm is the main component of this library. It controls navigation and the outer interface of pages. There are multiple ways to interface with it.

Providing a list (recommended)

A WizardForm can be also constructed using WizardForm.FromList(...), it takes in IEnumerable<WizardPage> (i.e. a list of pages). That methods automatically links pages together with their next one. Using this method is easy as:

var wizard = WizardForm.FromList(new WizardPage[]
{
    new StartPage(),
    new FirstPage(),
    new SecondPage(),
});

Manually linking pages (advanced)

This method requires you to manually define the next page of another page. You can do this by setting the NextPage property inside the constructor of your page control.

public FirstPage()
{
    InitializeComponent();
    NextPage = new SecondPage();
}

You can invoke the WizardForm by simple passing the starting page in its constructor like:

var startPage = new FirstPage();
var wizard = new WizardForm(startPage);

What happens if a page didn't link its next page?

WizardForm will simply assume it's the end of the wizard and finish after that.

Invoking the WizardForm

Since WizardForm is just a regular Form, it can be invoked like any other Form.

// If the application loop (Application.Run()) is already running:
wizardForm.ShowDialog();

// When your entire application uses the wizard interface:
Application.Run(wizardForm);

Learning more

This is the most basic usage of this library, there are pages about customizing pages and asynchronous work.