制作自定义工作流(WWF)设计器
May 2006
应用于:
???Windows Workflow Foundation beta 2.2
???Microsoft Visual C# Version 2.0
???Visual Studio 2005
demo下载:Download the code sample, WorkflowDesignerControl.exe.
·???????????????????????????
{
·??????????????????????????????protected?override?void?PerformLoad(IDesignerSerializationManager?serializationManager)
·?????????????????????????????????
{
·????????????????????????????????????base.PerformLoad(serializationManager);
·????????????????????????????????????//?Implement?the?logic?to?read?from?the?serialized?state,
·????????????????????????????????????//?create?the?activity?tree?and?the?corresponding?designer
·????????????????????????????????????//?tree?and?add?it?to?the?designer?host
·?????????????????????????????????}
·????????????????????????????
·??????????????????????????????protected?override?void?PerformFlush(IDesignerSerializationManager?manager)
·?????????????????????????????????
{
·????????????????????????????????????//?Implement?the?logic?to?save?the?activity?tree?to?a
·????????????????????????????????????//?serialized?state?along?with?any?code?beside?elements?
·?????????????????????????????????}
·???????????????????????????}
·???????????????????????????
{
·??????????????????????????????//?Get?the?designer?associated?with?the?root?component
·??????????????????????????????IRootDesigner?rootDesigner?=????designerHost.GetDesigner(designerHost.RootComponent)?as?IRootDesigner;
·??????????????????????????????if?(rootDesigner?!=?null)
·??????????????????????????????
{
·?????????????????????????????????this.designSurface?=?designSurface;
·?????????????????????????????????this.loader?=?loader;
·??????????????????????????????
·????????????????????????????????????//?Assign?the?default?view?of?the?rootdesigner?to?WorkflowView
·????????????????????????????????????this.workflowView?=?rootDesigner.GetView(ViewTechnology.Default)?as??????????WorkflowView;
·????????????????????????????
·????????????????????????????????????//?Add?the?workflow?view?control?to?winforms?app
·????????????????????????????????????this.workflowViewSplitter.Panel1.Controls.Add(this.workflowView);
·????????????????????????????????????this.workflowView.Focus();
·????????????????????????????????????this.propertyGrid.Site?=?designerHost.RootComponent.Site;
·??????????????????????????????}
·????????????????????????????}
·???????????????
{
·?????????????????????MenuCommand?command?=?FindCommand(id);
·?????????????????????if?(command?!=?null)
·??????????????????????
{
·????????????????????????//?For?each?command?create?a?new?menu?item?and?add?an
·????????????????????????MenuItem?menuItem?=?new?MenuItem(selectionCommands[id],?new??????????EventHandler(OnMenuClicked));
·????????????????????????menuItem.Tag?=?command;
·????????????????????????contextMenu.MenuItems.Add(menuItem);
·?????????????????????}
·???????????????}
·????????????????
·???????????????//?Handle?the?event?when?the?MenuItem?is?clicked
·???????????????private?void?OnMenuClicked(object?sender,?EventArgs?e)
·???????????????
{
·????????????????//?Retrieve?the?menu?item?that?was?clicked
·????????????????MenuItem?menuItem?=?sender?as?MenuItem;
·????????????????if?(menuItem?!=?null?&&?menuItem.Tag?is?MenuCommand)
·?????????????????????
{
·????????????????????????//?invoke?the?command?corresponding?to?the?menu?item?clicked
·????????????????????????MenuCommand?command?=?menuItem.Tag?as?MenuCommand;
·????????????????????????command.Invoke();
·?????????????????????}
·???????????????}
·??????????????????
{
·?????????????????????IMenuCommandService?menuService?=
·?????????????????????GetService(typeof(IMenuCommandService))?as?IMenuCommandService;
·?????????????????????if?(menuService?!=?null)
·?????????????????????menuService.GlobalInvoke(cmd);
·??????????????????}
2:生成后台代码MemberCreationService,和EventBindingService
·???????????????
{
·???????????????????????private?void?EventHandler(object?sender,?System.EventArgs?e)
·???????????????????????
{
·???????????????????????}
·???????????????}
4:显示组件属性的ActivityBind Dialog: IPropertyValueUIService
5:Rules Dialog:用来编辑各种Rule。
12.??????????????????????????
{
13.?????????????????????????????IList?loaderrors?=?null;
14.??????????????????????