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
Related
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 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
I am using the Scintilla .NET text editor control (ScintillaNet.dll) to display SQL. I am using the following command to position the caret cursor at a given line number. In the example below, I am positioning the caret cursor at line 102 (0 based. The grid displays 1-based line numbers.)
scintilla1.GoTo.Line(102); //0 based
I'd like text in the viewport to be displayed at the top of the screen as shown below, as the first visible line
How can I identify how to do this?
Update
This looked promising:
scintilla1.Lines.FirstVisible.Number = targetLineNumber;
but after executing, scintilla1.Lines.FirstVisible.Number wasn't always equal to targetLineNumber and I don't know what is interfering with it.There are hundreds of lines following the targetLineNumber line.
Get/Set first visible line works for me https://www.scintilla.org/ScintillaDoc.html#SCI_SETFIRSTVISIBLELINE
You can keep the cursor position first (SCI_GOTOPOS) and then set the first visible line
I have generated a chart in asp.net c#, which gets user data from the database and display it. Now I want to add a line to it which can indicate the baseline set by the user. I think it might be a new series which will be drawn from start to end. It will be ideal if the user is able to change it and on changing the line is redrawn. I have dates on x-axis and activity time on y axis. In the following picture I want line like Goal. Any suggestions?
There are two ways I know which can be used to achieve this line.
One is by adding the tag but the line will appear under the bars.
If you want the line to appear above the bars then you need to add another series of type line chart. Make its x axis secondary and specify the values so that it appears as a straight line. Hide the lengends and labels etc for line chart.
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.