System.Console is no longer used only for Reading and Writing operations. It has some interesting things to do with your console window. You can customize your output console window in many aspects such as setting background and foreground colors, resizing the window, positioning the cursor, keyboard reading etc.
Put this code in the Main function of your console application and run it.
Console.WindowHeight = Console.LargestWindowHeight; Console.WindowWidth = Console.LargestWindowWidth; Console.BufferHeight = Console.LargestWindowHeight; Console.BufferWidth = Console.LargestWindowWidth; Console.ForegroundColor = ConsoleColor.Red; Console.BackgroundColor = ConsoleColor.Yellow;
System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
Console.OutputEncoding = ue; Console.Title = "My Customized Console Window";
System.Console.SetCursorPosition(30, 10);
Console.WriteLine("Welcome to console Operations");
System.Console.SetCursorPosition(20, 15);
Console.Write("Enter your Name: "); Console.BackgroundColor = ConsoleColor.Gray; Console.ReadLine(); Console.BackgroundColor = ConsoleColor.Yellow; Console.WriteLine("Press Esc to resize the console window..."); Console.WriteLine("Press F1 to put your name on top!"); ConsoleKeyInfo ki = Console.ReadKey(true);
if (ki.Key == ConsoleKey.Escape) Console.SetWindowSize(10, 10); else if (ki.Key == ConsoleKey.F1) Console.MoveBufferArea(37, 15, 25, 1, 40, 1);
|
No responses found. Be the first to respond and make money from revenue sharing program.
|