Sample Title

 

Support of WF 4.5 Designer Improvements in Rehosted Scenarios

 

Overview

 
A lot of new features have been added in WF 4.5 (you can find more discussion of those features in this article). A number of those features (e.g. annotations, auto-surround with sequence, outline view, etc.) were developed to improve the authoring experience of workflows.

Many of the WF customers rehost the WF designer in their own application/domain-specific authoring environments. Naturally then, these customers have asked which of these new WF 4.5 designer capabilities are supported when rehosting the designer. A post on the Workflow Team’s blog lists the features that are supported in the rehosted scenarios. These features include:
In this sample, I will illustrate how these features can be enabled.

Keywords

WF 4.5, rehost, Windows Workflow 4.5, designer, .NET 4.5, outline view, annotations, multi-select, auto-surround, pan, toolbox search
 

Table of Contents 

 

Objectives

This sample aims to illustrate how the following new WF 4.5 features can be used in rehosted scenarios:
 

Pre-requisites

  

Software Requirements

Build Number Used For Sample Code

Description



1. Introduction

Among the many new features that have been introduced in WF 4.5, this sample focuses on the WF 4.5 designer capabilities that can be enabled in rehosted scenarios. These features include:


2. Outline View of Workflow Items
This feature was added in WF 4.5 in order to make hierarchical Workflows easier to navigate. It shows components of a workflow in a tree-style outline view. Clicking on a node in outline view will navigate to the corresponding activity in the workflow designer, and the outline view will be updated to show activities that are selected in the designer.

 
In order to see a code snippet for enabling the outline view, please see the “OutlineView” project under the “WF45ImprovementsInRehostedScenarios” solution.
The two main points that you need to keep in mind are that:
C#
Edit|Remove
wd.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework"new Version(45));
3. Designer Annotations
To facilitate developing larger workflows, the designer now supports adding annotations to help keep track of the design process. Annotation can be added to activities, states, flowchart nodes, variables and arguments. The following screenshot shows the context menu used to add annotations to the
designer.
 
 
 

You can use the following code snippet to enable this feature in rehosted scenarios:

 
C#
Edit|Remove
// create the workflow designer 
WorkflowDesigner wd = new WorkflowDesigner(); 
// enable annotations 
wd.Context.Services.GetService<DesignerConfigurationService>().AnnotationEnabled = true;  
// set the runtime Framework version to 4.5 as Annotation is a new feature in .NET 4.5 and did not exist in .NET 4 
wd.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework"new Version(45)); 
Please see the “Annotations” project under the “WF45ImprovementsInRehostedScenarios” solution for a standalone sample using this code.
 

4. Multi-Select

This feature is enabled by default in .NET 4.5.
 
 
5. Auto-surround with Sequence

Since a workflow or certain container activities can only contain a single root activity, adding a second activity in WF 4.0 required the developer to delete the first activity, add a Sequence activity, and then add both activities to the sequence activity. In .NET 4.5, when adding a second activity to the designer surface, a Sequence activity will be automatically created to wrap both activities.

In order to enable this feature in rehosted scenarios you would need to use a code snippet similar to the following:

C#
Edit|Remove
// create the workflow designer 
WorkflowDesigner wd = new WorkflowDesigner(); 
// set the runtime Framework version to 4.5 as Annotation is a new feature in .NET 4.5 and did not exist in .NET 4 
wd.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework"new Version(45)); 
// enable AutoSurroundWithSequence 
wd.Context.Services.GetService<DesignerConfigurationService>().AutoSurroundWithSequenceEnabled = true
Please see the“AutoSurroundWithSequence” project under the “WF45ImprovementsInRehostedScenarios” solution for a standalone sample using this code. 
  
  
6. Pan Mode

This feature is enabled by default in .NET 4.5.

 

7.  Toolbox Search

This feature is enabled by default.in .NET 4.5.

 

Summary

This sample illustrated how the following features could be enabled when rehosting the WF designer.

  • Outline view of workflow items
  • Designer annotations
  • Multi-select
  • Auto-surround with sequence
  • Pan mode
  • Toolbox search