Compartilhar via


Hosting Workflow Designers

Although there is a Visual Studio version of the Windows Workflow Foundation workflow visual designer, the workflow designer can be hosted in Windows applications outside Visual Studio. You can host the graphics-based workflow designer in your own custom Windows applications. Custom applications can implement a simple form of the workflow designer with basic designer functionality, such as the ability to display a pre-built workflow graphically, or you can implement a version of the workflow designer that has a more robust feature set, similar to the Visual Studio version of the designer.

The primary classes that you must use when you host a workflow designer are as follows:

  • The .NET DesignSurface class, which implements what the user perceives as a designer by providing a completely self-contained design surface.

  • The WorkflowView class, which displays a visual representation of a workflow that is described in workflow markup.

  • The WorkflowDesignerLoader class, which supports custom loading of a workflow designer and workflow designer components.

  • The WorkflowDesignerMessageFilter class, which can be derived from to create a custom message filter that can handle workflow designer events such as drag operations, layout and paint operations, and other designer events, by overriding the appropriate virtual methods.

The Basic Designer Hosting sample shows how to use these classes to create a simple version of the workflow designer hosted in a Windows application.

The WorkflowDesigner control that is part of the Workflow Tracking Profile Designer provides a good starting point for a custom workflow designer hosting application. The WorkflowDesigner control provides an easy way to add and extend workflow designer functionality in a host application.

Adding Menu Command Functionality

Because the workflow designer was built upon base designer classes in the .NET Framework SDK, to access menu commands in your custom application, you must derive from the MenuCommandService class, override some of its members, and add it as a service to the designer loader host used by your workflow loader object.

The following example demonstrates how to create a custom MenuCommandService. In this example, a context menu is created when the ShowContextMenu is called. In the GetSelectionMenuItems method, the WorkflowMenuCommands class is used to associate the proper menu commands provided by the workflow designer with their corresponding text. When this is finished, an event handler is associated with each command so that when the command is selected, the appropriate MenuCommand is invoked.

The following example shows how to add your derived MenuCommandService type to a designer loader host in an overridden Initialize method on a type derived from WorkflowDesignerLoader.

The following are commands with default implementations that you can use in your application:

The rest of the commands in WorkflowMenuCommands and StandardCommands must be implemented by you.

For commands like Undo and MultiLevelUndo, you must derive from and implement the following interfaces and classes:

After you create these derived service classes, then you must add them to the overridden Initialize method described earlier in this section.

Also, you must add any user-implemented command to your derived MenuCommandService type using the AddCommand method so that whenever the command is accessed in your designer, the proper event handler will be called.

For more information, see Extending Design-Time Support in the .NET Framework SDK.

Designer Hosting Samples

The following samples show how to host the workflow designer:

  • Basic Designer Hosting - Shows a simple version of the workflow designer hosted in a Windows application.

  • Outlook Workflow Wizard - Uses the WorkflowView class to demonstrate how you can use the Windows Workflow Foundation workflow object model to create a workflow definition that can be visualized using the workflow designer.

  • Workflow Monitor - Shows how to create a tool for displaying workflow and activity status information using the workflow designer.

  • Workflow Tracking Profile Designer - Shows how to create a tool to support the creation of tracking profiles from workflow definitions using the WorkflowDesigner control.

See Also

Reference

WorkflowView
WorkflowDesignerLoader
WorkflowDesignerMessageFilter

Other Resources

Basic Designer Hosting
Outlook Workflow Wizard
Workflow Monitor
Workflow Tracking Profile Designer