Esempio n. 1
0
        internal bool GetOrCreateStep(NovaTreeNodeStep treeStep, out IView view)
        {
            view = null;

            if (treeStep.GroupId != _groupId)
            {
                return(false);
            }

            var viewType      = treeStep.PageType;
            var viewModelType = treeStep.ViewModelType;

            var node = CurrentView.List.First;

            while (node != null)
            {
                var novaStep = node.Value;
                if (novaStep.ViewType == viewType && novaStep.ViewModelType == viewModelType)
                {
                    break;
                }

                node = node.Next;
            }

            if (node == null || node.Value == null)
            {
                return(false);
            }

            view = node.Value.GetOrCreateView(this);
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Builds the nova treenode step.
        /// </summary>
        /// <param name="page">The page.</param>
        /// <returns></returns>
        internal override NovaTreeNodeStep Build(INavigatablePage page)
        {
            var command = page.CreateNavigationalAction <TView, TViewModel>(Id, _parameters);
            var node    = new NovaTreeNodeStep <TView, TViewModel>(Id, Title, command);

            return(node);
        }
Esempio n. 3
0
        internal bool HasStep(NovaTreeNodeStep treeStep)
        {
            if (treeStep.GroupId != _groupId)
            {
                return(false);
            }

            var stepId = treeStep.Id;

            return(_steps.Any(x => x.NodeId == stepId));
        }
Esempio n. 4
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));
        }
Esempio n. 5
0
        private void CreateMultistep(NovaTreeNodeStep novaTreeNodeStep, bool hasChild)
        {
            var multistep = _current as MultiStepView;

            _navigatingInsideMultiStep = hasChild && multistep != null && Dispatch(() => multistep.GetOrCreateStep(novaTreeNodeStep, out _nextView));


            if (_navigatingInsideMultiStep)
            {
                return;
            }
            //Create new one.
            var steps = novaTreeNodeStep.Parent.Steps.Select(x => x.ConvertToNovaStep());

            var list        = new LinkedList <NovaStep>(steps);
            var initialView = GetInitialView(novaTreeNodeStep, list);

            var groupId = novaTreeNodeStep.GroupId;

            _nextView = Dispatch(() => new MultiStepView(View, ViewModel, groupId, initialView));
        }
Esempio n. 6
0
        private bool CreateNextView(bool currentlyInsideMultistep, NovaTreeNodeStep novaTreeNodeStep, bool hasStep,
                                    ActionContextEntry[] entries)
        {
            if (currentlyInsideMultistep)
            {
                CreateMultistep(novaTreeNodeStep, hasStep);
            }
            else
            {
                CreateNormalView();
            }

            var result = _nextView != null && _nextView.ViewModel.Enter(entries).Result;

            if (result)
            {
                return(true);
            }

            CreateNotAvailableView();

            return(true);
        }