Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Windows Workflow Foundation & Tetris

Blogs

Mike Taulty's Blog

Elsewhere

This one is purely for fun.

When I first started playing with .NET, one of the very first pieces of code that I wrote was a really basic Tetris game using Windows Forms.

I’d long since thought that I’d lost this altogether but the other day I had an idea around it and went digging and managed to find some of it but I could only find the executable and not the source code. It was actually MSN Search that found the executable attached to an old email from around 5 years ago.

So, I ran the executable through Reflector and using the right plug-in I managed to get some C# code back :-)

Once I’d recovered this source, I thought it’d be interesting to see if I could move some of the control flow and logic from the original code into Windows Workflow Foundation and have a Workflow drive the game execution.

I’ve put that together – the Workflow ends up looking like this;

I tied it up with Windows Forms to provide a UI of sorts and that ends up looking a little like this;

Now, there’s a lot of things that are “not so nice” about this code in that some of it is hacked together from decompiled IL but, beyond that, the division of the logic into Workflow Activities is somewhat arbitrary in that I made some code into activities purely because I was interested in trying to make sure that what was going on was visible on the Workflow diagram rather than for any other sensible reason and it’d definitely be easy to streamline the Workflow but then you lose some of the “visibility” of what’s going on so I left it as it is.

Notice also that the mechanism that the Workflow host (the WinForms application) uses to communicate with the Workflow is not the recommended mechanism and I’m just sharing some (rather badly designed) interfaces between the two.

Anyway, perhaps someone can take it and place a WPF front end onto it and make it look a little more sexy or maybe re-work the Workflow to see what can be done there. Or maybe just use it as a little sample to play with in running and debugging a Workflow.

Either way, the source code is here for download. This is WinFX Beta 2.

Enjoy! :-)


Posted Fri, May 26 2006 5:51 PM by mtaulty