-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorConsole.cs
More file actions
53 lines (46 loc) · 1.54 KB
/
ColorConsole.cs
File metadata and controls
53 lines (46 loc) · 1.54 KB
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
53
using System;
namespace WiFiManager
{
public static class ColorConsole
{
public static void WriteHeader(string text)
{
var originalColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(new string('=', text.Length + 4));
Console.WriteLine($" {text} ");
Console.WriteLine(new string('=', text.Length + 4));
Console.ForegroundColor = originalColor;
}
public static void WriteSuccess(string text)
{
WriteColored(text, ConsoleColor.Green);
}
public static void WriteError(string text)
{
WriteColored(text, ConsoleColor.Red);
}
public static void WriteWarning(string text)
{
WriteColored(text, ConsoleColor.Yellow);
}
public static void WriteInfo(string text)
{
WriteColored(text, ConsoleColor.Cyan);
}
public static void WriteColored(string text, ConsoleColor color)
{
var originalColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.Write(text);
Console.ForegroundColor = originalColor;
}
public static void WriteColoredLine(string text, ConsoleColor color)
{
var originalColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(text);
Console.ForegroundColor = originalColor;
}
}
}