wasSharpNET
/Console/ConsoleExtensions.cs |
@@ -69,8 +69,7 @@ |
switch (alignment) |
{ |
case ConsoleTextAlignment.TOP_CENTER: |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, |
0); |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
System.Console.WriteLine(data); |
break; |
|
@@ -84,8 +83,7 @@ |
switch (alignment) |
{ |
case ConsoleTextAlignment.TOP_CENTER: |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, |
0); |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
WriteLine(data, foregroundColor); |
break; |
|
@@ -103,8 +101,7 @@ |
switch (alignment) |
{ |
case ConsoleTextAlignment.TOP_CENTER: |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, |
0); |
System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
System.Console.Write(data); |
break; |
|
@@ -124,8 +121,7 @@ |
case ConsoleTextAlignment.TOP_CENTER: |
var enumerable = data as IList<object> ?? data.ToList(); |
var textBlock = enumerable.Select(o => o.ToString()).ToArray(); |
var padding = Math.Max(System.Console.WindowWidth / 2 - textBlock.Select(o => o.Length).Max() / 2, |
0); |
var padding = Math.Max(System.Console.WindowWidth / 2 - textBlock.Select(o => o.Length).Max() / 2, 0); |
foreach (var line in enumerable) |
{ |
System.Console.CursorLeft = padding; |
@@ -135,7 +131,9 @@ |
|
case ConsoleTextAlignment.TOP_LEFT: |
foreach (var line in data) |
{ |
WriteLine(line, System.Console.ForegroundColor); |
} |
break; |
|
default: |
@@ -143,4 +141,4 @@ |
} |
} |
} |
} |
} |
/Console/ConsoleSpin.cs |
@@ -19,7 +19,7 @@ |
public class ConsoleSpin : IDisposable |
{ |
private static readonly CircularQueue<string> spinArt = |
new CircularQueue<string>(new[] {".oOo", "oOo.", "Oo.o", "o.oO"}); |
new CircularQueue<string>(new[] { ".oOo", "oOo.", "Oo.o", "o.oO" }); |
|
private static readonly ManualResetEvent spinEvent = new ManualResetEvent(false); |
private static Thread spinThread; |
@@ -59,8 +59,8 @@ |
{ |
run = false; |
spinEvent.Reset(); |
if (!spinThread.ThreadState.Equals(ThreadState.Running) && |
!spinThread.ThreadState.Equals(ThreadState.WaitSleepJoin) || spinThread.Join(1000)) |
if ((!spinThread.ThreadState.Equals(ThreadState.Running) && |
!spinThread.ThreadState.Equals(ThreadState.WaitSleepJoin)) || spinThread.Join(1000)) |
return; |
spinThread.Abort(); |
spinThread.Join(); |
@@ -86,4 +86,4 @@ |
spinEvent.Reset(); |
} |
} |
} |
} |