protected virtual WizardNavigationButton CreateForwardButton(IWizard wizard)
        {
            var button = new WizardNavigationButton
            {
                Content            = _languageService.GetString("Wizard_Next"),
                IsVisibleEvaluator = () => !wizard.IsLastPage(),
                StyleEvaluator     = (x) =>
                {
                    var styleName = !wizard.IsLastPage() ? "WizardNavigationPrimaryButtonStyle" : "WizardNavigationButtonStyle";

                    var application = System.Windows.Application.Current;
                    return(application?.TryFindResource(styleName) as Style);
                },
                Command = new TaskCommand(async() =>
                {
                    await wizard.MoveForwardAsync();
                },
                                          () =>
                {
                    if (!wizard.HandleNavigationStates)
                    {
                        return(true);
                    }

                    return(wizard.CanMoveForward);
                })
            };

            return(button);
        }
        protected virtual WizardNavigationButton CreateFinishButton(IWizard wizard)
        {
            var button = new WizardNavigationButton
            {
                Content            = _languageService.GetString("Wizard_Finish"),
                IsVisibleEvaluator = () => wizard.IsLastPage(),
                Command            = new TaskCommand(async() =>
                {
                    await wizard.ResumeAsync();
                },
                                                     () =>
                {
                    if (!wizard.HandleNavigationStates)
                    {
                        return(true);
                    }

                    if (!Wizard.CanResume)
                    {
                        return(false);
                    }

                    // Don't validate
                    var validationSummary = wizard.GetValidationContextForCurrentPage(false);
                    if (!validationSummary.HasErrors)
                    {
                        return(true);
                    }

                    return(false);
                })
            };

            return(button);
        }
        protected virtual WizardNavigationButton CreateFinishButton(IWizard wizard)
        {
            var button = new WizardNavigationButton
            {
                Content            = _languageService.GetString("Wizard_Finish"),
                IsVisibleEvaluator = () => wizard.IsLastPage(),
                StyleEvaluator     = (x) =>
                {
                    var styleName = wizard.IsLastPage() ? "WizardNavigationPrimaryButtonStyle" : "WizardNavigationButtonStyle";

                    var application = System.Windows.Application.Current;
                    return(application?.TryFindResource(styleName) as Style);
                },
                Command = new TaskCommand(async() =>
                {
                    await wizard.ResumeAsync();
                },
                                          () =>
                {
                    if (!wizard.HandleNavigationStates)
                    {
                        return(true);
                    }

                    if (!Wizard.CanResume)
                    {
                        return(false);
                    }

                    // Don't validate
                    var validationSummary = wizard.GetValidationContextForCurrentPage(false);
                    if (!validationSummary.HasErrors)
                    {
                        return(true);
                    }

                    return(false);
                })
            };

            return(button);
        }
        protected virtual WizardNavigationButton CreateForwardButton(IWizard wizard)
        {
            var button = new WizardNavigationButton
            {
                Content            = _languageService.GetString("Wizard_Next"),
                IsVisibleEvaluator = () => !wizard.IsLastPage(),
                Command            = new TaskCommand(async() =>
                {
                    await wizard.MoveForwardAsync();
                },
                                                     () =>
                {
                    if (!wizard.HandleNavigationStates)
                    {
                        return(true);
                    }

                    return(wizard.CanMoveForward);
                })
            };

            return(button);
        }
Esempio n. 5
0
        protected override WizardNavigationButton CreateFinishButton(IWizard wizard)
        {
            var button = new WizardNavigationButton
            {
                Content            = _languageService.GetString("Wizard_Finish"),
                IsVisibleEvaluator = () => true,
                StyleEvaluator     = (x) =>
                {
                    var styleName = wizard.IsLastPage() ? "WizardNavigationPrimaryButtonStyle" : "WizardNavigationButtonStyle";

                    var application = System.Windows.Application.Current;
                    return(application?.TryFindResource(styleName) as Style);
                },
                Command = new TaskCommand(async() =>
                {
                    if (wizard.IsLastPage())
                    {
                        // Just resume
                        await wizard.ResumeAsync();
                        return;
                    }

                    var wizardPages = wizard.Pages.ToList();

                    var summaryPage = wizardPages.LastOrDefault(x => x is SummaryWizardPage) as SummaryWizardPage;
                    if (summaryPage is not null)
                    {
                        // Navigate to summary page
                        var typedWizard = wizard as WizardBase;
                        if (typedWizard is null)
                        {
                            // Manually move next
                            while (true)
                            {
                                if (wizard.IsLastPage())
                                {
                                    break;
                                }

                                if (ReferenceEquals(wizardPages, typedWizard))
                                {
                                    break;
                                }
                            }

                            return;
                        }

                        await typedWizard.MoveToPageAsync(summaryPage);
                        return;
                    }

                    // Last resort: try to resume normally
                    await wizard.ResumeAsync();
                },
                                          () =>
                {
                    if (!wizard.HandleNavigationStates)
                    {
                        return(true);
                    }

                    //var validationSummary = this.GetValidationSummary(true);
                    //return !validationSummary.HasErrors && !validationSummary.HasWarnings && Wizard.CanResume;

                    return(wizard.CanResume);
                })
            };

            return(button);
        }