how to divide console screen in four parts and each part work separately using C# [duplicate]
开发者_开发百科Possible Duplicate:
split a console in two parts for two outputs
I want to divide my console screen in four part and each part work separately, I think in this we use thread but I am not getting how to use?
You can't just divide the console, but you have enough control over it to do it yourself.
See Console class reference. You can SetCursorPosition
, set window position and size. Make your own method - something like WriteToArea(int area, string text). Track bounds of areas and wrap text to stay inside of area. Each area must have its own cursor position, track it too. And think how you will handle area overflow (or you need just four columns?)
Edit: I'm not going to give you fish, but here is your fishing rod ^_^
- Get dimensions of console window (Console.WindowWidth) in columns
- Divide that by four to get each area's width and calculate start and end column of each area. For example, if your console is 80 columns wide, you should get [0, 19], [20, 39], [40, 59], [60, 79] - these pairs are bounds of each area.
- Next, store cursor position for each area (initially that would be [left bound, 0])
- Implement method writeToArea(int area, String text):void. That's the hardest part. First, you
SetCursorPosition
into stored position for that area. Next, break text into parts that fit into area. Take into account how much space is left on current column. Write text with series ofConsole.Write
, line by line. Then update cursor position for that area [CursorLeft
,CursorTop
]. - Write, debug and have fun!
Well, theres libraries for this sort of thing. But you can't just split up the console window.
If you want more information about the library, check it out at sourceforge.
精彩评论