Suggestion to add skipCommit

Feb 8, 2013 at 10:28 AM
Sometimes it is useful to do not call CommitPage event when going to specified page (such implementation could be useful on cancel event and going to main page without commiting the previous page). Maybe not everyone would find it useful but still...
    /// <summary>
    /// Advances to the specified page.
    /// </summary>
    /// <param name="nextPage">The wizard page to go to next.</param>
    public virtual void NextPage(WizardPage nextPage)
    {
        this.NextPage(nextPage, false);
    }

    /// <summary>
    /// Advances to the specified page.
    /// </summary>
    /// <param name="nextPage">The wizard page to go to next.</param>
    /// <param name="skipCommit">if set to <c>true</c> skip CommitPage event.</param>
    /// <exception cref="System.ArgumentException">When specifying a value for nextPage, it must already be in the Pages collection.;nextPage</exception>
    public virtual void NextPage(WizardPage nextPage, bool skipCommit)
    {
        if (this.IsDesignMode())
        {
            int idx = this.SelectedPageIndex;
            if (idx < this.Pages.Count - 1)
            {
                this.SelectedPage = this.Pages[idx + 1];
            }

            return;
        }

        if (skipCommit || this.SelectedPage.CommitPage())
        {
            this.pageHistory.Push(this.SelectedPage);

            if (nextPage != null)
            {
                if (!this.Pages.Contains(nextPage))
                {
                    throw new ArgumentException("When specifying a value for nextPage, it must already be in the Pages collection.", "nextPage");
                }

                this.SelectedPage = nextPage;
            }
            else
            {
                WizardPage selNext = this.GetNextPage(this.SelectedPage);

                // Check for last page
                if (this.SelectedPage.IsFinishPage || selNext == null)
                {
                    this.OnFinished();
                    return;
                }

                // Set new SelectedPage value
                this.SelectedPage = selNext;
            }
        }
    }
Coordinator
Feb 8, 2013 at 2:59 PM
Nice suggestion. I have implemented it as a parameter with a default of 'false' in version 1.2.4.