Пример #1
0
 /// <summary>
 /// Determines whether given step is currently loaded in wizard.
 /// </summary>
 /// <param name="step">Step control to examine</param>
 /// <returns>TRUE if step is currently active</returns>
 public bool IsStepActive(AbstractStep step)
 {
     return(step == CurrentStep);
 }
Пример #2
0
        /// <summary>
        /// Performs step change of wizard.
        /// </summary>
        /// <param name="validate">Indicates whether to perform validation</param>
        /// <param name="forward">Whether to move forward or backward</param>
        private async void MakeStep(bool forward, bool validate)
        {
            int newStep = forward ? currentStep + 1 : currentStep - 1;

            // Adjust step
            switch (newStep)
            {
            case 8:
                if (ImportProfile.Sites.Count == 0)
                {
                    if (forward)
                    {
                        // Skip irrelevant steps
                        newStep = GetStepId <Step10>();
                    }
                }
                break;

            case 9:
                if (ImportProfile.Sites.Count == 0)
                {
                    if (!forward)
                    {
                        // Skip irrelevant steps
                        newStep = GetStepId <Step7>();
                    }
                }
                break;
            }

            AbstractStep fromStep = Steps[currentStep];
            AbstractStep toStep   = Steps[newStep];

            bool valid = (fromStep == null) || !validate || await fromStep.IsValid();

            // If current step is valid
            if (valid)
            {
                try
                {
                    currentStep = newStep;

                    // Delete all controls from wizard
                    WizardBody.Controls.Clear();

                    // Step should fill parent panel
                    toStep.Dock = DockStyle.Fill;

                    // Add new step
                    WizardBody.Controls.Add(toStep);
                }
                catch (Exception ex)
                {
                    // Show message
                    ShowError(ResHelper.GetString("Error_MovingStep"), ResHelper.GetString("Error_MovingStepCaption"), ex);
                }
            }

            // Set step name and description
            headerControl.SetTitle(ResHelper.GetString("StepName_" + currentStep));
            headerControl.SetSubtitle(ResHelper.GetString("StepDescription_" + currentStep));

            // Ensure waiting state is turned off
            if (validate && (currentStep != 11))
            {
                SetWaitState(false, string.Empty);
            }

            // Set visibility of next and back buttons
            ButtonBack.Visible = ((currentStep != 1) && (currentStep != 11));
            ButtonNext.Visible = (currentStep != 11);

            // Set caption of next button
            ButtonNext.Text    = ResHelper.GetString("Wizard_Next");
            ButtonNext.Enabled = true;

            // Raise step loaded event
            if (StepLoadedEvent != null)
            {
                StepLoadedEvent(this, null);
            }
        }