WizardForm Class

Definition

Provides the base class for wizard forms, which contain WizardPage objects.

public ref class WizardForm abstract : Microsoft::Web::Management::Client::Win32::BaseTaskForm
public abstract class WizardForm : Microsoft.Web.Management.Client.Win32.BaseTaskForm
type WizardForm = class
    inherit BaseTaskForm
Public MustInherit Class WizardForm
Inherits BaseTaskForm
Inheritance

Examples

The following example implements several of the methods and properties of the WizardForm class. The wizard form in the example contains three WizardPage objects. The first wizard page displays user name and password text boxes that have a Submit button to enable the user to submit the credentials for validation before moving to the next wizard page.

using System;
using System.Collections;
using System.Collections.Generic;
//using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Text;
using System.Windows.Forms;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.Client.Win32;

namespace ExtensibilityDemo
{
    public partial class DemoModuleWizardForm : WizardForm
    {
        public DemoModuleWizardForm(IServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            InitializeComponent();
            // Upon initial load, the StartPageIndex page is loaded.
            // Get the Pages for this Form;
            int pageCount = Pages.Count;
            TaskCaptionBorderStyle = BorderStyle.None;
            StartTaskProgress();
        }
        private void InitializeComponent()
        {
            this.LoginPage = new ExtensibilityDemo.
                DemoModuleWizardLoginPage();
            this.ModificationPage = new ExtensibilityDemo.
                DemoModuleWizardModificationPage();
            this.LabelPage = new ExtensibilityDemo.
                DemoModuleWizardLabelPage();
            this.SuspendLayout();
            //
            // demomModuleWizardLoginPage
            // 
            this.LoginPage.AutoSize = true;
            this.LoginPage.BackColor = System.Drawing.Color.Silver;
            this.LoginPage.Location = new System.Drawing.Point(25, 25);
            this.LoginPage.Name = "LoginPage";
            this.LoginPage.RightToLeftLayout = false;
            this.LoginPage.Size = new System.Drawing.Size(250, 200);
            this.LoginPage.TabIndex = 1;
            // 
            // demomModuleWizardModificationPage
            // 
            this.ModificationPage.AutoSize = true;
            this.ModificationPage.BackColor = System.Drawing.Color.Silver;
            this.ModificationPage.Location = new System.Drawing.Point(25, 25);
            this.ModificationPage.Name = "ModificationPage";
            //this.ModificationPage.RightToLeftLayout = false;
            this.ModificationPage.Size = new System.Drawing.Size(250, 200);
            this.ModificationPage.TabIndex = 2;
            // 
            // 
            // demomModuleWizardLabelPage
            // 
            this.LabelPage.AutoSize = true;
            this.LabelPage.BackColor = System.Drawing.Color.Silver;
            this.LabelPage.Location = new System.Drawing.Point(25, 25);
            this.LabelPage.Name = "LabelPage";
            this.LabelPage.RightToLeftLayout = false;
            this.LabelPage.Size = new System.Drawing.Size(250, 200);
            this.LabelPage.TabIndex = 3;
            // 
            // demoModuleWizardForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(400, 400);
            this.Name = "demoModuleWizardForm";
            this.Padding = new System.Windows.Forms.Padding(0, 64, 0, 0);
            //           
            // Establish Task Information
            //
            this.Text = "Wizard";
            this.Name = "Wizard";
            this.TaskCaption = "Wizard Form";
            this.TaskDescription = "Build Wizard Form and Wizard Pages.";
            this.ResumeLayout(false); 
        }

        private ExtensibilityDemo.DemoModuleWizardLoginPage LoginPage;
        private ExtensibilityDemo.DemoModuleWizardLabelPage LabelPage;
        private ExtensibilityDemo.DemoModuleWizardModificationPage ModificationPage;
        // Customize the abstract CompleteWizard();
        protected override void CompleteWizard()
        {
            Close();
        }
        // Customize the abstract GetWizardPages.
        protected override WizardPage[] GetWizardPages()
        {
            return new WizardPage[]
            {
                // Create each wizard page.
                new DemoModuleWizardLoginPage(),
                new DemoModuleWizardLabelPage(),
                new DemoModuleWizardModificationPage()
            };
        }
        protected new IList Pages
        {
            get
            {
                // Get a wizard page collection.
                WizardPage[] wizardPages = GetWizardPages();
                ShowMessage("There are " + wizardPages.Length + " wizard pages.");
                return wizardPages;
            }
        }
        // Customize the StartTaskProgressMethod.
        protected override void StartTaskProgress()
        {
            TaskProgressStartColor = Color.Red;
            TaskProgressEndColor = Color.Yellow;
            // Default TaskProgressScrollSpeed is a value of 6.
            TaskProgressScrollSpeed = 2;
            // Default TaskProgressGradientSpeed is a value of 1;
            TaskProgressGradientSpeed = 3;
            //Set the task Glyph.
            TaskGlyph = Icon.FromHandle(Cursors.Arrow.Handle).ToBitmap();
            TaskGlyph.RotateFlip(RotateFlipType.Rotate90FlipNone);
            // Implement the StartTaskProgress from the base class.
            base.StartTaskProgress();
        }
        // Customize the IsCancellable property. Default is true;
        protected override bool IsCancellable
        {
            get
            {
                return true;
            }
        }
        // Customize the CancelWizard method.
        protected override void CancelWizard()
        {
            //Check the IsCancellable property before performing a cancel.
            if (IsCancellable)
            {
                // Verify that the user wants to cancel the wizard.
                DialogResult result = ShowMessage("Are you sure you want to exit?",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    base.StopTaskProgress();
                    base.CancelWizard();
                }
            }
        }
        // Customize the OnPageChanged method
        protected override void  OnPageChanged(EventArgs e)
        {
            // To get to the LabelPage the user has been validated.
            if (this.CurrentPage.Name == "demoModuleWizardLabelPage")
            {
                this.TaskCaption = "User is signed in";
            }
            base.OnPageChanged(e);
        }
        // Customize the Border Margin. The default is 14 pixels;
        protected override int BorderMargin
        {
            get
            {
                return 25;
            }
        }
        // Customize the OnLoad method, with the user's name.
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Controls[0].Controls["_pageContainer"].
                Controls["demoModuleWizardLoginPage"].
                Controls["textBox1"].Text =
                System.Environment.UserName;
        }
    }
}
using System;
using System.Collections;
using System.Collections.Generic;
//using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Text;
using System.Windows.Forms;
using Microsoft.Web.Management.Client;
using Microsoft.Web.Management.Client.Win32;

namespace ExtensibilityDemo
{
    public partial class DemoModuleWizardForm : WizardForm
    {
        public DemoModuleWizardForm(IServiceProvider serviceProvider)
            : base(serviceProvider)
        {
            InitializeComponent();
            // Upon initial load, the StartPageIndex page is loaded.
            // Get the Pages for this Form;
            int pageCount = Pages.Count;
            TaskCaptionBorderStyle = BorderStyle.None;
            StartTaskProgress();
        }
        private void InitializeComponent()
        {
            this.LoginPage = new ExtensibilityDemo.
                DemoModuleWizardLoginPage();
            this.ModificationPage = new ExtensibilityDemo.
                DemoModuleWizardModificationPage();
            this.LabelPage = new ExtensibilityDemo.
                DemoModuleWizardLabelPage();
            this.SuspendLayout();
            //
            // demomModuleWizardLoginPage
            // 
            this.LoginPage.AutoSize = true;
            this.LoginPage.BackColor = System.Drawing.Color.Silver;
            this.LoginPage.Location = new System.Drawing.Point(25, 25);
            this.LoginPage.Name = "LoginPage";
            this.LoginPage.RightToLeftLayout = false;
            this.LoginPage.Size = new System.Drawing.Size(250, 200);
            this.LoginPage.TabIndex = 1;
            // 
            // demomModuleWizardModificationPage
            // 
            this.ModificationPage.AutoSize = true;
            this.ModificationPage.BackColor = System.Drawing.Color.Silver;
            this.ModificationPage.Location = new System.Drawing.Point(25, 25);
            this.ModificationPage.Name = "ModificationPage";
            //this.ModificationPage.RightToLeftLayout = false;
            this.ModificationPage.Size = new System.Drawing.Size(250, 200);
            this.ModificationPage.TabIndex = 2;
            // 
            // 
            // demomModuleWizardLabelPage
            // 
            this.LabelPage.AutoSize = true;
            this.LabelPage.BackColor = System.Drawing.Color.Silver;
            this.LabelPage.Location = new System.Drawing.Point(25, 25);
            this.LabelPage.Name = "LabelPage";
            this.LabelPage.RightToLeftLayout = false;
            this.LabelPage.Size = new System.Drawing.Size(250, 200);
            this.LabelPage.TabIndex = 3;
            // 
            // demoModuleWizardForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(400, 400);
            this.Name = "demoModuleWizardForm";
            this.Padding = new System.Windows.Forms.Padding(0, 64, 0, 0);
            //           
            // Establish Task Information
            //
            this.Text = "Wizard";
            this.Name = "Wizard";
            this.TaskCaption = "Wizard Form";
            this.TaskDescription = "Build Wizard Form and Wizard Pages.";
            this.ResumeLayout(false); 
        }

        private ExtensibilityDemo.DemoModuleWizardLoginPage LoginPage;
        private ExtensibilityDemo.DemoModuleWizardLabelPage LabelPage;
        private ExtensibilityDemo.DemoModuleWizardModificationPage ModificationPage;
        // Customize the abstract CompleteWizard();
        protected override void CompleteWizard()
        {
            Close();
        }
        // Customize the abstract GetWizardPages.
        protected override WizardPage[] GetWizardPages()
        {
            return new WizardPage[]
            {
                // Create each wizard page.
                new DemoModuleWizardLoginPage(),
                new DemoModuleWizardLabelPage(),
                new DemoModuleWizardModificationPage()
            };
        }
        protected new IList Pages
        {
            get
            {
                // Get a wizard page collection.
                WizardPage[] wizardPages = GetWizardPages();
                ShowMessage("There are " + wizardPages.Length + " wizard pages.");
                return wizardPages;
            }
        }
        // Customize the StartTaskProgressMethod.
        protected override void StartTaskProgress()
        {
            TaskProgressStartColor = Color.Red;
            TaskProgressEndColor = Color.Yellow;
            // Default TaskProgressScrollSpeed is a value of 6.
            TaskProgressScrollSpeed = 2;
            // Default TaskProgressGradientSpeed is a value of 1;
            TaskProgressGradientSpeed = 3;
            //Set the task Glyph.
            TaskGlyph = Icon.FromHandle(Cursors.Arrow.Handle).ToBitmap();
            TaskGlyph.RotateFlip(RotateFlipType.Rotate90FlipNone);
            // Implement the StartTaskProgress from the base class.
            base.StartTaskProgress();
        }
        // Customize the IsCancellable property. Default is true;
        protected override bool IsCancellable
        {
            get
            {
                return true;
            }
        }
        // Customize the CancelWizard method.
        protected override void CancelWizard()
        {
            //Check the IsCancellable property before performing a cancel.
            if (IsCancellable)
            {
                // Verify that the user wants to cancel the wizard.
                DialogResult result = ShowMessage("Are you sure you want to exit?",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Yes)
                {
                    base.StopTaskProgress();
                    base.CancelWizard();
                }
            }
        }
        // Customize the OnPageChanged method
        protected override void  OnPageChanged(EventArgs e)
        {
            // To get to the LabelPage the user has been validated.
            if (this.CurrentPage.Name == "demoModuleWizardLabelPage")
            {
                this.TaskCaption = "User is signed in";
            }
            base.OnPageChanged(e);
        }
        // Customize the Border Margin. The default is 14 pixels;
        protected override int BorderMargin
        {
            get
            {
                return 25;
            }
        }
        // Customize the OnLoad method, with the user's name.
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Controls[0].Controls["_pageContainer"].
                Controls["demoModuleWizardLoginPage"].
                Controls["textBox1"].Text =
                System.Environment.UserName;
        }
    }
}

Remarks

Because this class is abstract, you cannot create an instance of it directly.

A WizardForm object contains one or more wizard pages, which create a user interface (UI) to collect related data across multiple steps.

Notes to Implementers

When you inherit from WizardForm, you must override the following members: CompleteWizard() and GetWizardPages().

Constructors

WizardForm(IServiceProvider)

Initializes a new instance of the WizardForm class.

Properties

BackgroundJobRunning

Gets a value indicating whether the background worker thread is busy.

(Inherited from BaseTaskForm)
BorderMargin

Gets the width of the margins around the wizard page in the wizard form.

CanCancel

When overridden in a derived class, gets a value indicating whether the wizard can be canceled.

CanComplete

When overridden in a derived class, gets a value indicating whether the wizard can be completed.

CanShowHelp

Gets a value indicating whether the user can view the Help file.

CurrentPage

Gets the current page that is displayed in the wizard form.

IsCancellable

When overridden in a derived class, gets a value indicating whether the wizard can be canceled.

Pages

Gets the IList interface that contains the collection of pages in the wizard.

ServiceProvider

Gets the service object for the class.

(Inherited from BaseForm)
StartPageIndex

When overridden in a derived class, gets the page index of the first page that the wizard displays when it is first loaded.

TaskCaption

Gets or sets the caption of a task, wizard form, or other object.

TaskCaptionBorderStyle

Gets or sets the border style for the task caption.

TaskDescription

Gets or sets the description of a task, wizard form, or other object.

TaskGlyph

Gets or sets the image for the form.

TaskProgressEndColor

Gets or sets the ending color for the progress bar gradient.

TaskProgressGradientSpeed

Gets or sets the number of color-gradient cycles that the progress bar will display at any one time.

TaskProgressScrollSpeed

Gets or sets the scroll speed of the progress bar.

TaskProgressStartColor

Gets or sets the starting color for the progress bar gradient.

WizardData

When overridden in a derived class, gets the information for the wizard.

Methods

CancelAsyncTask()

Provides a method for the user to cancel the current task.

(Inherited from BaseTaskForm)
CancelWizard()

When overridden in a derived class, indicates that the user has canceled the wizard form.

CompleteWizard()

When overridden in a derived class, enables the user to close the wizard by clicking the Finish button.

DisplayErrorMessage(Exception, ResourceManager)

Displays a modal dialog box with an error message, based on the specified exception and resource manager.

(Inherited from BaseTaskForm)
Dispose(Boolean)

Releases the unmanaged resources used by the BaseForm and optionally releases the managed resources.

(Inherited from BaseForm)
GetService(Type)

Retrieves the requested service.

(Inherited from BaseForm)
GetWizardPages()

When overridden in a derived class, returns a collection of wizard pages that the wizard form contains.

InvalidateTask(Boolean)

Invalidates the progress bar and causes the control to be redrawn.

(Inherited from BaseTaskForm)
NavigateToNextPage()

Provides a mechanism to move to the next wizard page of the wizard form.

NavigateToPreviousPage()

Provides a mechanism to move to the previous wizard page of the wizard form.

OnActivated(EventArgs)

Occurs when the base form is activated.

(Inherited from BaseForm)
OnClosing(CancelEventArgs)

Indicates that the form is closing, and raises the Closing event.

OnHelpRequested(HelpEventArgs)

Occurs when a Help control is activated.

(Inherited from BaseForm)
OnInitialActivated(EventArgs)

Indicates that the form has been loaded for the first time, and raises the Activated event.

OnLoad(EventArgs)

Indicates that the wizard form is loaded, and raises the Load event.

OnPageChanged(EventArgs)

Indicates that the user has moved from the current page to the previous or next page of the wizard form.

OnPageChanging(EventArgs)

When overridden in a derived class, indicates that the user is moving from the current page to the previous or next page of the wizard form.

OnPaint(PaintEventArgs)

Indicates that the wizard form is being redrawn, and raises the Paint event.

SetButtonsPanel(Control)

Adds a button to the button panel.

(Inherited from BaseTaskForm)
SetContent(Control)

Sets the controls for the Content View page in IIS Manager.

(Inherited from BaseTaskForm)
ShouldShowPage(WizardPage)

When overridden in a derived class, determines which pages of the wizard can be shown in the wizard form.

ShowError(Exception, String, Boolean)

Displays the specified exception and information about the exception in a message box.

(Inherited from BaseForm)
ShowHelp()

Provides a mechanism to display the wizard Help file.

ShowMessage(String)

Displays a message box that uses the specified text.

(Inherited from BaseForm)
ShowMessage(String, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton)

Displays a message box that uses the specified text, button set, symbol, and default button.

(Inherited from BaseForm)
StartAsyncTask(DoWorkEventHandler, RunWorkerCompletedEventHandler)

Starts a task by using a worker thread, and configures the work-completed event handler.

(Inherited from BaseTaskForm)
StartAsyncTask(DoWorkEventHandler, RunWorkerCompletedEventHandler, MethodInvoker)

Starts a task by using a worker thread, and configures the work-completed and cancel-task event handlers.

(Inherited from BaseTaskForm)
StartAsyncTask(DoWorkEventHandler, RunWorkerCompletedEventHandler, MethodInvoker, Object)

Starts a task by using a worker thread, configures the work-completed and cancel-task event handlers, and passes an object to the task event handler.

(Inherited from BaseTaskForm)
StartTaskProgress()

Starts the progress bar.

StopTaskProgress()

Stops the progress bar.

Update()

Updates the view of the wizard form.

UpdateWizard()

Updates the view of the wizard form.

WndProc(Message)

Reroutes the context-sensitive Help button events to the ShowHelp() method.

(Inherited from BaseForm)

Applies to