Fondest greetings, and welcome to the blog home of the Merlin Wizard Framework! In spite of some tangential posts, this blog will be geared toward getting you up and running with the slickest, simplest, and richest WinForms wizard framework for .NET. If you read the blog posts in chronological order, it may even read like a tutorial.

Sunday, January 18, 2009

Step Sequence Manipulation

Putting aside the unrelenting bliss over the 1.0 release (and my propensity for exaggerating it), it’s time to lay down some more Merlin features. Specifically, we’re going to cover manipulating the step sequence when the wizard is already running.

Here’s how that works:

Somewhere in a step (generally in the NextHandler), you would access the wizard controller and call one or more of the following methods on it:

  • public void AddAfterCurrent(IStep step);
    Adds the specified step immediately after the current step. After the new step executes, the step that originally followed the current step will execute. 
    stepadd
  • public void AddAfterCurrent(IEnumerable<IStep> steps);
    Adds all the steps in the argument immediately after the current step. After all the new steps execute, the step that originally followed the current step will execute. 
    multiplestepadd
  • void DeleteAllAfterCurrent();
    Deletes all steps that follow the current step.
    delete

There are two blatant pitfalls possible here:

  • If a current step has a “Next” button (i.e. it’s not the last in a sequence), but then you delete all the steps that follow, the user will click Next and “run off the end” of the wizard. The wizard will just close, and the Wizard Controller will consider the wizard successfully completed.

  • If the current step is the last one, it will appear with a “Finish” button. If you dynamically add steps afterward, the user will be surprised that clicking the “Finish” button actually leads to more steps. To avoid this phenomenon, just place a dummy step after the first one, so that the first step appears with a “Next” button. Then, you can use DeleteAllAfterCurrent() to delete the placeholder step prior to adding new steps.
  • To see these features in action, check out our step sequence manipulation demo. In this demo, the user chooses a fruit type (apples or oranges), and the subsequent steps are determined by which fruit type the user has chosen.

    Bon appétit!

No comments:

Post a Comment