public IEnumerable <ConnectionPoint> UpdateConnections(IEnumerable <Connection> newConnections)
        {
            int inCount  = 0;
            int outCount = 0;

            foreach (Connection conn in newConnections)
            {
                if (conn.IsInput)
                {
                    inCount++;
                }
                else
                {
                    outCount++;
                }
            }
            int    gridHeight = Math.Max(1, Math.Max(inCount, outCount));
            int    height     = 32 * (gridHeight + 1);
            int    yOffs      = -32 * ((gridHeight / 2) + 1);
            Bounds newBounds  = new Bounds(-96, yOffs, 96, height);

            ConnectionPoint[] newConns = new ConnectionPoint[inCount + outCount];
            int inOffs  = yOffs + 32 * (1 + (gridHeight - inCount) / 2);
            int outOffs = yOffs + 32 * (1 + (gridHeight - outCount) / 2);

            for (int i = 0; i < newConns.Length; i++)
            {
                if (i < inCount)
                {
                    newConns[i] = ConnectionPoint.newPassive(-96, inOffs + 32 * i);
                }
                else
                {
                    newConns[i] = ConnectionPoint.newPassive(0, outOffs + 32 * (i - inCount));
                }
            }
            bounds      = newBounds;
            connections = newConns;
            return(newConns);
        }
示例#2
0
 public Pin()
 {
     ShareOffsetBounds(new Bounds(-64, -32, 64, 64));
     this.Connections = new ConnectionPoint[] { ConnectionPoint.newPassive(0, 0) };
 }