/// <summary>
        /// ��ҳ��cassviewΪ��λ���пؼ����������
        /// �������ؼ�������ؼ�����������б���ؼ�JMP��Ҫ��Ϣ��
        /// �Լ�����ָ����б�Ϳؼ���������ƥ��󷵻�
        /// </summary>
        /// <param name="alreadyOrderInfo">������Ŀؼ�������</param>
        /// <param name="pageName">��ǰCASSVIEW��ҳ����</param>
        /// <returns></returns>
        private List<string[]> OrderPacksNum(CassView curCas, List<ControlInfo[]> alreadyOrderInfo, string pageName)
        {
            List<Point> OrderPoint = new List<Point>();//���ÿ���ؼ���������Сֵ,��Ϊ�ؼ�������������
            List<ControlInfo[]> OrderPack = new List<ControlInfo[]>();//�ؼ�������������б�
            List<string> Indexs = new List<string>();//ÿ���ؼ��Ŀؼ��������
            List<string> PackName = new List<string>();//�ؼ������ļ���

            GenerateCode.CtrlsList.Clear();

            for (int Pindex = 0; Pindex < alreadyOrderInfo.Count; Pindex++)
            {
                List<string> CnumList = new List<string>();//ÿ���ؼ���ż���
                Point minP = new Point(1200, 1000);//ÿ���ؼ���С����
                //��һ����ȷ���ؼ�����
                //����ҳ��û��0������
                if (Pindex == 0)
                {
                    PackName.Add(pageName);
                }
                else
                {
                    PackName.Add(pageName + Pindex.ToString());//����ҳ����+���������Ϊ����
                }
                //�ڶ������ҵ�ÿ���ؼ���������Сֵ���ɴ˽��пؼ���������
                for (int Cindex = 0; Cindex < alreadyOrderInfo[Pindex].Length; Cindex++)
                {
                    if (alreadyOrderInfo[Pindex][Cindex].ControlNum != -1)
                    {
                        CnumList.Add(alreadyOrderInfo[Pindex][Cindex].ControlNum.ToString());
                        Point CurP = curCas.FindBlockInfo(alreadyOrderInfo[Pindex][Cindex]).StartPoint;
                        if (CurP != new Point() && (CurP.Y < minP.Y || (CurP.Y == minP.Y && CurP.X < minP.X)))
                        {//ȡYֵС�ĵ㣬��Y��ͬ��ȡX��ͬ�ĵ�
                            minP = CurP;
                        }
                    }
                }
                //2014.1.15
             //   GenerateCode.ctrlsNum = CnumList;
                GenerateCode.CtrlsList.Add(CnumList);
                ////������
                //if (CnumList != null)
                //{
                //    this.myDeleSendCtrlsNum(CnumList);
                //}
                if (OrderPoint.Count == 0
                    || minP.Y > OrderPoint[OrderPoint.Count - 1].Y
                    || (minP.Y == OrderPoint[OrderPoint.Count - 1].Y && minP.X >= OrderPoint[OrderPoint.Count - 1].X))
                {//�����򼯺�Ϊ�� �� Yֵ���ڼ���βԪ��Y �� Y��ͬXֵ���ڵ��ڼ���βԪ��X
                    OrderPoint.Add(minP);
                    OrderPack.Add(alreadyOrderInfo[Pindex]);
                    Indexs.Add(String.Join(",", CnumList.ToArray()));
                }
                else
                {
                    for (int Gindex = 0; Gindex < OrderPoint.Count; Gindex++)
                    {
                        if (minP.Y < OrderPoint[Gindex].Y || (minP.Y == OrderPoint[Gindex].Y && minP.X < OrderPoint[Gindex].X))
                        {//�������� YֵС�ڵ�ǰ��Y �� Yֵ��ͬXС�ڵ�ǰ��X
                            OrderPoint.Insert(Gindex, minP);
                            OrderPack.Insert(Gindex, alreadyOrderInfo[Pindex]);
                            Indexs.Insert(Gindex, String.Join(",", CnumList.ToArray()));
                            break;
                        }
                    }
                }
            }
            //�������ֽ������Ŀؼ�����������봮����������
            if (Indexs.Count == PackName.Count)
            {
                for (int i = 0; i < Indexs.Count; i++)
                {
                    PackInfos.Add(new string[] { PackName[i], Indexs[i] });
                }
            }
            //���IJ��ֽ��ؼ�����������������ɵ�ָ������������ϲ�����
            return InsertPackName(CreateCodeList(OrderPack), PackName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 逆向遍历找到尾端控件所关联的断层处(多输出)的连接口控件坐标
        /// 以此为依据进行排序
        /// </summary>
        /// <param name="endCtrls"></param>
        /// <returns></returns>
        private Stack <ControlInfo> OrderEndCtrls(CassView curCas, Stack <ControlInfo> endCtrls, List <ControlInfo> GroupCtrl)
        {
            List <ControlInfo>  orderList   = new List <ControlInfo>();  //控件排序用队列
            List <Point>        orderP      = new List <Point>();        //点坐标排序队列
            Stack <ControlInfo> returnStack = new Stack <ControlInfo>(); //返回用堆栈

            foreach (ControlInfo ctrl in endCtrls)
            {
                Stack <ControlInfo> Findctrls = new Stack <ControlInfo>();
                Findctrls.Push(ctrl);
                bool findPoint = false;
                while (!findPoint)
                {
                    ControlInfo Topctrl = Findctrls.Pop();
                    for (int x = Topctrl.InputInfo.Count - 1; x >= 0; x--)
                    {//逆向遍历上端口优先于下端口
                        string[] Input = Topctrl.InputInfo[x];
                        if (TempInfo.Contains(Input[1]))
                        {//出现临时变量找到断层跳出循环
                            findPoint = true;
                            //依据点的坐标以Y大的优先,Y相同X大的优先排序
                            Point sp = curCas.FindBlockInfo(Topctrl).StartPoint;
                            if (orderList.Count == 0)
                            {
                                orderList.Add(ctrl);
                                orderP.Add(sp);
                            }
                            else
                            {
                                for (int y = 0; y < orderP.Count; y++)
                                {
                                    if (orderP[y].Y > sp.Y || (orderP[y].Y == sp.Y && orderP[y].X > sp.X))
                                    {
                                        orderP.Insert(y, sp);
                                        orderList.Insert(y, ctrl);
                                        break;
                                    }
                                    if (y == orderList.Count - 1)
                                    {
                                        orderList.Add(ctrl);
                                        orderP.Add(sp);
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                        else if (Input[0] != null)
                        {//将前级输出控件压入堆栈
                            for (int i = 0; i < GroupCtrl.Count; i++)
                            {
                                if (GroupCtrl[i].ControlName == Input[0].Split('.')[0])
                                {
                                    Findctrls.Push(GroupCtrl[i]);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            foreach (ControlInfo element in orderList)
            {//将排序末端控件压入返回堆栈 栈顶控件为Y最小X最小控件
                returnStack.Push(element);
            }
            return(returnStack);
        }
 /// <summary>
 /// ��������ҵ�β�˿ؼ��������Ķϲ㴦��������������ӿڿؼ�����
 /// �Դ�Ϊ���ݽ�������
 /// </summary>
 /// <param name="endCtrls"></param>
 /// <returns></returns>
 private Stack<ControlInfo> OrderEndCtrls(CassView curCas, Stack<ControlInfo> endCtrls, List<ControlInfo> GroupCtrl)
 {
     List<ControlInfo> orderList = new List<ControlInfo>();//�ؼ������ö���
     List<Point> orderP = new List<Point>();//�������������
     Stack<ControlInfo> returnStack = new Stack<ControlInfo>();//�����ö�ջ
     foreach (ControlInfo ctrl in endCtrls)
     {
         Stack<ControlInfo> Findctrls = new Stack<ControlInfo>();
         Findctrls.Push(ctrl);
         bool findPoint = false;
         while (!findPoint)
         {
             ControlInfo Topctrl = Findctrls.Pop();
             for (int x = Topctrl.InputInfo.Count - 1; x >= 0; x--)
             {//��������϶˿��������¶˿�
                 string[] Input = Topctrl.InputInfo[x];
                 if (TempInfo.Contains(Input[1]))
                 {//������ʱ�����ҵ��ϲ�����ѭ��
                     findPoint = true;
                     //���ݵ��������Y������ȣ�Y��ͬX�����������
                     Point sp = curCas.FindBlockInfo(Topctrl).StartPoint;
                     if (orderList.Count == 0)
                     {
                         orderList.Add(ctrl);
                         orderP.Add(sp);
                     }
                     else
                     {
                         for (int y = 0; y < orderP.Count; y++)
                         {
                             if (orderP[y].Y > sp.Y || (orderP[y].Y == sp.Y && orderP[y].X > sp.X))
                             {
                                 orderP.Insert(y, sp);
                                 orderList.Insert(y, ctrl);
                                 break;
                             }
                             if (y == orderList.Count - 1)
                             {
                                 orderList.Add(ctrl);
                                 orderP.Add(sp);
                                 break;
                             }
                         }
                     }
                     break;
                 }
                 else if (Input[0] != null)
                 {//��ǰ������ؼ�ѹ���ջ
                     for (int i = 0; i < GroupCtrl.Count; i++)
                     {
                         if (GroupCtrl[i].ControlName == Input[0].Split('.')[0])
                         {
                             Findctrls.Push(GroupCtrl[i]);
                             break;
                         }
                     }
                 }
             }
         }
     }
     foreach (ControlInfo element in orderList)
     {//������ĩ�˿ؼ�ѹ�뷵�ض�ջ ջ���ؼ�ΪY��СX��С�ؼ�
         returnStack.Push(element);
     }
     return returnStack;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 以页面cassview为单位进行控件串间的排序
        /// 并产生控件串名与控件串序号整合列表(控件JMP需要信息)
        /// 以及生成指令表列表和控件串名进行匹配后返回
        /// </summary>
        /// <param name="alreadyOrderInfo">待排序的控件串集合</param>
        /// <param name="pageName">当前CASSVIEW的页面名</param>
        /// <returns></returns>
        private List <string[]> OrderPacksNum(CassView curCas, List <ControlInfo[]> alreadyOrderInfo, string pageName)
        {
            List <Point>         OrderPoint = new List <Point>();         //存放每串控件中坐标最小值,作为控件串间排序依据
            List <ControlInfo[]> OrderPack  = new List <ControlInfo[]>(); //控件串间排序后存放列表
            List <string>        Indexs     = new List <string>();        //每串控件的控件序号序列
            List <string>        PackName   = new List <string>();        //控件串名的集合

            for (int Pindex = 0; Pindex < alreadyOrderInfo.Count; Pindex++)
            {
                List <string> CnumList = new List <string>();   //每串控件序号集合
                Point         minP     = new Point(1200, 1000); //每串控件最小坐标
                //第一部分确定控件串名
                //所有页面没有0块命名
                if (Pindex == 0)
                {
                    PackName.Add(pageName);
                }
                else
                {
                    PackName.Add(pageName + Pindex.ToString());//所在页面名+数字序号作为块名
                }
                //第二部分找到每串控件中坐标最小值并由此进行控件串间排序
                for (int Cindex = 0; Cindex < alreadyOrderInfo[Pindex].Length; Cindex++)
                {
                    if (alreadyOrderInfo[Pindex][Cindex].ControlNum != -1)
                    {
                        CnumList.Add(alreadyOrderInfo[Pindex][Cindex].ControlNum.ToString());
                        Point CurP = curCas.FindBlockInfo(alreadyOrderInfo[Pindex][Cindex]).StartPoint;
                        if (CurP != new Point() && (CurP.Y < minP.Y || (CurP.Y == minP.Y && CurP.X < minP.X)))
                        {//取Y值小的点,当Y相同则取X相同的点
                            minP = CurP;
                        }
                    }
                }
                if (OrderPoint.Count == 0 ||
                    minP.Y > OrderPoint[OrderPoint.Count - 1].Y ||
                    (minP.Y == OrderPoint[OrderPoint.Count - 1].Y && minP.X >= OrderPoint[OrderPoint.Count - 1].X))
                {//点排序集合为空 或 Y值大于集合尾元素Y 或 Y相同X值大于等于集合尾元素X
                    OrderPoint.Add(minP);
                    OrderPack.Add(alreadyOrderInfo[Pindex]);
                    Indexs.Add(String.Join(",", CnumList.ToArray()));
                }
                else
                {
                    for (int Gindex = 0; Gindex < OrderPoint.Count; Gindex++)
                    {
                        if (minP.Y < OrderPoint[Gindex].Y || (minP.Y == OrderPoint[Gindex].Y && minP.X < OrderPoint[Gindex].X))
                        {//插入条件 Y值小于当前点Y 或 Y值相同X小于当前点X
                            OrderPoint.Insert(Gindex, minP);
                            OrderPack.Insert(Gindex, alreadyOrderInfo[Pindex]);
                            Indexs.Insert(Gindex, String.Join(",", CnumList.ToArray()));
                            break;
                        }
                    }
                }
            }
            //第三部分将产生的控件串序号依次与串名进行整合
            if (Indexs.Count == PackName.Count)
            {
                for (int i = 0; i < Indexs.Count; i++)
                {
                    PackInfos.Add(new string[] { PackName[i], Indexs[i] });
                }
            }
            //第四部分将控件串名与排序完后生成的指令数组进行整合并返回
            return(InsertPackName(CreateCodeList(OrderPack), PackName));
        }