Пример #1
0
        protected override bool OnBubbleEvent(object source, EventArgs e) {
            bool handled = false;

            CommandEventArgs ce = e as CommandEventArgs;
            if (ce != null) {
                if (String.Equals(CancelCommandName, ce.CommandName, StringComparison.OrdinalIgnoreCase)) {
                    OnCancelButtonClick(EventArgs.Empty);
                    return true;
                }

                int oldIndex = ActiveStepIndex;
                int newIndex = oldIndex;

                // Check if we need to validate the bubble commands VSWhidbey 312445
                bool verifyEvent = true;

                WizardStepType stepType = WizardStepType.Auto;
                WizardStepBase step = WizardSteps[oldIndex];

                // Don't validate commands if it's a templated wizard step
                if (step is TemplatedWizardStep) {
                    verifyEvent = false;
                } else {
                    stepType = GetStepType(step);
                }

                WizardNavigationEventArgs args = new WizardNavigationEventArgs(oldIndex, newIndex);

                // Do not navigate away from current view if view is not valid.
                if (_commandSender != null && Page != null && !Page.IsValid) {
                    args.Cancel = true;
                }

                bool previousButtonCommand = false;
                _activeStepIndexSet = false;

                if (String.Equals(MoveNextCommandName, ce.CommandName, StringComparison.OrdinalIgnoreCase)) {
                    if (verifyEvent) {
                        if (stepType != WizardStepType.Start && stepType != WizardStepType.Step) {
                            throw new InvalidOperationException(SR.GetString(SR.Wizard_InvalidBubbleEvent, MoveNextCommandName));
                        }
                    }

                    if (oldIndex < WizardSteps.Count - 1) {
                        args.SetNextStepIndex(oldIndex + 1);
                    }

                    OnNextButtonClick(args);
                    handled = true;
                } else if (String.Equals(MovePreviousCommandName, ce.CommandName, StringComparison.OrdinalIgnoreCase)) {
                    if (verifyEvent) {
                        if (stepType != WizardStepType.Step && stepType != WizardStepType.Finish) {
                            throw new InvalidOperationException(SR.GetString(SR.Wizard_InvalidBubbleEvent, MovePreviousCommandName));
                        }
                    }

                    previousButtonCommand = true;

                    int previousIndex = GetPreviousStepIndex(false);
                    if (previousIndex != -1) {
                        args.SetNextStepIndex(previousIndex);
                    }

                    OnPreviousButtonClick(args);
                    handled = true;
                } else if (String.Equals(MoveCompleteCommandName, ce.CommandName, StringComparison.OrdinalIgnoreCase)) {
                    if (verifyEvent) {
                        if (stepType != WizardStepType.Finish) {
                            throw new InvalidOperationException(SR.GetString(SR.Wizard_InvalidBubbleEvent, MoveCompleteCommandName));
                        }
                    }

                    if (oldIndex < WizardSteps.Count - 1) {
                        args.SetNextStepIndex(oldIndex + 1);
                    }

                    OnFinishButtonClick(args);
                    handled = true;
                } else if (String.Equals(MoveToCommandName, ce.CommandName, StringComparison.OrdinalIgnoreCase)) {
                    newIndex = Int32.Parse((String)ce.CommandArgument, CultureInfo.InvariantCulture);
                    args.SetNextStepIndex(newIndex);

                    handled = true;
                }

                if (handled) {
                    if (!args.Cancel) {
                        // Honor user's change if activeStepIndex is set explicitely;
                        if (!_activeStepIndexSet) {
                            // Make sure the next step is valid to navigate to
                            if (AllowNavigationToStep(args.NextStepIndex)) {
                                if (previousButtonCommand) {
                                    GetPreviousStepIndex(true);
                                }

                                ActiveStepIndex = args.NextStepIndex;
                            }
                        }
                    } else {
                        // revert active step if it's cancelled.
                        ActiveStepIndex = oldIndex;
                    }
                }
            }

            return handled;
        }
 protected override bool OnBubbleEvent(object source, EventArgs e)
 {
     bool flag = false;
     CommandEventArgs args = e as CommandEventArgs;
     if (args != null)
     {
         if (string.Equals(CancelCommandName, args.CommandName, StringComparison.OrdinalIgnoreCase))
         {
             this.OnCancelButtonClick(EventArgs.Empty);
             return true;
         }
         int activeStepIndex = this.ActiveStepIndex;
         int nextStepIndex = activeStepIndex;
         bool flag2 = true;
         WizardStepType auto = WizardStepType.Auto;
         WizardStepBase step = this.WizardSteps[activeStepIndex];
         if (step is TemplatedWizardStep)
         {
             flag2 = false;
         }
         else
         {
             auto = this.GetStepType(step);
         }
         WizardNavigationEventArgs args2 = new WizardNavigationEventArgs(activeStepIndex, nextStepIndex);
         if (((this._commandSender != null) && (this.Page != null)) && !this.Page.IsValid)
         {
             args2.Cancel = true;
         }
         bool flag3 = false;
         this._activeStepIndexSet = false;
         if (string.Equals(MoveNextCommandName, args.CommandName, StringComparison.OrdinalIgnoreCase))
         {
             if ((flag2 && (auto != WizardStepType.Start)) && (auto != WizardStepType.Step))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("Wizard_InvalidBubbleEvent", new object[] { MoveNextCommandName }));
             }
             if (activeStepIndex < (this.WizardSteps.Count - 1))
             {
                 args2.SetNextStepIndex(activeStepIndex + 1);
             }
             this.OnNextButtonClick(args2);
             flag = true;
         }
         else if (string.Equals(MovePreviousCommandName, args.CommandName, StringComparison.OrdinalIgnoreCase))
         {
             if ((flag2 && (auto != WizardStepType.Step)) && (auto != WizardStepType.Finish))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("Wizard_InvalidBubbleEvent", new object[] { MovePreviousCommandName }));
             }
             flag3 = true;
             int previousStepIndex = this.GetPreviousStepIndex(false);
             if (previousStepIndex != -1)
             {
                 args2.SetNextStepIndex(previousStepIndex);
             }
             this.OnPreviousButtonClick(args2);
             flag = true;
         }
         else if (string.Equals(MoveCompleteCommandName, args.CommandName, StringComparison.OrdinalIgnoreCase))
         {
             if (flag2 && (auto != WizardStepType.Finish))
             {
                 throw new InvalidOperationException(System.Web.SR.GetString("Wizard_InvalidBubbleEvent", new object[] { MoveCompleteCommandName }));
             }
             if (activeStepIndex < (this.WizardSteps.Count - 1))
             {
                 args2.SetNextStepIndex(activeStepIndex + 1);
             }
             this.OnFinishButtonClick(args2);
             flag = true;
         }
         else if (string.Equals(MoveToCommandName, args.CommandName, StringComparison.OrdinalIgnoreCase))
         {
             nextStepIndex = int.Parse((string) args.CommandArgument, CultureInfo.InvariantCulture);
             args2.SetNextStepIndex(nextStepIndex);
             flag = true;
         }
         if (flag)
         {
             if (!args2.Cancel)
             {
                 if (!this._activeStepIndexSet && this.AllowNavigationToStep(args2.NextStepIndex))
                 {
                     if (flag3)
                     {
                         this.GetPreviousStepIndex(true);
                     }
                     this.ActiveStepIndex = args2.NextStepIndex;
                 }
                 return flag;
             }
             this.ActiveStepIndex = activeStepIndex;
         }
     }
     return flag;
 }