Пример #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="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;
        }
Пример #4
0
        /// <summary>
        /// 获取设置状态的绘图元数据
        /// </summary>
        /// <param name="previousMetaData">前一个元数据</param>
        /// <param name="stateMetaData">状态元数据</param>
        private void InitSetStateMetaData(FlowChartMetaData previousMetaData, FlowChartMetaData stateMetaData)
        {
            FlowChartMetaData setStateMetaData = new FlowChartMetaData(maxID, null, "AISetStateNode");
            setStateMetaData.DisplayText = "设置状态";
            setStateMetaData.AddPreviousMetaData(previousMetaData);
            previousMetaData.AddNextMetaData(setStateMetaData);
            maxID++;

            FlowChartMetaData lineMetaData = new FlowChartMetaData(maxID, "1", "AILine");
            lineMetaData.DisplayText = "1";
            setStateMetaData.AddNextMetaData(lineMetaData);
            lineMetaData.AddPreviousMetaData(setStateMetaData);
            maxID++;

            lineMetaData.AddNextMetaData(stateMetaData);
            stateMetaData.AddPreviousMetaData(lineMetaData);            
        }
Пример #5
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);
                }
            }                        
        }