Beispiel #1
0
        private void RegisterViews(IWizardContext context)
        {
            ValidateContext(context);

            stepViews = new List <object>();

            var stepsRegion = GetStepsRegion(wizardRegionManager);

            var orderedSteps = context.OrderBy((s) => s.Index).ToList();

            foreach (var step in orderedSteps)
            {
                wizardContainer.RegisterType(step.IViewModel, step.ViewModel);

                wizardRegionManager.RegisterViewWithRegion(stepsRegion.Name, () =>
                {
                    var viewType         = step.View;
                    var stepViewInstance = wizardContainer.Resolve(viewType);
                    stepViews.Add(stepViewInstance);
                    return(stepViewInstance);
                });
            }

            var firstStep = orderedSteps.FirstOrDefault();

            if (firstStep != null)
            {
                firstStep.IsCurrent = true;
            }
        }
Beispiel #2
0
        private void ValidateContext(IWizardContext context)
        {
            var duplicateSteps = context.Select(ci => ci.Index).GroupBy(i => i).
                                 Where(g => g.Count() > 1).Select(g => g.Key);

            if (duplicateSteps.Count() > 0)
            {
                throw new Exception("Found duplicated step indices. All step indices must be unique");
            }

            var duplicateViewTypes = context.Select(ci => ci.View).GroupBy(i => i).
                                     Where(g => g.Count() > 1).Select(g => g.Key);

            if (duplicateViewTypes.Count() > 0)
            {
                throw new Exception("Found duplicated view types. Each step should have it's own unique view type");
            }
        }
Beispiel #3
0
        private void SwitchStepView(WizardStep currentStep, WizardStep nextStep, IWizardContext context)
        {
            if (currentStep != null)
            {
                if (currentStep.Index == nextStep.Index) // don't switch to already active step
                {
                    return;
                }

                currentStep.IsCurrent = false;

                var region         = GetStepsRegion(wizardRegionManager);
                var viewToActivate = stepViews[nextStep.Index]; //region.Views.Where((v) => v.GetType() == nextStep.View).FirstOrDefault();
                if (viewToActivate != null)
                {
                    region.Activate(viewToActivate);
                    eventAggregator.GetEvent <UpdateNavBarEvent>().Publish(context);

                    nextStep.IsCurrent = true;
                }
            }
        }
Beispiel #4
0
 public virtual void OnCancel( IWizardContext context, CancelEventArgs e )
 {
 }
Beispiel #5
0
 public abstract WizardPage CreateInitialPage( IWizardContext context );
Beispiel #6
0
 public virtual void OnPageOpened( IWizardContext context )
 {
     _context = context;
 }
Beispiel #7
0
 public virtual void OnPageClosed()
 {
     _context = null;
 }
 private void OnUpdateNavBarEvent(IWizardContext context)
 {
     UpdateSteps();
 }