/// <summary> /// 检查连接线是否有效 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <returns>连接线是否有效</returns> private bool CheckLineAvail(FlowChartManager flowChartManager) { bool avail = true; ConnectorContainer invalidLine = null; DocumentManager documentManager = DocumentManager.GetDocumentManager(); foreach (ConnectorContainer line in flowChartManager.CurrentGraphManager.ConnectorContainerList) { if (line.InSlotContainer == null || line.OutSlotContainer == null) // 连接线两端必须连接上结点 { avail = false; invalidLine = line; documentManager.PrintText(string.Format("ID为{0}的连接线没有正确连接!", line.ID)); break; } } if (!avail) // 流程图无效 { MessageBox.Show("绘图中有不完整的连接,请确认所有的连接是否正确!", "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information); // 显示细节 List <GraphElement> list = new List <GraphElement>(); list.Add(invalidLine); flowChartManager.CurrentGraphManager.SelectGraphElements(list); } return(avail); }
/// <summary> /// 解除连接图元 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicDisconnect(FlowChartManager flowChartManager, object logicData) { DataManager dataManager = flowChartManager.CurrentDataManager; object[] args = logicData as object[]; SlotGraphElement slot = args[0] as SlotGraphElement; ConnectorGraphElement connector = args[1] as ConnectorGraphElement; ConnectorContainer line = connector.Line; SlotContainer slotContainer = slot.SlotContainer; List <GraphElement> list = new List <GraphElement>(); // 记录遍历的图元的链表 if (connector.IsHeadPoint) // 移出连接线的头结点 { ReBindEventNode(dataManager, list, slotContainer, false); // 重新绑定当前图元与其连出图元的事件结点 } else // 移出连接线的尾结点 { SlotContainer outSlotContainer = connector.Line.OutSlotContainer; if (outSlotContainer != null) { ReBindEventNode(dataManager, list, connector.Line, false); // 重新绑定当前图元与其连出图元的事件结点 } } return(true); }
/// <summary> /// 打开脚本 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>操作是否成功</returns> protected override bool LogicViewCode(FlowChartManager flowChartManager, object logicData) { Helper helper = Helper.GetHelper(); string relevatePath = logicData as string; string path = Path.Combine(helper.OutputDir, "scripts\\Map"); path = Path.Combine(path, string.Format("{0}.lua", relevatePath)); if (File.Exists(path)) // 文件存在 { try { System.Diagnostics.Process.Start(path); } catch (IOException ex) { MessageBox.Show("在打开代码文件时产生IO异常:" + ex.Message, "查看脚本", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(string.Format("文件{0}不存在!", path), "查看脚本", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); }
public FamilySavingsMainForm() { InitializeComponent(); avatarSelector = new AvatarSelector(this); avatarSelector.Position = new Point(this.Left + picAvatar.Left + picAvatar.Width, this.Top + picAvatar.Top + picAvatar.Height); avatarSelector.AvatarPathChanged += AvatarSelector_AvatarPathChanged; this.Move += FamilySavings_Move; this.PropertyChanged += PropertyChangedHandler; //next participant NextParticipant = dataAccess.GetNextParticipant(); dataAccess.ParticipantDataUpdated += DataAccess_ParticipantDataUpdatedHandler; //set default image in the avatar selector DirectoryInfo dir = new DirectoryInfo(AppConstants.AvatarPath); FileInfo defaultFile = dir.GetFiles()[0]; picAvatar.Image = Image.FromFile(defaultFile.FullName); avatarSelector.SelectedImagePath = defaultFile.FullName; picAvatar.SizeMode = PictureBoxSizeMode.StretchImage; //flow chart flowChartManager = new FlowChartManager(panelFlowChart); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void read(org.w3c.dom.Element chartElem, org.maltparser.core.flow.FlowChartManager flowCharts) throws org.maltparser.core.exception.MaltChainedException public virtual void read(Element chartElem, FlowChartManager flowCharts) { Name = chartElem.getAttribute("name"); NodeList flowChartProcessList = chartElem.getElementsByTagName("preprocess"); if (flowChartProcessList.Length == 1) { readChartItems((Element)flowChartProcessList.item(0), flowCharts, preProcessChartItemSpecifications); } else if (flowChartProcessList.Length > 1) { throw new FlowException("The flow chart '" + Name + "' has more than one preprocess elements. "); } flowChartProcessList = chartElem.getElementsByTagName("process"); if (flowChartProcessList.Length == 1) { readChartItems((Element)flowChartProcessList.item(0), flowCharts, processChartItemSpecifications); } else if (flowChartProcessList.Length > 1) { throw new FlowException("The flow chart '" + Name + "' has more than one process elements. "); } flowChartProcessList = chartElem.getElementsByTagName("postprocess"); if (flowChartProcessList.Length == 1) { readChartItems((Element)flowChartProcessList.item(0), flowCharts, postProcessChartItemSpecifications); } else if (flowChartProcessList.Length > 1) { throw new FlowException("The flow chart '" + Name + "' has more than one postprocess elements. "); } }
/// <summary> /// 管理变量 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicManageArguments(FlowChartManager flowChartManager, object logicData) { DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager(); VarManager.Program varManager = new VarManager.Program(); varManager.Show(dataBaseManager.GetJx3webConnection()); return(true); }
/// <summary> /// 撤销命令 /// </summary> public override void Unexecute() { object o = dataBeforeExecute.LoadData(); GraphManager graphManager = data as GraphManager; FlowChartManager flowChartManager = graphManager.CurrentFlowChartManager; Hashtable args = o as Hashtable; flowChartManager.SetArguments(args); }
/// <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); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Engine() throws org.maltparser.core.exception.MaltChainedException public Engine() { startTime = DateTimeHelper.CurrentUnixTimeMillis(); flowChartManager = new FlowChartManager(); flowChartManager.FlowChartSystem.load(GetType().getResource("/appdata/flow/flowchartsystem.xml")); flowChartManager.FlowChartSystem.load(PluginLoader.instance()); flowChartManager.load(GetType().getResource("/appdata/flow/flowcharts.xml")); flowChartManager.load(PluginLoader.instance()); flowChartInstances = new SortedDictionary <int, FlowChartInstance>(); }
protected FlowChartManager flowChartManager; // 流程图管理器实例 /// <summary> /// 构造函数 /// </summary> /// <param name="data">当前对象</param> /// <param name="description">命令的描述</param> public FlowChartBaseCommand(object data, string description): base(data, description) { graphManager = data as GraphManager; flowChartManager = graphManager.CurrentFlowChartManager; dataManager = flowChartManager.CurrentDataManager; documentManager = DocumentManager.GetDocumentManager(); dataBeforeExecute = new SerialMemento(); dataAfterExecute = new SerialMemento(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void readChartItems(org.w3c.dom.Element chartElem, org.maltparser.core.flow.FlowChartManager flowCharts, java.util.LinkedHashSet<ChartItemSpecification> chartItemSpecifications) throws org.maltparser.core.exception.MaltChainedException private void readChartItems(Element chartElem, FlowChartManager flowCharts, LinkedHashSet <ChartItemSpecification> chartItemSpecifications) { NodeList flowChartItemList = chartElem.getElementsByTagName("chartitem"); for (int i = 0; i < flowChartItemList.Length; i++) { ChartItemSpecification chartItemSpecification = new ChartItemSpecification(); chartItemSpecification.read((Element)flowChartItemList.item(i), flowCharts); chartItemSpecifications.add(chartItemSpecification); } }
protected FlowChartManager flowChartManager; // 流程图管理器实例 /// <summary> /// 构造函数 /// </summary> /// <param name="data">当前对象</param> /// <param name="description">命令的描述</param> public FlowChartBaseCommand(object data, string description) : base(data, description) { graphManager = data as GraphManager; flowChartManager = graphManager.CurrentFlowChartManager; dataManager = flowChartManager.CurrentDataManager; documentManager = DocumentManager.GetDocumentManager(); dataBeforeExecute = new SerialMemento(); dataAfterExecute = new SerialMemento(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void read(org.w3c.dom.Element chartItemSpec, org.maltparser.core.flow.FlowChartManager flowCharts) throws org.maltparser.core.exception.MaltChainedException public virtual void read(Element chartItemSpec, FlowChartManager flowCharts) { chartItemName = chartItemSpec.getAttribute("item"); chartItemClass = flowCharts.FlowChartSystem.getChartElement(chartItemName).ChartItemClass; NamedNodeMap attrs = chartItemSpec.Attributes; for (int i = 0; i < attrs.Length; i++) { Attr attribute = (Attr)attrs.item(i); addChartItemAttribute(attribute.Name, attribute.Value); } }
/// <summary> /// 检查流程图的有效性 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <returns>流程图是否有效</returns> private bool CheckFlowChartAvail(FlowChartManager flowChartManager) { bool avail = true; // 检查连接线的有效性 avail = CheckLineAvail(flowChartManager); // 检查图元的有效性 if (avail) { avail = CheckGraphElementAvail(flowChartManager); } return(avail); }
/// <summary> /// 检查图元是否有效 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <returns>图元是否有效</returns> private bool CheckGraphElementAvail(FlowChartManager flowChartManager) { bool avail = true; bool unfinished = false; GraphElement invalidGraphElement = null; GraphElement unfinishedGraphElement = null; DocumentManager documentManager = DocumentManager.GetDocumentManager(); DataManager dataManager = flowChartManager.CurrentDataManager; foreach (GraphElement graphElement in flowChartManager.CurrentGraphManager.CurrentCanvas.GraphElementList) { if (!graphElement.Enable) { avail = false; invalidGraphElement = graphElement; documentManager.PrintText(string.Format("ID为{0}的图元没有正确连接事件结点!", graphElement.ID)); break; } } if (!avail) // 流程图无效 { MessageBox.Show("绘图中有不正确连接的图元,请确认所有的图元都已连接事件结点!", "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information); // 显示细节 List <GraphElement> list = new List <GraphElement>(); list.Add(invalidGraphElement); dataManager.CurrentFlowChartManager.CurrentGraphManager.SelectGraphElements(list); } if (unfinished && avail) // 有未编辑完成的图元 { avail = false; MessageBox.Show("绘图中有没有完成编辑的图元,请确认所有的图元都已设置参数!", "流程图有效性检查", MessageBoxButtons.OK, MessageBoxIcon.Information); // 显示细节 List <GraphElement> list = new List <GraphElement>(); list.Add(unfinishedGraphElement); dataManager.CurrentFlowChartManager.CurrentGraphManager.SelectGraphElements(list); } return(avail); }
/// <summary> /// 创建连接线 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicCreateLine(FlowChartManager flowChartManager, object logicData) { GraphManager graphManager = flowChartManager.CurrentGraphManager; DataManager dataManager = flowChartManager.CurrentDataManager; object[] args = logicData as object[]; int id = graphManager.AllocateGraphElementID(); SlotGraphElement slot = args[0] as SlotGraphElement; Point p = (Point)args[1]; // 创建连接线 base.LogicCreateLine(flowChartManager, logicData); // 绑定连接线的事件 List <GraphElement> list = new List <GraphElement>(); bool enable = dataManager.IsConnectEventNode(slot.SlotContainer); ReBindEventNode(dataManager, list, slot.SlotContainer, enable); return(true); }
/// <summary> /// 查看文件夹 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicViewFolder(FlowChartManager flowChartManager, object logicData) { DocumentManager documentManager = DocumentManager.GetDocumentManager(); Helper helper = Helper.GetHelper(); TreeNode currentNode = logicData as TreeNode; string path = Path.Combine(helper.OutputDir, "scripts\\Map"); path = Path.Combine(path, documentManager.GetNodePath(currentNode)); if (Directory.Exists(path)) // 当前目录存在 { System.Diagnostics.Process.Start("explorer.exe", path); } else // 当前目录不存在 { MessageBox.Show("该目录不存在!", "打开文件夹", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); }
/// <summary> /// 删除图元之后的操作 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicAfterDelete(FlowChartManager flowChartManager, object logicData) { DataManager dataManager = flowChartManager.CurrentDataManager; List <GraphElement> graphElementList = logicData as List <GraphElement>; foreach (GraphElement graphElement in graphElementList) { List <GraphElement> list = new List <GraphElement>(); // 记录遍历过图元的链表 ReBindEventNode(dataManager, list, graphElement, false); // 重新设定事件结点及图元是否可用 ConnectorContainer line = graphElement as ConnectorContainer; if (line != null) { // 连接线恢复可见状态 line.Moving = false; line.Visible = true; } } return(true); }
/// <summary> /// 在指定点创建结点 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicCreateNodeAtPoint(FlowChartManager flowChartManager, object logicData) { object[] args = logicData as object[]; int graphType = (int)args[0]; Point location = (Point)args[1]; switch (graphType) { case 1: // 创建事件结点 { CreateNode(GraphType.EventNode, location, false); break; } case 2: // 创建条件结点 { if (flowChartManager.CurrentGraphManager.SelectedGraphElement is SlotContainer) // 必须在有可连接的结点的基础上创建 { CreateNode(GraphType.ConditionNode, location, true); } break; } case 3: // 创建动作结点 { if (flowChartManager.CurrentGraphManager.SelectedGraphElement is SlotContainer) // 必须在有可能连接的结点的基础上创建 { CreateNode(GraphType.ActionNode, location, true); } break; } } return(true); }
/// <summary> /// 编辑图元 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicEdit(FlowChartManager flowChartManager, object logicData) { bool executeResult = true; GraphManager graphManager = flowChartManager.CurrentGraphManager; DataManager dataManager = flowChartManager.CurrentDataManager; DocumentManager documentManager = DocumentManager.GetDocumentManager(); GraphElement graphElement = logicData as GraphElement; DataElement dataElement = dataManager.GetDataElement(graphElement); if (CheckGraphElementEditable(graphElement)) // 检查图元是否能够编辑 { object data = dataManager.GetData(graphElement); Hashtable information = new Hashtable(); information["data"] = data; information["prev_data"] = dataManager.GetPreviousData(graphElement); information["next_data"] = dataManager.GetNextData(graphElement); information["neighbor_data"] = dataManager.GetNeighborData(graphElement); information["globe_args"] = dataManager.GlobeArgs; information["flowchart_name"] = flowChartManager.Name; information["map_name"] = flowChartManager.MapName; information["client_dir"] = Helper.GetHelper().OutputDir; if (graphElement is SlotContainer) { SlotContainer slotContainer = graphElement as SlotContainer; // 刷新当前事件结点 information["event_data"] = dataManager.GetEventData(slotContainer); } dataElement.PrintInformation = new DataElement.PrintInfo(documentManager.PrintText); try { executeResult = dataElement.EditData(information); } catch (Exception ex) { MessageBox.Show("当前图元由于以下原因无法编辑:\n\n" + ex.Message, "图元编辑", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (executeResult) // 保存图元数据 { Hashtable previousDataTable = information["prev_data"] as Hashtable; Hashtable nextDataTable = information["next_data"] as Hashtable; GraphElement currentGraphElement; DataElement editDataElement; // 检查是否需要更新图元和数据元的数据 foreach (string id in previousDataTable.Keys) { editDataElement = previousDataTable[id] as DataElement; if (editDataElement != null && editDataElement.Data == null) { currentGraphElement = dataManager.FindGraphElementByID(int.Parse(id)); currentGraphElement.Text = editDataElement.Text; currentGraphElement.TooltipText = editDataElement.TooltipText; currentGraphElement.ShowText = false; } } foreach (string id in nextDataTable.Keys) { editDataElement = nextDataTable[id] as DataElement; if (editDataElement != null && editDataElement.Data == null) { currentGraphElement = dataManager.FindGraphElementByID(int.Parse(id)); currentGraphElement.Text = editDataElement.Text; currentGraphElement.TooltipText = editDataElement.TooltipText; currentGraphElement.ShowText = false; } } graphElement.TooltipText = dataElement.TooltipText; graphElement.Text = dataElement.Text; if (dataElement.Text == "") { graphElement.ShowText = false; } else { graphElement.ShowText = true; } // 调整文本 if (graphElement is SlotContainer) { SlotContainer slotContainer = graphElement as SlotContainer; slotContainer.AdjustText(); // 根据文本内容调整插槽容器的大小 slotContainer.AdjustElementSize(); } else if (graphElement is ConnectorContainer) { ConnectorContainer line = graphElement as ConnectorContainer; line.AdjustText(); } } } return(executeResult); }
/// <summary> /// 删除图元 /// </summary> /// <param name="graphElement">要删除的图元</param> /// <return>是否删除成功</return> protected bool DeleteGraphElement(GraphElement graphElement) { Helper helper = Helper.GetHelper(); GraphManager graphManager = data as GraphManager; FlowChartManager flowChartManager = graphManager.CurrentFlowChartManager; DataManager dataManager = flowChartManager.CurrentDataManager; bool deleteSuccess = false; // 是否删除成功 // 执行逻辑操作 LogicBaseManager logicManager = helper.GetLogicManager(flowChartManager.CurrentChartMode); logicManager.DoLogicOperation(flowChartManager, LogicType.BeforeDelete, graphElement); if (graphElement is SlotContainer) // 要删除的图元是插槽容器 { SlotContainer slotContainer = graphElement as SlotContainer; List <GraphElement> graphElementList = new List <GraphElement>(); // 解除绑定连接线控制点 foreach (ConnectorContainer line in slotContainer.GetConnectedLine()) { graphElementList.Add(line); } slotContainer.UnBind(); // 执行逻辑操作 logicManager.DoLogicOperation(flowChartManager, LogicType.AfterDelete, graphElementList); graphManager.SlotContainerList.Remove(slotContainer); // 从插槽容器索引链表中删除 deleteSuccess = true; } else if (graphElement is ConnectorContainer) // 要删除的图元是连接线控制点容器 { ConnectorContainer connectorContainer = graphElement as ConnectorContainer; List <GraphElement> graphElementList = new List <GraphElement>(); SlotContainer inSlotContainer = connectorContainer.InSlotContainer; if (inSlotContainer != null) { connectorContainer.UnbindInSlotContainer(); } SlotContainer outSlotContainer = connectorContainer.OutSlotContainer; if (outSlotContainer != null) { graphElementList.Add(outSlotContainer); connectorContainer.UnbindOutSlotContainer(); } // 执行逻辑操作 logicManager.DoLogicOperation(flowChartManager, LogicType.AfterDelete, graphElementList); graphManager.ConnectorContainerList.Remove(connectorContainer); // 从连接线控制点索引容器中删除 deleteSuccess = true; } else if (graphElement is ConnectorGraphElement) // 要删除的图元是连接线控制点 { ConnectorGraphElement connector = graphElement as ConnectorGraphElement; ConnectorContainer connectorContainer = connector.Line; List <GraphElement> graphElementList = new List <GraphElement>(); SlotContainer inSlotContainer = connectorContainer.InSlotContainer; if (inSlotContainer != null) { connectorContainer.UnbindInSlotContainer(); } SlotContainer outSlotContainer = connectorContainer.OutSlotContainer; if (outSlotContainer != null) { graphElementList.Add(outSlotContainer); connectorContainer.UnbindOutSlotContainer(); } // 执行逻辑操作 logicManager.DoLogicOperation(flowChartManager, LogicType.AfterDelete, graphElementList); graphManager.ConnectorContainerList.Remove(connectorContainer); // 从连接线控制点索引容器中删除 deleteSuccess = true; } else if (graphElement is SlotGraphElement) // 要删除的图元是插槽 { SlotGraphElement slot = graphElement as SlotGraphElement; if (slot.CanDelete && (slot.IsInSlot || slot.SlotContainer.OutSlotCount > 1)) // 插槽可以删除 { SlotContainer slotContainer = slot.SlotContainer; slotContainer.RemoveSlot(slot); deleteSuccess = true; } else { MessageBox.Show("该插槽不能删除", "图元删除", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (graphElement is RemarkGraphElement) // 要删除的图元是注释结点 { RemarkGraphElement remarkGraphElement = graphElement as RemarkGraphElement; SlotContainer slotContainer = remarkGraphElement.Owner as SlotContainer; slotContainer.RemarkNode = null; remarkGraphElement.Owner = null; remarkGraphElement = null; deleteSuccess = true; } if (deleteSuccess) // 释放图元所占的资源 { dataManager.DeleteData(graphElement); graphElement.Release(); } return(deleteSuccess); }
/// <summary> /// 检查逻辑 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicData">逻辑数据</param> /// <returns>是否操作成功</returns> protected override bool LogicCheckLogic(FlowChartManager flowChartManager, object logicData) { bool executeResult = CheckFlowChartAvail(flowChartManager); return(executeResult); }
/// <summary> /// 复制图元及其信息 /// </summary> /// <param name="dataTable">保存图元信息的哈希表</param> /// <returns>复制的数据</returns> protected Hashtable CopyGraphElement(Hashtable dataTable) { GraphManager graphManager = data as GraphManager; FlowChartManager flowChartManager = graphManager.CurrentFlowChartManager; DataManager dataManager = flowChartManager.CurrentDataManager; Hashtable copyTable = new Hashtable(); Hashtable graphTable = new Hashtable(); List <ConnectorContainer> lineList = new List <ConnectorContainer>(); List <GraphElement> graphElementList = new List <GraphElement>(); SlotContainer slotContainer; SlotContainer newSlotContainer; ConnectorContainer line; ConnectorContainer newLine; ICloneable cloneData; foreach (object o in dataTable.Keys) { GraphElement graphElement = o as GraphElement; if (graphElement is SlotContainer) // 插槽容器 { slotContainer = graphElement as SlotContainer; newSlotContainer = slotContainer.Clone(); graphTable[slotContainer] = newSlotContainer; cloneData = dataTable[slotContainer] as ICloneable; if (cloneData != null) { copyTable[newSlotContainer] = cloneData.Clone(); } else { copyTable[newSlotContainer] = null; } graphElementList.Add(slotContainer); } else if (graphElement is ConnectorContainer) // 连接线 { line = graphElement as ConnectorContainer; newLine = line.Clone(); graphTable[line] = newLine; lineList.Add(line); cloneData = dataTable[line] as ICloneable; if (cloneData != null) { copyTable[newLine] = cloneData.Clone(); } else { copyTable[newLine] = null; } graphElementList.Add(line); } } // 重新构建复制图元的连接关系 foreach (ConnectorContainer connectorContainer in lineList) { int index; slotContainer = connectorContainer.InSlotContainer; if (slotContainer != null && graphElementList.Contains(slotContainer)) { index = slotContainer.GetBindedOutSlotIndex(connectorContainer); newSlotContainer = graphTable[slotContainer] as SlotContainer; newLine = graphTable[connectorContainer] as ConnectorContainer; newSlotContainer.BindOutLine(newLine, index); } slotContainer = connectorContainer.OutSlotContainer; if (slotContainer != null && graphElementList.Contains(slotContainer)) { index = slotContainer.GetBindedInSlotIndex(connectorContainer); newSlotContainer = graphTable[slotContainer] as SlotContainer; newLine = graphTable[connectorContainer] as ConnectorContainer; newSlotContainer.BindInLine(newLine, index); } } return(copyTable); }