/// <summary>
        /// Creates a command that navigates the current session to the specified page.
        /// </summary>
        /// <typeparam name="TPageView">The type of the page view.</typeparam>
        /// <typeparam name="TPageViewModel">The type of the page view model.</typeparam>
        /// <returns></returns>
        public ICommand New <TPageView, TPageViewModel>(Guid nodeId, params ActionContextEntry[] parameters)
            where TPageViewModel : ContentViewModel <TPageView, TPageViewModel>, new()
            where TPageView : ExtendedContentControl <TPageView, TPageViewModel>, new()
        {
            var viewModel      = _session.ViewModel;
            var createNextView = new Func <IView>(viewModel.Create <TPageView, TPageViewModel>);

            var next          = ActionContextEntry.Create(ActionContextConstants.CreateNextViewConstant, createNextView, false);
            var viewtype      = ActionContextEntry.Create(ActionContextConstants.ViewTypeConstant, typeof(TPageView), false);
            var viewModeltype = ActionContextEntry.Create(ActionContextConstants.ViewModelTypeConstant, typeof(TPageViewModel), false);


            var actionContextEntries = new List <ActionContextEntry>(parameters)
            {
                next,
                viewtype,
                viewModeltype
            };

            if (nodeId != Guid.Empty)
            {
                var id = ActionContextEntry.Create(ActionContextConstants.NodeId, nodeId, false);
                actionContextEntries.Add(id);
            }

            var command = RoutedAction.New <NavigationAction, SessionView, SessionViewModel>(_session, viewModel, actionContextEntries.ToArray());

            _navigatableActions.Add((IDisposable)command);

            return(command);
        }
示例#2
0
        /// <summary>
        /// Does the step.
        /// </summary>
        /// <param name="step">The step.</param>
        public void DoStep(StepInfo step)
        {
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }

            var entry = ActionContextEntry.Create(step, false);

            InvokeAction <WizardNavigationAction>(entry);
        }
示例#3
0
        /// <summary>
        /// Runs the finish action.
        /// </summary>
        protected virtual void RunFinishAction(object result = null, params ActionContextEntry[] entries)
        {
            if (result != null)
            {
                var entry = ActionContextEntry.Create(ActionContextConstants.DialogBoxResult, result, false);
                var actionContextEntries = entries.ToList();
                actionContextEntries.Add(entry);

                entries = actionContextEntries.ToArray();
            }

            InvokeAction <FinishAction <TView, TViewModel> >(entries);
        }
示例#4
0
        /// <summary>
        /// Closes the selected session.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private void CloseSession(object sender, RoutedEventArgs e)
        {
            var sessionView = e.OriginalSource as SessionView;

            if (sessionView == null)
            {
                return;
            }

            var entry = ActionContextEntry.Create(sessionView, false);

            InvokeAction <CloseSessionAction>(entry);
            e.Handled = true;
        }
示例#5
0
        /// <summary>
        /// unstacks a wizard.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="entries">The entries.</param>
        public void UnstackWizard(Guid id, IEnumerable <ActionContextEntry> entries)
        {
            var stackInfo = Unstack(id);

            if (stackInfo != null)
            {
                var actionContextEntries = entries.ToList();
                var handleEntry          = ActionContextEntry.Create(ActionContextConstants.StackHandle, stackInfo, false);
                actionContextEntries.Add(handleEntry);
                entries = actionContextEntries;
            }

            ((IContentViewModel)CurrentView.ViewModel).ReturnToUseCase(entries);
        }
示例#6
0
        public sealed override bool Execute()
        {
            var actionContextEntry = ActionContextEntry.Create("Cancelled", IsCancelled, false);

            ActionContext.Add(actionContextEntry);

            _entries = ActionContext.GetEntries();

            if (ActionContext.TryGetValue(ActionContextConstants.SessionDialogBox, out _unstackingSessionDialog) && _unstackingSessionDialog)
            {
                _dialogBoxResult = ActionContext.GetValue <string>(ActionContextConstants.DialogBoxResult);
            }

            return(base.Execute());
        }
示例#7
0
        protected override IEnumerable <IWizardButton> CreateButtons(ActionContext context)
        {
            IEnumerable <object> buttons;

            if (context.TryGetValue(ActionContextConstants.DialogBoxButtons, out buttons))
            {
                ActionContextEntry[] entries = { ActionContextEntry.Create(ActionContextConstants.SessionDialogBox, true, false) };

                return(buttons.Reverse().Select(x => CreateButton(x.ToString(), _ => RunFinishAction(x, entries))).ToList().AsReadOnly());
            }

            var ok           = RESX.OK;
            var wizardButton = CreateButton(ok, _ => RunFinishAction(ok));

            return(new[] { wizardButton });
        }
示例#8
0
        private StackHandle <T> PrepareAndShowDialogBox <T>(string message, IEnumerable <T> buttons, ImageSource image)
        {
            var dispatcher = View.Dispatcher;

            if (!dispatcher.CheckAccess())
            {
                return(dispatcher.Invoke(() => PrepareAndShowDialogBox <T>(message, buttons, image), DispatcherPriority.Send));
            }

            var entries = new List <ActionContextEntry>();

            var entry = ActionContextEntry.Create(ActionContextConstants.DialogBoxMessage, message, false);

            entries.Add(entry);

            if (image != null)
            {
                var imageEntry = ActionContextEntry.Create(ActionContextConstants.DialogBoxImage, image, false);
                entries.Add(imageEntry);
            }

            if (buttons != null)
            {
                var boxedButtons = buttons.Where(x => x != null).Cast <object>().ToList().AsReadOnly();

                if (boxedButtons.Count > 0)
                {
                    var buttonEntry = ActionContextEntry.Create(ActionContextConstants.DialogBoxButtons, boxedButtons, false);
                    entries.Add(buttonEntry);
                }
            }

            var builder = CreateWizardBuilder();

            builder.AddStep <DialogView, DialogViewModel>(parameters: entries.ToArray());
            builder.Size = new ExtendedSize(480, 120, minWidth: 480, minHeight: 120);

            Guid stackId;
            var  overlay = CreateWizardOverlay(builder, out stackId);

            var handle = new StackHandle <T>(stackId);

            overlay.Tag = handle;
            IsStacked   = Interlocked.Increment(ref _stackCounter) > 0;

            return(handle);
        }
示例#9
0
        public override bool Execute()
        {
            var actionContextEntries = ActionContext.GetEntries().ToList();

            _viewType      = ActionContext.GetValue <Type>(ActionContextConstants.ViewTypeConstant);
            _viewModelType = ActionContext.GetValue <Type>(ActionContextConstants.ViewModelTypeConstant);

            var currentlyInsideMultistep = typeof(IMultistepContentViewModel).IsAssignableFrom(_viewModelType);
            var triggerValidation        = !currentlyInsideMultistep;

            NovaTreeNodeStep novaTreeNodeStep = null;
            var hasStep = false;

            if (currentlyInsideMultistep)
            {
                Guid key;

                if (!ActionContext.TryGetValue(ActionContextConstants.NodeId, out key))
                {
                    throw new NotSupportedException("Navigating to a multistep view without providing a step key is not supported.");
                }

                novaTreeNodeStep = View._NovaTree.FindStep(key);

                if (novaTreeNodeStep == null)
                {
                    throw new NotSupportedException("Navigating to an unknown step.");
                }

                var multistep = _current as MultiStepView;

                if (multistep != null)
                {
                    hasStep           = multistep.HasStep(novaTreeNodeStep);
                    triggerValidation = !hasStep;
                }
            }

            var triggerEntry = ActionContextEntry.Create(ActionContextConstants.TriggerValidation, triggerValidation, false);

            actionContextEntries.Add(triggerEntry);

            var entries = actionContextEntries.ToArray();

            return(LeavePreviousView(entries) && CreateNextView(currentlyInsideMultistep, novaTreeNodeStep, hasStep, entries));
        }
示例#10
0
        /// <summary>
        /// Sets the current session in the action context.
        /// </summary>
        /// <param name="actionContext">The action context.</param>
        public void OnBeforeCloseSession(ActionContext actionContext)
        {
            //Check if already added by our event handler. If not, insert the current session.
            if (actionContext.ContainsKey(typeof(SessionView).FullName))
            {
                return;
            }

            if (CurrentSession == null)
            {
                return;
            }

            var entry = ActionContextEntry.Create(CurrentSession, false);

            actionContext.Add(entry);
        }
示例#11
0
 protected override void OnCreated()
 {
     _goToPage1Command = CreateNavigationalAction <TestPage, TestPageViewModel>(Module.Step1Id, ActionContextEntry.Create("this is a string", "test", false));
 }
示例#12
0
        /// <summary>
        /// Called before navigation.
        /// </summary>
        /// <param name="context">The context.</param>
        public void OnBeforeNavigation(ActionContext context)
        {
            var current = ActionContextEntry.Create(ActionContextConstants.CurrentViewConstant, CurrentView, false);

            context.Add(current);
        }
示例#13
0
        /// <summary>
        /// Configures the module.
        /// </summary>
        /// <param name="builder">The builder.</param>
        public void Configure(IModuleBuilder builder)
        {
            var seed   = (int)DateTime.Now.Ticks;
            var random = new Random(seed);

            var randomRanking = random.Next(1, 100);

            builder.SetModuleTitle("Module #" + randomRanking)
            .SetModuleRanking(randomRanking)

            .AddNavigation <TestPage, TestPageViewModel>(Step1Id, rank: 10, parameters: ActionContextEntry.Create("this is a string", "test", false))

            .AddNavigation <TestPage2, TestPage2ViewModel>(Step2Id, "Page #" + random.Next(1, 100))
            .AddNavigation <TestPage2, TestPage2ViewModel>("Page #" + random.Next(1, 100))
            .AddNavigation <TestPage2, TestPage2ViewModel>("Page #" + random.Next(1, 100))
            .AddNavigation <TestPage2, TestPage2ViewModel>("Page #" + random.Next(1, 100))
            .AddNavigation <TestPage2, TestPage2ViewModel>("Page #" + random.Next(1, 100))

            /*
             * .AddNavigation("Multistep", x => x.AddStep<TestPage, TestPageViewModel>(Step1Id)
             *                                 .AddStep<TestPage2, TestPage2ViewModel>()) */.AsStartup();
        }