views:

112

answers:

1

Intent of this post:

I realise that Workflow Foundation is not extremely popular on StackOverflow and that there will probably be not many answers, or none at all. This post is intended as a resource to people trying to customise workflow activities' appearance through custom designer classes.


Goals:

I am attempting to create a custom designer class for Workflow activities to achieve the following:

  1. Make activities look less technical. For example, I don't necessarily want to see the internal object name as the activity's "title" -- instead, I'd like to see something more descriptive.

  2. Display the values of certain properties beneath the title text. I would like to see some properties' values directly underneath the title so that I don't need to look somewhere else (namely, at the Properties window).

  3. Provide custom drop areas and draw custom internal arrows. As an example, I would like to be able to have custom drop areas in very specific places.


What I found out so far:

I created a custom designer class deriving from SequentialActivityDesigner as follows:

[Designer(typeof(SomeDesigner))]
public partial class SomeActivity: CompositeActivity
{
    ...
}

class PlainDesigner : SequentialActivityDesigner
{
    ...
}

Through overriding some properties and the OnPaint method, I found out about the following correspondences between the properties and how the activity will be displayed:

Diagram showing the relationships between some properties of a SequentialActivityDesigner and the displayed activity.
Figure 1. Relationship between some properties of an SequentialActivityDesigner and the displayed activity.

Possible solutions for goal #1 (make activities look less technical) and goal #2 (display values of properties beneath title text):

  • The displayed title can be changed through the Title property.

  • If more room is required to display additional information beneath the title, the TitleHeight property can be increased (ie., override the property and make it return base.TitleHeight + n, where n is some positive integer).

  • Override the OnPaint method and draw additional text in the area reserved through TitleHeight.


Open questions:

  • What are the connectors, connections, and connection points used for? They seem to be necessary, but for what purpose?

  • While the drop targets can be got through the GetDropTargets method, it seems that this is not necessarily where the designer will actually place dropped activities. When an activity is dragged across a workflow, the designer displays little green plus signs where activities can be dropped; how does it figure out the locations of these plus signs?

  • How does the designer figure out where to draw connector lines and arrows?

+2  A: 

Unless you have a really, really good reason to pour massive amounts (and this is going to be massive) into WF 3.5 then don't. Use WF4 instead. WF4 gives you much more control over the appearance of the activities being rendered using Xaml by WPF.

WF 3.5 was very technical and very scary to a user. WF4 is designed to address those issues and that seems in line with your goals.

AnthonyWJones
You are correct, this would be very much what I'm after. And I realise WF 3.5 takes much, much time to fine-tune (made worse by the fact that almost no information is available on how to do it). The only thing that's currently keeping me from WF 4 is that I haven't got a version of Visual Studio 2010 available that supports WF. There's no WF 4 add-on pack for VS 2008, or is there?
stakx
@staks: No, WF4 requires .NET 4 and therefore VS2010
AnthonyWJones