• WF4.0 应用篇(四) IActivityToolboxService 自动化工具栏


     

    WF4.0 应用篇(四) IActivityToolboxService 自动化工具栏

    例子下载: https://files.cnblogs.com/foundation/IActivityToolboxServiceSample.rar

     

     

    System.Activities.Presentation.IActivityToolboxService

     

    在设计工作流的创时,

    可以实现工具栏的上下文相关

    如当一个Activity被添加到工作流中后,会自动在工具栏中显示与该Activity相关的Activity

    当这个Activity从工作流中移除时,会自动在工具栏中隐藏相关的Activity

     

    实现思路如下:

    1.为Activity添加一个Designer

    2.override Designer的 OnModelItemChanged方法

    3.在 OnModelItemChanged方法内用IActivityToolboxService向工具栏添加关联的Activity

    4.关联Activity的移除是自动完成的,不用代码

     

     

    定义[myActivity],[myActivityOne],[myActivityTwo]

     

    当向流程中添加[myActivity]时[myActivityOne],[myActivityTwo]自动出现在工具栏中

    当这个[myActivity]从工作流中移除时,会自动在工具栏中隐藏[myActivityOne],[myActivityTwo]

     

    myActivityOne

    myActivityTwo

    任意

    myActivity

    [System.ComponentModel.Designer(typeof(myActivityDesigner))]

    public sealed class myActivity : CodeActivity

    {

     

    public InArgument<string> Text { get; set; }

     

    protected override void Execute(CodeActivityContext context)

    {

    string text = context.GetValue(this.Text);

    }

    }

    myActivityDesigner

    <sap:ActivityDesigner x:Class="IActivityToolboxServiceSample.myActivityDesigner"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"

    xmlns:sapv="clr-namespace:System.Activities.Presentation.View;assembly=System.Activities.Presentation">

    <Grid>

     

    </Grid>

    </sap:ActivityDesigner>

    public partial class myActivityDesigner

    {

    public myActivityDesigner()

    {

    InitializeComponent();

    }

     

    protected override void OnModelItemChanged(object newItem)

    {

     

    base.OnModelItemChanged(newItem);

    System.Activities.Presentation.IActivityToolboxService toolboxService = (System.Activities.Presentation.IActivityToolboxService)this.Context.Services.GetService(typeof(System.Activities.Presentation.IActivityToolboxService));

     

    toolboxService.AddCategory("myActivity自定义选卡");

    toolboxService.AddItem("IActivityToolboxServiceSample.myActivityOne,IActivityToolboxServiceSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

    , "myActivity自定义选卡");

    oolboxService.AddItem("IActivityToolboxServiceSample.myActivityTwo,IActivityToolboxServiceSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"

    , "myActivity自定义选卡");

    }

    }

    IActivityToolboxServiceSample.myActivityOne,IActivityToolboxServiceSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

    的查看

     

    使用

  • 相关阅读:
    Centos7网络配置(VMware)
    Djangoform表单Ajax控制跳转
    selenium Webdriver 处理iFrame之间的切换问题------------
    Eclipse相关的快捷键
    selenium webdriver----如何处理div弹窗、alert、confirm、prompt对话框-------------------
    处理basic认证,浏览器自带弹窗的(非windows弹窗)处理-----------------
    元素的Actions(特效)及基本UI控件操作
    查找页面元素一
    调用exe文件(一般处理登陆安全窗口)+睡眠等待(--------------------)
    用autoit识别windows窗口(保存弹窗及登陆(basic认证)相关的弹窗)-----
  • 原文地址:https://www.cnblogs.com/foundation/p/1734284.html
Copyright © 2020-2023  润新知