Esempio n. 1
0
        /// <summary>
        /// 初始化工具箱
        /// </summary>
        public void InitToolBox()
        {
            BaseWorkFlow startWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.Start);

            startWF.DragStarted += AddModel;
            ToolBox.WorkAreaItems.Add(startWF);

            BaseWorkFlow processWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.Process);

            ToolBox.WorkAreaItems.Add(processWF);
            processWF.DragStarted += AddModel;

            BaseWorkFlow decisionWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.Decision);

            ToolBox.WorkAreaItems.Add(decisionWF);
            decisionWF.DragStarted += AddModel;

            BaseWorkFlow endWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.End);

            endWF.DragStarted += AddModel;
            ToolBox.WorkAreaItems.Add(endWF);

            BaseWorkFlow lineWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.Line);

            lineWF.DragStarted += AddModel;
            ToolBox.WorkAreaItems.Add(lineWF);

            BaseWorkFlow polyLineWF = WorkFlowFactory.GetWorkFlow(WorkFlowEnum.PolyLine);

            polyLineWF.DragStarted += AddModel;
            ToolBox.WorkAreaItems.Add(polyLineWF);
        }
Esempio n. 2
0
 /// <summary>
 /// 递归子节点,添加xml子节点
 /// </summary>
 /// <param name="workFlows"></param>
 /// <param name="xmlDocument"></param>
 /// <param name="xmlElement"></param>
 private static void AddChildXml(WorkAreaModel workArea, XmlDocument xmlDocument, XmlElement xmlElement)
 {
     foreach (IWorkFlowAttributes item in workArea.WorkAreaItems)              //遍历工作区所有对象
     {
         Type type = item.GetType();
         //	var props = type.GetProperties();
         XmlElement itemNode = xmlDocument.CreateElement(string.Empty, type.Name, string.Empty); //新建节点
         foreach (string propName in item.Attributes)                                            //遍历需要序列化的属性
         {
             if (propName == "ChildWorkFlow")
             {
                 BaseWorkFlow wf = item as BaseWorkFlow;
                 if (wf.ChildWorkFlow != null)                           //如果存在子流程则递归子流程
                 {
                     AddChildXml(wf.ChildWorkFlow.WorkArea, xmlDocument, itemNode);
                 }
             }
             else
             {                                                                                                //不存在则设置xml节点属性
                 itemNode.SetAttribute(propName, type.GetProperty(propName).GetValue(item, null).ToString()); //设置节点属性
             }
         }
         xmlElement.AppendChild(itemNode);                  //附加对象节点到根节点
     }
 }
Esempio n. 3
0
        private static void LoadChildNode(WorkAreaModel workArea, XmlElement xmlElement)
        {
            XmlNodeList xmlNodeList = xmlElement.ChildNodes;

            foreach (XmlElement xe in xmlNodeList)                                                            //遍历模块节点
            {
                Assembly     assembly = Assembly.GetExecutingAssembly();                                      // 获取当前程序集
                BaseWorkFlow obj      = assembly.CreateInstance("WPFDrag.Themes." + xe.Name) as BaseWorkFlow; //反射新建实例
                Type         type     = obj.GetType();
                var          props    = type.GetProperties();
                foreach (var prop in props)
                {
                    if (xe.HasAttribute(prop.Name))                      //判断是否有该属性
                    {
                        if (prop.Name == "Points")
                        {
                            PointCollection pc = PointCollection.Parse(xe.GetAttribute("Points"));                              //设置复杂属性
                            prop.SetValue(obj, pc);
                        }
                        else
                        {
                            prop.SetValue(obj, Convert.ChangeType(xe.GetAttribute(prop.Name), prop.PropertyType));                              //根据类型设置属性
                        }
                    }
                }
                workArea.WorkAreaItems.Add(obj);
                workArea.RegistModelEvent(obj);
                if (xe.HasChildNodes)                   //如果有子节点,则递归读取
                {
                    obj.ChildWorkFlow = new WorkFlowModel();
                    LoadChildNode(obj.ChildWorkFlow.WorkArea, xe);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 注册流程模块的事件和数据上下文
 /// </summary>
 /// <param name="workFlow"></param>
 public void RegistModelEvent(BaseWorkFlow workFlow)
 {
     workFlow.DataContext         = workFlow;                  //设定数据上下文
     workFlow.MouseRightButtonUp += AddWf_MouseRightButtonUp;  //注册右键删除事件
     workFlow.DragStarted        += AddWf_DragStarted;         //注册鼠标选定事件
     workFlow.MouseDoubleClick   += WorkFlow_MouseDoubleClick; //注册双击打开子流程事件
 }
Esempio n. 5
0
        /// <summary>
        /// 工作区添加流程
        /// </summary>
        /// <param name="workFlowEnum">流程类型</param>
        public void AddModelToWorkArea(WorkFlowEnum workFlowEnum)
        {
            BaseWorkFlow addWf = WorkFlowFactory.GetWorkFlow(workFlowEnum);

            WorkAreaItems.Add(addWf);
            SelectItem = addWf;
            RegistModelEvent(addWf);
        }
Esempio n. 6
0
        private void WorkFlow_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            BaseWorkFlow wf = sender as BaseWorkFlow;

            if (wf.ChildWorkFlow == null)
            {
                wf.ChildWorkFlow = new WorkFlowModel();                    //新建子流程
            }

            if (AddChildWorkFlowEventHandler != null)
            {
                AddChildWorkFlowEventHandler(wf.ChildWorkFlow);                     //调用事件处理委托通知
                if (wf.ChildWorkFlow.WorkArea.AddChildWorkFlowEventHandler == null) //注册子流程双击事件 递归添加
                {
                    wf.ChildWorkFlow.WorkArea.AddChildWorkFlowEventHandler += (obj) => Messenger.Default.Send <object>(obj, MessageToken.ChildWindowMessageToken);
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 添加流程到工作区中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddModel(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
        {
            BaseWorkFlow wf = sender as BaseWorkFlow;

            WorkArea.AddModelToWorkArea(wf.WorkFlowEnum);
        }
Esempio n. 8
0
 /// <summary>
 /// 从工作区移除流程
 /// </summary>
 /// <param name="workFlow"></param>
 /// <param name="workArea"></param>
 public void RemoveModelFromWorkArea(BaseWorkFlow workFlow)
 {
     WorkAreaItems.Remove(workFlow);
 }
Esempio n. 9
0
 private void AddWf_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
 {
     SelectItem = sender as BaseWorkFlow;
 }