Changed a lot of Actions.cs and a few other things to be more easily
extendable.
This commit is contained in:
36
ColoredConsole.cs
Normal file
36
ColoredConsole.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
public static class ColoredConsole
|
||||
{
|
||||
public static void WriteLine(string text, ConsoleColor color)
|
||||
{
|
||||
ConsoleColor previousColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
Console.WriteLine(text);
|
||||
Console.ForegroundColor = previousColor;
|
||||
}
|
||||
|
||||
public static void Write(string text, ConsoleColor color)
|
||||
{
|
||||
ConsoleColor previousColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = color;
|
||||
Console.Write(text);
|
||||
Console.ForegroundColor = previousColor;
|
||||
}
|
||||
|
||||
public static string Prompt(string text)
|
||||
{
|
||||
try
|
||||
{
|
||||
ConsoleColor previousColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.Write($"{text}: ");
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
string input = Console.ReadLine() ?? "";
|
||||
Console.ForegroundColor = previousColor;
|
||||
return input;
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user