Experimenting with ControlStateMachine and Fluent interfaces
A long time ago i read Build your own CAB series and recently i noticed that there is a wiki: Presentation Patterns Wiki! and it inspired me to experiment with state machines. Here are a couple of examples:
controlStateMachine = new ControlStateMachine<States>(this); controlStateMachine.AfterEachStateChange() .Do(MakeRelevantButtonsVisible); controlStateMachine.WhenStateChangesTo(States.RetrievingSubscriptionPeriod) .TheOnlyVisibleControlsAre(flowLayoutPanel1, datePicker1); controlStateMachine.WhenStateChangesTo(States.RetrievingCustomerInformation) .MakeVisible(customerInput1) .Do(() => customerInput1.Dock = DockStyle.Fill); controlStateMachine.WhenStateChangesTo(States.Ready) .MakeInvisible(customerInput1);
And here is another example:
wizardStateMachine = new WizardStateMachine<States>(controlStateMachine);
wizardStateMachine.InState(States.RetrievingSubscriptionPeriod)
.OnCommand(WizardCommands.Next)
.TransitionTo(States.RetrievingCustomerInformation);
wizardStateMachine.InState(States.RetrievingCustomerInformation)
.OnCommand(WizardCommands.Back)
.TransitionTo(States.RetrievingSubscriptionPeriod)
.OnCommand(WizardCommands.Finish)
.TransitionTo(States.Ready);
wizardStateMachine.InState(States.Ready)
.OnCommand(WizardCommands.New)
.Do(() => MessageBox.Show("Currently not supported"));
Stay tuned for future posts where i describe the problem space that have lead to this API.
[...] while ago i presented the ControlStateMachine and in Silverlight this concept is implemented as the Visual State [...]
October 16th, 2009 at 21:37