Highlighting Activities in the AJAX Workflow Monitor Example
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.DrawRectangle(p, r);
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
- Hosting WF Designer in a Web Application
- DinnerNow scenario
- Channel9 video that describes DinnerNow
- Windows Workflow Foundation: Everything About Re-Hosting the Workflow Designer
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...
Comments
Anonymous
September 17, 2007
PingBack from http://msdnrss.thecoderblogs.com/2007/09/17/highlighting-activities-in-the-ajax-workflow-monitor-example/Anonymous
October 17, 2007
I read your excellent article about WF monitor tool in .NET Beta 2. But, when I downloaded the source, two of the projects - WorkflowLibrary1 and WorkflowConsoleApplication1 gave me errors while loading the solution. The error was "The project type is not supported by this installation". I have VS 2008 Beta 2 installed. Please reply if you can help at rupakg [at] gmail [dot] com.Anonymous
December 11, 2008
This post will show how to create a simple console application that executes tracking queries in Windows