I set out a few weeks ago to build a simple example application that takes advantage of the new user interface technologies in Microsoft’s Windows Vista. These technologies are packaged as .NET 3.0, which is an extension of the 2.0 version of the framework. Extension is the right term, I think, despite the fact that the extending bits are pretty significant. Basically .NET 3.0 retains all of 2.0 unaltered, and adds three major new layers of types. Really these are three new frameworks within the larger .NET space. They are: the Windows Presentation Foundation (WPF), formerly called Avalon; the Windows Communication Foundation (WCF), once named Indigo; and the Windows Workflow Foundation (WWF), which probably also had a codename, but I don’t know what it was. The WPF targets Windows user-interface development, the space that Windows Forms has inhabited for a few years now. The WCF is focused on enabling advanced networking applications, while the WWF is a standardized means of representing and executing logical workflows. There are some very cool possibilities in all of it – I’ve recently read about peer-to-peer information sharing apps on WCF, and I know of one or two people fooling with using workflows to drive game agent behavior – lots worth writing about there. But for now I will stick with WPF, because it is enough of a revolution for one article. If you want a place to start digging in you can’t go wrong with Microsoft’s .NET 3.0 website.
I said I set out to build a simple application, but as usually happens with me when working on something where I control the deadlines, I ended up adding a lot more to it than I expected. The application I chose to work on is an implementation of John Conway’s famous Game of Life. Not long into work on it I realized that, of course, I wasn’t the only one who had chosen Life as a framework for exploring WPF. Among those who have also done so is Scott Allen, and I would be remiss in not pointing you to his article on OdeToCode.com. At least one technique I use in my implementation was derived from Scott’s examples. I’ll point out which one when I get there. So perhaps because I became aware that others had already done Life in WPF, I was spurred on to polish up my implementation as much as possible. The result is AvalonLife, a screenshot of which you can see below. In the process I learned a lot about the peaks and valleys of WPF, and ended up with a fun tool that does a pretty good job of testing just how much stress the framework can take. As you’ll see in a bit, the WPF changes much in the way Windows user interfaces are developed, and it is more than a little interesting to see just how well these technologies work when you start to bang on them hard. Before we dive into that a couple of words on downloading and installing the sample application and source.
AvalonLife running Gosper’s Glider Gun
You’ll find links to the AvalonLife program alone, as well as the program and source, at the bottom of this post. The executable is small (around 88kb), and makes no changes to the registry or other parts of the operating system. You can simply download it and unzip it into a folder and it should work fine, provided you have all the other system pieces in place. If you’re running Vista you’re all set, since the .NET 3.0 framework ships with the operating system. If you want to run the program on XP you will need to install the framework first, which is available here. That’s pretty much it. But if you want to build and monkey around with the source on either system you’ll need to jump through a couple of additional hoops. One reason for this is that Visual Studio 2005 doesn’t fully support the 3.0 framework classes and the new XAML GUI markup language out of the box. That support is coming in Visual Studio codename Orcas, which is available as a CTP to MSDN subscribers. For now VS2005 users can get by with a CTP extension. You’ll need to download and install the VS2005 Extensions for .NET 3.0. I also suggest installing the Windows SDK for Vista and .NET Framework 3.0 in order to take full advantage of class library documentation, samples, and other materials.
The source contains the Visual Studio 2005 solution and project files in the VS2005 folder of the archive. Create a folder in your Visual Studio projects folder called AvalonLife, and copy the contents of the VS2005 archive folder to this directory. If you have everything installed correctly you’ll be able to load the project file included in the source distribution, open the ALMainWin.xaml file, and see the Cider visual designer come up displaying AvalonLife’s main window. If for some reason that doesn’t happen feel free to email me and I will try to help you get it set up. In the next section I’ll take a quick drive through the architecture of the application, and then dive into the GUI stuff.