




已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1 自定义Activity说明自定义Activity1.可以从System.Workflow.Activities.SequenceActivity继承,从SequenceActivity派生的类,将不能实现 IActivityEventListener 接口.或不能被正确执行2.可以从System.Workflow.ComponentModel.Activity继承3.可以从System.Workflow.ComponentModel.CompositeActivity继承4.可以从System.Workflow.Activities.StateActivity继承5.以下系统提供的Activity可以继承System.Workflow.Activities.CallExternalMethodActivitySystem.Workflow.Activities.HandleExternalEventActivity6.使用设计器创建Activity默认从System.Workflow.Activities.SequenceActivity继承从SequenceActivity派生的类,将不能实现 IActivityEventListener 接口.或不能被正确执行2 从System.Workflow.ComponentModel.Activity继承定义using System.Workflow.ComponentModel;using System.ComponentModel;public class wxdActivity : System.Workflow.ComponentModel.Activity public wxdActivity() InitializeComponent(); System.Diagnostics.DebuggerNonUserCode private void InitializeComponent() this.Name = wxd; /自定义事件,开始执行理 public event System.EventHandler wxdBeginEnent; /自定义事件,执行完成时 public event System.EventHandler wxdEndEvent; /自定义属性public static DependencyProperty wxdValueProperty = DependencyProperty.Register(wxdValue, typeof(string), typeof(wxdActivity); Browsable(true) DesignerSerializationVisibility(DesignerSerializationVisibility.Visible) public string wxdValue get return (string)(base.GetValue(wxdActivity.wxdValueProperty); set base.SetValue(wxdActivity.wxdValueProperty, value); /override Activity的Execute方法 protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) wxdBeginEnent(null, null); System.Console.WriteLine(this.Parent.Name); System.Console.WriteLine(this.wxdValue); wxdEndEvent(null, null); return base.Execute(executionContext); / executionContext /执行上下文对象 使用3 使用3.1 为Activity添加图标在类前添加 System.Drawing.ToolboxBitmap(typeof(wxdActivity), wxd.bmp) public class wxdActivity : System.Workflow.ComponentModel.Activity3.2 为Activity设置外观 /设计器样式类 ActivityDesignerThemeAttribute(typeof(wxdTheme) public class wxdActivityDesigner : ActivityDesigner /主题类 public class wxdTheme : ActivityDesignerTheme public wxdTheme(WorkflowTheme theme) : base(theme) this.BorderColor = Color.Red; /边框色 this.BorderStyle = DashStyle.Dash ; /边框线条 this.BackColorStart = Color.White; /渐变开始色 this.BackColorEnd = Color.Blue; /渐变结束色 this.BackgroundStyle = LinearGradientMode.ForwardDiagonal;/渐变方向 Designer(typeof(wxdActivityDesigner), typeof(IDesigner)public class wxdActivity : System.Workflow.ComponentModel.Activity如果在继承了SequenceActivity的Activity使用了上面的主题,可以使用其内部Activity不显示Designer(typeof(wxdActivityDesigner), typeof(IDesigner)public partial class Activity1: SequenceActivity3.3 为Activity添加菜单using System.Workflow.ComponentModel;using System.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Drawing;using System.Drawing.Drawing2D;using System.ComponentModel.Design;using System;using System.Collections.Generic;namespace wxwinter /自定义Activity Designer(typeof(wxdActivityDesigner), typeof(IDesigner) public class wxdActivity : System.Workflow.ComponentModel.Activity public static DependencyProperty wxdValueProperty = DependencyProperty.Register(wxdValue, typeof(string), typeof(wxdActivity); Browsable(true) DesignerSerializationVisibility(DesignerSerializationVisibility.Visible) public string wxdValue get return (string)(base.GetValue(wxdActivity.wxdValueProperty); set base.SetValue(wxdActivity.wxdValueProperty, value); /自定义设计器 public class wxdActivityDesigner : ActivityDesigner protected override System.Collections.ObjectModel.ReadOnlyCollection DesignerActions get List list = new List(); foreach (DesignerAction temp in base.DesignerActions) list.Add(new DesignerAction(this, temp.ActionId, temp.Text); return list.AsReadOnly(); protected override ActivityDesignerVerbCollection Verbs get ActivityDesignerVerbCollection NewVerbs = new ActivityDesignerVerbCollection(); NewVerbs.AddRange(base.Verbs); ActivityDesignerVerb menu = new ActivityDesignerVerb(this, DesignerVerbGroup.View, 设置wxdValue, new EventHandler(menu_click); NewVerbs.Add(menu); return NewVerbs; /当添加的菜单单击时要执行的操作 private void menu_click(object sender, EventArgs e) using (wxdSetForm wf = new wxdSetForm() string v = (string)this.Activity.GetValue(wxdActivity.wxdValueProperty); wf.Value = v; wf.ShowDialog(); this.Activity.SetValue(wxdActivity.wxdValueProperty,wf.Value); /自定义数据设置窗体 public class wxdSetForm : System.Windows.Forms.Form public string Value; System.Windows.Forms.TextBox tx = new System.Windows.Forms.TextBox(); System.Windows.Forms.Button bt = new System.Windows.Forms.Button(); public wxdSetForm() bt.Top=30; this.Controls.Add(tx); this.Controls.Add(bt); bt.Click += new EventHandler(bt_Click); bt.Text = 确定; this.Load += new EventHandler(wxdSetForm_Load); void wxdSetForm_Load(object sender, EventArgs e) this.tx.Text = Value; void bt_Click(object sender, EventArgs e) this.Value = this.tx.Text; this.Hide(); 在自定义的设计器中也可以使用3.4 为Activity添加属性验证器using System.Workflow.ComponentModel;using System.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Drawing;using System.Drawing.Drawing2D;using System.ComponentModel.Design;using System;using System.Collections.Generic;using System.Workflow.ComponentModel.Compiler;namespace wxwinter /自定义Activity ActivityValidator(typeof(wxdActivityValidator) public class wxdActivity : System.Workflow.ComponentModel.Activity public static DependencyProperty wxdValueProperty = DependencyProperty.Register(wxdValue, typeof(string), typeof(wxdActivity); Browsable(true) DesignerSerializationVisibility(DesignerSerializationVisibility.Visible) public string wxdValue get return (string)(base.GetValue(wxdActivity.wxdV
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 幼儿表演能力培养游戏方案
- 圆柱模板施工详细方案与指导书
- 物流企业客户管理及满意度提升方案
- 2025-2030动态手势控制与生物识别融合智能家居解决方案研究
- 2025-2030动力锂电池梯次利用标准体系构建与价值评估报告
- 教师帮扶制度及职业成长路径设计
- 2025-2030动力电池租赁商业模式对整车企业盈利结构影响深度分析报告
- 隧道掘进施工流程及安全管理
- 建筑防烟排烟系统安装验收技术规范
- 2025-2030动力电池梯次利用商业模式与经济效益报告
- 机加工安全生产培训考核试题及答案(班组级)(精)
- 电梯从业证考试试题及答案解析
- 第二十四届上海市青少年计算机创新应用竞赛 python校内选拔试题及答案
- 2024年武汉商学院公开招聘辅导员笔试题含答案
- 江苏省宿迁市泗阳县2024-2025学年高二下册期末调研测试语文试题【附答案】
- 2025年《传染病防治法》综合培训试题(附答案)
- 非典型骨折课件
- 封闭区倒塌围墙修复施工方案
- 户口本翻译样本-Word范文-Word范文
- 企业融资计划书2022
- 光纤损耗测试记录
评论
0/150
提交评论