.NET Console Applications, possible to create labels and regions?
c#
Solution
Yes, you can do this.
You can use Console.SetCursorPosition to reposition the cursor after writing.
For example:
Console.WriteLine("Starting algorithm...");
int line = Console.CursorTop;
for (int i=0;i<100;++i)
{
Console.SetCursorPosition(0,line);
Console.Write("Progress is {0}% ",i); // Pad with spaces to make sure we cover old text
Thread.Sleep(100);
}
Console.SetCursorPosition(0,line);
Console.WriteLine("Algorithm Complete. "); // Pad with spaces to make sure we cover old text
Problem
Is it possible to have a C# console application output text to labels already drawn? I've seen some native win 32 console apps that can do this. So onscreen the user sees: Progress: 1% or Progress: 50% depending on when the label is updated (and the label progress stays in the same place, while only the value of the progress percentage gets updated. Rather than the only way I know how to do it currently which is console.writeLine which would produce a seperate line for each Progress update. EG: Progress: 1% Progress: 2%