Custom Windows workflow Desiger 自定义Windows工作流设计器
Software Development Engineer Test
Microsoft Corporation
Windows Workflow Foundation beta 2.2
Microsoft Visual C# Version 2.0
Visual Studio 2005
· {
· 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
· }
· }
加载工作流,显示
·
· DesignSurface designSurface = new DesignSurface();
· WorkflowLoader loader = new WorkflowLoader();
·
· // load the design surface using the loader. This will call the
· // PerformLoad method on the loader, create the activity tree and
· // add the corresponding designer components to the designer host
·
· designSurface.BeginLoad(loader);
·
· // Get the designer host and retrieve the corresponding root component
· IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost;
· if (designerHost != null && designerHost.RootComponent != null)
· {
· // 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;
· }
· }
· ContextMenu contextMenu = new ContextMenu();
· Dictionary<CommandID, string> selectionCommands = new Dictionary<CommandID, string>();
·
· // Add the required commands
· selectionCommands.Add(WorkflowMenuCommands.Cut, "Cut");
· selectionCommands.Add(WorkflowMenuCommands.Copy, "Copy");
· selectionCommands.Add(WorkflowMenuCommands.Paste, "Paste");
· selectionCommands.Add(WorkflowMenuCommands.Delete, "Delete");
· foreach (CommandID id in selectionCommands.Keys)
· {
· 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();
· }
· }
这样,在界面上就可以显示出你自己的上下文菜单了
· this.workflowDesignerControl1.InvokeStandardCommand(WorkflowMenuCommands.Expand);
·
· public void InvokeStandardCommand(CommandID cmd)
· {
· IMenuCommandService menuService =
· GetService(typeof(IMenuCommandService)) as IMenuCommandService;
· if (menuService != null)
· menuService.GlobalInvoke(cmd);
· }
http://msdn2.microsoft.com/en-us/library/Aa480213.wfdsgnrehst03(en-us,MSDN.10).gif
2:生成后台代码MemberCreationService,和EventBindingService
· CodeMemberMethod method = new CodeMemberMethod();
· method.Name = methodName;
· method.Parameters.AddRange(paramCollection);
· method.ReturnType = new CodeTypeReference(returnType);
· method.Attributes = modifiers;
·
· //push the method into the code compile unit
· typeDeclaration.Members.Insert(index, method);
·
· // refresh the code compile unit
· TypeProvider typeProvider = (TypeProvider)this.serviceProvider.GetService(typeof(ITypeProvider));
· typeProvider.RefreshCodeCompileUnit(this.ccu,new EventHandler(RefreshCCU));
· {
· private void EventHandler(object sender, System.EventArgs e)
· {
· }
· }
xml
4:显示组件属性的ActivityBind Dialog: IPropertyValueUIService
5:Rules Dialog:用来编辑各种Rule。
2. string layoutFile = Path.Combine(Path.GetDirectoryName(this.xoml), Path.GetFileNameWithoutExtension(this.xoml) + ".layout");
3. ActivityDesigner rootdesigner = host.GetDesigner(rootActivity) as ActivityDesigner;
4. XmlWriter layoutwriter = XmlWriter.Create(layoutFile);
5. IList errors = null;
6. SaveDesignerLayout(layoutwriter, rootdesigner, out errors);
7. layoutwriter.Close();
8.
9. // Load the layout
10. string layoutFile = Path.Combine(Path.GetDirectoryName(this.xoml), Path.GetFileNameWithoutExtension(this.xoml) + ".layout");
11. if (File.Exists(layoutFile))
12. {
13. IList loaderrors = null;
14. using (XmlReader xmlReader = XmlReader.Create(layoutFile))
15. LoadDesignerLayout(xmlReader, out loaderrors);
16. }
http://msdn2.microsoft.com/en-us/library/Aa480213.wfdsgnrehst09(en-us,MSDN.10).gif
· WorkflowCompilerParameters parameters = new WorkflowCompilerParameters();
·
· // adding the code beside file and XAML file to the arraylist of files to
· // be compiled
· ArrayList files = new ArrayList();
· files.Add(this.loader.Xoml);
· files.Add(codeBesideFile);
·
· // adding the rules file to the resources
· string resources = @"/resource:" + rulesFile + "," + this.NameSpace + "." + this.TypeName + "." + "rules";
· parameters.CompilerOptions += resources;
·
· parameters.OutputAssembly = "CustomWorkflow" + Guid.NewGuid().ToString() + ".dll";
·
· // Compile the workflow
· WorkflowCompilerResults results = compiler.Compile(parameters, strArr);
结论
Custom Windows workflow Desiger 自定义Windows工作流设计器相关推荐
- Windows Workflow Foundation(1)- Windows Workflow Foundation 概述
Windows Workflow Foundation(第一章)- Windows Workflow Foundation 概述 工作流概述 活动(Activity)是工作流的基本单元,用于描述实际进 ...
- baq在聊天中啥意思,Epicor 10在BPM工作流设计器中链接BAQ(避免自定义代码)
目前,我的任务是检查由Epicor创建的BPM,该BPM未按预期运行.目前BPM基于下面的代码,其目的是参考系统中的订单,以及如果价格发生变化,订单/部件将反映新价格的时间.看起来代码导致不正确的价格 ...
- bpmn-js + vue实现工作流设计器
bpmn-js + vue实现工作流设计器 1.bpmn-js初体验 安装vue 使用vue-cli创建项目 安装bpmn-js 简单的查看工作流图形的例子 使用中间遇到的问题 2.新需求:可以拖拽自 ...
- [WF4.0]工作流设计器Rehosting(一)
因为WF4.0使用WPF做可视化设计,能够利用WPF的数据绑定和其他一些内部实现,极大的简化了工作流设计器的开发工作:不用像3.5和3.0中那样,要开发一些服务类来支持工作流的设计操作. 首先看看Wo ...
- 一招搞定可视化工作流设计器开发 巧用draw2d绝战可视化工作流设计器 友好的开源协议MIT
技术岛公众号 工作流通常会使用xml进行管理与配置,之间流转关系使用不同的xml节点进行配置,看着xml文件,很难直接Get到流程之间的流转关系.如果使用可视化的呈现来展现工作流,则很好的解决这个问题 ...
- 基于springboot+element ui+vue的java快速开发平台,集成html5工作流设计器,flowable, element ui 表单设计器
前后端分离.maven多模块开发,方便多人协同开发 后端选型:springboot2 + mybatis + shiro + jwt token + flowable 前端选型:vue + eleme ...
- 基于地图的工作流设计器,及基于地图的业务流程办理界面(二)
基于地图的工作流设计器,及基于地图的业务流程办理界面(二) ---------------------------------------------------------------------- ...
- 【转】Silverlight全开源工作流设计器
声明 此工作流是作者自行构思和设计的被动式数据触发模式的工作流.没有遵循各种现有的工作流设计标准(如WFMC或WSFL),也没有与其他工作流通用性的接口规范.这里体现更多的是作者对工作流的使用思想,及 ...
- js 图形化工作流设计器
最近比较闲,打算开发一个用js 写的 图形化工作流设计器,附上草图一张,要看运行效果请下载附件,这个版本还在开发中,以后会持续更新,直到满意为止.上面的列子虽然变形,我还是贴出来了,给大家一个直观的感 ...
最新文章
- Python 技术篇 - python3使用speech库常见问题原因及解决方法
- <马哲>科学技术在社会发展中的作用2017-12-27
- python正则表达式指南_Python正则表达式指南(转)
- 机器学习理论《统计学习方法》学习笔记:第三章 k近邻法
- Hessian序列化复杂对象
- 转换流/序列化/反序列化
- java导入包srcy有红叉_eclipse导入项目后出现红色叉号的解决方案
- paip.wscript.shell.run路径空格与VBs转义符 作者Attilax , EMAIL:1466519819@qq.com ,112237553@qq.com 来源:attilax
- [从零开始学FPGA编程-4]:快速入门篇 - 操作步骤1 - 常见可编程器件PROM、PLA、PAL、GAL、CPLD、FPGA
- Cropper详细笔记
- php7.4 ffi,PHP7.4中FFI的介绍(代码示例)
- 计算机二级ms在线模拟,2018年全国计算机二级在线自测模拟考场/网页版:MS Office高级应用(含真题及答案)...
- 动物识别系统代码python_人工智能-动物识别专家系统算法Python + Pyqt 实现
- JavaScript-ES6-基础语法
- shell脚本之AWK-AWK的变量和AWK运算符
- 回答阿里社招面试如何准备,顺便谈谈对于Java程序猿学习当中各个阶段的建议 - 左潇龙 - 博客园...
- 聊聊并发编程的12种业务场景
- 进程文件: dllhost 或者 dllhost.exe
- hifi android 手机吗,手机真能玩HiFi吗?手机玩HiFi必备的APP
- 在Hbuilder上使用GitHub
热门文章
- 外文翻译原文附在后面_外文翻译及外文原文(参考格式).doc
- [Codeforces 940E]Cashback(dp+set)
- CodeForces - 940E Cashback (DP+思维模型)
- ASEMI代理ON/安森美FGH40N60SMD原厂渠道车规级IGBT
- 用Python爬取微博热搜数据
- 高通平台之TP代码分析
- 流量就是这么省出来的
- jQuery设置内容以及属性
- php7不再把十六进制当数字,php7 参数、整形及字符串处理机制修改实例分析
- 网络填坑之路(6)ethtool - 命令管理以太网卡