wasSharpNET – Diff between revs 11 and 12
?pathlinks?
Rev 11 | Rev 12 | |||
---|---|---|---|---|
Line 37... | Line 37... | |||
37 | System.Console.ForegroundColor = foreground; |
37 | System.Console.ForegroundColor = foreground; |
|
38 | System.Console.WriteLine(data); |
38 | System.Console.WriteLine(data); |
|
39 | System.Console.ForegroundColor = cFG; |
39 | System.Console.ForegroundColor = cFG; |
|
40 | } |
40 | } |
|
Line -... | Line 41... | |||
- | 41 | |
||
- | 42 | public static void WriteLine(this object data) |
||
- | 43 | { |
||
- | 44 | System.Console.WriteLine(data); |
||
- | 45 | } |
||
41 | |
46 | |
|
42 | public static void Write(this object data, ConsoleColor foreground, |
47 | public static void Write(this object data, ConsoleColor foreground, |
|
43 | ConsoleColor background) |
48 | ConsoleColor background) |
|
44 | { |
49 | { |
|
45 | var cFG = System.Console.ForegroundColor; |
50 | var cFG = System.Console.ForegroundColor; |
|
Line 49... | Line 54... | |||
49 | System.Console.Write(data); |
54 | System.Console.Write(data); |
|
50 | System.Console.ForegroundColor = cFG; |
55 | System.Console.ForegroundColor = cFG; |
|
51 | System.Console.BackgroundColor = cBG; |
56 | System.Console.BackgroundColor = cBG; |
|
52 | } |
57 | } |
|
Line -... | Line 58... | |||
- | 58 | |
||
- | 59 | public static void Write(this object data, ConsoleColor foreground) |
||
- | 60 | { |
||
- | 61 | var cFG = System.Console.ForegroundColor; |
||
- | 62 | System.Console.ForegroundColor = foreground; |
||
- | 63 | System.Console.Write(data); |
||
- | 64 | System.Console.ForegroundColor = cFG; |
||
- | 65 | } |
||
53 | |
66 | |
|
54 | public static void WriteLine(this object data, ConsoleTextAlignment alignment) |
67 | public static void WriteLine(this object data, ConsoleTextAlignment alignment) |
|
55 | { |
68 | { |
|
56 | switch (alignment) |
69 | switch (alignment) |
|
57 | { |
70 | { |
|
58 | case ConsoleTextAlignment.TOP_CENTER: |
71 | case ConsoleTextAlignment.TOP_CENTER: |
|
59 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
72 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
60 | WriteLine(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
73 | System.Console.WriteLine(data); |
|
Line 61... | Line 74... | |||
61 | break; |
74 | break; |
|
62 | |
75 | |
|
63 | default: |
76 | default: |
|
Line 69... | Line 82... | |||
69 | { |
82 | { |
|
70 | switch (alignment) |
83 | switch (alignment) |
|
71 | { |
84 | { |
|
72 | case ConsoleTextAlignment.TOP_CENTER: |
85 | case ConsoleTextAlignment.TOP_CENTER: |
|
73 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
86 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
- | 87 | WriteLine(data, foregroundColor); |
||
- | 88 | break; |
||
- | 89 | |
||
- | 90 | case ConsoleTextAlignment.TOP_LEFT: |
||
74 | WriteLine(data, foregroundColor, System.Console.BackgroundColor); |
91 | WriteLine(data, foregroundColor); |
|
75 | break; |
92 | break; |
|
Line 76... | Line 93... | |||
76 | |
93 | |
|
77 | default: |
94 | default: |
|
78 | throw new NotImplementedException(); |
95 | throw new NotImplementedException(); |
|
Line 83... | Line 100... | |||
83 | { |
100 | { |
|
84 | switch (alignment) |
101 | switch (alignment) |
|
85 | { |
102 | { |
|
86 | case ConsoleTextAlignment.TOP_CENTER: |
103 | case ConsoleTextAlignment.TOP_CENTER: |
|
87 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
104 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
- | 105 | System.Console.Write(data); |
||
- | 106 | break; |
||
- | 107 | |
||
- | 108 | case ConsoleTextAlignment.TOP_LEFT: |
||
88 | Write(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
109 | System.Console.Write(data); |
|
89 | break; |
110 | break; |
|
Line 90... | Line 111... | |||
90 | |
111 | |
|
91 | default: |
112 | default: |
|
92 | throw new NotImplementedException(); |
113 | throw new NotImplementedException(); |
|
Line 101... | Line 122... | |||
101 | var textBlock = data.Select(o => o.ToString()).ToArray(); |
122 | var textBlock = data.Select(o => o.ToString()).ToArray(); |
|
102 | var padding = Math.Max(System.Console.WindowWidth / 2 - textBlock.Select(o => o.Length).Max() / 2, 0); |
123 | var padding = Math.Max(System.Console.WindowWidth / 2 - textBlock.Select(o => o.Length).Max() / 2, 0); |
|
103 | foreach (var line in data) |
124 | foreach (var line in data) |
|
104 | { |
125 | { |
|
105 | System.Console.CursorLeft = padding; |
126 | System.Console.CursorLeft = padding; |
|
106 | WriteLine(line, System.Console.ForegroundColor, System.Console.BackgroundColor); |
127 | WriteLine(line, System.Console.ForegroundColor); |
|
- | 128 | } |
||
- | 129 | break; |
||
- | 130 | |
||
- | 131 | case ConsoleTextAlignment.TOP_LEFT: |
||
- | 132 | foreach (var line in data) |
||
- | 133 | { |
||
- | 134 | WriteLine(line, System.Console.ForegroundColor); |
||
107 | } |
135 | } |
|
108 | break; |
136 | break; |
|
Line 109... | Line 137... | |||
109 | |
137 | |
|
110 | default: |
138 | default: |