using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WorkflowDemonstration.Models; using Caliburn.Micro; namespace WorkflowDemonstration.ViewModels { public class ApplicationControllerViewModel : Conductor.Collection.OneActive { public ApplicationControllerViewModel() { initializeMap(); activateFirstScreen(); } private void activateFirstScreen() { var screen = new Input1ViewModel(new WorkflowState()); this.ActivateItem(screen); } private void initializeMap() { TransitionMap.Add(StateTransition.Input1Success); TransitionMap.Add(StateTransition.Cancel); TransitionMap.Add(StateTransition.Option1); TransitionMap.Add(StateTransition.Option2); TransitionMap.Add(StateTransition.Cancel); TransitionMap.Add(StateTransition.Input3Success); TransitionMap.Add(StateTransition.Cancel); TransitionMap.Add(StateTransition.Cancel); } protected override IScreen DetermineNextItemToActivate(IList list, int lastIndex) { var theScreenThatJustClosed = list[lastIndex] as BaseViewModel; var state = theScreenThatJustClosed.WorkflowState; var nextScreenType = TransitionMap.GetNextScreenType(theScreenThatJustClosed); var nextScreen = Activator.CreateInstance(nextScreenType, state); return nextScreen as IScreen; } } }