@@ -8,6 +8,7 @@ namespace Station
8
8
{
9
9
class Program
10
10
{
11
+ public static bool inputOn = false ;
11
12
/// <summary>
12
13
/// Only one thread can print at a time
13
14
/// This can prevent potential interleaving output from different threads and buggies
@@ -28,8 +29,9 @@ class Program
28
29
29
30
static void Main ( string [ ] args )
30
31
{
31
- Console . WriteLine ( "Initialising..." ) ;
32
+ print ( "Initialising..." , ConsoleColor . DarkYellow ) ;
32
33
Station station = new Station ( ) ;
34
+ inputOn = true ;
33
35
while ( true )
34
36
{
35
37
string input = readInput ( ) ;
@@ -38,7 +40,9 @@ static void Main(string[] args)
38
40
Environment . Exit ( 0 ) ;
39
41
if ( input == "RESET" )
40
42
{
43
+ inputOn = false ;
41
44
station . setUp ( ) ;
45
+ inputOn = true ;
42
46
continue ;
43
47
}
44
48
@@ -105,6 +109,8 @@ private static bool executeCommand(Station station, string command, int buggyID)
105
109
/// </summary>
106
110
private static void printInput ( )
107
111
{
112
+ if ( ! inputOn )
113
+ return ;
108
114
clearInput ( ) ;
109
115
lock ( printLock )
110
116
{
@@ -213,16 +219,20 @@ public static void print(string message)
213
219
/// Prints <c>message</c> with the specified background colour.
214
220
/// Adds newline and redraws the input buffer
215
221
/// </summary>
216
- public static void print ( string message , ConsoleColor ? backgroundColor )
222
+ public static void print ( string message ,
223
+ ConsoleColor ? backgroundColour ,
224
+ ConsoleColor ? foregroundColour = ConsoleColor . Gray )
217
225
{
218
226
lock ( printLock )
219
227
{
220
228
clearInput ( ) ;
221
229
Console . CursorLeft = 0 ;
222
- Console . BackgroundColor = backgroundColor ?? emptyColour ;
230
+ Console . BackgroundColor = backgroundColour ?? emptyColour ;
231
+ Console . ForegroundColor = foregroundColour ?? ConsoleColor . Gray ;
223
232
Console . WriteLine ( message ) ;
224
233
printInput ( ) ;
225
234
Console . BackgroundColor = emptyColour ;
235
+ Console . ForegroundColor = ConsoleColor . Gray ;
226
236
}
227
237
}
228
238
}
0 commit comments