I promised posts with more “meat,” so here it goes. I’m going to demonstrate how to start writing a CAB application by building a simple image manipulation program.
Overview:
The application will load an image from some flexible source (file system, flickr, whatever). The image will be displayed on the canvas. The user will have various filters to apply to the image. These filters should be easily added later on, and they should all manipulate the image in some way. When everything is done, the user will have the option of saving the changes to disk.
So now that we have our high-level description of the app, let’s build it!
Start up Visual Studio 2005, create a blank solution called CAB-ImageEditor. Add a new C# Windows application called ImageEditorShell. This will be the basic structure of the application, and we will add things to it.
Add the following references to your project:
- Microsoft.Practices.CompositeUI
- Microsoft.Practices.ObjectBuilder
- Microsoft.Practices.CompositeUI.WinForms
First you need to delete the files that Visual Studio gives you out of the box. We will start from scratch.
Create a new Form called ImageEditorShell.cs. Give it a window title if you like.

Create a new class called ImageEditorApplication.cs. This will be the entry point for our application. We need to inherit the class from FormShellApplication<T,K> and give it the type of the root work item and our shell.
using System;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.WinForms;
namespace ImageEditorShell
{
public class ImageEditorApplication : FormShellApplication<WorkItem, ImageEditorShell>
{
}
}
We need an entry point to start the application, so add that…
public class ImageEditorApplication : FormShellApplication<WorkItem, ImageEditorShell>
{
[STAThread]
public static void Main()
{
new ImageEditorApplication().Run();
}
}
That’s all we need to get our application running. Go ahead and push F5 and see what happens.
Man, are you impressed yet? Hehe, chill out. There’s more to come…