A library that gives functionality to the console (Progressbar, selection menu, acceptance field)
-
void Progressbar(int value, int min = 0, int max = 100, string information = "")
Shows a progressbarint value
- Progressbar valueint min
- Progressbar minimum value (default 0)int max
- Progressbar minimum value (default 100)string information
- Additional information (e.q. download speed)ArgumentOutOfRangeException
- The exception is returned when the progressbar value is outside its range (min < = value < = max)
-
int Selector(List<string> options, int selectedIndex = 0)
Shows a form with options to choose fromList<string> options
- List of options to choose fromint selectedIndex
- Currently selected option, no need to specify, needed for recursionReturn
- The index of the selected option
-
bool Acceptance(string text, bool approvalRequired = false)
Shows acceptable condition (Y/N)string text
- Acceptable conditionbool approvalRequired
- Whether the user must accept the terms to proceedReturn
- Whether the user has accepted the terms
-
void ClearLastLine()
Clears the last console line
using Console = ConsoleFeatures.Console;
System.Console.WriteLine("Progressbar");
Random rand = new();
for (var i = 0; i <= 100; i++)
{
var downloadSpeed = rand.NextInt64(1, 20);
Console.Progressbar(i, information: $"{downloadSpeed} Mb/s");
Thread.Sleep(100);
}
System.Console.Write("\n");
System.Console.WriteLine("Selector");
var options = new List<string>()
{
"First option",
"Second option",
"Third option"
};
var selectedOptionIndex = Console.Selector(options);
System.Console.WriteLine($"Selected option: {options[selectedOptionIndex]}");
System.Console.Write("\n");
System.Console.WriteLine("Acceptance");
var accepted = Console.Acceptance("Do you accept sth?");
System.Console.WriteLine(accepted.ToString());
System.Console.Write("\n");
Console.Acceptance("Do you accept sth? required", true);