/// <summary> /// 连接图元 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicConnect(FlowChartManager flowChartManager, object logicData) { bool executeSuccess = true; DataManager dataManager = flowChartManager.CurrentDataManager; object[] data = logicData as object[]; SlotGraphElement slot = data[0] as SlotGraphElement; ConnectorGraphElement connector = data[1] as ConnectorGraphElement; bool enableConnect = true; List <GraphElement> list = new List <GraphElement>(); // 记录遍历过的图元的链表 if (connector.IsHeadPoint) // 连入插槽容器 { SlotContainer inSlotContainer = connector.Line.InSlotContainer; if (inSlotContainer != null) { List <DataElement> eventList = dataManager.GetEventList(connector.Line.OutSlotContainer); // 检查事件结点互斥 enableConnect = LogicCheck.CheckEventExclusion(eventList); if (enableConnect) // 允许连接事件结点 { bool enable = dataManager.IsConnectEventNode(inSlotContainer); ReBindEventNode(dataManager, list, slot.SlotContainer, enable); // 重新绑定当前图元与其连出图元的事件结点 } else { slot.UnBind(); executeSuccess = false; } } } else // 连出插槽容器 { SlotContainer outSlotContainer = connector.Line.OutSlotContainer; if (outSlotContainer != null) { List <DataElement> eventList = dataManager.GetEventList(outSlotContainer); if (enableConnect) // 允许连接事件结点 { bool enable = dataManager.IsConnectEventNode(slot.SlotContainer); ReBindEventNode(dataManager, list, connector.Line, enable); // 重新绑定当前图元与其连出图元的事件结点 } else { slot.UnBind(); executeSuccess = false; } } } return(executeSuccess); }
/// <summary> /// 执行命令 /// </summary> /// <param name="o">当前对象</param> /// <returns>是否执行成功</returns> public override bool Execute(object o) { bool success = true; Helper helper = Helper.GetHelper(); SlotGraphElement slot = o as SlotGraphElement; // 保存命令执行前的数据 if (firstCommand) // 只有第一条命令保存执行前的数据 { SaveBeforeExecute(flowChartManager.GetArguments()); } ConnectorGraphElement connector = slot.BindingConnector; ConnectorContainer line = connector.Line; SlotContainer slotContainer = slot.SlotContainer; description = "解除连接图元 " + slotContainer.Name; slot.UnBind(); if (slot.CanDelete && (slot.IsInSlot || slot.SlotContainer.OutSlotCount > 1)) // 插槽可以删除 { slotContainer.RemoveSlot(slot); } // 执行逻辑操作 LogicBaseManager logicManager = helper.GetLogicManager(flowChartManager.CurrentChartMode); object[] logicData = new object[] { slot, connector }; logicManager.DoLogicOperation(flowChartManager, LogicType.Disconnect, logicData); if (success) // 保存命令执行后的数据 { flowChartManager.ContentChanged = true; SaveAfterExecute(flowChartManager.GetArguments()); } return(success); }