WWF 工作流程學習筆記(三進街)

來源:互聯網
上載者:User

using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Workflow.Activities;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel;

 

namespace WindowsApplication3
{
    public partial class Form1 : Form
    {
        private WorkflowView wlv;
        private WorkflowViewWrapper workflowViewWrapper;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //這樣是錯誤的
           // wlv = new WorkflowView();
           // this.panel1.Controls.Add(wlv);

            //這個是正確的
            this.workflowViewWrapper=new WorkflowViewWrapper(this);
            this.panel1.Controls.Add(this.workflowViewWrapper.workflowView);
            this.workflowViewWrapper.LoadDefaulttWorkflow();
        }
    }

    public class WorkflowViewWrapper
    {
        private DesignSurface surface;
        public WorkflowView workflowView;
        private IDesignerHost host;
        private SequentialWorkflowActivity sequentialWorkflow;

        public WorkflowViewWrapper(Form parent)
        {
             //Create a Workflow Design Surface
            //建立設計時的環境以顯示WorkflowView
            this.surface = new DesignSurface();

            //Get the Workflow Designer Host
            //獲得管理設計器的介面對象
            this.host=this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;
            if(this.host==null)
                return;
           
            //Create a Sequential Workflow by using the Workflow Designer Host
            sequentialWorkflow=(SequentialWorkflowActivity)host.CreateComponent(typeof(SequentialWorkflowActivity));
            //sequentialWorkflow.ID=\"SequentialWorkflow1\";
           
            //Create a Workflow view on the workflow Design surface
            //指定的Surface顯示WorkflowView
            this.workflowView=new WorkflowView(this.surface as IServiceProvider);
            this.workflowView.Dock=DockStyle.Fill;

            //Activate the Workflow view
            this.host.Activate();
        }

        public void LoadDefaulttWorkflow()
        {
            //Create a code activity
            CodeActivity CodeActivity1= new CodeActivity();
            sequentialWorkflow.Activities.Add(CodeActivity1);
            host.RootComponent.Site.Container.Add(CodeActivity1);
        }

    }  
}

[img]http://p.blog.csdn.net/images/p_blog_csdn_net/Eroschina/20060627.gif[/img]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.