Пример #1
0
        protected void AddBitCells(int bits)
        {
            if (bits == 0)
            {
                return;
            }

            int     offsetX         = (bits - 1) * 25;
            int     centerY         = Center.Y;
            BitCell previousBitCell = null;
            BitCell nextBitCell     = null;

            for (int i = 0; i < bits; i++)
            {
                int bitNumber = bits - i - 1;
                int centerX   = Center.X - offsetX + i * 50;

                nextBitCell = new BitCell(centerX, centerY, bitNumber);
                allBitCells.AddLast(nextBitCell);

                if (previousBitCell != null)
                {
                    Dataline connectorLine = new Dataline(previousBitCell, nextBitCell);
                }

                previousBitCell = nextBitCell;
            }
        }
Пример #2
0
        protected void AddIOLines(Point center, int bits)
        {
            Size size   = GetSize();
            int  width  = size.Width;
            int  height = size.Height;

            int inputX = center.X - width / 2 - 15;
            int inputY = center.Y + 40;

            if (bits == 0)
            {
                inputY = center.Y + height / 4;
            }

            this.InputPoint = new Point(inputX, inputY);
            this.inputGate  = new Gate(InputPoint);
            //this.inputGate.SetIsOpen(false);    // testing

            int   outputX     = inputX + width + 30;
            int   outputY     = inputY;
            Point outputPoint = new Point(outputX, outputY);

            this.Output = new OutputConnection(outputPoint);

            this.outputGate = new Gate(outputPoint);
            this.outputGate.SetIsOpen(false);

            //Connector nextConnector = this.Output.GetNextConnector();
            //this.outputGate.ConnectTo(nextConnector);

            Dataline lineFromInput;

            if (bits == 0)
            {
                lineFromInput = new Dataline(this.inputGate, this.outputGate);
                //lineFromInput.ConnectTo(this.Output.Branches);
                return;
            }

            BitCell firstBitCell = allBitCells.ElementAt(0);

            lineFromInput = new Dataline(this.inputGate, firstBitCell);

            BitCell  lastBitCell  = allBitCells.ElementAt(allBitCells.Count - 1);
            Dataline lineToOutput = new Dataline(lastBitCell, this.outputGate);
        }