dahall / AeroWizard

Library for easy creation of custom and Aero Wizards. Aero Wizard strictly follows Microsoft guidelines and uses Visual Styles to get visual theming.
MIT License
112 stars 32 forks source link

Suggestion to add skipCommit #49

Closed dahall closed 5 years ago

dahall commented 5 years ago

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;
            }
        }
    }

Originally posted: 2013-02-08T04:28:31

dahall commented 5 years ago

Nice suggestion. I have implemented it as a parameter with a default of 'false' in version 1.2.4.

Originally posted: 2013-02-08T08:59:46