/// <summary>
        /// Overloaded. Initializes and displays the wizard container form.
        /// In order to define the wizard pages, there must be created an array
        /// of "wizard pages types". This array must be passed to the function.
        /// </summary>
        /// <param name="wizardName">The name of the wizard,
        /// that will be displayed in the title bar.
        /// </param>
        /// <param name="wizardPages">The array of "wizard pages types" that
        /// must be passed to the function.
        /// </param>
        /// <param name="hasFinishPage">A flag indicating if the wizard should
        /// display a finish page.</param>
        /// <param name="initVariableTable">A variable list that has to be passed
        /// to the wizard before initialization.
        /// </param>
        /// <returns>The wizard dialog result (OK, Cancel etc).</returns>
        public static DialogResult CreateWizard(string wizardName,
                                                Type[] wizardPages,
                                                bool hasFinishPage,
                                                BackgroundTask initTask,
                                                Icon customIcon = null)
        {
            // Test there have been defined any wizard pages.
            // If not, then do not show the wizard.
            if (wizardPages.Length <= 0)
            {
                return(DialogResult.Abort);
            }

            // Initialize the wizard container form
            WizardHostForm wizardHostForm = new WizardHostForm();

            // Define the wizard pages/steps
            foreach (Type wizardPage in wizardPages)
            {
                wizardHostForm.AddWizardPage(wizardPage);
            }

            // Set the wizard name
            wizardHostForm.WizardName    = wizardName;
            wizardHostForm.HasFinishPage = hasFinishPage;
            wizardHostForm.KeyPreview    = false;

            // Display the wizard container form
            wizardHostForm.task = initTask;


            if (customIcon != null)
            {
                wizardHostForm.InheritAppIcon = false;
                wizardHostForm.Icon           = customIcon;
            }

            try
            {
                return(wizardHostForm.ShowDialog());
            }
            catch { }

            return(DialogResult.Cancel);
        }
Пример #2
0
        /// <summary>
        /// Overloaded. Initializes and displays the wizard container form.
        /// In order to define the wizard pages, there must be created an array
        /// of "wizard pages types". This array must be passed to the function.
        /// </summary>
        /// <param name="wizardName">The name of the wizard, 
        /// that will be displayed in the title bar.
        /// </param>
        /// <param name="wizardPages">The array of "wizard pages types" that 
        /// must be passed to the function.
        /// </param>
        /// <param name="hasFinishPage">A flag indicating if the wizard should
        /// display a finish page.</param>
        /// <param name="initVariableTable">A variable list that has to be passed
        /// to the wizard before initialization.
        /// </param>
        /// <returns>The wizard dialog result (OK, Cancel etc).</returns>
        public static DialogResult CreateWizard(string wizardName, 
            Type[] wizardPages,
            bool hasFinishPage,
            BackgroundTask initTask, 
            Icon customIcon = null)
        {
            // Test there have been defined any wizard pages.
            // If not, then do not show the wizard.
            if (wizardPages.Length <= 0)
                return DialogResult.Abort;

            // Initialize the wizard container form
            WizardHostForm wizardHostForm = new WizardHostForm();

            // Define the wizard pages/steps
            foreach (Type wizardPage in wizardPages)
            {
                wizardHostForm.AddWizardPage(wizardPage);
            }

            // Set the wizard name
            wizardHostForm.WizardName = wizardName;
            wizardHostForm.HasFinishPage = hasFinishPage;
            wizardHostForm.KeyPreview = false;

            // Display the wizard container form
            wizardHostForm.task = initTask;


            if (customIcon != null)
            {
                wizardHostForm.InheritAppIcon = false;
                wizardHostForm.Icon = customIcon;
            }

            try
            {
                return wizardHostForm.ShowDialog();
            }
            catch { }

            return DialogResult.Cancel;
        }