Exemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Puts character at some position, optionally joining it with underlying
        /// box characters if it itself is a box character.
        /// </summary>
        ///
        public void PutBox(int x, int y, char character, BoxLines join)
        {
            x += this.offset.X;
            y += this.offset.Y;

            if (x < this.clipStart.X || x >= this.clipEnd.X)
            {
                return;
            }
            if (y < this.clipStart.Y || y >= this.clipEnd.Y)
            {
                return;
            }

            IsRowDirty[y] = true;

            if (join == BoxLines.Joined &&
                Box.IsPrivateUnicode(Area[y, x].Character))
            {
                int box1 = Box.GetBoxBits(Area[y, x].Character);
                int box2 = Box.GetBoxBits(character);

                Area[y, x].Character = Box.GetAsPrivateUnicode(box1 | box2);
                Area[y, x].ForeColor = Screen.ForeColor;
                Area[y, x].BackColor = Screen.BackColor;
            }
            else
            {
                Area[y, x].Character = character;
                Area[y, x].ForeColor = Screen.ForeColor;
                Area[y, x].BackColor = Screen.BackColor;
            }
        }
Exemplo n.º 2
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Draws frame (rectangle) in the buffer.
        /// </summary>
        ///
        public void DrawFrame(
            int left, int top, int width, int height,
            BoxLines connect = BoxLines.NotJoined
            )
        {
            if (Buffer != null)
            {
                Buffer.DrawRectangle(left, top, width, height, connect);
                Invalidate();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws a vertical line. Private method.
        /// </summary>
        ///
        private void DrawVertical(int left, int top, int height,
                                  BoxLines connect = BoxLines.NotJoined)
        {
            for (int i = 0; i < height; ++i)
            {
                char boxElement = i == 0          ? Box._sDss
                                : i == height - 1 ? Box._Usss
                                                  : Box._UDss;

                Buffer.PutBox(left, top + i, boxElement, connect);
            }
        }
Exemplo n.º 4
0
        /////////////////////////////////////////////////////////////////////////////////

        #region [ Private Methods used by DrawRectangle ]

        /// <summary>
        /// Draws a horizontal line. Private method.
        /// </summary>
        ///
        private void DrawHorizontal(int left, int top, int width,
                                    BoxLines connect = BoxLines.NotJoined)
        {
            for (int i = 0; i < width; ++i)
            {
                char boxElement = i == 0         ? Box._sssR
                                : i == width - 1 ? Box._ssLs
                                                 : Box._ssLR;

                Buffer.PutBox(left + i, top, boxElement, connect);
            }
        }
Exemplo n.º 5
0
        /////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Draws a rectangle, which edges may be optionally joined (connected
        /// when crossing) with existing lines in the screen buffer.
        /// </summary>
        ///
        public void DrawRectangle(
            int left, int top, int width, int height,
            BoxLines connect = BoxLines.NotJoined
            )
        {
            if (height == 1 && width == 1)
            {
                Buffer.Put(left, top, Box.Rectangle);
            }
            else if (height == 1)
            {
                DrawHorizontal(left, top, width, connect);
            }
            else if (width == 1)
            {
                DrawVertical(left, top, height, connect);
            }
            else if (connect == BoxLines.Joined)
            {
                // Draw top & bottom horizontal edge
                //
                DrawHorizontal(left, top, width, connect);
                DrawHorizontal(left, top + height - 1, width, connect);

                // Draw left & right vertical edge
                //
                DrawVertical(left, top, height, connect);
                DrawVertical(left + width - 1, top, height, connect);
            }
            else
            {
                // Draw top & left edges
                //
                Put(left, top, Box._sDsR);
                Put(left, top + height - 1, Box._UssR);

                DrawHorizontal(left + 1, top, width - 2);
                DrawVertical(left, top + 1, height - 2);

                // Draw bottom & right edges
                //
                Put(left + width - 1, top + height - 1, Box._UsLs);
                Put(left + width - 1, top, Box._sDLs);
                DrawHorizontal(left + 1, top + height - 1, width - 2);
                DrawVertical(left + width - 1, top + 1, height - 2);
            }
        }
Exemplo n.º 6
0
        public BoxLines[] FitOntoBoxes(string[] lines)
        {
            List <BoxLines> boxes = new List <BoxLines>();

            BoxLines workingBox = new BoxLines();

            foreach (string line in lines)
            {
                string workingLine = line;

                if (workingLine.Length > 1)
                {
                    if (workingLine.Last() == SEGMENT_SEPERATOR)
                    {
                        workingLine = workingLine.Substring(0, workingLine.Length - 1);
                    }

                    if (workingLine.Last() != CHOSEN_NEWLINE)
                    {
                        workingLine = workingLine + CHOSEN_NEWLINE;
                    }
                }

                if (workingBox.IsFull)
                {
                    boxes.Add(workingBox);
                    workingBox = new BoxLines();
                }

                if (workingBox.TotalSize + workingLine.Length > BOX_MAX_LENGTH)
                {
                    boxes.Add(workingBox);
                    workingBox = new BoxLines();
                }

                workingBox.AddLine(workingLine);
            }

            if (!workingBox.IsEmpty)
            {
                boxes.Add(workingBox);
            }

            return(boxes.ToArray());
        }