Workflow Designer Flexibility

I've been testing WWF for very mainstream workflow purposes, but I think a flexible embedded WWF designer in a winform itself could be potentially very useful for, well, many other things as well.

In any case, the example I have in mind is using the WWF designer to create or modify a logical expression (I will need this sort of functionality in the application I'm designing). So here is what I was thinking...

Let me preface all this by saying I realize the WWF designer wasn't probably intended to work this way, but I'm curious as to know exactly what the limits will be for this control.

I thought the benefits of using this would be:
- Because I plan on using the WWF designer in its normal use case (for designing actual workflows on the fly), it might provide a more unified and familiar UI experience to represent it in the same sort of control.
- The expand / collapse part of a logical expression on a node (such as a high level and/or) would be useful in quickly determining the actual meaning of the logical expression
- Easy to parse into a useful data structure for our application
- It might be a intuitive way for users to create such an expression if they did not want to type it directly in, or we determine that for some reason there were syntax pitfalls we could avoid by allowing them to type it in.

For a logical expression such as:
(((a > 10) && (b < 100)) || (c == 0))

you could represent this as a 3-level tree like so:
OR
| \
AND c==0
| \
a>10 b<100

So I'd have a custom "boolean operator" activity node for OR, AND, and NOT. Then I'd have a custom "basic expression" activity node for my "c==0", "a>10", "b<100", etc etc.

Of course, trying to do something like this would take alot of customization to the designer control.

Of the things I think I could do right now (correct me if I'm wrong), I would need to:
- Provide custom designer functionality for each of my activities.
- Have a toolbox of sorts to allow dropping of my custom activies.

Of the things I am unsure I could do but would need or like to do:
- Only view the "SequentialWorkflow" tab (not Exceptions, Events, Compensation).
- Preferable to not have the "begin / start image" (that green button at the top)
- Strongly prefer not have the "terminate / end image" (that red button at the bottom), which means that there would be no lines going to the terminate. This would successfully present the workflow as a tree instead of a start/terminate linear design.
- Change that default drop message in the UI from "Drop Activies Here" and "Drop Activies to create a Sequential Workflow" to be something of my choosing. For instance "Drop Expresion Here".

So am I insane for considering trying something like this? How (im)possible is this to do? Would you highly recommend not doing this or have an alternate suggestion?

Any help or comments appreciated. Thanks an advance.

Mark Doughty

[3011 byte] By [MarkDoughty] at [2007-12-17]
# 1
Mark,

I could certainly see how this could be possible to implement with our current designer and activity infrastructure, and would certainly be an interesting exercise. If evaluation performance is an issue for you then I wouldn't recommend this way, as the execution of a single activity would only map to the evaluation of an expression predicate. If your goal is to have a re-hostable way for receiving input for declarative, conditional expressions, an easier route would be to simply rehost the declarative condition designer.

Hope this helps a little,
Arjun

ArjunBanker at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2
Thanks for the reply Arjun. So you are saying all those "things I am unsure I could do but would need or like to do" listed above are do-able (if not currently then by the actual release)?

I hadn't thought about rehosting the declarative condition designer dialog. Good idea. Though in my case my expressions are not necessarily related to a workflow/activity at all. I'm a little wary that I might run into problems if this dialog assumes/requires an activity to go along with it....

Mark

MarkDoughty at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3
Sorry Mark, I should have been a bit clearer. I actually didn't mean to address the 'things you were unsure about' list, but taking a look at them now, I think they should be possible. The reason I think so is because the State Machine Workflow designer uses the same underlying designer infrastructure and accomplishes all the points you mentioned. Hopefully someone on the designer team might be able to help you out with the implementation specifics.

This is definitely a pretty neat use of the activity designer, I'd like to see the result :-)

Arjun

ArjunBanker at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

Hi Mark,

For the UI part, this is what you can do. You will need to create a custom designer for the Sequential workflow

[Designer(typeof(MyDesigner))]
public partial class MyWorkflow : SequentialWorkflow
{
public MyWorkflow ()
{
InitializeComponent();
}
}

public class MyDesigner : SequentialWorkflowWithDataContextDesigner
{
public MyDesigner()
{
}
}

and override the following properties

Mark Doughty wrote:
- Only view the "SequentialWorkflow" tab (not Exceptions, Events, Compensation).

protected override bool ShowSmartTag
{
get { return false; }
}

Mark Doughty wrote:
- - Change that default drop message in the UI from "Drop Activies Here" and "Drop Activies to create a Sequential Workflow" to be something of my choosing. For instance "Drop Expresion Here".

protected override string HelpText
{
get
{
return "My Custom Text";
}
set
{

}
}

Similarly the begin/start image and the terminate/stop image can be overriden using the header and footer properties

Hope this helps,

Vihang

vihang at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
Hi Vihang,

I'm also very interested in what you've shown here. I've tried to imitate it, but my custom designer does not appear to be loading. I've tried overriding the HelpText and ShowSmartTag properties but I don't see any change to the designer. I also put debug statements in the constructor of the MyDesigner code and they don't get displayed. I've attached to the devenv.exe process in another instance and set a breakpoint in the constructor of the MyDesigner code, but the breakpoint is not hit. Finally, I tried changing the Designer attribute on my workflow to this style:

[Designer(typeof(MyDesigner), typeof(IDesigner)]

as this is what I've used successfully in my custom activity but this doesn't help me either. Is there anything else I can try? Any further debugging steps? What is the architecture for attaching a designer to a workflow? It looks like you use the DesignerAttribute to associate a companion designer class, the same as you would with an Activity; is that right?

Thanks,
Notre

Notre at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Notre wrote:

I've tried to imitate it, but my custom designer does not appear to be loading.

I just got around to trying this, and I have this exact same problem. I'm using the Microsoft WorkflowDesignerExample as my basic source. I changed the SequentialWorkflow in the appropriate places to substitute in my custom workflow, but when I run this line:

IRootDesigner rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as IRootDesigner;

...I get back the SequentialWorkflowWithDataContextDesigner and not the custom designer. Note that designerHost.RootComponent *is* returning me my custom workflow and *not* the generic SequentialWorkflow.

Again, any help would be appreciated.

Mark

-

Oops! Looks like this is addressed.

See related thread at:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=171723&SiteID=1

MarkDoughty at 2007-9-8 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified