Class Core
- Namespace
- ConsoleAppVisuals
- Assembly
- ConsoleAppVisuals.dll
The Core class is a collection of low-level methods responsible of all the interactions between the library and the console (e.g. changing colors, writing text, etc.).
public static class Core
- Inheritance
-
Core
- Inherited Members
Remarks
For more information, consider visiting the documentation available here.
Fields
NEGATIVE_ANCHOR
Defines the negative anchor to put inside a string to be recognized as negative.
The following line will put " negative " in negative on the screen and not print the "/neg" anchors.
string str = "This is a /neg negative /neg string";
public const string NEGATIVE_ANCHOR = "/neg"
Field Value
Properties
ColorPanel
Gets the current color panel used in the console.
public static (ConsoleColor, ConsoleColor) ColorPanel { get; }
Property Value
InitialColorPanel
Gets the initial color panel of the console.
public static (ConsoleColor, ConsoleColor) InitialColorPanel { get; }
Property Value
Methods
ApplyNegative(bool)
Switches the font and background colors of the console in order to apply a negative to highlight the text.
[Visual]
public static void ApplyNegative(bool negative = false)
Parameters
negativeboolIf true, the text is highlighted.
Remarks
For more information, consider visiting the documentation available here.
BannerToString((string, string, string))
Converts a banner tuple into a string.
[Visual]
public static string BannerToString(this (string, string, string) banner)
Parameters
Returns
- string
Converts the banner to a string.
Remarks
For more information, consider visiting the documentation available here.
ClearMultiplePositionedLines(Placement, int, params string[])
Clears a multiple lines in the console given a certain starting line.
[Visual]
public static void ClearMultiplePositionedLines(Placement placement, int line, params string[] text)
Parameters
placementPlacementThe placement of the paragraph.
lineintThe height of the paragraph.
textstring[]The lines of the paragraph.
Remarks
For more information, consider visiting the documentation available here.
GetRandomColor()
Gets a random color from a list of predefined colors (the default ones).
public static ConsoleColor GetRandomColor()
Returns
- ConsoleColor
A random color.
Remarks
For more information, consider visiting the documentation available here.
GetRangeAndRemoveNegativeAnchors(string)
Gets the range of a negative sequence in a string and remove the negative anchors.
public static (string, (int, int)?) GetRangeAndRemoveNegativeAnchors(this string str)
Parameters
strstringThe string to check.
Returns
- (string, (int, int)?)
The string without the negative anchors and the range of the negative sequence.
Remarks
For more information, consider visiting the documentation available here.
InsertString(string, string, TextAlignment)
Inserts a specified string into another string, at a specified position.
public static string InsertString(this string inserted, string toInsert, TextAlignment align = TextAlignment.Center)
Parameters
insertedstringThe string that receives the other.
toInsertstringThe string to insert.
alignTextAlignmentThe alignment of the string to insert.
Returns
- string
The final string after computing.
Remarks
For more information, consider visiting the documentation available here.
IsScreenUpdated()
Checks if the screen has been updated (colors or dimensions have changed)
[Visual]
public static bool IsScreenUpdated()
Returns
- bool
True if the screen has been updated, false otherwise.
Remarks
For more information, consider visiting the documentation available here.
LoadSavedColorPanel()
Loads the saved color panel (consider saving it beforehand)
[Visual]
public static void LoadSavedColorPanel()
Remarks
For more information, consider visiting the documentation available here.
LoadTerminalColorPanel()
Loads the terminal color panel.
[Visual]
public static void LoadTerminalColorPanel()
Remarks
For more information, consider visiting the documentation available here.
ResizeString(string, int, TextAlignment, bool)
Builds a new string with a specific size and a specific placement.
public static string ResizeString(this string str, int size, TextAlignment align = TextAlignment.Center, bool truncate = true)
Parameters
strstringThe string to build.
sizeintThe size of the string.
alignTextAlignmentThe alignment of the string.
truncateboolIf true, the string is truncated if it is too long.
Returns
- string
The built string.
Remarks
For more information, consider visiting the documentation available here.
RestoreColorPanel()
Restores the default colors of the console with the initial color panel.
[Visual]
public static void RestoreColorPanel()
Remarks
For more information, consider visiting the documentation available here.
SaveColorPanel()
Saves the current color panel in a variable.
[Visual]
public static void SaveColorPanel()
Remarks
For more information, consider visiting the documentation available here.
SetBackgroundColor(ConsoleColor)
Changes the background color of the console.
[Visual]
public static void SetBackgroundColor(ConsoleColor color)
Parameters
colorConsoleColorThe new background color.
Remarks
For more information, consider visiting the documentation available here.
SetConsoleColors()
Set the console colors to the Core variables associated. It does not change the actual colors of the console.
[Visual]
public static void SetConsoleColors()
Remarks
For more information, consider visiting the documentation available here.
SetConsoleDimensions()
Set the dimensions of the console to the Core variables associated. It does not change the actual dimensions of the console.
[Visual]
public static void SetConsoleDimensions()
Remarks
For more information, consider visiting the documentation available here.
SetForegroundColor(ConsoleColor)
Changes the foreground color of the console.
[Visual]
public static void SetForegroundColor(ConsoleColor color)
Parameters
colorConsoleColorThe new color.
Remarks
For more information, consider visiting the documentation available here.
ToPlacement(TextAlignment)
Converts a TextAlignment into a Placement.
public static Placement ToPlacement(this TextAlignment align)
Parameters
alignTextAlignmentThe alignment to convert.
Returns
- Placement
The converted alignment.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentException
Thrown when the alignment is not valid.
ToTextAlignment(Placement)
Converts a Placement into a TextAlignment.
public static TextAlignment ToTextAlignment(this Placement placement)
Parameters
placementPlacementThe placement to convert.
Returns
- TextAlignment
The converted placement.
Remarks
For more information, consider visiting the documentation available here.
Exceptions
- ArgumentException
Thrown when the placement is not valid.
WriteContinuousString(string, int?, bool, int, int, int?, TextAlignment, Placement)
Writes a string continuously in the console. The string is written letter by letter on the console.
[Visual]
public static void WriteContinuousString(string str, int? line, bool negative = false, int printTime = 2000, int additionalTime = 1000, int? length = null, TextAlignment align = TextAlignment.Center, Placement placement = Placement.TopCenter)
Parameters
strstringThe string to write.
lineint?The line where the string is written in the console. If null, will be written where the cursor is.
negativeboolIf true, the text is highlighted.
printTimeintThe total time to write the string in ms.
additionalTimeintThe additional time to wait after the string is written in ms.
lengthint?The length of the string. If null, the length is the window width.
alignTextAlignmentThe alignment of the string.
placementPlacementThe placement of the string.
Remarks
For more information, consider visiting the documentation available here.
WriteDebugMessage(Placement, params string[])
[Debugging purposes] It overwrites any text in the console at a specified placement to display a debug message.
[Visual]
public static void WriteDebugMessage(Placement placement = Placement.TopRight, params string[] lines)
Parameters
Remarks
For more information, consider visiting the documentation available here.
WriteMultiplePositionedLines(bool, TextAlignment, Placement, bool, int?, params string[])
Writes multiple lines in the console given a certain placement and line.
[Visual]
public static void WriteMultiplePositionedLines(bool equalizeLengths = true, TextAlignment align = TextAlignment.Center, Placement placement = Placement.TopCenter, bool negative = false, int? line = null, params string[] text)
Parameters
equalizeLengthsboolWhether or not the lines of the paragraph should be equalized to the same length.
alignTextAlignmentThe alignment of the paragraph.
placementPlacementThe placement of the paragraph.
negativeboolIf true, the paragraph is printed in the negative colors.
lineint?The height of the paragraph.
textstring[]The lines of the paragraph.
Remarks
For more information, consider visiting the documentation available here.
WritePositionedString(string, Placement, bool, int?, bool)
Writes a string in the console given a certain placement and line.
[Visual]
public static void WritePositionedString(string str, Placement placement = Placement.TopCenter, bool negative = false, int? line = null, bool writeLine = false)
Parameters
strstringThe string to write.
placementPlacementThe placement of the string in the console.
negativeboolIf true, the text is highlighted.
lineint?The line where the string is written in the console. If null, will be written where the cursor is.
writeLineboolIf true, the string is written with a line break.
Remarks
For more information, consider visiting the documentation available here.
WritePositionedStyledText(string[]?, int?, int?, int?, TextAlignment, bool)
Writes a styled text in the console. The height will depend on the font used. Font enum for details.
[Visual]
public static void WritePositionedStyledText(string[]? text = null, int? line = null, int? width = null, int? margin = null, TextAlignment align = TextAlignment.Center, bool negative = false)
Parameters
textstring[]The styled string to write.
lineint?The line where the string is written in the console. If null, will be written from the ContentHeight.
widthint?The width of the string. If null, the width is the window width.
marginint?The upper and lower margin.
alignTextAlignmentThe alignment of the string.
negativeboolIf true, the text is highlighted.
Remarks
For more information, consider visiting the documentation available here.