• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MorganKryze / ConsoleAppVisuals / 7972444880

pending completion
7972444880

push

github

MorganKryze
📖 add legacy docs

827 of 916 branches covered (90.28%)

Branch coverage included in aggregate %.

1676 of 1694 relevant lines covered (98.94%)

105.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.62
/src/ConsoleAppVisuals/Window.cs
1
/*
2
    GNU GPL License 2024 MorganKryze(Yann Vidamment)
3
    For full license information, please visit: https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/LICENSE
4
*/
5
namespace ConsoleAppVisuals;
6

7
/// <summary>
8
/// The major class of the library. The window is used to collect the elements of the console and draw them.
9
/// </summary>
10
/// <remarks>
11
/// For more information, refer to the following resources:
12
/// <list type="bullet">
13
/// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
14
/// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
15
/// </list>
16
/// </remarks>
17
public static class Window
18
{
19
    #region Setup
20
    /// <summary>
21
    /// This method sets up the window without the need to call it.
22
    /// </summary>
23
    [ExcludeFromCodeCoverage]
24
    static Window()
25
    {
26
        Console.Clear();
27
        Console.CursorVisible = false;
28
    }
29
    #endregion
30

31
    #region Fields: s_elements
32
    private static readonly List<Element> s_elements = new();
33
    #endregion
34

35
    #region Constants: DefaultVisibility
36
    /// <summary>
37
    /// The default visibility of the elements when they are added to the window.
38
    /// </summary>
39
    public const bool DEFAULT_VISIBILITY = false;
40
    #endregion
41

42
    #region Properties: NextId, NumberOfElements
43
    /// <summary>
44
    /// Gives the next id number each time a new element is added to the window.
45
    /// </summary>
46
    public static int NextId => s_elements.Count;
1,137✔
47

48
    /// <summary>
49
    /// Gives the number of elements in the window.
50
    /// </summary>
51
    public static int CountElements => s_elements.Count;
27✔
52

53
    /// <summary>
54
    /// Gives the list of elements in the window.
55
    /// </summary>
56
    public static List<Element> Elements => s_elements;
6✔
57
    #endregion
58

59
    #region Basic Methods: Get, Add, Insert, Remove, RemoveAll
60
    /// <summary>
61
    /// This method returns the first element of the given type.
62
    /// </summary>
63
    /// <typeparam name="T">The type of the element.</typeparam>
64
    /// <returns>The element with the given type if it exists, null otherwise.</returns>
65
    /// <remarks>
66
    /// For more information, refer to the following resources:
67
    /// <list type="bullet">
68
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
69
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
70
    /// </list>
71
    /// </remarks>
72
    public static T? GetElement<T>()
73
        where T : Element
74
    {
75
        return s_elements.Find(element => element.GetType() == typeof(T)) as T;
102✔
76
    }
77

78
    /// <summary>
79
    /// This method returns the element with the given id.
80
    /// </summary>
81
    /// <param name="id">The id of the element.</param>
82
    /// <returns>The element with the given id if it exists, null otherwise.</returns>
83
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the id is out of range.</exception>
84
    /// <remarks>
85
    /// For more information, refer to the following resources:
86
    /// <list type="bullet">
87
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
88
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
89
    /// </list>
90
    /// </remarks>
91
    public static T? GetElement<T>(int id)
92
        where T : Element
93
    {
94
        if (id < 0 || id >= s_elements.Count)
15✔
95
        {
96
            throw new ArgumentOutOfRangeException(nameof(id), "Invalid element ID.");
6✔
97
        }
98
        return (T)s_elements[id];
9✔
99
    }
100

101
    /// <summary>
102
    /// This method returns the first visible element with the given type.
103
    /// </summary>
104
    /// <typeparam name="T">The type of the element.</typeparam>
105
    /// <returns>The visible element with the given type if it exists, null otherwise.</returns>
106
    /// <remarks>
107
    /// For more information, refer to the following resources:
108
    /// <list type="bullet">
109
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
110
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
111
    /// </list>
112
    /// </remarks>
113
    public static T? GetVisibleElement<T>()
114
        where T : Element
115
    {
116
        return s_elements.Find(element => element.GetType() == typeof(T) && element.Visibility)
39✔
117
            as T;
24✔
118
    }
119

120
    /// <summary>
121
    /// This method adds an element to the window.
122
    /// </summary>
123
    /// <param name="element">The element to be added.</param>
124
    /// <remarks>
125
    /// For more information, refer to the following resources:
126
    /// <list type="bullet">
127
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
128
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
129
    /// </list>
130
    /// </remarks>
131
    public static void AddElement(Element element)
132
    {
133
        s_elements.Add(element);
189✔
134
        if (!element.IsInteractive && AllowVisibilityToggle(element.Id))
189✔
135
        {
136
            element.ToggleVisibility();
87✔
137
        }
138
    }
189✔
139

140
    /// <summary>
141
    /// This method inserts an element to the window at the given id.
142
    /// </summary>
143
    /// <param name="element">The element to be inserted.</param>
144
    /// <param name="id">The id of the element.</param>
145
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the id is out of range.</exception>
146
    /// <remarks>
147
    /// For more information, refer to the following resources:
148
    /// <list type="bullet">
149
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
150
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
151
    /// </list>
152
    /// </remarks>
153
    public static void InsertElement(Element element, int id)
154
    {
155
        if (id < 0 || id > s_elements.Count)
9✔
156
        {
157
            throw new ArgumentOutOfRangeException(nameof(id), "Invalid element ID.");
6✔
158
        }
159
        s_elements.Insert(id, element);
3✔
160
    }
3✔
161

162
    /// <summary>
163
    /// This method removes the element with the given id.
164
    /// </summary>
165
    /// <param name="id">The id of the element.</param>
166
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the id is out of range.</exception>
167
    /// <remarks>
168
    /// For more information, refer to the following resources:
169
    /// <list type="bullet">
170
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
171
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
172
    /// </list>
173
    /// </remarks>
174
    public static void RemoveElement(int id)
175
    {
176
        if (id < 0 || id >= s_elements.Count)
9✔
177
        {
178
            throw new ArgumentOutOfRangeException(nameof(id), "Invalid element ID.");
6✔
179
        }
180
        s_elements.RemoveAt(id);
3✔
181
        UpdateIDs();
3✔
182
    }
3✔
183

184
    /// <summary>
185
    /// This method removes the given element.
186
    /// </summary>
187
    /// <param name="element">The element to be removed.</param>
188
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
189
    /// <returns>True if the element is successfully removed, false otherwise.</returns>
190
    /// <remarks>
191
    /// For more information, refer to the following resources:
192
    /// <list type="bullet">
193
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
194
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
195
    /// </list>
196
    /// </remarks>
197
    public static bool RemoveElement(Element element)
198
    {
199
        if (!s_elements.Contains(element))
9✔
200
        {
201
            throw new ElementNotFoundException("Invalid element. Not found in the window.");
3✔
202
        }
203
        var state = s_elements.Remove(element);
6✔
204
        UpdateIDs();
6✔
205
        return state;
6✔
206
    }
207

208
    /// <summary>
209
    /// This method removes the first element with the given type.
210
    /// </summary>
211
    /// <typeparam name="T">The type of the element.</typeparam>
212
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
213
    /// <returns>True if the element is successfully removed, false otherwise.</returns>
214
    /// <remarks>
215
    /// For more information, refer to the following resources:
216
    /// <list type="bullet">
217
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
218
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
219
    /// </list>
220
    /// </remarks>
221
    public static bool RemoveElement<T>()
222
        where T : Element
223
    {
224
        var element =
12✔
225
            GetElement<T>()
12✔
226
            ?? throw new ElementNotFoundException("Invalid element. Not found in the window.");
12✔
227
        var state = s_elements.Remove(element);
9✔
228
        UpdateIDs();
9✔
229
        return state;
9✔
230
    }
231

232
    /// <summary>
233
    /// This method removes the first element with the given type created by the library itself.
234
    /// </summary>
235
    /// <typeparam name="T">The type of the element.</typeparam>
236
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
237
    /// <exception cref="InvalidOperationException">Thrown when the element is not created by the library.</exception>
238
    /// <returns>True if the element is successfully removed, false otherwise.</returns>
239
    /// <remarks>
240
    /// For more information, refer to the following resources:
241
    /// <list type="bullet">
242
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
243
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
244
    /// </list>
245
    /// </remarks>
246
    public static bool RemoveLibraryElement<T>()
247
        where T : Element
248
    {
249
        var element =
18✔
250
            GetElement<T>()
18✔
251
            ?? throw new ElementNotFoundException("Invalid element. Not found in the window.");
18✔
252
        if (element.ElementSource == Source.Library)
15✔
253
        {
254
            var state = s_elements.Remove(element);
12✔
255
            UpdateIDs();
12✔
256
            return state;
12✔
257
        }
258
        throw new InvalidOperationException("Invalid element. Not created by the library.");
3✔
259
    }
260

261
    /// <summary>
262
    /// This method removes all elements from the window.
263
    /// </summary>
264
    /// <remarks>
265
    /// For more information, refer to the following resources:
266
    /// <list type="bullet">
267
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
268
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
269
    /// </list>
270
    /// </remarks>
271
    public static void RemoveAllElements()
272
    {
273
        s_elements.Clear();
1,089✔
274
    }
1,089✔
275
    #endregion
276

277
    #region Manipulation Methods: ActivateElement, ActivateAllElements, DeactivateElement, DeactivateAllElements
278
    /// <summary>
279
    /// This method attempts to activate the visibility of the element with the given id.
280
    /// </summary>
281
    /// <param name="id">The id of the element.</param>
282
    /// <param name="render">If true, the element will be rendered.</param>
283
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the id is out of range.</exception>
284
    /// <remarks>
285
    /// For more information, refer to the following resources:
286
    /// <list type="bullet">
287
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
288
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
289
    /// </list>
290
    /// </remarks>
291
    [Visual]
292
    public static void ActivateElement(int id, bool render = true)
293
    {
294
        if (id < 0 || id >= s_elements.Count)
295
        {
296
            throw new ArgumentOutOfRangeException(nameof(id), "Invalid element ID.");
297
        }
298
        if (!s_elements[id].Visibility)
299
        {
300
            s_elements[id].ToggleVisibility();
301
        }
302
        if (render)
303
        {
304
            s_elements[id].RenderElement();
305
        }
306
    }
307

308
    /// <summary>
309
    /// This method attempts to activate the visibility of the first element of the given type.
310
    /// </summary>
311
    /// <param name="render">If true, the element will be rendered.</param>
312
    /// <typeparam name="T">The type of the element.</typeparam>
313
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
314
    /// <remarks>
315
    /// For more information, refer to the following resources:
316
    /// <list type="bullet">
317
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
318
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
319
    /// </list>
320
    /// </remarks>
321
    [Visual]
322
    public static void ActivateElement<T>(bool render = true)
323
        where T : Element
324
    {
325
        var element =
326
            GetElement<T>()
327
            ?? throw new ElementNotFoundException("Invalid element. Not found in the window.");
328
        if (!element.Visibility)
329
        {
330
            element.ToggleVisibility();
331
        }
332
        if (render)
333
        {
334
            element.RenderElement();
335
        }
336
    }
337

338
    /// <summary>
339
    /// After activating the visibility of an interactive element, this method will return the response for the user.
340
    /// </summary>
341
    /// <param name="clear">If true, the element will be cleared.</param>
342
    /// <typeparam name="T">The type of interactive element.</typeparam>
343
    /// <typeparam name="TResponse">The type of the response (int, string, float...).</typeparam>
344
    /// <returns>The response of the user.</returns>
345
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
346
    /// <remarks>
347
    /// For more information, refer to the following resources:
348
    /// <list type="bullet">
349
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
350
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
351
    /// </list>
352
    /// </remarks>
353
    [Visual]
354
    public static InteractionEventArgs<TResponse>? GetResponse<T, TResponse>(bool clear = true)
355
        where T : InteractiveElement<TResponse>
356
    {
357
        var element =
358
            GetVisibleElement<T>()
359
            ?? throw new ElementNotFoundException("Invalid element. Not found in the window.");
360
        DeactivateElement<T>(clear);
361
        return element.GetInteractionResponse;
362
    }
363

364
    /// <summary>
365
    /// This method attempts to activate the visibility of all elements.
366
    /// </summary>
367
    /// <remarks>
368
    /// For more information, refer to the following resources:
369
    /// <list type="bullet">
370
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
371
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
372
    /// </list>
373
    /// </remarks>
374
    public static void ActivateAllElements()
375
    {
376
        foreach (var element in s_elements)
48✔
377
        {
378
            if (!element.Visibility)
15✔
379
            {
380
                element.ToggleVisibility();
6✔
381
            }
382
        }
383
    }
9✔
384

385
    /// <summary>
386
    /// This method to deactivate the visibility of the element with the given id.
387
    /// </summary>
388
    /// <param name="id">The id of the element.</param>
389
    /// <param name="clear">If true, the element will be cleared.</param>
390
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the id is out of range.</exception>
391
    /// <remarks>
392
    /// For more information, refer to the following resources:
393
    /// <list type="bullet">
394
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
395
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
396
    /// </list>
397
    /// </remarks>
398
    public static void DeactivateElement(int id, bool clear = true)
399
    {
400
        if (id < 0 || id >= s_elements.Count)
6✔
401
        {
402
            throw new ArgumentOutOfRangeException(nameof(id), "Invalid element ID.");
3✔
403
        }
404
        if (s_elements[id].Visibility)
3✔
405
        {
406
            s_elements[id].ToggleVisibility();
3✔
407
            if (clear)
3✔
408
            {
409
                s_elements[id].Clear();
3✔
410
            }
411
        }
412
        Refresh();
3✔
413
    }
3✔
414

415
    /// <summary>
416
    /// This method deactivate the visibility of the element with the given type.
417
    /// </summary>
418
    /// <param name="element">The element to be deactivated.</param>
419
    /// <param name="clear">If true, the element will be cleared.</param>
420
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
421
    /// <remarks>
422
    /// For more information, refer to the following resources:
423
    /// <list type="bullet">
424
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
425
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
426
    /// </list>
427
    /// </remarks>
428
    public static void DeactivateElement(Element element, bool clear = true)
429
    {
430
        if (!s_elements.Contains(element))
9✔
431
        {
432
            throw new ElementNotFoundException("Invalid element. Not found in the window.");
3✔
433
        }
434

435
        if (element.Visibility)
6✔
436
        {
437
            element.ToggleVisibility();
6✔
438
            if (clear)
6✔
439
            {
440
                element.Clear();
3✔
441
            }
442
        }
443
    }
6✔
444

445
    /// <summary>
446
    /// This method deactivate the visibility of the first element with the given type.
447
    /// </summary>
448
    /// <param name="clear">If true, the element will be cleared.</param>
449
    /// <typeparam name="T">The type of the element.</typeparam>
450
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
451
    /// <remarks>
452
    /// For more information, refer to the following resources:
453
    /// <list type="bullet">
454
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
455
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
456
    /// </list>
457
    /// </remarks>
458
    public static void DeactivateElement<T>(bool clear = true)
459
        where T : Element
460
    {
461
        var element =
9✔
462
            GetVisibleElement<T>()
9✔
463
            ?? throw new ElementNotFoundException("Invalid element. Not found in the window.");
9✔
464
        if (element.Visibility)
6✔
465
        {
466
            element.ToggleVisibility();
6✔
467
            if (clear)
6✔
468
            {
469
                element.Clear();
3✔
470
            }
471
        }
472
    }
6✔
473

474
    /// <summary>
475
    /// This method deactivate the visibility of all elements.
476
    /// </summary>
477
    /// <remarks>
478
    /// For more information, refer to the following resources:
479
    /// <list type="bullet">
480
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
481
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
482
    /// </list>
483
    /// </remarks>
484
    public static void DeactivateAllElements()
485
    {
486
        foreach (var element in s_elements)
12✔
487
        {
488
            if (element.Visibility)
3✔
489
            {
490
                element.ToggleVisibility();
3✔
491
            }
492
        }
493
        Refresh();
3✔
494
    }
3✔
495
    #endregion
496

497
    #region Utility Methods: AllowVisibilityToggle, GetLineAvailable, Clear, StopExecution, RenderOne, Refresh
498
    [ExcludeFromCodeCoverage]
499
    private static void UpdateIDs()
500
    {
501
        for (int i = 0; i < s_elements.Count; i++)
502
        {
503
            s_elements[i].Id = i;
504
        }
505
    }
506

507
    /// <summary>
508
    /// This method checks if the element can be toggled to visible.
509
    /// </summary>
510
    /// <param name="id">The id of the element.</param>
511
    /// <returns>True if the element can be toggled to visible, false otherwise.</returns>
512
    public static bool AllowVisibilityToggle(int id)
513
    {
514
        if (s_elements[id].IsInteractive)
216✔
515
        {
516
            int numberOfVisibleInteractiveElements = s_elements.Count(
33✔
517
                element => element.IsInteractive && element.Visibility
39✔
518
            );
33✔
519
            return numberOfVisibleInteractiveElements == 0;
33✔
520
        }
521
        else
522
        {
523
            int numberOfVisibleElements = s_elements.Count(
183✔
524
                element => element.GetType() == s_elements[id].GetType() && element.Visibility
222✔
525
            );
183✔
526
            return numberOfVisibleElements < s_elements[id].MaxNumberOfThisElement;
183✔
527
        }
528
    }
529

530
    /// <summary>
531
    /// Gives the last line available to draw an element on the console from a placement.
532
    /// </summary>
533
    /// <param name="placement">The placement of the element.</param>
534
    /// <returns>The last line available to draw an element on the console from a placement.</returns>
535
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the placement is invalid.</exception>
536
    /// <remarks>
537
    /// For more information, refer to the following resources:
538
    /// <list type="bullet">
539
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
540
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
541
    /// </list>
542
    /// </remarks>
543
    public static int GetLineAvailable(Placement placement)
544
    {
545
        return placement switch
660!
546
        {
660✔
547
            Placement.TopCenterFullWidth
660✔
548
                => s_elements
51✔
549
                    .Where(e => e.Placement == Placement.TopCenterFullWidth && e.Visibility)
15✔
550
                    .Sum(e => e.Height)
3✔
551
                    + s_elements
51✔
552
                        .Where(e => e.Placement == Placement.TopCenter && e.Visibility)
15✔
553
                        .Sum(e => e.Height)
3✔
554
                    + s_elements
51✔
555
                        .Where(e => e.Placement == Placement.TopLeft && e.Visibility)
15✔
556
                        .Sum(e => e.Height)
3✔
557
                    + s_elements
51✔
558
                        .Where(e => e.Placement == Placement.TopRight && e.Visibility)
15✔
559
                        .Sum(e => e.Height),
54✔
560
            Placement.TopCenter
660✔
561
                => s_elements
558✔
562
                    .Where(e => e.Placement == Placement.TopCenterFullWidth && e.Visibility)
39✔
563
                    .Sum(e => e.Height)
21✔
564
                    + s_elements
558✔
565
                        .Where(e => e.Placement == Placement.TopCenter && e.Visibility)
39✔
566
                        .Sum(e => e.Height),
567✔
567
            Placement.TopLeft
660✔
568
                => s_elements
15✔
569
                    .Where(e => e.Placement == Placement.TopCenterFullWidth && e.Visibility)
6✔
570
                    .Sum(e => e.Height)
3✔
571
                    + s_elements
15✔
572
                        .Where(e => e.Placement == Placement.TopLeft && e.Visibility)
6!
573
                        .Sum(e => e.Height),
15✔
574

660✔
575
            Placement.TopRight
660✔
576
                => s_elements
24✔
577
                    .Where(e => e.Placement == Placement.TopCenterFullWidth && e.Visibility)
15✔
578
                    .Sum(e => e.Height)
3✔
579
                    + s_elements
24✔
580
                        .Where(e => e.Placement == Placement.TopRight && e.Visibility)
15!
581
                        .Sum(e => e.Height),
24✔
582
            Placement.BottomCenterFullWidth
660✔
583
                => Console.WindowHeight
12✔
584
                    - s_elements
12✔
585
                        .Where(e => e.Placement == Placement.BottomCenterFullWidth && e.Visibility)
6!
586
                        .Sum(e => e.Height),
12✔
587
            _ => throw new ArgumentOutOfRangeException(nameof(placement), "Invalid placement.")
×
588
        };
660✔
589
    }
590

591
    /// <summary>
592
    /// This method checks if the line is valid.
593
    /// </summary>
594
    /// <param name="line">The line to be checked.</param>
595
    /// <returns>The line if it is valid.</returns>
596
    /// <exception cref="ArgumentOutOfRangeException">Thrown when the line is out of range.</exception>
597
    /// <remarks>
598
    /// For more information, refer to the following resources:
599
    /// <list type="bullet">
600
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
601
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
602
    /// </list>
603
    /// </remarks>
604
    public static int? CheckLine(int? line)
605
    {
606
        int minLine = 0;
909✔
607
        int maxLine = Console.WindowHeight == 0 ? 0 : Console.WindowHeight - 1;
909!
608
        if (line is null)
909✔
609
        {
610
            return line;
639✔
611
        }
612
        if (line < minLine || line > maxLine)
270✔
613
        {
614
            throw new ArgumentOutOfRangeException(
15✔
615
                nameof(line),
15✔
616
                $"Invalid line. The line must be between 0 and {maxLine}."
15✔
617
            );
15✔
618
        }
619
        return line;
255✔
620
    }
621

622
    /// <summary>
623
    /// This method clears the window.
624
    /// </summary>
625
    /// <param name="continuous">If true, the window will be cleared continuously.</param>
626
    /// <returns>True if the window is successfully cleared, false otherwise.</returns>
627
    /// <remarks>
628
    /// For more information, refer to the following resources:
629
    /// <list type="bullet">
630
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
631
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
632
    /// </list>
633
    /// </remarks>
634
    public static bool Clear(bool continuous = false)
635
    {
636
        if (continuous)
15✔
637
        {
638
            for (int i = 0; i < Console.WindowHeight; i++)
6!
639
            {
640
                Core.WriteContinuousString("".PadRight(Console.WindowWidth), i, false, 100, 10);
×
641
            }
642
        }
643
        else
644
        {
645
            for (int i = 0; i < Console.WindowHeight; i++)
24!
646
            {
647
                Core.WritePositionedString(
×
648
                    "".PadRight(Console.WindowWidth),
×
649
                    TextAlignment.Center,
×
650
                    false,
×
651
                    i
×
652
                );
×
653
            }
654
        }
655
        return true;
15✔
656
    }
657

658
    /// <summary>
659
    /// This method stops the execution of the program until a key is pressed.
660
    /// </summary>
661
    /// <remarks>
662
    /// For more information, refer to the following resources:
663
    /// <list type="bullet">
664
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
665
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
666
    /// </list>
667
    /// </remarks>
668
    [Visual]
669
    public static void StopExecution(ConsoleKey key = ConsoleKey.Enter)
670
    {
671
        // wait until the user presses a key
672
        while (Console.ReadKey(intercept: true).Key != key)
673
        {
674
            Thread.Sleep(10);
675
        }
676
    }
677

678
    /// <summary>
679
    /// This method draws the element with the given id on the console.
680
    /// </summary>
681
    /// <param name="id">The id of the element.</param>
682
    /// <exception cref="ElementNotFoundException">Thrown when the id is out of range.</exception>
683
    /// <returns>True if the element is successfully drawn, false otherwise.</returns>
684
    /// <remarks>
685
    /// For more information, refer to the following resources:
686
    /// <list type="bullet">
687
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
688
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
689
    /// </list>
690
    /// </remarks>
691
    public static bool RenderOneElement(int id)
692
    {
693
        if (id < 0 || id >= s_elements.Count)
6✔
694
        {
695
            throw new ElementNotFoundException("Invalid element ID.");
3✔
696
        }
697
        s_elements[id].RenderElement();
3✔
698
        return true;
3✔
699
    }
700

701
    /// <summary>
702
    /// This method draws the given element on the console.
703
    /// </summary>
704
    /// <param name="element">The element to be drawn.</param>
705
    /// <exception cref="ElementNotFoundException">Thrown when the element is invalid.</exception>
706
    /// <returns>True if the element is successfully drawn, false otherwise.</returns>
707
    /// <remarks>
708
    /// For more information, refer to the following resources:
709
    /// <list type="bullet">
710
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
711
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
712
    /// </list>
713
    /// </remarks>
714
    public static bool RenderOneElement(Element element)
715
    {
716
        if (element == null || !s_elements.Contains(element))
6✔
717
        {
718
            throw new ElementNotFoundException("Invalid element. Not found in the window.");
3✔
719
        }
720

721
        element.RenderElement();
3✔
722
        return true;
3✔
723
    }
724

725
    /// <summary>
726
    /// This method draws all the non interactive elements of the window on the console.
727
    /// </summary>
728
    /// <remarks>
729
    /// For more information, refer to the following resources:
730
    /// <list type="bullet">
731
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
732
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
733
    /// </list>
734
    /// </remarks>
735
    public static void Refresh()
736
    {
737
        Clear();
12✔
738
        foreach (var element in s_elements)
48✔
739
        {
740
            element.RenderElement();
12✔
741
        }
742
    }
12✔
743

744
    /// <summary>
745
    /// This method is called to refresh the window when the size of the console is changed.
746
    /// </summary>
747
    /// <returns>True if the window is refreshed, false otherwise.</returns>
748
    public static bool OnResize()
749
    {
750
        if (Core.IsScreenUpdated)
6✔
751
        {
752
            Core.SetConsoleDimensions();
3✔
753
            Refresh();
3✔
754
            return true;
3✔
755
        }
756
        return false;
3✔
757
    }
758

759
    /// <summary>
760
    /// This method draws all the space of the elements of the window on the console.
761
    /// </summary>
762
    /// <returns>True if the space of the elements is successfully drawn, false otherwise.</returns>
763
    /// <remarks>
764
    /// For more information, refer to the following resources:
765
    /// <list type="bullet">
766
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
767
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
768
    /// </list>
769
    /// </remarks>
770
    public static bool RenderAllElementsSpace()
771
    {
772
        foreach (var element in s_elements)
12✔
773
        {
774
            element.RenderElementSpace();
3✔
775
        }
776
        return true;
3✔
777
    }
778

779
    /// <summary>
780
    /// This method closes the window and exit the program.
781
    /// </summary>
782
    /// <remarks>
783
    /// For more information, refer to the following resources:
784
    /// <list type="bullet">
785
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
786
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
787
    /// </list>
788
    /// </remarks>
789
    [ExcludeFromCodeCoverage]
790
    public static void Close()
791
    {
792
        Core.LoadTerminalColorPanel();
793
        Clear(true);
794
        Console.CursorVisible = true;
795
        Environment.Exit(0);
796
    }
797
    #endregion
798

799
    #region Info Methods: ListWindowElements, ListClassesInheritingElement, ListClassesInheritingInteractiveElement
800
    /// <summary>
801
    /// This method displays a list of all elements in the window and adds a table to the window.
802
    /// </summary>
803
    /// <param name="placement">The placement of the element.</param>
804
    /// <remarks>
805
    /// For more information, refer to the following resources:
806
    /// <list type="bullet">
807
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
808
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
809
    /// </list>
810
    /// </remarks>
811
    public static void AddListWindowElements(Placement placement = Placement.TopCenter)
812
    {
813
        TableView<string> table =
15✔
814
            new(
15✔
815
                "Window Elements",
15✔
816
                new List<string>
15✔
817
                {
15✔
818
                    "Id",
15✔
819
                    "Type",
15✔
820
                    "Visibility",
15✔
821
                    "Height",
15✔
822
                    "Width",
15✔
823
                    "Line",
15✔
824
                    "Placement",
15✔
825
                    "IsInteractive",
15✔
826
                    "Source"
15✔
827
                },
15✔
828
                null,
15✔
829
                true,
15✔
830
                placement
15✔
831
            )
15✔
832
            {
15✔
833
                ElementSource = Source.Library
15✔
834
            };
15✔
835
        AddElement(table);
15✔
836
        foreach (var element in s_elements)
60✔
837
        {
838
            table.AddLine(
15✔
839
                new List<string>
15✔
840
                {
15✔
841
                    element.Id.ToString(),
15✔
842
                    element.GetType().Name,
15✔
843
                    element.Visibility.ToString(),
15✔
844
                    element.Height.ToString(),
15✔
845
                    element.Width.ToString(),
15✔
846
                    element.Line.ToString(),
15✔
847
                    element.Placement.ToString(),
15✔
848
                    element.IsInteractive.ToString(),
15✔
849
                    element.ElementSource.ToString()
15✔
850
                }
15✔
851
            );
15✔
852
        }
853
    }
15✔
854

855
    /// <summary>
856
    /// This method is used to get a list of all the types of the elements in the window.
857
    /// </summary>
858
    /// <returns>A list of all the types of the elements in the window.</returns>
859
    /// <remarks>
860
    /// For more information, refer to the following resources:
861
    /// <list type="bullet">
862
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
863
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
864
    /// </list>
865
    /// </remarks>
866
    public static List<string>? GetListWindowElements()
867
    {
868
        TableView<string> table =
3✔
869
            new(
3✔
870
                "Window Elements",
3✔
871
                new List<string>
3✔
872
                {
3✔
873
                    "Id",
3✔
874
                    "Type",
3✔
875
                    "Visibility",
3✔
876
                    "Height",
3✔
877
                    "Width",
3✔
878
                    "Line",
3✔
879
                    "Placement",
3✔
880
                    "IsInteractive",
3✔
881
                    "Source"
3✔
882
                }
3✔
883
            )
3✔
884
            {
3✔
885
                ElementSource = Source.Library
3✔
886
            };
3✔
887
        foreach (var element in s_elements)
12✔
888
        {
889
            table.AddLine(
3✔
890
                new List<string>
3✔
891
                {
3✔
892
                    element.Id.ToString(),
3✔
893
                    element.GetType().Name,
3✔
894
                    element.Visibility.ToString(),
3✔
895
                    element.Height.ToString(),
3✔
896
                    element.Width.ToString(),
3✔
897
                    element.Line.ToString(),
3✔
898
                    element.Placement.ToString(),
3✔
899
                    element.IsInteractive.ToString(),
3✔
900
                    element.ElementSource.ToString()
3✔
901
                }
3✔
902
            );
3✔
903
        }
904
        return table.GetColumnData("Type");
3✔
905
    }
906

907
    /// <summary>
908
    /// This method gives a list of all classes inheriting from the Element (and so InteractiveElement as well) class and adds a table to the window.
909
    /// </summary>
910
    /// <param name="placement">The placement of the element.</param>
911
    /// <returns>The list of all classes inheriting from the Element class.</returns>
912
    /// <remarks>
913
    /// For more information, refer to the following resources:
914
    /// <list type="bullet">
915
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
916
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
917
    /// </list>
918
    /// </remarks>
919
    public static void AddListClassesInheritingElement(Placement placement = Placement.TopCenter)
920
    {
921
        var types = new List<Type>();
9✔
922
        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
1,380✔
923
        {
924
            if (
681✔
925
                assembly.FullName != null
681✔
926
                && !assembly.FullName.StartsWith("mscorlib")
681✔
927
                && !assembly.FullName.StartsWith("System")
681✔
928
                && !assembly.FullName.StartsWith("Microsoft")
681✔
929
            )
681✔
930
            {
931
                types.AddRange(assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Element))));
17,748✔
932
            }
933
        }
934
        TableView<string> table =
9✔
935
            new(
9✔
936
                "Element Classes",
9✔
937
                new List<string> { "Id", "Type", "Project" },
9✔
938
                null,
9✔
939
                true,
9✔
940
                placement
9✔
941
            );
9✔
942
        var id = 0;
9✔
943
        foreach (var type in types)
324✔
944
        {
945
            if (type.IsAbstract)
153✔
946
            {
947
                continue;
948
            }
949
            table.AddLine(
144!
950
                new List<string> { $"{id}", type.Name, type.Assembly.GetName().Name ?? "Unknown" }
144✔
951
            );
144✔
952
            id += 1;
144✔
953
        }
954
        table.ElementSource = Source.Library;
9✔
955
        AddElement(table);
9✔
956
    }
9✔
957

958
    /// <summary>
959
    /// This method is used to get a list of all the types of the classes inheriting from the Element class.
960
    /// </summary>
961
    /// <returns>A list of all the types of the classes inheriting from the Element class.</returns>
962
    /// <remarks>
963
    /// For more information, refer to the following resources:
964
    /// <list type="bullet">
965
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
966
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
967
    /// </list>
968
    /// </remarks>
969
    public static List<string>? GetListClassesInheritingElement()
970
    {
971
        var types = new List<Type>();
3✔
972
        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
462✔
973
        {
974
            if (
228✔
975
                assembly.FullName != null
228✔
976
                && !assembly.FullName.StartsWith("mscorlib")
228✔
977
                && !assembly.FullName.StartsWith("System")
228✔
978
                && !assembly.FullName.StartsWith("Microsoft")
228✔
979
            )
228✔
980
            {
981
                types.AddRange(
30✔
982
                    assembly
30✔
983
                        .GetTypes()
30✔
984
                        .Where(
30✔
985
                            t =>
30✔
986
                                t.IsSubclassOf(typeof(Element)) && t != typeof(InteractiveElement<>)
5,886✔
987
                        )
30✔
988
                );
30✔
989
            }
990
        }
991
        TableView<string> table =
3✔
992
            new("Element Classes", new List<string> { "Id", "Type", "Project" });
3✔
993
        var id = 0;
3✔
994
        foreach (var type in types)
102✔
995
        {
996
            if (type.IsAbstract)
48✔
997
            {
998
                continue;
999
            }
1000
            table.AddLine(
48!
1001
                new List<string> { $"{id}", type.Name, type.Assembly.GetName().Name ?? "Unknown" }
48✔
1002
            );
48✔
1003
            id += 1;
48✔
1004
        }
1005
        return table.GetColumnData("Type");
3✔
1006
    }
1007

1008
    /// <summary>
1009
    /// This method gives a list of all classes inheriting from the InteractiveElement class and adds a table to the window.
1010
    /// </summary>
1011
    /// <param name="placement">The placement of the element.</param>
1012
    /// <returns>The list of all classes inheriting from the InteractiveElement class.</returns>
1013
    public static void AddListClassesInheritingInteractiveElement(
1014
        Placement placement = Placement.TopCenter
1015
    )
1016
    {
1017
        var types = new List<Type>();
9✔
1018
        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
1,386✔
1019
        {
1020
            if (
684✔
1021
                assembly.FullName != null
684✔
1022
                && !assembly.FullName.StartsWith("mscorlib")
684✔
1023
                && !assembly.FullName.StartsWith("System")
684✔
1024
                && !assembly.FullName.StartsWith("Microsoft")
684✔
1025
            )
684✔
1026
            {
1027
                types.AddRange(
90✔
1028
                    assembly
90✔
1029
                        .GetTypes()
90✔
1030
                        .Where(
90✔
1031
                            t =>
90✔
1032
                                t.BaseType != null
17,658✔
1033
                                && t.BaseType.IsGenericType
17,658✔
1034
                                && t.BaseType.GetGenericTypeDefinition()
17,658✔
1035
                                    == typeof(InteractiveElement<>)
17,658✔
1036
                        )
90✔
1037
                );
90✔
1038
            }
1039
        }
1040
        TableView<string> table =
9✔
1041
            new(
9✔
1042
                "Interactive Element Classes",
9✔
1043
                new List<string> { "Id", "Type", "Project" },
9✔
1044
                null,
9✔
1045
                true,
9✔
1046
                placement
9✔
1047
            );
9✔
1048
        var id = 0;
9✔
1049
        foreach (var type in types)
144✔
1050
        {
1051
            table.AddLine(
63!
1052
                new List<string> { $"{id}", type.Name, type.Assembly.GetName().Name ?? "Unknown" }
63✔
1053
            );
63✔
1054
            id += 1;
63✔
1055
        }
1056
        table.ElementSource = Source.Library;
9✔
1057
        AddElement(table);
9✔
1058
    }
9✔
1059

1060
    /// <summary>
1061
    /// This method is used to get a list of all the types of the classes inheriting from the InteractiveElement class.
1062
    /// </summary>
1063
    /// <returns>A list of all the types of the classes inheriting from the InteractiveElement class.</returns>
1064
    /// <remarks>
1065
    /// For more information, refer to the following resources:
1066
    /// <list type="bullet">
1067
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
1068
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
1069
    /// </list>
1070
    /// </remarks>
1071
    public static List<string>? GetListClassesInheritingInteractiveElement()
1072
    {
1073
        var types = new List<Type>();
3✔
1074
        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
462✔
1075
        {
1076
            if (
228✔
1077
                assembly.FullName != null
228✔
1078
                && !assembly.FullName.StartsWith("mscorlib")
228✔
1079
                && !assembly.FullName.StartsWith("System")
228✔
1080
                && !assembly.FullName.StartsWith("Microsoft")
228✔
1081
            )
228✔
1082
            {
1083
                types.AddRange(
30✔
1084
                    assembly
30✔
1085
                        .GetTypes()
30✔
1086
                        .Where(
30✔
1087
                            t =>
30✔
1088
                                t.BaseType != null
5,886✔
1089
                                && t.BaseType.IsGenericType
5,886✔
1090
                                && t.BaseType.GetGenericTypeDefinition()
5,886✔
1091
                                    == typeof(InteractiveElement<>)
5,886✔
1092
                        )
30✔
1093
                );
30✔
1094
            }
1095
        }
1096
        TableView<string> table =
3✔
1097
            new("Interactive Element Classes", new List<string> { "Id", "Type", "Project" });
3✔
1098
        var id = 0;
3✔
1099
        foreach (var type in types)
48✔
1100
        {
1101
            table.AddLine(
21!
1102
                new List<string> { $"{id}", type.Name, type.Assembly.GetName().Name ?? "Unknown" }
21✔
1103
            );
21✔
1104
            id += 1;
21✔
1105
        }
1106
        return table.GetColumnData("Type");
3✔
1107
    }
1108

1109
    /// <summary>
1110
    /// This method displays a list of all classes inheriting from the Element class and a list of all classes inheriting from the InteractiveElement class.
1111
    /// </summary>
1112
    /// <remarks>
1113
    /// For more information, refer to the following resources:
1114
    /// <list type="bullet">
1115
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
1116
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
1117
    /// </list>
1118
    /// </remarks>
1119
    public static void AddClassesDashboard()
1120
    {
1121
        AddListClassesInheritingElement(Placement.TopLeft);
6✔
1122
        AddListClassesInheritingInteractiveElement(Placement.TopRight);
6✔
1123
    }
6✔
1124

1125
    /// <summary>
1126
    /// This method removes the dashboard TableView from the window.
1127
    /// </summary>
1128
    /// <remarks>
1129
    /// For more information, refer to the following resources:
1130
    /// <list type="bullet">
1131
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
1132
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
1133
    /// </list>
1134
    /// </remarks>
1135
    public static void RemoveClassesDashboard()
1136
    {
1137
        RemoveLibraryElement<TableView<string>>();
3✔
1138
        RemoveLibraryElement<TableView<string>>();
3✔
1139
    }
3✔
1140

1141
    /// <summary>
1142
    /// This method displays a list of all elements in the window.
1143
    /// </summary>
1144
    /// <remarks>
1145
    /// For more information, refer to the following resources:
1146
    /// <list type="bullet">
1147
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
1148
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
1149
    /// </list>
1150
    /// </remarks>
1151
    public static void AddWindowElementsDashboard()
1152
    {
1153
        AddListWindowElements(Placement.TopCenter);
6✔
1154
    }
6✔
1155

1156
    /// <summary>
1157
    /// This method removes the dashboard TableView from the window.
1158
    /// </summary>
1159
    /// <remarks>
1160
    /// For more information, refer to the following resources:
1161
    /// <list type="bullet">
1162
    /// <item><description><a href="https://morgankryze.github.io/ConsoleAppVisuals/">Documentation</a></description></item>
1163
    /// <item><description><a href="https://github.com/MorganKryze/ConsoleAppVisuals/blob/main/example/Program.cs">Example Project</a></description></item>
1164
    /// </list>
1165
    /// </remarks>
1166
    public static void RemoveWindowElementsDashboard()
1167
    {
1168
        RemoveLibraryElement<TableView<string>>();
3✔
1169
    }
3✔
1170
    #endregion
1171
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc