コード例 #1
0
        private void SetActiveControl(IWizardControl control)
        {
            try
            {
                IWizardControl oldActiveControl = _currentControl as IWizardControl;
                if (null != oldActiveControl)
                {
                    oldActiveControl.ReadyStateChanged -= new ReadyStateChangedHandler(currentControl_ReadyStateChanged);
                }

                foreach (Control item in panelControls.Controls)
                {
                    item.Visible = false;
                }

                if (null != oldActiveControl)
                {
                    oldActiveControl.Deactivate();
                }

                (control as Control).Visible = true;
                _currentControl      = control;
                nextButton.Enabled   = false;
                backButton.Enabled   = !IsFirstControl(_currentControl);
                backButton.Visible   = true;
                cancelButton.Visible = true;
                if (IsLastControl(_currentControl))
                {
                    finishButton.Location = nextButton.Location;
                    nextButton.Visible    = false;
                    finishButton.Visible  = true;
                }
                else
                {
                    nextButton.Visible   = true;
                    finishButton.Visible = false;
                }

                (_currentControl as IWizardControl).Translate();
                (_currentControl as IWizardControl).Activate();
                labelCaption.Text     = Captions.GetCaption(_currentControl as IWizardControl);
                labelDescription.Text = Captions.GetDescription(_currentControl as IWizardControl);
                if ((_currentControl as IWizardControl).Image == ImageType.Question)
                {
                    imageBox.Image = imageListIcons.Images[0];
                }
                else
                {
                    imageBox.Image = imageListIcons.Images[1];
                }
                nextButton.Enabled = (_currentControl as IWizardControl).IsReadyForNextStep;

                int currentIndex = GetControlIndex(_currentControl) + 1;
                int totalCount   = IsAddinProject == true ? _listControls.Count : _listControls.Count - 2;
                if (currentIndex > totalCount)
                {
                    currentIndex = totalCount;
                }

                labelCurrentStep.Text = Localized.StepProgress.Replace("{0}", currentIndex.ToString()).Replace("{1}", totalCount.ToString());

                labelCurrentStep.Tag = new string[] { (GetControlIndex(_currentControl) + 1).ToString(), _listControls.Count.ToString() };

                (_currentControl as IWizardControl).ReadyStateChanged += new ReadyStateChangedHandler(currentControl_ReadyStateChanged);

                int index = GetControlIndex(_currentControl);
                BorderCurrentStep(index);
                (_currentControl as Control).Focus();
            }
            catch (Exception exception)
            {
                Forms.ErrorForm.ShowError(this, exception);
            }
        }