예제 #1
0
 /// <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;
             }
         }
     }
 }
예제 #2
0
        // ==================================================================
        // Protected Methods
        // ==================================================================

        /// <seealso cref="System.Windows.Forms.Control.OnControlAdded">
        /// System.Windows.Forms.Control.OnControlAdded
        /// </seealso>
        protected override void OnControlAdded(ControlEventArgs e)
        {
            // Invoke base class implementation
            base.OnControlAdded(e);

            // Set default properties for all WizardPage instances added to
            // this form
            SinglePage page = e.Control as SinglePage;

            if (page != null)
            {
                page.Visible  = false;
                page.Location = new Point(0, 0);
                page.Size     = new Size(Width, m_separator.Location.Y);
                m_pages.Add(page);
                if (m_selectedIndex == -1)
                {
                    m_selectedIndex = 0;
                }
            }
        }
예제 #3
0
        /// <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();
        }