-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColorConsole.cs
52 lines (44 loc) · 1.16 KB
/
ColorConsole.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using static System.Console;
namespace CryCompressor;
public static class ColorConsole
{
static void WriteDatetime()
{
ForegroundColor = ConsoleColor.DarkGray;
Write($"[{DateTime.Now:HH:mm:ss.ffff}] ");
}
public static void WriteInfo(string message)
{
WriteDatetime();
ResetColor();
WriteLine(message);
}
public static void WriteError(string message)
{
WriteDatetime();
ForegroundColor = ConsoleColor.Red;
WriteLine(message);
ResetColor();
}
public static void WriteUpdate(int total, int current)
{
var prg = (current / (double)total) * 100;
Write("\r");
WriteDatetime();
ResetColor();
Write($"Progress: ");
ForegroundColor = ConsoleColor.Cyan;
Write($"{prg:0.00}%");
ResetColor();
Write($" ({current}/{total})" + emptyLineShort);
}
readonly static string emptyLine = new string(' ', 50);
readonly static string emptyLineShort = new string(' ', 7);
public static void WriteEmpty()
{
Write("\r");
Write(emptyLine);
ResetColor();
}
}