Exemplo n.º 1
0
        public void SetPortCount(int[] newPortCount)
        {
            int i;
            int ex = 0;

            //левые порты
            if (PortCount[0] != newPortCount[0])
            {
                ex = 1;
                if (PortCount[0] < newPortCount[0])
                {
                    for (i = PortCount[0]; i < newPortCount[0]; i++)
                    {
                        PortPoints.Insert(i, new Point[PortPointCount]);
                        InLinePoints.Insert(i, new Point());
                        ConnectionObj.Insert(i, null);
                        ConnectionEnd.Insert(i, -1);
                    }
                }
                else
                {
                    intTemp = newPortCount[0] - 1;
                    for (i = PortCount[0] - 1; i > intTemp; i--)
                    {
                        PortPoints.RemoveAt(i);
                        InLinePoints.RemoveAt(i);
                        ClearConnection(i, -1);
                        ConnectionObj.RemoveAt(i);
                        ConnectionEnd.RemoveAt(i);
                    }
                }

                PortCount[0] = newPortCount[0];
            }

            //правые порты
            if (PortCount[1] != newPortCount[1])
            {
                ex = 1;
                if (PortCount[1] < newPortCount[1])
                {
                    for (i = PortCount[1]; i < newPortCount[1]; i++)
                    {
                        PortPoints.Add(new Point[PortPointCount]);
                        InLinePoints.Add(new Point());
                        ConnectionObj.Add(null);
                        ConnectionEnd.Add(-1);
                    }
                }
                else
                {
                    intTemp = newPortCount[1] - 1;
                    for (i = PortCount[1] + PortCount[0] - 1; i > intTemp + PortCount[0]; i--)
                    {
                        PortPoints.RemoveAt(i);
                        InLinePoints.RemoveAt(i);
                        ClearConnection(i);
                        ConnectionObj.RemoveAt(i);
                        ConnectionEnd.RemoveAt(i);
                    }
                }

                PortCount[1] = newPortCount[1];
            }

            if (ex == 1)
            {
                ChangeLocation(ShapePoints[0], true);
            }
        }