Ejemplo n.º 1
0
        /// <summary>
        /// 检查是否更新事件结点
        /// </summary>
        /// <param name="graphManager">图元管理器</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="eventNode">事件结点</param>
        /// <returns>是否需要更新</returns>
        private bool CheckCanBindEventNode(GraphManager graphManager, GraphElement graphElement, EventGraphElement eventNode)
        {
            bool avail = true;            
            DataManager dataManager = graphManager.CurrentFlowChartManager.CurrentDataManager;
            IComparable com1;
            IComparable com2;

            if (graphElement is SlotContainer) // 插槽容器
            {
                SlotContainer slotContainer = graphElement as SlotContainer;
                if (slotContainer.EventNode != null && slotContainer.EventNode != eventNode)
                {
                    com1 = dataManager.GetData(slotContainer.EventNode) as IComparable;
                    com2 = dataManager.GetData(eventNode) as IComparable;
                    avail = (com1.CompareTo(com2) == 0);
                }
            }
            else if (graphElement is ConnectorContainer) // 连接线
            {
                ConnectorContainer line = graphElement as ConnectorContainer;
                if (line.EventNode != null && line.EventNode != eventNode)
                {
                    com1 = dataManager.GetData(line.EventNode) as IComparable;
                    com2 = dataManager.GetData(eventNode) as IComparable;
                    avail = (com1.CompareTo(com2) == 0);
                }
            }

            return avail;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 复制图元
        /// </summary>
        /// <returns>复制的图元</returns>
        public override SlotContainer Clone()
        {
            EventGraphElement eventGraphElement = new EventGraphElement(location, elementSize);

            CopyData(this, eventGraphElement);

            return(eventGraphElement);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建缩略的图元
        /// </summary>
        /// <param name="graphType">图元类型</param>
        /// <param name="centerLocation">图元中心位置</param>
        /// <param name="elementSize">图元大小</param>
        /// <param name="moveSize">图元的移动大小</param>
        /// <returns>图元对象</returns>
        private GraphElement CreateAbbreviateGraphElement(GraphType graphType, Point centerLocation)
        {
            GraphElement abbreviateGraphElement = null;

            switch (graphType)
            {
                case GraphType.ConditionNode: // 条件结点
                    {
                        abbreviateGraphElement = new ConditionGraphElement(centerLocation - graphSetting.ConditionNodeMoveOffset, graphSetting.ConditionNodeElementSize);
                        moveOffset = graphSetting.ConditionNodeMoveOffset;

                        break;
                    }
                case GraphType.ActionNode: // 动作结点
                    {
                        abbreviateGraphElement = new ActionGraphElement(centerLocation - graphSetting.ActionNodeMoveOffset, graphSetting.ActionNodeElementSize);
                        moveOffset = graphSetting.ActionNodeMoveOffset;

                        break;
                    }
                case GraphType.EventNode: // 事件结点
                    {
                        abbreviateGraphElement = new EventGraphElement(centerLocation - graphSetting.EventNodeMoveOffset, graphSetting.EventNodeElementSize);
                        moveOffset = graphSetting.EventNodeMoveOffset;

                        break;
                    }
                case GraphType.AIStateNode: // AI状态结点
                    {
                        abbreviateGraphElement = new AIStateGraphElement(centerLocation - graphSetting.AIStateNodeMoveOffset, graphSetting.AIStateNodeElementSize);
                        moveOffset = graphSetting.AIStateNodeMoveOffset;

                        break;
                    }
                case GraphType.AIActionNode: // AI动作结点
                    {
                        abbreviateGraphElement = new AIActionGraphElement(centerLocation - graphSetting.AIActionNodeMoveOffset, graphSetting.AIActionsNodeElementSize);
                        moveOffset = graphSetting.AIActionNodeMoveOffset;

                        break;
                    }
                case GraphType.AIActionsNode: // AI动作组结点
                    {
                        abbreviateGraphElement = new AIActionsGraphElement(centerLocation - graphSetting.AIActionsNodeMoveOffset, graphSetting.AIActionsNodeElementSize);
                        moveOffset = graphSetting.AIActionsNodeMoveOffset;

                        break;
                    }
                case GraphType.InnerChart: // 子绘图结点
                    {
                        abbreviateGraphElement = new InnerChart(centerLocation - graphSetting.InnerChartMoveOffset, graphSetting.InnerChartElementSize);
                        moveOffset = graphSetting.InnerChartMoveOffset;

                        break;
                    }
                case GraphType.InterfaceNode: // 接口结点
                    {
                        abbreviateGraphElement = new InterfaceGraphElement(centerLocation - graphSetting.InterfaceNodeMoveOffset, graphSetting.InterfaceNodeElementSize);
                        moveOffset = graphSetting.InterfaceNodeMoveOffset;

                        break;
                    }
            }

            if (abbreviateGraphElement != null)
            {
                abbreviateGraphElement.Refresh();
            }

            return abbreviateGraphElement;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 复制图元
        /// </summary>
        /// <returns>复制的图元</returns>
        public override SlotContainer Clone()
        {
            EventGraphElement eventGraphElement = new EventGraphElement(location, elementSize);
            CopyData(this, eventGraphElement);            

            return eventGraphElement;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 设置图元是否可用
        /// </summary>
        /// <param name="graphManager">图元管理器</param>
        /// <param name="list">遍历过的图元链表</param>
        /// <param name="graphElement">当前图元</param>
        /// <param name="eventNode">事件结点</param>
        /// <param name="enable">图元是否可用</param>
        public void ReBindEventNode(GraphManager graphManager, List<GraphElement> list, GraphElement graphElement, EventGraphElement eventNode, bool enable)
        {
            if (!list.Contains(graphElement)) // 还没有遍历过当前图元
            {
                DataManager dataManager = graphManager.CurrentFlowChartManager.CurrentDataManager;

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

                    if (!enable && slotContainer.EventNode != null && dataManager.IsConnect(slotContainer.EventNode, slotContainer)) // 不需要更新当前图元的事件结点
                    {

                    }
                    else
                    {
                        list.Add(slotContainer);
                        slotContainer.Enable = enable;
                        slotContainer.EventNode = eventNode;

                        foreach (GraphElement g in dataManager.GetNextGraphElements(graphElement))
                        {
                            ReBindEventNode(graphManager, list, g, eventNode, enable);
                        }
                    }
                }
                else if (graphElement is ConnectorContainer) // 该图元是连接线控制点容器
                {
                    ConnectorContainer line = graphElement as ConnectorContainer;

                    if (!enable && line.EventNode != null && dataManager.IsConnect(line.EventNode, line)) // 不需要更新当前图元的事件结点
                    {

                    }
                    else
                    {
                        list.Add(line);
                        line.Enable = enable;
                        line.EventNode = eventNode;

                        foreach (GraphElement g in dataManager.GetNextGraphElements(graphElement))
                        {
                            ReBindEventNode(graphManager, list, g, eventNode, enable);
                        }
                    }
                }
            }
        }