/// <summary> /// Handles the Click event for the Finish button. /// </summary> private void OnClickFinish(object sender, EventArgs e) { // Ensure a page is currently selected if (m_selectedIndex != -1) { // Inform selected page that the Finish button was clicked SinglePage page = (SinglePage)m_pages[m_selectedIndex]; if (page.OnWizardFinish()) { // Deactivate page and close wizard if (page.OnKillActive()) { DialogResult = DialogResult.OK; } } } }
/// <summary> /// Activates the page at the specified index in the page array. /// </summary> /// <param name="newIndex"> /// Index of new page to be selected. /// </param> private void ActivatePage(int newIndex) { // Ensure the index is valid if (newIndex < 0 || newIndex >= m_pages.Count) { throw new ArgumentOutOfRangeException(); } // Deactivate the current page if applicable SinglePage currentPage = null; if (m_selectedIndex != -1) { currentPage = (SinglePage)m_pages[m_selectedIndex]; if (!currentPage.OnKillActive()) { return; } } // Activate the new page SinglePage newPage = (SinglePage)m_pages[newIndex]; if (!newPage.OnSetActive()) { return; } // Update state m_selectedIndex = newIndex; if (currentPage != null) { currentPage.Visible = false; } newPage.Visible = true; newPage.Focus(); }