예제 #1
0
        /// <summary>
        /// Moves to details view helper.
        /// </summary>
        /// <param name="message">The message.</param>
        private void MoveToDetailsViewHelper(MoveToDetailsViewMessage message)
        {
            switch (message.Strategy)
            {
                case MoveStrategy.AddContextToExisting:
                    if (CurrentlySelectedContextProvider.SelectedContext != null)
                    {
                        this.CurrentContext.Add(CurrentlySelectedContextProvider.SelectedContext);
                        //Notify that the context was added
                        MessageBus.Current.SendMessage(new AddContextMessage(CurrentlySelectedContextProvider.SelectedContext));
                    }
                    break;
                case MoveStrategy.StartFresh:
                    foreach (var context in CurrentContext.ToArray())
                    {
                        this.CurrentContext.Remove(context);
                        //Notify that the context was removed
                        MessageBus.Current.SendMessage(new RemoveContextMessage(context));
                    }
                    break;
                case MoveStrategy.MoveBackwards:
                    var contextToMoveTo = this.CurrentContext.Where(o => o.GetType().ToString() == message.TypeOfDetailsView).LastOrDefault();
                    if (contextToMoveTo != null)
                    {
                        SetObjectDisplayControl(contextToMoveTo.GetType().ToString(), contextToMoveTo);
                    }
                    break;
            }

            var objectDisplay = ObjectTypeDisplay(message.TypeOfDetailsView);
            if (objectDisplay != null && objectDisplay.ContextProvider != null)
                CurrentlySelectedContextProvider = objectDisplay.ContextProvider;

            //Setup the UI
            SetupUI();
        }
예제 #2
0
        /// <summary>
        /// Called when you are supposed to [move to details view message].
        /// </summary>
        /// <param name="message">The message.</param>
        private void OnMoveToDetailsViewMessage(MoveToDetailsViewMessage message)
        {
            //Get the corresponding ObjectToDisplay
            var objectToDisplay = ObjectTypeDisplayControls.FirstOrDefault(objectDisplayControl => objectDisplayControl.ObjectTypeToDisplay == message.TypeOfDetailsView.ToString());

            if (objectToDisplay == null)
                return;

            var contextProvider = objectToDisplay.ContextProvider;
            if (contextProvider == null)
                return;

            //Check if the CurrentlySelectedContextProvider prevents navigation
            var currentProvider = CurrentlySelectedContextProvider as IPreventNavigationFrom;
            if (currentProvider == null)
                MoveToDetailsViewHelper(message);
            else
                currentProvider.CanNavigateFrom(() => MoveToDetailsViewHelper(message));
        }