Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Little Workflow Foundation Sample

Blogs

Mike Taulty's Blog

Elsewhere

Archives

I built a little sample with WF the other week for an internal group meeting just as a bit of fun to try and illustrate (to people who are not developers) what Workflow Foundation can enable.

I thought I'd share the bits here. Essentially, it's a small sample which includes some of;

  1. Hosting the WF Runtime
  2. Hosting the WF Designer
  3. Dynamically creating and running a WF that was just designed
  4. Building Activities to perform domain-specific tasks
  5. Building Services to support those Activities built in (4) and adding them to the runtime.

The code's pretty hacky to be honest as I didn't spend a lot of time on it.

The essential idea is to get someone without developer knowledge to build this WPF "application";

all the application does is to create a new Window and then randomly create a number of shapes (triangle, rectangle, etc) in a random number of colours, draw them at random locations on the screen and then make them spin.

After it's created the necessary number of shapes, it waits for a while and then it exits.

The way in which this "program" is built is by using another program that hosts the WF designer. That program is as below.

The essential flow for this is that a user comes along and just drags and drops the components from the right hand side onto the design surface (they're listen in the right order) to build;

which just says;

  1. Create Window.
  2. Repeat N Times.
  3. Create Random Shape.
  4. Create Random Point.
  5. Create Random Colour.
  6. Draw a Shape using the random shape, point, colour just created (this needs ActivityBinds) in steps 3, 4 and 5.
  7. Spin the Shape that we just drew (this needs ActivityBinds) in step 6.
  8. Pause for a little while (say 1 second).
  9. Pause for a while (well as long as you want the program to keep running - say 1 minute).
  10. Close the Window.

The only "tricky" bits are in steps 6 and step 7 where you have to do Activity binds in order to;

  1. Bind the Point, ShapeType, Colour on the DrawShape activity to the right properties from the RandomShape, RandomColour, RandomPoint activities.
  2. Bind the Shape property on the SpinShape to the Shape property on the DrawShape activity.

The properties dialog after step (1) would look like;

Here's the sample code if you want to play with it.


Posted Wed, Dec 13 2006 5:21 AM by mtaulty

Comments

Sam Gentile wrote New and Notable 131
on Thu, Dec 14 2006 1:46 PM
I am SO busy with INETA trips and tons to do at work. Here is what I have stored up for the last week
Marc My Words wrote Mike is looking at LINQ
on Wed, Feb 7 2007 4:33 AM
Mike Taulty's blog - he's a colleague of mine here in Reading - has a load of great content. Very recently
Sam Gentile wrote New and Notable 131
on Sat, Oct 20 2007 12:26 PM
I am SO busy with INETA trips and tons to do at work. Here is what I have stored up for the last week
Sam Gentile's Blog wrote New and Notable 131
on Wed, Dec 3 2008 10:07 AM
<p>I am SO busy with INETA trips and tons to do at work. Here is what I have stored up for the last week or so. WCF/SOA/Workflow/WF Tomas blogs about something I face every day in WCF with WCF ServiceHost Failures and IDisposable with "The