-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInfoBorder.cs
98 lines (87 loc) · 2.8 KB
/
InfoBorder.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
namespace Roguelike
{
class InfoBorder : Rectangle
{
private string[] Info;
private int Index = 0;
public InfoBorder() { }
public InfoBorder(int width, int height, Point location) : base(width, height, location)
{
Info = new string[height - 2];
}
public InfoBorder(int width, int height, int x, int y) : base(width, height, x, y)
{
Info = new string[height - 2];
}
public void Clear()
{
if (Info == null)
Info = new string[Height - 2];
Index = 0;
for (int i = 0; i < Info.Length; i++)
Info[i] = null;
for (int i = 0; i < Height - 2; i++)
{
ClearLine(i);
}
}
public void ClearAndWrite(string line)
{
Clear();
WriteLine(line);
Info[Index] = line;
Index++;
}
public void WriteNextLine(string line)
{
if (Info == null)
Info = new string[Height - 2];
if (Index < Height - 2)
{
Info[Index] = line;
ClearLineAndWrite(line, Index);
Index++;
}
else
{
for (int i = 0; i < Info.Length - 1; i++)
{
Info[i] = Info[i + 1];
ClearLineAndWrite(Info[i], i);
}
ClearLineAndWrite(line, Index - 1);
Info[Index - 1] = line;
}
}
public void ClearLine(int number = 0)
{
Console.SetCursorPosition(Offset.X, Offset.Y + number);
Console.Write(new string(' ', Width - 2));
}
public void WriteLine(string line, int number = 0)
{
Console.SetCursorPosition(Offset.X, Offset.Y + number);
Console.Write(line);
}
public void WriteLine(string line, ConsoleColor color, int numOfSymb, int number = 0)
{
Console.SetCursorPosition(Offset.X, Offset.Y + number);
Console.Write(line.Substring(0, numOfSymb));
Console.ForegroundColor = color;
Console.SetCursorPosition(Offset.X + numOfSymb, Offset.Y + number);
Console.Write(line.Substring(numOfSymb));
Console.ForegroundColor = ConsoleColor.White;
}
public void ClearLineAndWrite(string line, int number = 0)
{
ClearLine(number);
WriteLine(line, number);
}
public void ClearLineAndWrite(string line, ConsoleColor color, int numOfSymbol, int number = 0)
{
ClearLine(number);
WriteLine(line, color, numOfSymbol, number);
}
}
}