wasSharpNET – Diff between revs 9 and 11
?pathlinks?
Rev 9 | Rev 11 | |||
---|---|---|---|---|
Line 17... | Line 17... | |||
17 | TOP_LEFT, |
17 | TOP_LEFT, |
|
18 | TOP_CENTER, |
18 | TOP_CENTER, |
|
19 | TOP_RIGHT |
19 | TOP_RIGHT |
|
20 | } |
20 | } |
|
Line 21... | Line -... | |||
21 | |
- | ||
22 | |
21 | |
|
23 | public static void WriteLine(this object data, ConsoleColor foreground, |
22 | public static void WriteLine(this object data, ConsoleColor foreground, |
|
24 | ConsoleColor background) |
23 | ConsoleColor background) |
|
25 | { |
24 | { |
|
26 | var cFG = System.Console.ForegroundColor; |
25 | var cFG = System.Console.ForegroundColor; |
|
Line 55... | Line 54... | |||
55 | public static void WriteLine(this object data, ConsoleTextAlignment alignment) |
54 | public static void WriteLine(this object data, ConsoleTextAlignment alignment) |
|
56 | { |
55 | { |
|
57 | switch (alignment) |
56 | switch (alignment) |
|
58 | { |
57 | { |
|
59 | case ConsoleTextAlignment.TOP_CENTER: |
58 | case ConsoleTextAlignment.TOP_CENTER: |
|
60 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth/2 - data.ToString().Length/2, 0); |
59 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
61 | WriteLine(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
60 | WriteLine(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
|
62 | break; |
61 | break; |
|
- | 62 | |
||
63 | default: |
63 | default: |
|
64 | throw new NotImplementedException(); |
64 | throw new NotImplementedException(); |
|
65 | } |
65 | } |
|
66 | } |
66 | } |
|
Line 71... | Line 71... | |||
71 | { |
71 | { |
|
72 | case ConsoleTextAlignment.TOP_CENTER: |
72 | case ConsoleTextAlignment.TOP_CENTER: |
|
73 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
73 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
74 | WriteLine(data, foregroundColor, System.Console.BackgroundColor); |
74 | WriteLine(data, foregroundColor, System.Console.BackgroundColor); |
|
75 | break; |
75 | break; |
|
- | 76 | |
||
76 | default: |
77 | default: |
|
77 | throw new NotImplementedException(); |
78 | throw new NotImplementedException(); |
|
78 | } |
79 | } |
|
79 | } |
80 | } |
|
Line 80... | Line 81... | |||
80 | |
81 | |
|
81 | public static void Write(this object data, ConsoleTextAlignment alignment) |
82 | public static void Write(this object data, ConsoleTextAlignment alignment) |
|
82 | { |
83 | { |
|
83 | switch (alignment) |
84 | switch (alignment) |
|
84 | { |
85 | { |
|
85 | case ConsoleTextAlignment.TOP_CENTER: |
86 | case ConsoleTextAlignment.TOP_CENTER: |
|
86 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth/2 - data.ToString().Length/2, 0); |
87 | System.Console.CursorLeft = Math.Max(System.Console.WindowWidth / 2 - data.ToString().Length / 2, 0); |
|
87 | Write(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
88 | Write(data, System.Console.ForegroundColor, System.Console.BackgroundColor); |
|
- | 89 | break; |
||
88 | break; |
90 | |
|
89 | default: |
91 | default: |
|
90 | throw new NotImplementedException(); |
92 | throw new NotImplementedException(); |
|
91 | } |
93 | } |
|
Line 95... | Line 97... | |||
95 | { |
97 | { |
|
96 | switch (alignment) |
98 | switch (alignment) |
|
97 | { |
99 | { |
|
98 | case ConsoleTextAlignment.TOP_CENTER: |
100 | case ConsoleTextAlignment.TOP_CENTER: |
|
99 | var textBlock = data.Select(o => o.ToString()).ToArray(); |
101 | var textBlock = data.Select(o => o.ToString()).ToArray(); |
|
100 | var padding = Math.Max(System.Console.WindowWidth/2 - textBlock.Select(o => o.Length).Max()/2, 0); |
102 | var padding = Math.Max(System.Console.WindowWidth / 2 - textBlock.Select(o => o.Length).Max() / 2, 0); |
|
101 | foreach (var line in data) |
103 | foreach (var line in data) |
|
102 | { |
104 | { |
|
103 | System.Console.CursorLeft = padding; |
105 | System.Console.CursorLeft = padding; |
|
104 | WriteLine(line, System.Console.ForegroundColor, System.Console.BackgroundColor); |
106 | WriteLine(line, System.Console.ForegroundColor, System.Console.BackgroundColor); |
|
105 | } |
107 | } |
|
106 | break; |
108 | break; |
|
- | 109 | |
||
107 | default: |
110 | default: |
|
108 | throw new NotImplementedException(); |
111 | throw new NotImplementedException(); |
|
109 | } |
112 | } |
|
110 | } |
113 | } |
|
111 | } |
114 | } |
|
112 | } |
- | ||
113 | |
115 | } |
|
- | 116 | |