zoukankan      html  css  js  c++  java
  • 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

    的查看

     

    使用

  • 相关阅读:
    Java数据结构概述·14
    Java之自定义异常·13
    idea spirng项目jsp页面乱码
    HashMap和LinkedHashMap的区别
    jar包导入仓库中
    后台接口接受前端参数的时候使用包装类和基本类型接受
    转 为什么程序员怕改需求?
    thymeleaf常用标签
    linux查看端口占用情况
    查询linux硬件配置
  • 原文地址:https://www.cnblogs.com/foundation/p/1734284.html
Copyright © 2011-2022 走看看