WF工作流设计器

先创建一个WinForm应用程序吧,再放SplitContainer,再工具箱WPF项下elementHost分别放三个,如下


再添加一个类,factory.cs


代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities.Presentation;
using System.Activities.Presentation.Hosting;
using System.Windows;
using System.Windows.Controls;
using System.Activities.Presentation.Toolbox;
using System.Activities.Statements;

namespace WindowsFormsApp3
{
    public class factory
    {
        private WorkflowDesigner wd;

        private string DefaultXamlActivity
        {
            get
            {
                return @"<Activity x:Class='EmptyActivity' mva:VisualBasic.Settings='Assembly references and imported namespaces serialized as XML namespaces' xmlns='http://schemas.microsoft.com/netfx/2009/xaml/activities' xmlns:mva='clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' />";
            }
        }

        public void RegisterMetadata()
        {
            System.Activities.Core.Presentation.DesignerMetadata designers = new System.Activities.Core.Presentation.DesignerMetadata();
            designers.Register();
        }

        public UIElement LoadDesigner(string xaml)
        {
            this.wd = new WorkflowDesigner();
            this.wd.Context.Items.GetValue<ReadOnlyState>().IsReadOnly = false;

            this.wd.ModelChanged += delegate (object source, EventArgs args)
            {
                this.wd.Flush();
            };

            this.wd.Text = string.IsNullOrEmpty(xaml) ? this.DefaultXamlActivity : xaml;
            this.wd.Load();

            Grid.SetColumn(this.wd.View, 1);
            UIElement element = this.wd.View;
            element.IsEnabled = true;
            element.IsHitTestVisible = true;
            return element;

        }

        public UIElement LoadPropertyInspector()
        {
            Grid.SetColumn(wd.PropertyInspectorView, 2);
            return wd.PropertyInspectorView;
        }

        public UIElement LoadToolBox()
        {
            ToolboxControl tc = GetToolboxControl();
            Grid.SetColumn(tc, 0);
            return tc;
        }

        private ToolboxControl GetToolboxControl()
        {
            ToolboxControl ctrl = new ToolboxControl();

            #region MS Built-in Activity
            ToolboxCategory categoryFlowchart = new ToolboxCategory("Flowchart")
{
new ToolboxItemWrapper(typeof(Flowchart)),
new ToolboxItemWrapper(typeof(FlowDecision))
};

            ToolboxCategory categoryCollection = new ToolboxCategory("Collection")
{
new ToolboxItemWrapper(typeof(AddToCollection<>)),
new ToolboxItemWrapper(typeof(ClearCollection<>)),
new ToolboxItemWrapper(typeof(ExistsInCollection<>)),
new ToolboxItemWrapper(typeof(RemoveFromCollection<>)),
};

            ToolboxCategory categoryPrimitives = new ToolboxCategory("Primitives")
{
new ToolboxItemWrapper(typeof(Assign)),
new ToolboxItemWrapper(typeof(Assign<>)),
new ToolboxItemWrapper(typeof(Delay)),
new ToolboxItemWrapper(typeof(InvokeMethod)),
new ToolboxItemWrapper(typeof(WriteLine)),
};

            ToolboxCategory categoryControlFlow = new ToolboxCategory("ControlFlow")
{
new ToolboxItemWrapper(typeof(DoWhile)),
new ToolboxItemWrapper(typeof(ForEach<>)),
new ToolboxItemWrapper(typeof(If)),
new ToolboxItemWrapper(typeof(Parallel)),
new ToolboxItemWrapper(typeof(ParallelForEach<>)),
new ToolboxItemWrapper(typeof(Pick)),
new ToolboxItemWrapper(typeof(PickBranch)),
new ToolboxItemWrapper(typeof(Sequence)),
new ToolboxItemWrapper(typeof(Switch<>)),
new ToolboxItemWrapper(typeof(While)),
};

            ToolboxCategory categoryTransaction = new ToolboxCategory("Transaction")
{
new ToolboxItemWrapper(typeof(CancellationScope)),
new ToolboxItemWrapper(typeof(CompensableActivity)),
new ToolboxItemWrapper(typeof(Compensate)),
new ToolboxItemWrapper(typeof(Confirm)),
new ToolboxItemWrapper(typeof(TransactionScope)),
};

            ToolboxCategory categoryErrorHandling = new ToolboxCategory("Error Handling")
{
new ToolboxItemWrapper(typeof(Rethrow)),
new ToolboxItemWrapper(typeof(Throw)),
new ToolboxItemWrapper(typeof(TryCatch)),
};
            #endregion

            ctrl.Categories.Add(categoryPrimitives);
            ctrl.Categories.Add(categoryControlFlow);
            ctrl.Categories.Add(categoryErrorHandling);
            ctrl.Categories.Add(categoryFlowchart);
            ctrl.Categories.Add(categoryTransaction);
            ctrl.Categories.Add(categoryCollection);

            return ctrl;
        }
    }
}


窗口引用:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities.Presentation;
using System.Activities.Presentation.Hosting;
using System.Windows;
using System.Windows.Controls;
using System.Activities.Presentation.Toolbox;
using System.Activities.Statements;
using System.Windows.Forms;

namespace WindowsFormsApp3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            factory.RegisterMetadata();
            elementHost1.Child = factory.LoadToolBox();
            elementHost2.Child = factory.LoadDesigner("");
            elementHost3.Child = factory.LoadPropertyInspector();



        }

        private factory factory = new factory();
    }

}

效果:


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: u8 生产工作流是一种企业资源计划(ERP)系统,用于管理和优化生产流程。在这个系统中,wf_activeflow instance(工作流活动实例)是指正在进行中的工作流程。 wf_activeflow instance 是根据预先定义的工作流模板创建的,它根据具体的生产任务和需求进行自动化和调度。每个工作流活动实例都有一个唯一的标识符,以便系统能够跟踪和管理它们的状态。 工作流活动实例可以通过多种方式创建,例如,当一个新的生产任务被指派给某个员工时,系统会自动创建相应的工作流活动实例。这个实例将指导员工完成任务的各个阶段,包括访问生产文件、审批报告、记录生产数据等。 在整个生产过程中,工作流活动实例可以根据需要进行调整和修改。例如,如果有新的需求或紧急情况出现,可以通过修改工作流活动实例的流程或添加额外的活动来适应变化。 通过使用u8 生产工作流 wf_activeflow instance,企业可以实现生产过程的自动化和优化。这不仅提高了生产效率,减少了错误和延迟,还提供了实时监控和数据分析功能,帮助企业精确掌握生产进度和资源分配。 总之,u8 生产工作流 wf_activeflow instance 在生产管理中发挥了重要的作用,为企业实现高效和可持续的生产提供了强有力的支持。 ### 回答2: u8 生产工作流wf_activeflow instance)是用于管理和监控业务流程的工具。它是u8企业管理软件的一部分,旨在帮助企业提高生产效率和管理制度。 u8生产工作流可以通过定义和实施工作流程来规范企业的生产流程。它可以将复杂的生产过程划分为一系列简单的任务和环节,并通过自动化和协作功能来简化和加快任务的执行。该工作流可以适应企业的不同生产模式和业务需求,提供灵活的配置选项。 在运行过程中,wf_activeflow instance可以实时跟踪和监控工作流的执行情况。它记录每个任务的状态和进展,并提供详细的报表和统计信息。这些数据可以帮助企业了解生产过程中的瓶颈和问题,及时做出调整和改进。 此外,u8生产工作流还具有权限管理功能,可以根据用户角色和职责来限制和控制任务的执行权限。这样能够确保只有具备相应权限的人员才能参与和操作生产过程,保证生产活动的安全性和可靠性。 总之,u8生产工作流wf_activeflow instance)是一个强大的工具,可以帮助企业规范和优化生产流程,提高生产效率和质量。它是u8软件在生产管理领域的核心组件之一,为企业提供了全面的生产管理解决方案。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

赵之章

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值