예제 #1
0
        public bool ShowPage(int pageNo)
        {
            if (panelMiddle.Controls.Count > 0)
            {
                UserControl currentPage    = panelMiddle.Controls[0] as UserControl;
                IWizardPage currentWizPage = currentPage as IWizardPage;

                bool nextEnabled     = buttonNext.Enabled;
                bool previousEnabled = buttonPrevious.Enabled;
                bool cancelEnabled   = buttonCancel.Enabled;

                buttonNext.Enabled     = false;
                buttonPrevious.Enabled = false;
                buttonCancel.Enabled   = false;

                try
                {
                    if (!currentWizPage.OnLeavePage(pageNo > _currentPage))
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return(false);
                }
                finally
                {
                    buttonNext.Enabled     = true;
                    buttonPrevious.Enabled = true;
                    buttonCancel.Enabled   = true;
                }
            }

            _currentPage = pageNo;

            UserControl page    = _pages[_currentPage];
            IWizardPage wizPage = page as IWizardPage;

            new TabOrderManager(page).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst);

            panelMiddle.Controls.Clear();
            panelMiddle.Controls.Add(page);

            page.Dock = DockStyle.Fill;

            labelTitle.Text = wizPage.Title;

            EnableDisable();
            SetButtonTexts();

            wizPage.OnShowPage(_state);

            if (PageChanged != null)
            {
                PageChanged(_currentPage + 1, _pages.Count);
            }

            return(true);
        }