Reputation: 39
Back in the day when I learned programming in school we used Pascal to learn basic concepts. Now, using C#, I am trying to solve something I thought was basic, but I cannot find a solution.
What I am after is having multiple "windows" in the console that I can write output to and they scroll inside these "virtual windows" or "areas" individually without affecting the others. I also want an input line for commands, but I think that is easier to achieve.
An example could be for instance an IRC chat where I have one area for the chat, one area for the online users and one line for input.
Is there any other way than creating a class that keep track of all the "areas" and do a lot of SetCursorPosition()??? Isn't there anything built-in to .net for this?
Upvotes: 0
Views: 206
Reputation: 26446
Even though the Console
allows you to set a cursor position, the interface is designed towards being able to "dump and forget" output. Your user interface probably breaks when someone resizes the console.
However in a Windows Forms application, you can easily get an IRC-like interface by:
SplitContainer
, where "panel2" can be used for usersSplitContainer
in "panel1", set Oritentation
to Horizontal
ListBox
controls to the top and right panels, set Dock
to Fill
TextBox
control to the bottom panel, and perhaps a Button
with its Text
set to "Send"This should already be pretty close to where you want to be:
You can also play around with WPF if you don't like the typical WinForms controls, but the idea is the same.
Upvotes: 3