/// <summary> /// Moves to the next page in the collection /// </summary> /// <returns>Next page as IWizard</returns> public IWizardPage MovePageNext() { bool check = CurrentPage.CheckForm(); if (!check) { MessageBox.Show(CurrentPage.ValidationMessage); return(null); } int previousPageIndex = IndexOf(CurrentPage); if (PageLocation != WizardPageLocation.End && CurrentPage != null) { // Find the index of the next page int nextPageIndex = (from x in this where x.Key > IndexOf(CurrentPage) select x.Key).Min(); // Find the index of the last page int lastPageIndex = (from x in this select x.Key).Max(); // If the next page is the last page if (nextPageIndex == lastPageIndex) { PageLocation = WizardPageLocation.End; } else { PageLocation = WizardPageLocation.Middle; } // Set the current page to be the next page CurrentPage = this[nextPageIndex]; NotifyPageChanged(previousPageIndex); return(CurrentPage); } return(null); }