已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 执行和解协议书变更效力
- onvif协议书改成海康
- 2025年RCEP项下绿色产品原产地规则应用考核试卷
- 2025初级商业人像摄影师布光与修图协同创新案例考核试卷
- 包子店加盟协议书
- 汽车服务安全协议书
- nvme官方协议书中文
- 2025年共享出行行业共享出行模式与共享经济发展研究报告及未来发展趋势预测
- 102.2025年金融与财经行业准入考试金融数据治理规范(金融数据治理中的人才培养模式创新)考核试卷
- 新能源汽车高压安全工具使用考核试卷
- 《现代企业管理》期末考试复习题(附答案)
- 湖南省长沙市师大附中2025-2026学年高一上学期10月月考化学试题(原卷版)
- 南充市嘉陵城市发展集团有限公司2025年公开招聘工作人员(10人)笔试历年参考题库附带答案详解
- 2025广东深圳市龙岗区国资国企系统面向全市集中选聘中层管理人员考试及考察笔试历年参考题库附带答案详解
- 2025年炼钢项目可行性研究报告
- 知道智慧树网课《人工智能与科学之美(湘潭大学)》课后章节测试答案
- 安全生产考核巡查办法全文
- 铁路工程提、抽、压、注水文地质试验教程
- 叶片泵的叶轮理论与性能
- 脑干系统定位诊断
- SMARO型自动络筒机常见故障分析及操作说明ppt课件
评论
0/150
提交评论