I need help making something that is always on top of the console application.
The problem is that I don't know how to restore the cursor position to the bottom to write normal text.
For example, imagine a screen...
\[This text is always here!!!]
hello
hello
...
Wassup?
Something like the green part that steam uses:
Use Console.CursorTop and Console.CursorLeft properties.
https://msdn.microsoft.com/en-us/library/system.console.cursortop.aspx
https://msdn.microsoft.com/en-us/library/system.console.cursorleft.aspx
Related
I have already managed to remove the cursor itself with Console.CursorVisible = false;. However, the line that the cursor exists in still takes up space at the bottom of my program. In other words, I would like to print to my console so that it fills the entire console screen. Here's an image of how it currently looks, with the bottom row not getting filled.
Can you show what you're doing to fill up the space? The solution may just be as simple as using Console.Write() instead of Console.WriteLine() so that it doesn't automatically make a new line, which in turn shouldn't create that empty line at the bottom
I'm learning how to code C# from scratch. Right now, I'm learning how to build a scene on the command line and update it as necessary.
Part of what i want to do is to "scroll text as it is generated".
The scene is a square command line (Size 100 by 40) and outlined by a box of "#" characters. This is the canvas on which everything is presented.
As the user interacts via simple inputs, the program will provide textual feedback, like a text-based game.
However, unlike a normal text-based game, I cannot allow for the natural flow of the command line to move the canvas. In other words, if I allow for the command line to act naturally, then the canvas would slowly travel upwards until it's no longer visible.
I need a way to read whatever is already being presented on the screen and storing it on memory. Then, I can delete a portion of the screen an paste the previously copied information shifted upwards, making space for new information.
Here is a mockup of what I want to do:
Image 1: desirable outcome
My question is: Is there a way to "read" only a specific portion of the command space and store into memory?
I know you can store whatever is being printed at the moment of printing, or I could keep track of a certain number of previously displayed information and print it again, but I would like to "copy, then paste shifted" a portion of the screen.
PS: This is what I'm trying to avoid
Image 2: Undesirable outcome
Since the top line needs to be moved too, really the only way to do this is to clear the screen and redraw everything. Instead of printing directly to the screen, save the new line to a list, clear the screen, then print that list to the screen, together with the border.
While I haven't found a way to store a portion of the command line to a variable for later use, I've succesfully "scrolled" the text, and found a workaround to "store" it.
Simply put, Console.MoveBufferArea() allows one to select a portion of the command line buffer and move it somewhere else on the buffer.
This way I can:
-Clear whatever space i need at the top by moving the cursor to, say, (1,1) and writing a box of spaces via a string.
-Console.MoveBofferArea() the portion of the buffer a few rows upwards
-Write the new text at the bottom
As a byproduct, i can also "store" a portion of the screen for late use by:
-Setting the buffer to a wider area with Console.SetBufferSize()
-Use Console.MoveBufferArea() to the buffer portion that is outside of normal view
-Do whatever i need to do on the screen
-Use Console.MoveBufferArea() to retrieve the "stored" portion back to where i need it
-Reduce the buffer area (I could also just leave it be)
I have some text printed in my C# console (Lots of it) and I am wondering what would be the simplest way to change the text color all at once without clearing the console and reprinting it in the new color, sort of having the same effect as System(color ##) command in C++...Thanks in advance.
You can change the console output color using Console.BackgroundColor and Console.ForegroundColor properties. After you are done writing in the new color, use Console.ResetColor() to go back to defaults.
Changing the colors after the fact is a problem, because C# has no direct way to read text at a given position.You can rewrite it however, if you know what exactly is there, in a different color (first jumping to the location using Console.SetCursorPosition method and then writing over the original text).
If you want to be as efficient as possible, you will need a higher caliber in form of some P/Invoke wizadry. This is quite well described in the accepted answer to this similar question. The solution there takes advantage of writing the entire Console buffer at once, which is very fast.
I working a project with wpf in c#.. I want to use chart tools for graphics on the picture. Yellow line is reference position for purple (Actual) line. When Actual line touch reference line or when it cross the yellow line then I have to mark this touch point.(You can see an exmp. on picture). Of course same time I have to any action in programs.
How Can I do it with best easy way?
Can I do it with C# WPF or another question I use which editor program for this chart?
Thank you.
I'm using in my winform project a RichTextBox control to display a kind of old console screen.
This works perfectly but there is a space between the lines.
Is it possible to change this space to be 0 or anything near that.
If i paint a line from vetical line from line 1 to line 5 i don't want any spacing between the line.
Hope you can help me.
There's actually a lot that the Windows Forms RichTextBox doesn't expose. If you have the HWND (Handle property) to the control, you can use the SendMessage API to send the EM_SETPARAFORMAT message to play with the formatting.
In particular the PARAFORMAT2 structure does have some line spacing options that may be relevant. You will have to get your hands dirty with interop though.