Example #1
0
        /// <summary>
        /// 查找指定节点的后续节点
        /// </summary>
        /// <param name="nodeIndex"></param>
        /// <returns></returns>
        public List <Tx_Node> FindNextNodes(Tx_Node node)
        {
            var lstNextNodes = new List <Tx_Node>();

            //根据线条查找后续节点串
            foreach (Tx_Entry entry in this.m_LstEntrys)
            {
                if (entry.StartNode == node.Flow_code)
                {
                    foreach (var nodes in m_Nodes)
                    {
                        if (nodes.Flow_code == entry.EndNode)
                        {
                            lstNextNodes.Add(nodes);
                        }
                    }
                }
            }
            return(lstNextNodes);
        }
Example #2
0
        /// <summary>
        /// 查找指定节点的前导节点
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public List <Tx_Node> FindPreNodes(Tx_Node node)
        {
            var            subtxCode   = "";
            List <Tx_Node> lstPreNodes = new List <Tx_Node>();

            //根据线条查找后续节点串
            foreach (Tx_Node entry in this.m_Nodes)
            {
                if (entry.Flow_code == node.Flow_code)
                {
                    subtxCode = node.Flow_code;
                    foreach (Tx_Node lstentry in this.m_LstNodes)
                    {
                        if (lstentry.Sub_tx_code == subtxCode)
                        {
                            lstPreNodes.Add(lstentry);
                        }
                    }
                }
            }
            return(lstPreNodes);
        }
Example #3
0
        /// <summary>
        /// 找出交易流程的所有头结点
        /// </summary>
        /// <returns></returns>
        //public List<Tx_Node> GetHeadNodes()
        //{
        //    List<Tx_Node> headNodes = new List<Tx_Node>();

        //    foreach (Tx_Node node in m_Nodes)
        //    {
        //        bool found = false;
        //        foreach (Tx_Entry entry in this.m_LstEntrys)
        //        {
        //            if (entry.EndNode == node.Flow_code)
        //            {
        //                found = true;
        //                break;
        //            }
        //        }

        //        if (!found)
        //        {
        //            headNodes.Add(node);
        //        }
        //    }
        //    return headNodes;
        //}
        /// <summary>
        /// 计算一个节点后续节点的位置算法
        /// </summary>
        /// <param name="nodeIndex"></param>
        public void LayOut_NextNodes(Tx_Node node)
        {
            //获取后续节点串
            var lstNextNodes = this.FindNextNodes(node);

            //若后续节点串为空或者已布局节点数等于全部节点数,则退出布局

            if (lstNextNodes == null || lstNextNodes.Count == 0)
            {
                return;
            }
            var half = 0f;

            //偶数个节点
            if (lstNextNodes.Count % 2 != 0)
            {
                half = lstNextNodes.Count / 2 - 1f;
            }
            else
            {
                half = lstNextNodes.Count / 2;
            }

            for (int i = 0; i < lstNextNodes.Count; i++)
            {
                //只对还没有定位的,进行定位;并对其后续节点定位
                if (lstNextNodes[i].X == 0 && lstNextNodes[i].Y == 0)
                {
                    lstNextNodes[i].Y = node.Y + mc_OFFSET_Y;

                    lstNextNodes[i].X = node.X + (i - half) * mc_OFFSET_X;
                    if (lstNextNodes[i].X < 30)
                    {
                        lstNextNodes[i].X = 30;
                    }

                    if (!string.IsNullOrWhiteSpace(node.Sub_tx_code))
                    {
                        string[] sub_node = node.Sub_tx_code.Split('@');
                        //for (int y = 0; y < sub_node.Count(); y++)
                        //{
                        //    if (sub_node.Count() <= 1)
                        //    {
                        //        break;
                        //    }
                        //    else
                        //    {
                        //        float offset = i - half == 0 ? 1 : i - half;
                        //        //lstNextNodes[i].X =node.X + offset * mc_OFFSET_X;
                        //    }
                        //    //if (lstNextNodes[i].Sub_tx_code == sub_node[y])
                        //    //{

                        //    //}
                        //}
                    }
                    pointList.ForEach(x =>
                    {
                        if (x.Y == lstNextNodes[i].Y)
                        {
                            if (x.X >= lstNextNodes[i].X)
                            {
                                lstNextNodes[i].X = (float)x.X + 150;
                            }
                        }
                    });


                    m_LstNodes.Add(lstNextNodes[i]);
                    pointList.Add(new Point(lstNextNodes[i].X, lstNextNodes[i].Y));
                    //保存界面最左的图形节点的X坐标值
                    if (lstNextNodes[i].X < m_Leftest_X)
                    {
                        m_Leftest_X = lstNextNodes[i].X;
                    }

                    if (lstNextNodes.Count() >= 1)
                    {
                        this.m_LayOutCount++;
                        //递归对后续节点进行布局
                        LayOut_NextNodes(lstNextNodes[i]);
                    }
                }
            }

            ////递归对后续节点进行布局
            //if (lstNextNodes.Count() > 1)
            //{
            //    this.m_LayOutCount++;
            //}
        }
Example #4
0
        /// <summary>
        /// 布局算法 确定节点位置
        /// </summary>
        public void LayOut()
        {
            m_LayOutCount = 0;
            m_LstNodes    = new List <Tx_Node>();
            m_Nodes       = new List <Tx_Node>();
            m_LstEntrys   = new List <Tx_Entry>();
            foreach (TradeFlow item in flowList)
            {
                var      tradeFlowJoin = new StringBuilder();//串连交易流程
                string[] str           = { "#", "=" };
                var      _tradeFlow    = item.Trade_Flow.Trim();
                var      x3            = _tradeFlow.Remove(_tradeFlow.Length - 2, 2);
                var      _s            = x3.Split(str, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Count() > 0)
                {
                    var i = 0;
                    _s.ToList().ForEach(k =>
                    {
                        i++;
                        var m         = k.Remove(k.Length - 1, 1);
                        var condition = m.Split('@')[0].ToString();
                        var subtxCode = m.Split('@')[1].ToString();

                        tradeFlowJoin.Append(subtxCode);
                        if (_s.Count() > 1 && i < _s.Count())
                        {
                            tradeFlowJoin.Append('@');
                        }

                        var entry = new Tx_Entry(item.FlowCode, subtxCode, condition, m_Connection[item.CompCode]);
                        m_LstEntrys.Add(entry);
                    });
                }
                if (tradeFlowJoin == null)
                {
                    tradeFlowJoin.Append("");
                }
                var node = new Tx_Node(item.FlowCode.Trim(), tradeFlowJoin.ToString(), item.CompCode.Trim())
                {
                    X = 0.0f,
                    Y = 0.0f
                };
                m_Nodes.Add(node);
            }
            if (m_Nodes.Count < 1)
            {
                return;
            }
            var firstNode = FindFirstNode();

            firstNode.X = mc_START_X;
            firstNode.Y = mc_START_Y;
            m_LstNodes.Add(firstNode);
            pointList = new List <Point>();
            pointList.Add(new Point(firstNode.X, firstNode.Y));
            m_LayOutCount++;
            LayOut_NextNodes(firstNode);
            //m_LstHeadNode = GetHeadNodes();
            //foreach (Tx_Node nextLayNode in m_Nodes)
            //{
            //    if (m_LstHeadNode != null)
            //    {
            //        //非起始子交易的头结点树的分布控制
            //        foreach (Tx_Node txNodeHaad in m_LstHeadNode)
            //        {
            //            if (txNodeHaad.Flow_code == nextLayNode.Flow_code)
            //            {
            //                txNodeHaad.X = mc_START_X + 250;
            //                txNodeHaad.Y = mc_START_Y;
            //                this.m_LayOutCount++;
            //                m_LstNodes.Add(txNodeHaad);
            //                this.LayOut_NextNodes(txNodeHaad);
            //            }
            //        }
            //    }
            //    this.LayOut_NextNodes(nextLayNode);
            //}
        }
Example #5
0
        /// <summary>
        /// 找出交易流程的所有头结点
        /// </summary>
        /// <returns></returns>
        //public List<Tx_Node> GetHeadNodes()
        //{
        //    List<Tx_Node> headNodes = new List<Tx_Node>();
        //    foreach (Tx_Node node in m_Nodes)
        //    {
        //        bool found = false;
        //        foreach (Tx_Entry entry in this.m_LstEntrys)
        //        {
        //            if (entry.EndNode == node.Flow_code)
        //            {
        //                found = true;
        //                break;
        //            }
        //        }
        //        if (!found)
        //        {
        //            headNodes.Add(node);
        //        }
        //    }
        //    return headNodes;
        //}
        /// <summary>
        /// 计算一个节点后续节点的位置算法
        /// </summary>
        /// <param name="nodeIndex"></param>
        public void LayOut_NextNodes(Tx_Node node)
        {
            //获取后续节点串
            var lstNextNodes = this.FindNextNodes(node);

            //若后续节点串为空或者已布局节点数等于全部节点数,则退出布局

            if (lstNextNodes == null || lstNextNodes.Count == 0)
            {
                return;
            }
            var half = 0f;

            //偶数个节点
            if (lstNextNodes.Count % 2 != 0)
            {
                half = lstNextNodes.Count / 2 - 1f;
            }
            else
            {
                half = lstNextNodes.Count / 2;
            }

            for (int i = 0; i < lstNextNodes.Count; i++)
            {
                //只对还没有定位的,进行定位;并对其后续节点定位
                if (lstNextNodes[i].X == 0 && lstNextNodes[i].Y == 0)
                {
                    lstNextNodes[i].Y = node.Y + mc_OFFSET_Y;

                    lstNextNodes[i].X = node.X + (i - half) * mc_OFFSET_X;
                    if (lstNextNodes[i].X <30)
                    {
                        lstNextNodes[i].X = 30;
                    }

                    if (!string.IsNullOrWhiteSpace(node.Sub_tx_code))
                    {

                        string[] sub_node = node.Sub_tx_code.Split('@');
                        //for (int y = 0; y < sub_node.Count(); y++)
                        //{
                        //    if (sub_node.Count() <= 1)
                        //    {
                        //        break;
                        //    }
                        //    else
                        //    {
                        //        float offset = i - half == 0 ? 1 : i - half;
                        //        //lstNextNodes[i].X =node.X + offset * mc_OFFSET_X;
                        //    }
                        //    //if (lstNextNodes[i].Sub_tx_code == sub_node[y])
                        //    //{

                        //    //}
                        //}
                    }
                    pointList.ForEach(x =>
                    {
                        if (x.Y == lstNextNodes[i].Y)
                        {
                            if (x.X >= lstNextNodes[i].X)
                            {
                                lstNextNodes[i].X = (float)x.X + 150;
                            }
                        }
                    });

                    m_LstNodes.Add(lstNextNodes[i]);
                    pointList.Add(new Point(lstNextNodes[i].X, lstNextNodes[i].Y));
                    //保存界面最左的图形节点的X坐标值
                    if (lstNextNodes[i].X < m_Leftest_X)
                    {
                        m_Leftest_X = lstNextNodes[i].X;
                    }

                    if (lstNextNodes.Count() >= 1)
                    {
                        this.m_LayOutCount++;
                        //递归对后续节点进行布局
                        LayOut_NextNodes(lstNextNodes[i]);
                    }
                }

            }

            ////递归对后续节点进行布局
            //if (lstNextNodes.Count() > 1)
            //{
            //    this.m_LayOutCount++;
            //}
        }
Example #6
0
        /// <summary>
        /// 布局算法 确定节点位置
        /// </summary>
        public void LayOut()
        {
            m_LayOutCount = 0;
            m_LstNodes = new List<Tx_Node>();
            m_Nodes = new List<Tx_Node>();
            m_LstEntrys = new List<Tx_Entry>();
            foreach (TradeFlow item in flowList)
            {
                var tradeFlowJoin = new StringBuilder();//串连交易流程
                string[] str = { "#", "=" };
                var _tradeFlow = item.Trade_Flow.Trim();
                var x3 = _tradeFlow.Remove(_tradeFlow.Length - 2, 2);
                var _s = x3.Split(str, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Count() > 0)
                {
                    var i=0;
                    _s.ToList().ForEach(k =>
                    {
                        i++;
                        var m = k.Remove(k.Length - 1, 1);
                        var condition = m.Split('@')[0].ToString();
                        var subtxCode = m.Split('@')[1].ToString();

                        tradeFlowJoin.Append(subtxCode);
                        if (_s.Count() > 1 && i < _s.Count())
                        {
                            tradeFlowJoin.Append('@');
                        }

                        var entry = new Tx_Entry(item.FlowCode, subtxCode,condition, m_Connection[item.CompCode]);
                        m_LstEntrys.Add(entry);
                    });
                }
                if (tradeFlowJoin == null)
                    tradeFlowJoin.Append("");
                var node = new Tx_Node(item.FlowCode.Trim(), tradeFlowJoin.ToString(), item.CompCode.Trim())
                {
                    X=0.0f,
                    Y=0.0f
                };
                m_Nodes.Add(node);
            }
            if (m_Nodes.Count < 1)
            {
                return;
            }
            var firstNode = FindFirstNode();
            firstNode.X = mc_START_X;
            firstNode.Y = mc_START_Y;
            m_LstNodes.Add(firstNode);
            pointList = new List<Point>();
            pointList.Add(new Point(firstNode.X, firstNode.Y));
            m_LayOutCount++;
            LayOut_NextNodes(firstNode);
            //m_LstHeadNode = GetHeadNodes();
            //foreach (Tx_Node nextLayNode in m_Nodes)
            //{
            //    if (m_LstHeadNode != null)
            //    {
            //        //非起始子交易的头结点树的分布控制
            //        foreach (Tx_Node txNodeHaad in m_LstHeadNode)
            //        {
            //            if (txNodeHaad.Flow_code == nextLayNode.Flow_code)
            //            {
            //                txNodeHaad.X = mc_START_X + 250;
            //                txNodeHaad.Y = mc_START_Y;
            //                this.m_LayOutCount++;
            //                m_LstNodes.Add(txNodeHaad);
            //                this.LayOut_NextNodes(txNodeHaad);
            //            }
            //        }
            //    }
            //    this.LayOut_NextNodes(nextLayNode);
            //}
        }
Example #7
0
 /// <summary>
 /// 查找指定节点的前导节点
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public List<Tx_Node> FindPreNodes(Tx_Node node)
 {
     var subtxCode = "";
     List<Tx_Node> lstPreNodes = new List<Tx_Node>();
     //根据线条查找后续节点串
     foreach (Tx_Node entry in this.m_Nodes)
     {
         if (entry.Flow_code == node.Flow_code)
         {
             subtxCode = node.Flow_code;
             foreach (Tx_Node lstentry in this.m_LstNodes)
             {
                 if (lstentry.Sub_tx_code == subtxCode)
                 {
                     lstPreNodes.Add(lstentry);
                 }
             }
         }
     }
     return lstPreNodes;
 }
Example #8
0
        /// <summary>
        /// 查找指定节点的后续节点
        /// </summary>
        /// <param name="nodeIndex"></param>
        /// <returns></returns>
        public List<Tx_Node> FindNextNodes(Tx_Node node)
        {
            var lstNextNodes = new List<Tx_Node>();

            //根据线条查找后续节点串
            foreach (Tx_Entry entry in this.m_LstEntrys)
            {
                if (entry.StartNode == node.Flow_code)
                {
                    foreach (var nodes in m_Nodes)
                    {
                        if (nodes.Flow_code == entry.EndNode)
                        {
                            lstNextNodes.Add(nodes);
                        }
                    }
                }
            }
            return lstNextNodes;
        }