namespace Xorog.UniversalExtensions;
public static class StringTools
{
///
/// Generate an ASCII Progressbar
///
/// The current progress
/// The maximum progress
/// How long the ASCII Progressbar should be (default: 44)
/// What character the filled part should be (default: █)
/// What character the not-filled part should be (default: ∙)
/// What character the start-part should be (default: [)
/// What character the end-part part should be (default: ])
/// A progressbar
public static string GenerateASCIIProgressbar(double current, double max, int charlength = 44, char fill = '█', char empty = '∙', char start = '[', char end = ']')
{
long first = (long)Math.Round((current / max) * charlength, 0);
long second = charlength - first;
string mediadisplay = start.ToString();
for (long i = 0; i < first; i++)
mediadisplay += fill;
for (long i = 0; i < second; i++)
mediadisplay += empty;
mediadisplay += end;
return mediadisplay;
}
}