版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、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.以下系统提供的Acti
2、vity可以继承System.Workflow.Activities.CallExternalMethodActivitySystem.Workflow.Activities.HandleExternalEventActivity6.使用设计器创建Activity默认从System.Workflow.Activities.SequenceActivity继承从SequenceActivity派生的类,将不能实现 IActivityEventListener 接口.或不能被正确执行2 从继承定义using System.Workflow.ComponentModel;using System.C
3、omponentModel;public class wxdActivity : System.Workflow.ComponentModel.Activity public wxdActivity() InitializeComponent(); System.Diagnostics.DebuggerNonUserCode private void InitializeComponent() this.Name = "wxd" /自定义事件,开始执行理 public event System.EventHandler wxdBeginEnent; /自定义事件,执行完成时
4、 public event System.EventHandler wxdEndEvent; /自定义属性public static DependencyProperty wxdValueProperty = DependencyProperty.Register("wxdValue", typeof(string), typeof(wxdActivity); Browsable(true) DesignerSerializationVisibility(DesignerSerializationVisibility.Visible) public string wxdVa
5、lue 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(
6、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.Compo
7、nentModel.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 =
8、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如果在继承了Seque
9、nceActivity的Activity使用了上面的主题,可以使用其内部Activity不显示Designer(typeof(wxdActivityDesigner), typeof(IDesigner)public partial class Activity1: SequenceActivity3.3 为Activity添加菜单using System.Workflow.ComponentModel;using System.ComponentModel;usingtModel.Design;using System.Drawing;using System.Drawing.Drawing
10、2D;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 = Dependenc
11、yProperty.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.wxdValuePropert
12、y, value); /自定义设计器 public class wxdActivityDesigner : ActivityDesigner protected override System.Collections.ObjectModel.ReadOnlyCollection<DesignerAction> DesignerActions get List<DesignerAction> list = new List<DesignerAction>(); foreach (DesignerAction temp in base.DesignerActio
13、ns) 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 Activi
14、tyDesignerVerb(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.w
15、xdValueProperty); 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 = n
16、ew 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
17、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.
18、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)(bas
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2026学年江西教招教学设计语文
- 2025榆林府谷能源投资集团有限公司选聘(45人)笔试参考题库附带答案详解
- 2026广西南宁市良庆区银岭幼儿园临聘保育员招聘1人笔试参考题库及答案解析
- 2025-2026学年批教案的话术
- 2025新疆伊吾县城市建设投资管理有限公司招聘9人笔试参考题库附带答案详解
- 2026福建宁德市特殊教育学校遴选在职教师10人考试备考试题及答案解析
- 2026荣丰现代农业发展有限公司招聘6人笔试模拟试题及答案解析
- 2025广东深圳市龙岗中心医院第二批公开招聘21人笔试历年典型考题及考点剖析附带答案详解试卷2套
- 2025广东广州医科大学附属第四医院编外人员招聘12人(一)笔试历年典型考题及考点剖析附带答案详解试卷2套
- 2025年郑州市中原区须水镇卫生院特招医学院校毕业生和特岗全科医生招聘8人笔试历年典型考题及考点剖析附带答案详解试卷2套
- JJG34-2022指示表检定规程
- 2025年湖南省事业单位联考真题试卷 公共基础知识附答案详解(完整版)
- 人工智能通识 课件 唐志航 第1-8章 人工智能发展简史- 办公软件实战应用
- 2025年驾照满分学习题库及答案
- 猪场建设施工合同范本
- 公墓管理员中级面试问题
- 中国持续葡萄糖监测临床应用指南(2025年版)
- 多智能体深度强化学习通信机制综述
- 复工复产安全培训考试题
- 分子与细胞免疫学
- 《现代语言学习理论》课件
评论
0/150
提交评论