コード例 #1
0
ファイル: InnerChartEditor.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 获取接口结点
        /// </summary>
        /// <param name="interfaceID">结点ID</param>
        /// <returns>接口结点</returns>
        public InterfaceGraphElement GetInterfaceNode(string interfaceID)
        {
            InterfaceGraphElement interfaceGraphElement = null;

            if (interfaceNodeTable != null)
            {
                interfaceGraphElement = interfaceNodeTable[interfaceID] as InterfaceGraphElement;
            }

            return(interfaceGraphElement);
        }
コード例 #2
0
ファイル: InnerChartForm.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 选择确定
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void bOK_Click(object sender, EventArgs e)
        {
            innerChartPath = innerChartBox.Text;

            if (innerChartPath != "")
            {
                string    id        = idTable[innerChartPath].ToString();
                Hashtable infoTable = diagramTable[id] as Hashtable;

                if (infoTable != null)
                {
                    Hashtable logicData = infoTable["logicData"] as Hashtable;
                    graphTable = logicData["graphTable"] as Hashtable;

                    foreach (GraphElement graphElement in graphTable.Keys)
                    {
                        if (graphElement is InterfaceGraphElement)
                        {
                            InterfaceGraphElement interfaceGraphElement = graphElement as InterfaceGraphElement;
                            InterfaceNodeEditor   interfaceEditor       = graphTable[graphElement] as InterfaceNodeEditor;

                            if (interfaceEditor.IsInput)
                            {
                                inSlotInfo[interfaceEditor.ID.ToString()] = interfaceEditor.InterfaceName;
                                inSlotCount++;
                            }
                            else
                            {
                                outSlotInfo[interfaceEditor.ID.ToString()] = interfaceEditor.InterfaceName;
                                outSlotCount++;
                            }

                            interfaceNodeTable[interfaceEditor.ID.ToString()] = graphElement;
                        }
                        else // 记录所有的非接口结点
                        {
                            graphElementList.Add(graphElement);
                        }
                    }
                }

                DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("请先选择子绘图!", "子绘图编辑",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
        /// <summary>
        /// 编辑数据
        /// </summary>
        /// <param name="o">数据元的数据</param>
        /// <return>是否编辑成功</return>
        public override bool EditData(Hashtable table)
        {
            bool editSuccess = false;

            Hashtable infoTable = new Hashtable();

            InterfaceNodeForm interfaceNodeForm = new InterfaceNodeForm(interfaceName, isInput);

            if (interfaceNodeForm.ShowDialog() == DialogResult.OK)
            {
                interfaceName = interfaceNodeForm.InterfaceName;
                isInput       = interfaceNodeForm.IsInput;

                infoTable["interfaceName"] = interfaceName;
                infoTable["isInput"]       = isInput;

                // 初始化表现信息
                InitDisplayInfo();

                this.data = infoTable;

                DocumentManager       documentManager       = DocumentManager.GetDocumentManager();
                InterfaceGraphElement interfaceGraphElement = documentManager.CurrentFlowChartManager.CurrentDataManager.FindGraphElementByID(id) as InterfaceGraphElement;

                if (isInput)
                {
                    interfaceGraphElement.InSlotCount  = 0;
                    interfaceGraphElement.OutSlotCount = 1;
                }
                else
                {
                    interfaceGraphElement.InSlotCount  = 1;
                    interfaceGraphElement.OutSlotCount = 0;
                }

                // 锁定出口插槽
                interfaceGraphElement.LockOutSlot();

                editSuccess = true;
            }

            return(editSuccess);
        }
コード例 #4
0
        /// <summary>
        /// 执行命令
        /// </summary>
        /// <param name="o">当前对象</param>
        /// <returns>是否执行成功</returns>
        public override bool Execute(object o)
        {
            bool success = true;

            object[]     args         = o as object[];
            int          id           = graphManager.AllocateGraphElementID();
            Point        p            = (Point)args[0];
            string       typeString   = args[1] as string;
            GraphSetting graphSetting = GraphSetting.GetGraphSetting();

            // 保存命令执行前的数据
            if (firstCommand) // 只有第一条命令保存执行前的数据
            {
                SaveBeforeExecute(flowChartManager.GetArguments());
            }

            switch (typeString)
            {
            case "ConditionNode":     // 条件结点
            {
                ConditionGraphElement conditionGraphElement = new ConditionGraphElement(p, graphSetting.ConditionNodeElementSize);
                InitSlotContainer(conditionGraphElement, id, "条件结点");

                break;
            }

            case "ActionNode":     // 动作结点
            {
                ActionGraphElement actionGraphElement = new ActionGraphElement(p, graphSetting.ActionNodeElementSize);
                InitSlotContainer(actionGraphElement, id, "动作结点");

                break;
            }

            case "EventNode":     // 事件结点
            {
                EventGraphElement eventGraphElement = new EventGraphElement(p, graphSetting.EventNodeElementSize);
                InitSlotContainer(eventGraphElement, id, "事件结点");

                break;
            }

            case "AIStateNode":     // ai状态结点
            {
                AIStateGraphElement aiStateGraphElement = new AIStateGraphElement(p, graphSetting.AIStateNodeElementSize);
                InitSlotContainer(aiStateGraphElement, id, "AI状态结点");

                break;
            }

            case "AIActionNode":     // ai动作结点
            {
                AIActionGraphElement aiActionGraphElement = new AIActionGraphElement(p, graphSetting.AIActionNodeElementSize);
                InitSlotContainer(aiActionGraphElement, id, "AI动作结点");

                break;
            }

            case "AIActionsNode":     // ai动作组结点
            {
                AIActionsGraphElement aiActionsGraphElement = new AIActionsGraphElement(p, graphSetting.AIActionsNodeElementSize);
                InitSlotContainer(aiActionsGraphElement, id, "AI动作组结点");

                break;
            }

            case "InnerChart":     // 子绘图结点
            {
                InnerChart innerChart = new InnerChart(p, graphSetting.InnerChartElementSize);
                InitSlotContainer(innerChart, id, "子绘图结点");

                break;
            }

            case "InterfaceNode":     // 接口结点
            {
                InterfaceGraphElement interfaceGraphElement = new InterfaceGraphElement(p, graphSetting.InterfaceNodeElementSize);
                InitSlotContainer(interfaceGraphElement, id, "接口结点");

                break;
            }
            }

            if (success) // 保存命令执行后的数据
            {
                flowChartManager.ContentChanged = true;
                SaveAfterExecute(flowChartManager.GetArguments());
            }

            return(success);
        }
コード例 #5
0
        /// <summary>
        /// 获取连出的图元链表
        /// </summary>
        /// <param name="graphElement">当前图元</param>
        /// <param name="hasInnerChart">是否处理子绘图</param>
        /// <returns>连出的图元链表</returns>
        public List <GraphElement> GetNextGraphElements(GraphElement graphElement, bool dealInnerChart)
        {
            List <GraphElement> list = new List <GraphElement>();

            if (graphElement is SlotContainer) // 当前图元是插槽容器
            {
                SlotContainer slotContainer = graphElement as SlotContainer;

                foreach (SlotGraphElement slot in slotContainer.GetOutSlotList())
                {
                    if (slot.Binded)
                    {
                        list.Add(slot.BindingConnector.Line);
                    }
                }
            }
            else if (graphElement is ConnectorContainer) // 当前图元是连接线控制点容器
            {
                ConnectorContainer line = graphElement as ConnectorContainer;

                if (line.OutSlotContainer != null)
                {
                    if (dealInnerChart)
                    {
                        SlotContainer slotContainer = line.OutSlotContainer;

                        if (slotContainer is InnerChart)
                        {
                            SlotGraphElement slot             = slotContainer.GetBindedInSlot(line);
                            InnerChartEditor innerChartEditor = GetDataElement(slotContainer) as InnerChartEditor;

                            if (slot != null)
                            {
                                InterfaceGraphElement interfaceNode = innerChartEditor.GetInterfaceNode(slot.Tag.ToString());

                                if (interfaceNode != null)
                                {
                                    GraphElement connectedGraphElement = interfaceNode.GetConnectedOutGraphElement();

                                    if (connectedGraphElement != null)
                                    {
                                        list.Add(connectedGraphElement);
                                    }
                                }
                            }
                        }
                        else if (slotContainer is InterfaceGraphElement)
                        {
                            InnerChart innerChart = FindGraphElementByID(int.Parse(slotContainer.Tag as string)) as InnerChart;

                            foreach (SlotGraphElement slot in innerChart.GetOutSlotList())
                            {
                                if (slot.Binded)
                                {
                                    ConnectorContainer connectedLine = slot.BindingConnector.Line;
                                    string             lineData      = GetData(connectedLine) as string;

                                    if (!string.IsNullOrEmpty(lineData))
                                    {
                                        string[] dataArray = lineData.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                                        if (dataArray[0] == slotContainer.ID.ToString())
                                        {
                                            list.AddRange(GetNextGraphElements(slot.BindingConnector.Line, true));
                                            break;
                                        }
                                    }

                                    /*
                                     * if (!string.IsNullOrEmpty(connectedLine.Text))
                                     * {
                                     *  string[] dataArray = connectedLine.Text.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                                     *
                                     *  if (dataArray[0] == slotContainer.ID.ToString())
                                     *  {
                                     *      list.AddRange(GetNextGraphElements(slot.BindingConnector.Line, true));
                                     *      break;
                                     *  }
                                     * }
                                     */
                                }
                            }

                            /*
                             * foreach (SlotGraphElement slot in innerChart.GetOutSlotList())
                             * {
                             *  if (slot.Tag.ToString() == slotContainer.ID.ToString())
                             *  {
                             *      slotGraphElement = slot;
                             *      break;
                             *  }
                             * }
                             *
                             * if (slotGraphElement != null)
                             * {
                             *  if (slotGraphElement.Binded)
                             *  {
                             *      list.AddRange(GetNextGraphElements(slotGraphElement.BindingConnector.Line, true));
                             *  }
                             * }
                             */
                        }
                        else
                        {
                            list.Add(slotContainer);
                        }
                    }
                    else
                    {
                        list.Add(line.OutSlotContainer);
                    }
                }
            }

            return(list);
        }
コード例 #6
0
ファイル: InnerChartEditor.cs プロジェクト: weimingtom/pap2
        /// <summary>
        /// 重读数据
        /// </summary>
        /// <param name="table">当前数据</param>
        /// <return>是否重读成功</return>
        public override bool ReloadData(Hashtable table)
        {
            Hashtable dataInfo = data as Hashtable;

            if (dataInfo != null)
            {
                innerChartPath = dataInfo["innerChartPath"] as string;

                // 初始化绘图数据表
                InitGraphTable();

                if (graphTable != null)
                {
                    int       inSlotCount  = 0;
                    int       outSlotCount = 0;
                    Hashtable inSlotInfo   = new Hashtable();
                    Hashtable outSlotInfo  = new Hashtable();
                    graphElementList   = new List <GraphElement>();
                    interfaceNodeTable = new Hashtable();

                    List <int> inIDList  = new List <int>();
                    List <int> outIDList = new List <int>();

                    foreach (GraphElement graphElement in graphTable.Keys)
                    {
                        if (graphElement is InterfaceGraphElement)
                        {
                            InterfaceGraphElement interfaceGraphElement = graphElement as InterfaceGraphElement;
                            InterfaceNodeEditor   interfaceEditor       = graphTable[graphElement] as InterfaceNodeEditor;

                            if (interfaceEditor.IsInput)
                            {
                                inSlotInfo[interfaceEditor.ID.ToString()] = interfaceEditor.InterfaceName;
                                inIDList.Add(interfaceGraphElement.ID);
                                inSlotCount++;
                            }
                            else
                            {
                                outSlotInfo[interfaceEditor.ID.ToString()] = interfaceEditor.InterfaceName;
                                outIDList.Add(interfaceGraphElement.ID);
                                outSlotCount++;
                            }

                            interfaceGraphElement.Tag = id.ToString();
                            interfaceNodeTable[interfaceEditor.ID.ToString()] = graphElement;
                        }
                        else
                        {
                            graphElementList.Add(graphElement);
                        }
                    }

                    InnerChart innerChart = DocumentManager.GetDocumentManager().CurrentFlowChartManager.CurrentDataManager.FindGraphElementByID(id) as InnerChart;

                    // 更新数据
                    UpdateData(inSlotInfo, outSlotInfo);

                    // 更新插槽数量
                    UpdateSlotCount(innerChart, inSlotCount, outSlotCount, true);

                    // 更新插槽信息
                    RefreshSlotInfo(innerChart, inIDList, outIDList, inSlotInfo, outSlotInfo);
                }
            }

            return(true);
        }