/// <summary> /// Draws only the changes to the screen /// </summary> private void DrawChanges() { // // save old values so we can restore // int oldCursorLeft = Console.CursorLeft; int oldCursorTop = Console.CursorTop; Console.CursorVisible = false; ConsoleColor currentForeground = Console.ForegroundColor; ConsoleColor currentBackground = Console.BackgroundColor; foreach (Window.Point change in handler.GetChanges()) { // get char and color at this coordinate // Window.CharacterData thisConsoleData = handler.GetConsoleDataAt(change.x, change.y); // // only set the console color if it has changed // if (thisConsoleData.foreground != currentForeground) { Console.ForegroundColor = thisConsoleData.foreground; currentForeground = thisConsoleData.foreground; } if (thisConsoleData.background != currentBackground) { Console.BackgroundColor = thisConsoleData.background; currentBackground = thisConsoleData.background; } // // write the character // Console.SetCursorPosition(change.x, change.y); Console.Write(thisConsoleData.character); } // // restore old values // Console.SetCursorPosition(oldCursorLeft, oldCursorTop); Console.CursorVisible = true; }
/// <summary> /// Writes all of the characters to the screen /// </summary> private void DrawEntireScreen() { ConsoleColor currentForeground = ConsoleColor.White; ConsoleColor currentBackground = ConsoleColor.Black; for (int y = 0; y < SCREENHEIGHT; y++) { for (int x = 0; x < SCREENWIDTH; x++) { // // get char and color at this coordinate // Window.CharacterData thisConsoleData = handler.GetConsoleDataAt(x, y); // // only set the console color if it has changed // if (thisConsoleData.foreground != currentForeground) { Console.ForegroundColor = thisConsoleData.foreground; currentForeground = thisConsoleData.foreground; } if (thisConsoleData.background != currentBackground) { Console.BackgroundColor = thisConsoleData.background; currentBackground = thisConsoleData.background; } // // write the character // Console.Write(thisConsoleData.character); } Console.WriteLine(); } }