コード例 #1
0
        /// <summary>
        /// 初始化数据元
        /// </summary>
        /// <param name="flowChartManager">绘图管理器</param>
        /// <param name="logicData">逻辑数据</param>
        /// <returns>是否操作成功</returns>
        protected virtual bool LogicInitializeDataElement(FlowChartManager flowChartManager, object logicData)
        {
            bool         executeSuccess = true;
            GraphElement graphElement   = logicData as GraphElement;
            DataElement  dataElement    = null;

            try
            {
                switch (graphElement.TypeString)
                {
                case "InnerChart":     // 基础图元
                {
                    dataElement = new InnerChartEditor();

                    break;
                }

                case "InterfaceNode":     // 基础图元
                {
                    dataElement = new InterfaceNodeEditor();

                    break;
                }

                default:     // 自定义图元
                {
                    DataElementInfo dataElementInfo = dataElementInfoDirectory[graphElement.TypeString];

                    if (dataElementInfo != null)
                    {
                        dataElement = dataElementInfo.GetDataElement();
                    }

                    break;
                }
                }

                if (dataElement != null)
                {
                    dataElement.ID       = graphElement.ID;
                    dataElement.DataType = graphElement.TypeString;
                }
            }
            catch (Exception ex)
            {
                executeSuccess = false;
                MessageBox.Show("在初始化数据元时产生异常: " + ex.ToString(), "数据元初始化", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            flowChartManager.CurrentDataManager.InitializedDataElement = dataElement;

            return(executeSuccess);
        }
コード例 #2
0
ファイル: LogicBaseManager.cs プロジェクト: viticm/pap2
        /// <summary>
        /// 初始化数据元
        /// </summary>
        /// <param name="flowChartManager">绘图管理器</param>
        /// <param name="logicData">逻辑数据</param>
        /// <returns>是否操作成功</returns>
        protected virtual bool LogicInitializeDataElement(FlowChartManager flowChartManager, object logicData)
        {
            bool executeSuccess = true;
            GraphElement graphElement = logicData as GraphElement;
            DataElement dataElement = null;

            try
            {
                switch (graphElement.TypeString)
                {
                    case "InnerChart": // 基础图元
                        {
                            dataElement = new InnerChartEditor();

                            break;
                        }
                    case "InterfaceNode": // 基础图元
                        {
                            dataElement = new InterfaceNodeEditor();

                            break;
                        }
                    default: // 自定义图元
                        {
                            DataElementInfo dataElementInfo = dataElementInfoDirectory[graphElement.TypeString];

                            if (dataElementInfo != null)
                            {
                                dataElement = dataElementInfo.GetDataElement();                                                                    
                            }

                            break;
                        }
                }

                if (dataElement != null)
                {
                    dataElement.ID = graphElement.ID;
                    dataElement.DataType = graphElement.TypeString;
                }
            }
            catch (Exception ex)
            {
                executeSuccess = false;
                MessageBox.Show("在初始化数据元时产生异常: " + ex.ToString(), "数据元初始化", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            flowChartManager.CurrentDataManager.InitializedDataElement = dataElement;

            return executeSuccess;
        }
コード例 #3
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);
        }