/// <summary>
 /// Instantiates a new console GUI, creating a consoleRenderer and an array to hold the GUI elements.
 /// </summary>
 public ConsoleGUI()
 {
     consoleRenderer = new ConsoleRenderer(Console.WindowWidth, Console.WindowHeight);
     screen = new List<Element>(); //This list contains every element to be drawn to the screen. Elements are rendered in the order they're added to the list.
     numberOfElements = -1;
     activeElement = -1;
 }
 public override void DrawElement(ConsoleRenderer consoleRenderer)
 {
     if (border == BorderStyles.none) {
         //no border, just draw the log.
         WriteBuffer(0, consoleRenderer);
     }
     else {
         //Draw a border before writing the text.
         consoleRenderer.DrawBox(xPosition, yPosition, width, height, border);
         WriteBuffer(1, consoleRenderer);
     }
 }
            private void WriteBuffer(int borderOffset, ConsoleRenderer consoleRenderer)
            {
                int tempWidth = width - (borderOffset * 2);
                int tempHeight = height - (borderOffset * 2);
                int tempX = xPosition + borderOffset;
                int tempY = yPosition + borderOffset;

                int linesRemaining = tempHeight;
                int charsPerLine = tempWidth;
                for (int currentString = 0; currentString < bufferSize; currentString++) {
                    if (linesRemaining > 0) {
                        //For each line, calculate how many lines it will take up in the logbox.
                        int numberOfLines = (int)Math.Ceiling((double)buffer[currentString].Length / (double)charsPerLine);

                        if (numberOfLines < 2) {
                            //We only need to write one line; simple!
                            consoleRenderer.WriteString(tempX, tempY + (linesRemaining - 1), buffer[currentString]);
                            linesRemaining--;
                        }
                        else {
                            //This is where it gets awkward. We need to account for text wrapping.
                            //To do this we split up the string into several substrings that will fit in the Log Box.
                            string[] substringArray = new string[numberOfLines];
                            for (int c = 0; c < numberOfLines - 1; c++) {
                                substringArray[c] = buffer[currentString].Substring(c * charsPerLine, charsPerLine);
                            }
                            substringArray[numberOfLines - 1] = buffer[currentString].Substring((numberOfLines - 1) * charsPerLine);    //The last substring must go to the end of the string.

                            //Now, add each substring to the buffer and update the linesRemaining variable.
                            for (int c = numberOfLines - 1; c >= 0; c--) {
                                if (linesRemaining > 0) {
                                    consoleRenderer.WriteString(tempX, tempY + (linesRemaining - 1), substringArray[c]);
                                    linesRemaining--;
                                }
                            }
                        }
                    }
                }
            }
 public abstract void DrawElement(ConsoleRenderer consoleRenderer);