示例#1
0
        /// <summary>
        /// 获取下一个图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">绘图索引哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, false);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetData(g);

                if (!graphElementList.Contains(g))
                {
                    DataElement dataElement = dataManager.GetDataElement(g);
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.DisplayText = g.TooltipText;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                    FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable);
                }
                else
                {
                    FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                }
            }
        }
示例#2
0
        /// <summary>
        /// 获取下一个绘图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">绘图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">流程图索引哈希表</param>
        /// <param name="actionsTable">动作组数据哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable, Hashtable actionsTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, true);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetCompileData(g);
                DataElement dataElement =  dataManager.GetCompileDataElement(g);

                if (!graphElementList.Contains(g))
                {                    
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.DisplayText = g.Text;                    
                    
                    if (g is AIStateGraphElement) // 状态
                    {
                        string stateNodeName = CodeProviderClass.GetStateString(data);
                        newMetaData.Code = stateNodeName;

                        InitSetStateMetaData(metaData, newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);
                    }
                    else if (g is AILineGraphElement) // 连接线
                    {
                        newMetaData.Code = CodeProviderClass.GetEventString(data);

                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);                        
                    }
                    else if (g is AIActionGraphElement) // 动作
                    {
                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                        FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable, actionsTable);
                    }
                    else if (g is AIActionsGraphElement) // 动作组
                    {                    
                        List<FlowChartMetaData> metaDataList = actionsTable[g] as List<FlowChartMetaData>;

                        metaDataList[0].AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(metaDataList[0]);

                        FindNextMetaData(dataManager, g, metaDataList[metaDataList.Count - 1], graphElementList, graphElementTable, actionsTable);
                    }
                }
                else
                {
                    if (g is AIActionsGraphElement) // 动作组要特殊处理
                    {
                        List<FlowChartMetaData> metaDataList = actionsTable[g] as List<FlowChartMetaData>;
                        metaDataList[0].AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(metaDataList[0]);
                    }
                    else if (g is AIStateGraphElement) // 状态结点要特殊处理
                    {
                        FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;

                        InitSetStateMetaData(metaData, newMetaData);
                    }
                    else
                    {
                        FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                        newMetaData.AddPreviousMetaData(metaData);
                        metaData.AddNextMetaData(newMetaData);
                    }                    
                }
            }                      
        }
示例#3
0
        /// <summary>
        /// 获取图元数据链表
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">插槽容器链表</param>
        /// <returns>图元数据链表</returns>
        protected virtual List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer.IsEntrance)
                {
                    object data = dataManager.GetData(slotContainer);
                    DataElement dataElement = dataManager.GetDataElement(slotContainer);
                    FlowChartMetaData metaData = new FlowChartMetaData(slotContainer.ID, data, slotContainer.TypeString);
                    metaData.DisplayText = slotContainer.TooltipText;
                    FindNextMetaData(dataManager, slotContainer, metaData, graphElementList, graphElementTable);
                    metaDataList.Add(metaData);
                }
            }

            return metaDataList;
        }
示例#4
0
        /// <summary>
        /// 获取动作组的元数据链表
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="aiActionsGraphElement">动作组图元</param>
        /// <returns>动作组的元数据链表</returns>
        private List<FlowChartMetaData> GetActionsMetaDataList(DataManager dataManager, AIActionsGraphElement aiActionsGraphElement)
        {
            object data = dataManager.GetCompileData(aiActionsGraphElement);

            List<object> actions = CodeProviderClass.SplitMultiActionIntoSingle(data);
            List<FlowChartMetaData> actionsMetaDataList = new List<FlowChartMetaData>();

            // 把显示文本拆分
            List<string> displayTextList = new List<string>();
            string[] tempArray = aiActionsGraphElement.Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string s in tempArray)
            {
                displayTextList.Add(s.TrimEnd(new char[] { '\r' }).TrimStart(new char[] { '◆', ' ' }));
            }

            for (int i = 0; i < actions.Count; i++)
            {
                FlowChartMetaData actionMetaData = new FlowChartMetaData(maxID, actions[i], "AIActionNode");
                actionMetaData.DisplayText = displayTextList[i];
                actionsMetaDataList.Add(actionMetaData);
                maxID++;
            }

            for (int i = 0; i < actions.Count - 1; i++)
            {
                FlowChartMetaData actionMetaData = actionsMetaDataList[i];
                FlowChartMetaData nextMetaData = actionsMetaDataList[i + 1];

                FlowChartMetaData lineMetaData;
                int returnValueCount = CodeProviderClass.GetActionRetCount(actions[i]);

                for (int j = 1; j <= returnValueCount; j++)
                {
                    lineMetaData = new FlowChartMetaData(maxID, j.ToString(), "AILine");
                    lineMetaData.DisplayText = j.ToString();
                    actionMetaData.AddNextMetaData(lineMetaData);
                    lineMetaData.AddPreviousMetaData(actionMetaData);
                    lineMetaData.AddNextMetaData(nextMetaData);
                    nextMetaData.AddPreviousMetaData(lineMetaData);

                    maxID++;
                }
            }

            return actionsMetaDataList;
        }
示例#5
0
        /// <summary>
        /// 获取流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">流程图插槽容器的链表</param>
        /// <returns>流程图元数据的链表</returns>
        protected override List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            // 初始化ID
            maxID = dataManager.CurrentFlowChartManager.CurrentGraphManager.IDIndex + 1;

            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();
            dataManager.InitCompileTable();

            Hashtable actionsTable = new Hashtable(); // 动作组数据哈希表

            // 预处理动作组结点
            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is AIActionsGraphElement)
                {
                    AIActionsGraphElement actionsGraphElement = slotContainer as AIActionsGraphElement;
                    List<FlowChartMetaData> actionsMetaDataList = GetActionsMetaDataList(dataManager, actionsGraphElement);
                    actionsTable[actionsGraphElement] = actionsMetaDataList;
                }
            }

            // 预处理子绘图结点
            AIStateGraphElement stateNode = null;            

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                // 所有子绘图的图元都重新分配ID
                if (slotContainer is InnerChart)
                {
                    InnerChart innerChart = slotContainer as InnerChart;
                    InnerChartEditor innerChartEditor = dataManager.GetDataElement(innerChart) as InnerChartEditor;
                    List<GraphElement> list = innerChartEditor.GraphElementList;

                    foreach (GraphElement graphElement in list)
                    {
                        graphElement.ID = maxID;
                        graphElement.Tag = innerChart.ID;
                        maxID++;

                        dataManager.AddCompileData(graphElement, innerChartEditor.GetDataElement(graphElement));

                        // 重命名名称                        
                        RenameGraphElement(dataManager, graphElement);

                        if (graphElement is AIStateGraphElement)
                        {
                            AIStateGraphElement aiStateGraphElement = graphElement as AIStateGraphElement;

                            if (aiStateGraphElement.IsInitialState)
                            {
                                stateNode = aiStateGraphElement;
                            }
                        }
                        else if (graphElement is AIActionsGraphElement)
                        {
                            AIActionsGraphElement actionsGraphElement = graphElement as AIActionsGraphElement;
                            List<FlowChartMetaData> actionsMetaDataList = GetActionsMetaDataList(dataManager, actionsGraphElement);
                            actionsTable[actionsGraphElement] = actionsMetaDataList;
                        }
                    }
                }
            }

            // 处理绘图结点
            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is AIStateGraphElement)
                {
                    AIStateGraphElement stateGraphElement = slotContainer as AIStateGraphElement;

                    if (stateGraphElement.IsInitialState)
                    {
                        stateNode = stateGraphElement;
                        break;
                    }                    
                }
            }

            if (stateNode != null)
            {
                object data = dataManager.GetCompileData(stateNode);
                DataElement dataElement = dataManager.GetCompileDataElement(stateNode);
                FlowChartMetaData metaData = new FlowChartMetaData(stateNode.ID, data, "AIStateNode");
                string stateNodeName = CodeProviderClass.GetStateString(data);

                metaData.Code = stateNodeName;
                metaData.DisplayText = stateNode.Text;
                FindNextMetaData(dataManager, stateNode, metaData, graphElementList, graphElementTable, actionsTable);
                metaDataList.Add(metaData);
            }

            return metaDataList;
        }
示例#6
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 /// <param name="canvas">绘图板实例</param>
 /// <param name="propertyGrid">属性面板实例</param>
 public void Init(Canvas canvas)
 {
     graphManager = new GraphManager(this, canvas);
     dataManager = new DataManager(this);
     dataBaseManager = DataBaseManager.GetDataBaseManager();
     int i = path.IndexOf('\\');
     mapName = path.Substring(0, i);
     flowChartInteractor = new FlowChartInteractor();
 }                
示例#7
0
        /// <summary>
        /// 重命名图元
        /// </summary>
        /// <param name="graphElement">数据管理器</param>
        /// <param name="graphElement">图元</param>
        private void RenameGraphElement(DataManager dataManager, GraphElement graphElement)
        {
            object data = dataManager.GetCompileData(graphElement);

            if (graphElement is AIStateGraphElement) // 自动为状态结点重命名
            {
                AI_State aiState = data as AI_State;

                if (aiState != null)
                {
                    aiState.Ename = string.Format("State{0}", graphElement.ID.ToString());
                }
            }
            else if (graphElement is AIActionGraphElement) // 自动为自定义脚本的动作结点重命名
            {
                AI_SingleAction singleAction = data as AI_SingleAction;

                if (singleAction != null)
                {
                    string newName = string.Format("CustomAction{0}", graphElement.ID.ToString());
                    int actionID = 2000 + graphElement.ID;
                    RenameAIAction(singleAction.Action, newName, actionID);
                }
            }
            else if (graphElement is AIActionsGraphElement) // 自动为动作组中自定义脚本的动作结点重命名
            {                
                AI_MultiAction multiAction = data as AI_MultiAction;

                if (multiAction != null)
                {
                    int actionIndex = 0;
                    List<AI_SingleAction> aiActionList = multiAction.ActionList;

                    foreach (AI_SingleAction singleAction in aiActionList)
                    {
                        string newName = string.Format("CustomAction{0}_{1}", graphElement.ID.ToString(),
                                                        actionIndex.ToString());
                        int actionID = (2000 + graphElement.ID) * 10 + actionIndex;
                        RenameAIAction(singleAction.Action, newName, actionID);
                        actionIndex++;
                    }
                }
            } 
        }
示例#8
0
        /// <summary>
        /// 检查连接线是否有效
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="name">流程图的名称</param>
        /// <param name="connectorContainerList">连接线链表</param>
        /// <param name="showDetail">是否显示细节</param>
        /// <param name="logBox">输出日志窗体</param>
        /// <returns>连接线是否有效</returns>
        private bool CheckLineAvail(DataManager dataManager, string name, List<ConnectorContainer> connectorContainerList, TextBoxX logBox, bool showDetail)
        {
            bool avail = true;
            ConnectorContainer invalidLine = null;

            foreach (ConnectorContainer line in connectorContainerList)
            {
                if (line.InSlotContainer == null || line.OutSlotContainer == null) // 连接线两端必须连接上结点
                {
                    avail = false;
                    invalidLine = line;
                    logBox.AppendText(string.Format("ID为{0}的连接线没有正确连接!\r\n", line.ID));
                    break;
                }
                else if (line.Invalid) // 连接线必须有效
                {
                    avail = false;
                    invalidLine = line;
                    logBox.AppendText(string.Format("ID为{0}的连接线没有设置条件!\r\n", line.ID));
                    break;
                }
            }

            if (!avail) // 流程图无效 
            {
                MessageBox.Show(string.Format("流程图 {0} 中有不完整的连接,请确认所有的连接是否正确!", name),
                    "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (showDetail) // 显示细节
                {
                    List<GraphElement> list = new List<GraphElement>();
                    list.Add(invalidLine);
                    dataManager.CurrentFlowChartManager.CurrentGraphManager.SelectGraphElements(list);
                }
            }

            return avail;
        }
示例#9
0
        /// <summary>
        /// 检测循环圈是否有效
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="name">流程图的名称</param>
        /// <param name="slotContainerList">插槽容器链表</param>
        /// <param name="showDetail">是否显示细节</param>
        /// <param name="logBox">输出日志窗体</param>
        /// <return>循环圈是否有效</return>
        private bool CheckCircleAvail(DataManager dataManager, string name, List<SlotContainer> slotContainerList, TextBoxX logBox, bool showDetail)
        {
            bool avail = true;
            List<SlotContainer> list = new List<SlotContainer>();
            List<List<SlotContainer>> circleLists = new List<List<SlotContainer>>();
            List<SlotContainer> circleNodeList = new List<SlotContainer>();
            List<List<SlotContainer>> markList = new List<List<SlotContainer>>();

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is EventGraphElement)
                {
                    dataManager.FindNextNode(slotContainer, list, circleLists, circleNodeList);
                }
            }

            if (circleLists.Count > 0)
            {
                foreach (List<SlotContainer> circleList in circleLists)
                {
                    avail = false;

                    foreach (SlotContainer node in circleList)
                    {
                        if (node is ConditionGraphElement) // 找到所有的条件结点
                        {
                            // 检查当前圈中的连接线是设置了条件的条件连接线
                            foreach (GraphElement graphElement in dataManager.GetNextGraphElements(node))
                            {
                                ConnectorContainer line = graphElement as ConnectorContainer;
                                if (dataManager.GetData(line) != null && circleList.Contains(line.OutSlotContainer))
                                {
                                    avail = true;
                                    break;
                                }
                            }

                            if (avail)
                            {
                                break;
                            }

                            // 检查是否有通过条件结点连出圈的结点
                            foreach (SlotContainer nextNode in dataManager.GetSpecifyNextSlotContainers(node, circleList))
                            {
                                if (!circleNodeList.Contains(nextNode)) // 有连出圈的结点
                                {
                                    avail = true;
                                    break;
                                }
                            }

                            if (avail)
                            {
                                break;
                            }
                        }
                    }

                    if (!avail)
                    {
                        markList.Add(circleList);
                        string circleString = "";
                        for (int i = 0; i < circleList.Count; i++)
                        {
                            circleString += circleList[i].ID + " -> ";
                        }
                        circleString += circleList[0].ID;
                        logBox.AppendText(string.Format("检测出循环圈{0}!\r\n", circleString));
                    }
                }

                if (markList.Count > 0) // 检测到无效的循环
                {
                    avail = false;
                    MessageBox.Show(string.Format("流程图 {0} 中有可能无效的循环,请确认所有的循环是否设置了有效出口!", name),
                        "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (showDetail) // 显示细节
                    {
                        CheckCircleForm cForm = new CheckCircleForm(dataManager.CurrentFlowChartManager.CurrentGraphManager, markList);
                        cForm.ShowDialog();
                    }
                }
            }

            return avail;
        }
示例#10
0
        /// <summary>
        /// 检查流程图的有效性
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="name">流程图的名称</param>
        /// <param name="slotContainerList">插槽容器链表</param>
        /// <param name="connectorContainerList">连接线链表</param>
        /// <param name="logBox">输入日志窗体</param>
        /// <param name="showDetail">是否显示细节</param>
        /// <returns>流程图是否有效</returns>
        private bool CheckFlowChartAvail(DataManager dataManager, string name, List<SlotContainer> slotContainerList, List<ConnectorContainer> connectorContainerList,
            TextBoxX logBox, bool showDetail)
        {
            bool avail = true;

            // 检查连接线的有效性
            avail = CheckLineAvail(dataManager, name, connectorContainerList, logBox, showDetail);

            // 检查图元的有效性
            if (avail)
            {
                List<GraphElement> list = new List<GraphElement>();
                foreach (SlotContainer slotContainer in slotContainerList)
                {
                    list.Add(slotContainer);
                }

                foreach (ConnectorContainer line in connectorContainerList)
                {
                    list.Add(line);
                }

                avail = CheckGraphElementAvail(dataManager, name, list, logBox, showDetail);
            }

            // 检查循环的有效性
            if (avail)
            {
                avail = CheckCircleAvail(dataManager, name, slotContainerList, logBox, showDetail);
            }

            return avail;
        }
示例#11
0
        /// <summary>
        /// 检查图元是否有效
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="name">流程图的名称</param>
        /// <param name="graphElementList">图元链表</param>
        /// <param name="showDetail">是否显示细节</param>
        /// <param name="logBox">输出日志窗体</param>
        /// <returns>图元是否有效</returns>
        private bool CheckGraphElementAvail(DataManager dataManager, string name, List<GraphElement> graphElementList, TextBoxX logBox, bool showDetail)
        {
            bool avail = true;
            GraphElement invalidGraphElement = null;

            foreach (GraphElement graphElement in graphElementList)
            {
                if (!graphElement.Enable)
                {
                    avail = false;
                    invalidGraphElement = graphElement;
                    logBox.AppendText(string.Format("ID为{0}的图元没有正确连接事件结点!", graphElement.ID));
                    break;
                }
            }

            if (!avail) // 流程图无效 
            {
                MessageBox.Show(string.Format("流程图 {0} 中有不正确连接的图元,请确认所有的图元都已连接事件结点!", name),
                        "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (showDetail) // 显示细节
                {
                    List<GraphElement> list = new List<GraphElement>();
                    list.Add(invalidGraphElement);
                    dataManager.CurrentFlowChartManager.CurrentGraphManager.SelectGraphElements(list);
                }
            }

            return avail;
        }
示例#12
0
        /// <summary>
        /// 检查插槽容器的所有连出的线是否有效
        /// </summary>
        /// <param name="slotContainer">插槽容器</param>
        private void CheckLineValid(DataManager dataManager, SlotContainer slotContainer)
        {
            int invalidLineCount = 0;
            List<ConnectorContainer> list = new List<ConnectorContainer>();

            foreach (SlotGraphElement slot in slotContainer.GetOutSlotList())
            {
                if (slot.Binded)
                {
                    object data = dataManager.GetData(slot.BindingConnector.Line);
                    if (data == null)
                    {
                        list.Add(slot.BindingConnector.Line);
                        invalidLineCount++;
                    }
                    else
                    {
                        slot.BindingConnector.Line.Invalid = false;
                    }
                }
            }

            if (invalidLineCount == 1) // 无效连接线数等于1
            {
                foreach (ConnectorContainer line in list)
                {
                    line.Invalid = false;
                    line.Text = "else";
                    line.ShowText = true;
                    line.AdjustText();
                }
            }
            else if (invalidLineCount > 1) // 无效连接线数大于1
            {
                foreach (ConnectorContainer line in list)
                {
                    line.Invalid = true;
                    line.Text = "×";
                    line.ShowText = true;
                    line.AdjustText();
                }
            }
            else
            {
                foreach (ConnectorContainer line in list)
                {
                    line.Invalid = false;
                    line.ShowText = false;
                }
            }
        }
示例#13
0
        /// <summary>
        /// 刷新未初始化数据元的图元的数据
        /// </summary>
        /// <param name="dataManager">数据管理器实例</param>
        /// <param name="graphElement">图元对象</param>
        /// <param name="data">数据</param>
        private void ReloadData(DataManager dataManager, GraphElement graphElement, object data)
        {
            DataElement dataElement = dataManager.InitDataElement(graphElement);
            Hashtable table = new Hashtable();
            table["globe_args"] = dataManager.GlobeArgs;

            if (dataElement != null)
            {
                dataElement.Data = data;
                dataElement.ReloadData(table);
            }
        }
示例#14
0
        /// <summary>
        /// 设置图元是否可用
        /// </summary>
        /// <param name="dataManager">事件管理器</param>
        /// <param name="list">遍历过的图元链表</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="enable">图元是否可用</param>
        public void ReBindEventNode(DataManager dataManager, List<GraphElement> list, GraphElement graphElement, bool enable)
        {
            if (!list.Contains(graphElement)) // 还没有遍历过当前图元
            {
                list.Add(graphElement);

                if(enable)
                {
                    graphElement.Enable = enable;
                }
                else
                {
                    if(graphElement is SlotContainer) // 插槽容器
                    {
                        if(!dataManager.IsConnectEventNode(graphElement as SlotContainer))
                        {
                            graphElement.Enable = enable;
                        }
                    }
                    else if(graphElement is ConnectorContainer) // 连接线
                    {
                        if (!dataManager.IsConnectEventNode(graphElement as ConnectorContainer))
                        {
                            graphElement.Enable = enable;
                        }
                    }                    
                }

                foreach (GraphElement g in dataManager.GetNextGraphElements(graphElement, false))
                {
                    ReBindEventNode(dataManager, list, g, enable);
                }
            }
        }
示例#15
0
        /// <summary>
        /// 获取下一个流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="metaData">流程图元数据</param>
        /// <param name="graphElementList">遍历过的图元链表</param>
        /// <param name="graphElementTable">流程图索引哈希表</param>
        private void FindNextMetaData(DataManager dataManager, GraphElement graphElement, FlowChartMetaData metaData, List<GraphElement> graphElementList, Hashtable graphElementTable)
        {
            graphElementList.Add(graphElement);
            graphElementTable[graphElement] = metaData;
            List<GraphElement> list = dataManager.GetNextGraphElements(graphElement, false);

            foreach (GraphElement g in list)
            {
                object data = dataManager.GetData(g);                
                
                if(!graphElementList.Contains(g))
                {
                    DataElement dataElement = dataManager.GetDataElement(g);
                    FlowChartMetaData newMetaData = new FlowChartMetaData(g.ID, data, dataElement.DataType);
                    newMetaData.Code = CodeProvider.CodeProviderClass.ConvertToCode(data, dataElement.DataType);
                    newMetaData.DisplayText = g.TooltipText;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                    FindNextMetaData(dataManager, g, newMetaData, graphElementList, graphElementTable);
                }
                else
                {
                    FlowChartMetaData newMetaData = graphElementTable[g] as FlowChartMetaData;
                    newMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(newMetaData);
                }
            }

            if (graphElement is ConditionGraphElement) // 条件结点
            {
                bool avail = true; // 是否需要生成else连接线

                foreach(GraphElement g in list)
                {
                    if(dataManager.GetData(g) == null) // 找到else连接线
                    {
                        avail = false;
                        break;
                    }
                }

                if(avail) // 需要生成else连接线
                {
                    FlowChartMetaData lineMetaData = new FlowChartMetaData(0, null, "Line");
                    lineMetaData.Code = "";
                    lineMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(lineMetaData);
                    FlowChartMetaData endMetaData = new FlowChartMetaData(0, null, "EndNode");
                    endMetaData.AddPreviousMetaData(lineMetaData);
                    lineMetaData.AddNextMetaData(endMetaData);
                }
                else // 连接线需要重排序
                {
                    List<GraphElement> lineList = new List<GraphElement>();
                    GraphElement elseLine = null;
                    FlowChartMetaData newMetaData;

                    foreach(GraphElement g in list)
                    {
                        if(dataManager.GetData(g) == null) // else连接线
                        {
                            elseLine = g;
                        }
                        else // 普通连接线
                        {
                            lineList.Add(g);
                        }
                    }

                    metaData.ClearNextMetaDataList();
                    foreach(GraphElement g in lineList)
                    {
                        newMetaData = graphElementTable[g] as FlowChartMetaData;
                        metaData.AddNextMetaData(newMetaData);
                    }
                    newMetaData = graphElementTable[elseLine] as FlowChartMetaData;
                    metaData.AddNextMetaData(newMetaData);
                }
            }
            else
            {
                if(list.Count == 0) // 当前图元没有后续图元
                {
                    FlowChartMetaData lineMetaData = new FlowChartMetaData(0, null, "Line");
                    lineMetaData.AddPreviousMetaData(metaData);
                    metaData.AddNextMetaData(lineMetaData);
                    FlowChartMetaData endMetaData = new FlowChartMetaData(0, null, "EndNode");
                    endMetaData.AddPreviousMetaData(lineMetaData);
                    lineMetaData.AddNextMetaData(endMetaData);
                }
            }                        
        }
示例#16
0
        /// <summary>
        /// 获取流程图元数据
        /// </summary>
        /// <param name="dataManager">数据管理器</param>
        /// <param name="slotContainerList">流程图插槽容器的链表</param>
        /// <returns>流程图元数据的链表</returns>
        protected override List<FlowChartMetaData> GetMetaData(DataManager dataManager, List<SlotContainer> slotContainerList)
        {
            List<FlowChartMetaData> metaDataList = new List<FlowChartMetaData>();
            List<GraphElement> graphElementList = new List<GraphElement>();
            Hashtable graphElementTable = new Hashtable();

            foreach (SlotContainer slotContainer in slotContainerList)
            {
                if (slotContainer is EventGraphElement)
                {
                    object data = dataManager.GetData(slotContainer);
                    DataElement dataElement = dataManager.GetDataElement(slotContainer);
                    FlowChartMetaData metaData = new FlowChartMetaData(slotContainer.ID, data, "EventNode");
                    metaData.Code = CodeProvider.CodeProviderClass.ConvertToCode(data, dataElement.DataType);
                    metaData.DisplayText = slotContainer.TooltipText;
                    FindNextMetaData(dataManager, slotContainer, metaData, graphElementList, graphElementTable);
                    metaDataList.Add(metaData);
                }
            }

            return metaDataList;
        }