⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wizardcontrol.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 4 页
字号:
        {
            if (WizardPageEnter != null)
                WizardPageEnter(wp, this);
        }

        public virtual void OnWizardPageLeave(WizardPage wp)
        {
            if (WizardPageLeave != null)
                WizardPageLeave(wp, this);
        }

        public virtual void OnSelectionChanged(EventArgs e)
        {
            if (SelectionChanged != null)
                SelectionChanged(this, e);
        }
                
        public virtual void OnCloseClick(EventArgs e)
        {
            if (CloseClick != null)
                CloseClick(this, e);
        }

        public virtual void OnFinishClick(EventArgs e)
        {
            if (FinishClick != null)
                FinishClick(this, e);
        }
    
        public virtual void OnNextClick(CancelEventArgs e)
        {
            if (NextClick != null)
                NextClick(this, e);
        }
    
        public virtual void OnBackClick(CancelEventArgs e)
        {
            if (BackClick != null)
                BackClick(this, e);
        }

        public virtual void OnCancelClick(EventArgs e)
        {
            if (CancelClick != null)
                CancelClick(this, e);
        }
        
        public virtual void OnUpdateClick(EventArgs e)
        {
            if (UpdateClick != null)
                UpdateClick(this, e);
        }
        
        public virtual void OnHelpClick(EventArgs e)
        {
            if (HelpClick != null)
                HelpClick(this, e);
        }

        protected void UpdateControlButtons()
        {
            // Track next button inserted position
            int x = this.Width - _buttonGap - _buttonFinish.Width;
            
            bool showHelp = ShouldShowHelp();
            bool showClose = ShouldShowClose();
            bool showFinish = ShouldShowFinish();
            bool showNext = ShouldShowNext();
            bool showBack = ShouldShowBack();
            bool showCancel = ShouldShowCancel();
            bool showUpdate = ShouldShowUpdate();
            
            if (showHelp) 
            {
                _buttonHelp.Left = x;
                x -= _buttonHelp.Width + _buttonGap;
                _buttonHelp.Enabled = ShouldEnableHelp();
                _buttonHelp.Show();
            }
            else
                _buttonHelp.Hide();

            if (showClose) 
            {
                _buttonClose.Left = x;
                x -= _buttonClose.Width + _buttonGap;
                _buttonClose.Enabled = ShouldEnableClose();
                _buttonClose.Show();
            }
            else
                _buttonClose.Hide();

            if (showFinish) 
            {
                _buttonFinish.Left = x;
                x -= _buttonFinish.Width + _buttonGap;
                _buttonFinish.Enabled = ShouldEnableFinish();
                _buttonFinish.Show();
            }
            else
                _buttonFinish.Hide();

            if (showNext) 
            {
                _buttonNext.Left = x;
                x -= _buttonNext.Width + _buttonGap;
                _buttonNext.Enabled = ShouldEnableNext();
                _buttonNext.Show();
            }
            else
                _buttonNext.Hide();

            if (showBack) 
            {
                _buttonBack.Left = x;
                x -= _buttonBack.Width + _buttonGap;
                _buttonBack.Enabled = ShouldEnableBack();
                _buttonBack.Show();
            }
            else
                _buttonBack.Hide();

            if (showCancel) 
            {
                _buttonCancel.Left = x;
                x -= _buttonCancel.Width + _buttonGap;
                _buttonCancel.Enabled = ShouldEnableCancel();
                _buttonCancel.Show();
            }
            else
                _buttonCancel.Hide();

            if (showUpdate) 
            {
                _buttonUpdate.Left = x;
                x -= _buttonUpdate.Width + _buttonGap;
                _buttonUpdate.Enabled = ShouldEnableUpdate();
                _buttonUpdate.Show();
            }
            else
                _buttonUpdate.Hide();
                
            AutoAssignDefaultButton();
        }
        
        protected void AutoAssignDefaultButton()
        {
            // Get our parent Form instance
            Form parentForm = this.FindForm();
            
            // Cannot assign a default button if we are not on a Form
            if (parentForm != null)
            {
                // Can only assign a particular button if we have been requested 
                // to auto- assign and we are on a selected page
                if (_assignDefault && (_tabControl.SelectedIndex >= 0))
                {
                    // Button default depends on the profile mode
                    switch(_profile)
                    {
                        case Profiles.Install:
                            // Is this the last page?
                            if (_tabControl.SelectedIndex == (_tabControl.TabPages.Count - 1))
                            {
                                // Then use the Close button
                                parentForm.AcceptButton = _buttonClose;
                            }
                            else
                            {
                                // Is this the second from last page?
                                if (_tabControl.SelectedIndex == (_tabControl.TabPages.Count - 2))
                                {
                                    // Then use the Cancel button
                                    parentForm.AcceptButton = _buttonCancel;
                                }
                                else
                                {
                                    // Then use the Next button
                                    parentForm.AcceptButton = _buttonNext;
                                }
                            }
                            break;
                        case Profiles.Configure:
                            // Is this the last page?
                            if (_tabControl.SelectedIndex == (_tabControl.TabPages.Count - 1))
                            {
                                // Then always use the Finish button
                                parentForm.AcceptButton = _buttonFinish;
                            }
                            else
                            {
                                // Else we are not on last page, use the Next button
                                parentForm.AcceptButton = _buttonNext;
                            }
                            break;
                        case Profiles.Controller:
                            // Always use the Update button
                            parentForm.AcceptButton = _buttonUpdate;
                            break;
                    }
                }
                else
                {
                    // Remove any assigned default button
                    parentForm.AcceptButton = null;
                }
            }
        }
        
        protected bool ShouldShowClose()
        {
            bool ret = false;
        
            switch(_showClose)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                switch(_profile)
                {
                    case Profiles.Install:
                        // Must have at least one page
                        if (_tabControl.SelectedIndex != -1)
                        {
                            // Cannot 'Close' unless on the last page
                            if (_tabControl.SelectedIndex == (_tabControl.TabPages.Count - 1))
                                ret = true;
                        }
                        break;
                    case Profiles.Configure:
                        break;
                    case Profiles.Controller:
                        break;
                }
                    break;
            }

            return ret;
        }

        protected bool ShouldEnableClose()
        {
            bool ret = false;
        
            switch(_enableClose)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    ret = true;
                    break;
            }

            return ret;
        }

        protected bool ShouldShowFinish()
        {
            bool ret = false;
        
            switch(_showFinish)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    switch(_profile)
                    {
                        case Profiles.Install:
                            break;
                        case Profiles.Configure:
                            ret = true;
                            break;
                        case Profiles.Controller:
                            break;
                    }
                    break;
            }

            return ret;
        }

        protected bool ShouldEnableFinish()
        {
            bool ret = false;
        
            switch(_enableFinish)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    ret = true;
                    break;
            }

            return ret;
        }

        protected bool ShouldShowNext()
        {
            bool ret = false;

            switch(_showNext)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    switch(_profile)
                    {
                        case Profiles.Install:
                            // Must have at least one page
                            if (_tabControl.SelectedIndex != -1)
                            {
                                // Cannot 'Next' when at the last or second to last pages
                                if (_tabControl.SelectedIndex < (_tabControl.TabPages.Count - 2))
                                    ret = true;
                            }
                            break;
                        case Profiles.Configure:
                            ret = true;
                            break;
                        case Profiles.Controller:
                            break;
                    }
                    break;
            }

            return ret;
        }

        protected bool ShouldEnableNext()
        {
            bool ret = false;

            switch(_enableNext)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    switch(_profile)
                    {
                        case Profiles.Install:
                            // Must have at least one page
                            if (_tabControl.SelectedIndex != -1)
                            {
                                // Cannot 'Next' when at the last or second to last pages
                                if (_tabControl.SelectedIndex < (_tabControl.TabPages.Count - 2))
                                    ret = true;
                            }
                            break;
                        case Profiles.Configure:
                        case Profiles.Controller:
                            // Must have at least one page
                            if (_tabControl.SelectedIndex != -1)
                            {
                                // Cannot 'Next' when at the last or second to last pages
                                if (_tabControl.SelectedIndex < (_tabControl.TabPages.Count - 1))
                                    ret = true;
                            }
                            break;
                    }
                    break;
            }

            return ret;
        }

        protected bool ShouldShowBack()
        {
            bool ret = false;

            switch(_showBack)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    switch(_profile)
                    {
                        case Profiles.Install:
                            // Cannot 'Back' when one the first page or on the last two special pages
                            if ((_tabControl.SelectedIndex > 0) && (_tabControl.SelectedIndex < (_tabControl.TabPages.Count - 2)))
                                ret = true;
                            break;
                        case Profiles.Configure:
                            ret = true;
                            break;
                        case Profiles.Controller:
                            break;
                    }
                    break;
            }

            return ret;
        }

        protected bool ShouldEnableBack()
        {
            bool ret = false;

            switch(_enableBack)
            {
                case Status.No:
                    break;
                case Status.Yes:
                    ret = true;
                    break;
                case Status.Default:
                    // Cannot 'Back' when one the first page
                    if (_tabControl.SelectedIndex > 0)
                        ret = true;
                    break;
            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -