示例#1
0
        // Private methods

        private void ConfigureWizard()
        {
            _wizardContext = new WizardContext();

            // Create the state machine with the correct context
            _sm = new SolidMachine<WizardTrigger>(_wizardContext);
            _sm.Transitioned += StateMachineOnTransitioned;

            // Assign the state machine to the context so it's accessible
            _wizardContext.StateMachine = _sm;

            _sm.State<WelcomePage>()
                .On(WizardTrigger.Cancel).GoesTo<ShutdownApplicationState>()
                .On(WizardTrigger.Next).GoesTo<InfoSelectionPage>();

            _sm.State<InfoSelectionPage>()
                .On(WizardTrigger.Cancel).GoesTo<ShutdownApplicationState>()
                .On(WizardTrigger.Next, () => _wizardContext.InfoSelection == InfoSelectionMode.Family).GoesTo<FamilyInfoPage1>()
                .On(WizardTrigger.Next, () => _wizardContext.InfoSelection == InfoSelectionMode.Work).GoesTo<WorkInfoPage>();

            _sm.State<FamilyInfoPage1>()
                .On(WizardTrigger.Cancel).GoesTo<ShutdownApplicationState>()
                .On(WizardTrigger.Next).GoesTo<FamilyInfoPage2>();
            _sm.State<FamilyInfoPage2>()
                .On(WizardTrigger.Cancel).GoesTo<ShutdownApplicationState>()
                .On(WizardTrigger.Next).GoesTo<FinishPage>();

            _sm.State<WorkInfoPage>()
                .On(WizardTrigger.Cancel).GoesTo<ShutdownApplicationState>()
                .On(WizardTrigger.Next).GoesTo<FinishPage>();

            _sm.State<FinishPage>()
                .On(WizardTrigger.Finish).GoesTo<ShutdownApplicationState>();

            _sm.Start();

        }
示例#2
0
        // Private methods

        private void ConfigureWizard()
        {
            _wizardContext = new WizardContext();

            // Create the state machine with the correct context
            _sm = new SolidMachine <WizardTrigger>(_wizardContext);
            _sm.Transitioned += StateMachineOnTransitioned;

            // Assign the state machine to the context so it's accessible
            _wizardContext.StateMachine = _sm;

            _sm.State <WelcomePage>()
            .On(WizardTrigger.Cancel).GoesTo <ShutdownApplicationState>()
            .On(WizardTrigger.Next).GoesTo <InfoSelectionPage>();

            _sm.State <InfoSelectionPage>()
            .On(WizardTrigger.Cancel).GoesTo <ShutdownApplicationState>()
            .On(WizardTrigger.Next, () => _wizardContext.InfoSelection == InfoSelectionMode.Family).GoesTo <FamilyInfoPage1>()
            .On(WizardTrigger.Next, () => _wizardContext.InfoSelection == InfoSelectionMode.Work).GoesTo <WorkInfoPage>();

            _sm.State <FamilyInfoPage1>()
            .On(WizardTrigger.Cancel).GoesTo <ShutdownApplicationState>()
            .On(WizardTrigger.Next).GoesTo <FamilyInfoPage2>();
            _sm.State <FamilyInfoPage2>()
            .On(WizardTrigger.Cancel).GoesTo <ShutdownApplicationState>()
            .On(WizardTrigger.Next).GoesTo <FinishPage>();

            _sm.State <WorkInfoPage>()
            .On(WizardTrigger.Cancel).GoesTo <ShutdownApplicationState>()
            .On(WizardTrigger.Next).GoesTo <FinishPage>();

            _sm.State <FinishPage>()
            .On(WizardTrigger.Finish).GoesTo <ShutdownApplicationState>();

            _sm.Start();
        }