In my last post, I showed how you can use Jon Flanders’s AJAX Workflow Monitor example with Visual Studio 2008 Beta 2. After I got it working, I was so giddy that I kept on tinkering for most of the day. If you have seen the DinnerNow scenario, you have probably seen the WF designer control hosted in the MMC snap-in with its executing and completed activities highlighted in different colors. I wanted to figure out how to do that without downloading the source to find out how they did that.
It was actually really easy to do.
- Go download the source for the AJAX Workflow Monitor example.
- In the project WorkflowDesignerControl, open the file DesignerGlyphProvider.cs.
- Edit the OnPaint method of the ExecutingGlyph class.
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
Bitmap bitmap = Resources.Executing;
bitmap.MakeTransparent(Color.FromArgb(0, 255, 255));
if (bitmap != null)
Rectangle r = new Rectangle(designer.Bounds.X, designer.Bounds.Y, designer.Bounds.Width, designer.Bounds.Height);
Pen p = new Pen(Color.Green, 2);
graphics.DrawImage(bitmap, GetBounds(designer, activated), new Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel);
Save, build, and run the sample. The effect you will see is that any activities that currently have a status of ActivityExecutionStatus.Executing will be highlighted in green (as well as having the green “play” icon from the resource file).
In this screen shot, you can see that the entire workflow is highlighted in green and the “Processing” activity is also highlighted green because the “Processing” state in this state machine workflow has not yet completed. Pretty cool effect for 3 lines of code, eh?
If you are wondering, “what the heck is DinnerNow?” then I apologize, I should have blogged about this sample much, much more loudly. If you haven’t seen DinnerNow, then you owe it to yourself to go check out the Channel9 video that describes DinnerNow.
For more information on topics covered in this post:
- Jon Flanders’s post on creating an AJAX Workflow Monitor sample
- My post that shows how to use Jon Flanders’s AJAX Workflow Monitor example with Visual Studio 2008 Beta 2
Channel9 video that describes DinnerNow
The more I understand about WF, the more I think this is the most disruptive technology that Microsoft has released in years. If there’s one technology you should focus your energy on, this is it.
I have a really cool demo that shows “why Workflow” that I am hoping to find an avenue for. It would be a huge blog post, but I am not yet confident in my screencast skillz. Gotta find an outlet to share this one…