-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleColors.cs
More file actions
45 lines (45 loc) · 1.23 KB
/
ConsoleColors.cs
File metadata and controls
45 lines (45 loc) · 1.23 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
using System;
namespace AdvancedConsole
{
public class ConsoleColors
{
private ConsoleColor m_fore;
private ConsoleColor m_back;
public ConsoleColors(ConsoleColor fore, ConsoleColor back)
{
m_fore = fore;
m_back = back;
}
public ConsoleColors(ConsoleColor fore)
{
m_fore = fore;
m_back = Console.BackgroundColor;
}
public ConsoleColors()
{
m_fore = Console.ForegroundColor;
m_back = Console.BackgroundColor;
}
public void Apply()
{
Console.ForegroundColor = m_fore;
Console.BackgroundColor = m_back;
}
public void ApplyBackgroundColor()
{
Console.BackgroundColor = m_back;
}
public void ApplyForegroundCOlor()
{
Console.ForegroundColor = m_fore;
}
public static ConsoleColors InitWithBackgroundColor(ConsoleColor back)
{
return new ConsoleColors(Console.ForegroundColor, back);
}
public static ConsoleColors InitWithForegroundColor(ConsoleColor fore)
{
return new ConsoleColors(fore);
}
}
}