C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to add rich user experience by customizing your Console Window?


Posted Date: 24 Feb 2007    Resource Type: Code Snippets    Category: Console Applications

Posted By: Balamurali Balaji       Member Level: Diamond
Rating:     Points: 10



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);




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Previous Resource: Quick Console Utility to hide itself and do activities in the background
Return to Discussion Resource Index
Post New Resource
Category: Console Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

masks masks masks

Contact Us    Privacy Policy    Terms Of Use