Class Window
- Namespace
- ConsoleAppVisuals
- Assembly
- ConsoleAppVisuals.dll
The Window class is a collection of methods to manage visual elements stored in itself. You may add, remove, or render elements in the console after adding them to the Window class.
public static class Window
- Inheritance
-
Window
- Inherited Members
Remarks
For more information, consider visiting the documentation available here.
Fields
INTERVAL_BETWEEN_READS
Defines the interval of milliseconds between different read key of the console (used in the Freeze(ConsoleKey) method).
public const int INTERVAL_BETWEEN_READS = 10
Field Value
Properties
CountElements
Gets the number of elements currently stored in the window.
public static int CountElements { get; }
Property Value
Elements
Gets the list of elements stored in the window.
public static List<Element> Elements { get; }
Property Value
NextId
Gets the next id number each time a new element is added to the window.
public static int NextId { get; }
Property Value
Methods
ActivateAllElements()
Attempts to toggle the visibility of all Element in the window if the element fits the max number constraint.
public static void ActivateAllElements()
Remarks
For more information, consider visiting the documentation available here.
ActivateElement(Element, bool)
Attempts to toggle the visibility of the given Element if it fits the max number constraint. The element will be rendered if the render parameter is true.
[Visual]
public static void ActivateElement(Element element, bool render = true)
Parameters
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ElementNotFoundException
Thrown when the element is invalid.
ActivateElement(int, bool)
Attempts to toggle the visibility of the Element with the given id if the element fits the max number constraint. The element will be rendered if the render parameter is true.
[Visual]
public static void ActivateElement(int id, bool render = true)
Parameters
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the id is out of the range of the Window elements.
ActivateElement<T>(bool)
Attempts to toggle the visibility of the first Element with the given type if the element fits the max number constraint.
[Visual]
public static void ActivateElement<T>(bool render = true) where T : Element
Parameters
render
boolIf true, the element will be rendered.
Type Parameters
T
The type of the element.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ElementNotFoundException
Thrown when the element is invalid.
AddElement(params Element[])
Adds one or more Element to the window. If the element is passive, it will try to toggle its visibility to true.
public static void AddElement(params Element[] elements)
Parameters
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentException
Thrown when no Element are provided.
- DuplicateElementException
CheckLine(int?)
Checks if the line is not out of the console range.
public static int? CheckLine(int? line)
Parameters
line
int?The line to be checked.
Returns
- int?
The line if it is valid.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- LineOutOfConsoleException
Thrown when the line is out of the console range.
Clear(bool, int?, int?, int)
Clears the console given a range of lines.
[Visual]
public static bool Clear(bool continuous = false, int? startLine = null, int? length = null, int step = 1)
Parameters
continuous
boolIf true, the window will be cleared continuously.
startLine
int?The start line of the window to be cleared.
length
int?The number of lines to be cleared.
step
intThe step of the window to be cleared.
Returns
- bool
True if the window is successfully cleared, false otherwise.
Remarks
For more information, consider visiting the documentation available here.
Close()
Clears the console, show the cursor, and exit the program.
[Visual]
public static void Close()
Remarks
For more information, consider visiting the documentation available here.
DeactivateAllElements(bool)
This method deactivate the visibility of all Element.
public static void DeactivateAllElements(bool clear = true)
Parameters
clear
bool
Remarks
For more information, consider visiting the documentation available here.
DeactivateElement(Element, bool)
Deactivates the visibility of the given Element. The console space taken by the element will be cleared if the clear parameter is true.
public static void DeactivateElement(Element element, bool clear = true)
Parameters
element
ElementThe Element to be deactivated.
clear
boolIf true, the Element space will be cleared from the console.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ElementNotFoundException
Thrown when the element is invalid.
DeactivateElement(int, bool)
Deactivates the visibility of the Element with the given id. The console space taken by the element will be cleared if the clear parameter is true.
public static void DeactivateElement(int id, bool clear = true)
Parameters
id
intThe id of the Element.
clear
boolIf true, the Element space will be cleared from the console.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the id is out of the range of the Window elements.
DeactivateElement<T>(bool)
Deactivates the visibility of the first Element with the given type. The console space taken by the element will be cleared if the clear parameter is true.
public static void DeactivateElement<T>(bool clear = true) where T : Element
Parameters
clear
boolIf true, the element will be cleared.
Type Parameters
T
The type of the element.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ElementNotFoundException
Thrown when the element is invalid.
Freeze(ConsoleKey)
Freezes the execution of the program until the given key is pressed.
[Visual]
public static void Freeze(ConsoleKey key = ConsoleKey.Enter)
Parameters
key
ConsoleKeyThe key to be pressed to continue the execution.
Remarks
For more information, consider visiting the documentation available here.
GetElement<T>()
public static T? GetElement<T>() where T : Element
Returns
- T
The element with the given type if it exists, null otherwise.
Type Parameters
T
The type of the element.
Remarks
For more information, consider visiting the documentation available here.
GetElement<T>(int)
public static T? GetElement<T>(int id) where T : Element
Parameters
id
intThe id of the element.
Returns
- T
The Element with the given id if it exists, null otherwise.
Type Parameters
T
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the id is out of the range of the Window elements.
GetLineAvailable(Placement)
Gets the last line available to render an Element on the console given a placement.
public static int GetLineAvailable(Placement placement)
Parameters
placement
PlacementThe placement to get the line.
Returns
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the placement is invalid.
GetVisibleElement<T>()
public static T? GetVisibleElement<T>() where T : Element
Returns
- T
The visible Element with the given type if it exists, null otherwise.
Type Parameters
T
The type of the element.
Remarks
For more information, consider visiting the documentation available here.
InsertElement(Element, int)
public static void InsertElement(Element element, int id)
Parameters
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the id is out of the range of the Window elements.
IsElementActivatable(int)
Tests if an Element given by an id can be activated
public static bool IsElementActivatable(int id)
Parameters
Returns
Remarks
For more information, consider visiting the documentation available here.
Open()
Clears the console and hide the cursor.
[Visual]
public static void Open()
Remarks
For more information, consider visiting the documentation available here.
Range(int, int)
Collects a range of Element given a start id and a count.
public static List<Element> Range(int index, int count)
Parameters
Returns
Remarks
For more information, consider visiting the documentation available here.
RemoveAllElements()
Removes all Element from the window.
public static void RemoveAllElements()
Remarks
For more information, consider visiting the documentation available here.
RemoveElement(params Element[])
public static bool RemoveElement(params Element[] elements)
Parameters
Returns
- bool
True if the element is successfully removed, false otherwise.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
RemoveElement(int)
public static void RemoveElement(int id)
Parameters
id
intThe id of the element to be removed.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentOutOfRangeException
Thrown when the id is out of the range of the Window elements.
RemoveElement<T>()
public static bool RemoveElement<T>() where T : Element
Returns
- bool
True if the element is successfully removed, false otherwise.
Type Parameters
T
The type of the element.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
Render()
Displays all the visible Element in the window.
[Visual]
public static void Render()
Remarks
For more information, consider visiting the documentation available here.
Render(params Element[])
Displays the given Element in the window.
[Visual]
public static void Render(params Element[] elements)
Parameters
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ElementNotFoundException
Thrown when the element is not found in the Window.
RenderElementsSpace(bool)
Renders the space of all visible Element in the window. May ignore the visibility to display the hidden Element spaces.
[Visual]
public static bool RenderElementsSpace(bool ignoreVisibility = false)
Parameters
Returns
Remarks
For more information, consider visiting the documentation available here.