定义

提供设计器画布,该设计器画布呈现工作流模型正在设计时的可视表示形式。

属性

表 2
Context

EditingContext 发布和请求的。

ContextMenu

获取此设计器的上下文菜单。

DebugManagerView

DebuggerService。

OutlineView

获取工作流设计器视图的大纲视图。

PropertyInspectorFontAndColorData

以序列化的字典格式设置属性检查器的字体和颜色数据。

PropertyInspectorView

获取通常称为属性网格的属性检查器。

Text

获取或设置工作流的 XAML 字符串表示形式。

View

此 UI 元素通常称为工作流画布。

方法

表 3
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
Flush()

Text 属性。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

Type。

(继承自 Object)
IsInErrorState()

Windows 工作流设计器 是否是错误状态。

Load()

Text 属性中包含的 XAML 中加载工作流。

Load(Object)

使用指定的实例加载工作流。

Load(String)

从指定文件中包含的 XAML 中加载工作流。

MemberwiseClone()

Object 的浅表副本。

(继承自 Object)
Save(String)

将工作流保存到 XAML 文件。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

事件

表 4
ModelChanged

表示在工作流模型中的内容发生更改时生效的事件处理程序。

TextChanged

Text 属性值更改时发生。

 

WorkflowDesigner主要是用来呈现和设计Activity,支持直接拖拽活动和编辑,用来在WPF界面上显示。

使用方法:

WorkflowDesigner wf = new WorkflowDesigner();
wf.Context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName = new System.Runtime.Versioning.FrameworkName(".NETFramework", new Version(4, 5));
wf.Context.Services.GetService<DesignerConfigurationService>().LoadingFromUntrustedSourceEnabled = true;

//load Workflow Xaml
wf.Load("TestActivity.xaml");

gd.Children.Add(wf.View);//设计画布
gdOut.Children.Add(wf.OutlineView);//设计大纲
gdPro.Children.Add(wf.PropertyInspectorView);//设计属性栏

 

问题1:在加载完xaml后,加载的活动无法编辑,显示不正常,如图

使用WorkflowDesigner中遇到的一些问题,记录一下

 

正常加载应该如下图

 使用WorkflowDesigner中遇到的一些问题,记录一下

解决办法:需要注册设计器的元数据

//associates all of the basic activities with their designers
new DesignerMetadata().Register();

 

问题2:加载后代码编辑器无法使用,如图

使用WorkflowDesigner中遇到的一些问题,记录一下

解决办法:出现这种问题的原因是加载的xaml文件中把编辑器设置成了"C#",而默认的编辑器是VB编辑器,导致编辑器无法识别,删除对应代码即可。

附上默认xaml代码,其中第二行删除即可解决问题

(TODO可以添加自定义表达式编辑器,可参考https://www.cnblogs.com/zhuqil/archive/2010/02/03/implementing-a-custom-expression-editor.html

 1 <Activity mc:Ignorable="sap sap2010 sads" x:Class="RPAEditor.TestActivity" 
 2           sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#"
 3           sap2010:WorkflowViewState.IdRef="RPAEditor.TestActivity_1"
 4  xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 5  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 6  xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 7  xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 8  xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 9  xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
10  xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
11  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
12   <TextExpression.NamespacesForImplementation>
13     <sco:Collection x:TypeArguments="x:String">
14       <x:String>System</x:String>
15       <x:String>System.Collections.Generic</x:String>
16       <x:String>System.Data</x:String>
17       <x:String>System.Linq</x:String>
18       <x:String>System.Text</x:String>
19     </sco:Collection>
20   </TextExpression.NamespacesForImplementation>
21   <TextExpression.ReferencesForImplementation>
22     <sco:Collection x:TypeArguments="AssemblyReference">
23       <AssemblyReference>mscorlib</AssemblyReference>
24       <AssemblyReference>System</AssemblyReference>
25       <AssemblyReference>System.Core</AssemblyReference>
26       <AssemblyReference>System.Data</AssemblyReference>
27       <AssemblyReference>System.ServiceModel</AssemblyReference>
28       <AssemblyReference>System.Xml</AssemblyReference>
29     </sco:Collection>
30   </TextExpression.ReferencesForImplementation>
31   <Sequence sap2010:WorkflowViewState.IdRef="Sequence_1" sads:DebugSymbol.Symbol="dy5FOlxQcm9qZWN0XFJQQVRlc3RcUlBBRWRpdG9yXFRlc3RBY3Rpdml0eS54YW1sAR0DHW8CAQE=" />
32   <sap2010:WorkflowViewState.ViewStateManager>
33     <sap2010:ViewStateManager>
34       <sap2010:ViewStateData Id="Sequence_1" sap:VirtualizedContainerService.HintSize="200,101">
35         <sap:WorkflowViewStateService.ViewState>
36           <scg:Dictionary x:TypeArguments="x:String, x:Object">
37             <x:Boolean x:Key="IsExpanded">True</x:Boolean>
38           </scg:Dictionary>
39         </sap:WorkflowViewStateService.ViewState>
40       </sap2010:ViewStateData>
41       <sap2010:ViewStateData Id="RPAEditor.TestActivity_1" sap:VirtualizedContainerService.HintSize="240,181" />
42     </sap2010:ViewStateManager>
43   </sap2010:WorkflowViewState.ViewStateManager>
44 </Activity>

 

问题3:表达式编辑器没有智能提示(解决中)

 

 

相关文章: