Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Source/ConsoleDraw/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,29 @@ namespace ConsoleDraw
{
public static class WindowManager
{
public static void DrawColourBlock(ConsoleColor colour, int startX, int startY, int endX, int endY)

public static void DrawColourBlock(ConsoleColor colour, int startX, int startY, int endX, int endY,bool restoreSetting = true)
{
Console.BackgroundColor = colour;
ConsoleColor oldcolor = Console.BackgroundColor;
int oldX = Console.CursorLeft;
int oldy = Console.CursorTop;

Console.BackgroundColor = colour;

for (var i = startX; i < endX; i++)
{
Console.CursorLeft = startY;
Console.CursorTop = i;

Console.WriteLine("".PadLeft(endY - startY));
}

if(restoreSetting)
{
Console.BackgroundColor = oldcolor;
Console.CursorLeft = oldX;
Console.CursorTop = oldy;
}
}

public static void WirteText(String text, int startX, int startY, ConsoleColor textColour, ConsoleColor backgroundColour)
Expand Down
3 changes: 3 additions & 0 deletions Source/InlineTestApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static void Main(string[] args)
Console.WriteLine();
Console.WriteLine();

WindowManager.DrawColourBlock(ConsoleColor.Red, 15, 20, 20, 25);


for (var i = 0; i < 2; i++ )
Console.WriteLine(i.ToString());

Expand Down