Exemplo n.º 1
0
        /// <summary>
        /// Rewrites the console using the latest values in the Buffer and moves the cursor to the end of the line.
        /// </summary>
        /// <param name="newBuffer">The new line of text that will replace the current buffer.</param>
        public void ReplaceConsole(ConsoleString newBuffer)
        {
            this.Console.CursorLeft = this.ConsoleStartLeft;
            this.Console.CursorTop  = this.ConsoleStartTop;
            for (int i = 0; i < newBuffer.Length; i++)
            {
                this.Console.Write(newBuffer[i]);
            }

            var newLeft = this.Console.CursorLeft;
            var newTop  = this.Console.CursorTop;

            for (int i = 0; i < this.Buffer.Count - newBuffer.Length; i++)
            {
                this.Console.Write(" ");
            }

            this.Console.CursorTop  = newTop;
            this.Console.CursorLeft = newLeft;
            this.Buffer             = newBuffer.ToList();;
        }