wasSharpNET

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 11  →  ?path2? @ 12
/Console/ConsoleExtensions.cs
@@ -39,6 +39,11 @@
System.Console.ForegroundColor = cFG;
}
 
public static void WriteLine(this object data)
{
System.Console.WriteLine(data);
}
 
public static void Write(this object data, ConsoleColor foreground,
ConsoleColor background)
{
@@ -51,6 +56,14 @@
System.Console.BackgroundColor = cBG;
}
 
public static void Write(this object data, ConsoleColor foreground)
{
var cFG = System.Console.ForegroundColor;
System.Console.ForegroundColor = foreground;
System.Console.Write(data);
System.Console.ForegroundColor = cFG;
}
 
public static void WriteLine(this object data, ConsoleTextAlignment alignment)
{
switch (alignment)
@@ -57,7 +70,7 @@
{
case ConsoleTextAlignment.TOP_CENTER:
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0);
WriteLine(data, System.Console.ForegroundColor, System.Console.BackgroundColor);
System.Console.WriteLine(data);
break;
 
default:
@@ -71,9 +84,13 @@
{
case ConsoleTextAlignment.TOP_CENTER:
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0);
WriteLine(data, foregroundColor, System.Console.BackgroundColor);
WriteLine(data, foregroundColor);
break;
 
case ConsoleTextAlignment.TOP_LEFT:
WriteLine(data, foregroundColor);
break;
 
default:
throw new NotImplementedException();
}
@@ -85,9 +102,13 @@
{
case ConsoleTextAlignment.TOP_CENTER:
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0);
Write(data, System.Console.ForegroundColor, System.Console.BackgroundColor);
System.Console.Write(data);
break;
 
case ConsoleTextAlignment.TOP_LEFT:
System.Console.Write(data);
break;
 
default:
throw new NotImplementedException();
}
@@ -103,10 +124,17 @@
foreach (var line in data)
{
System.Console.CursorLeft = padding;
WriteLine(line, System.Console.ForegroundColor, System.Console.BackgroundColor);
WriteLine(line, System.Console.ForegroundColor);
}
break;
 
case ConsoleTextAlignment.TOP_LEFT:
foreach (var line in data)
{
WriteLine(line, System.Console.ForegroundColor);
}
break;
 
default:
throw new NotImplementedException();
}