Search Results for

    Show / Hide Table of Contents

    Class ColorTools

    Color tools and management

    Inheritance
    object
    ColorTools
    Namespace: Terminaux.Colors
    Assembly: Terminaux.dll
    Syntax
    public static class ColorTools

    Properties

    | Edit this page View Source

    AllowBackground

    Whether applications are allowed to set the current background color or not

    Declaration
    public static bool AllowBackground { get; set; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    CurrentBackgroundColor

    Current background color

    Declaration
    public static Color CurrentBackgroundColor { get; }
    Property Value
    Type Description
    Color
    | Edit this page View Source

    CurrentForegroundColor

    Current foreground color

    Declaration
    public static Color CurrentForegroundColor { get; }
    Property Value
    Type Description
    Color
    | Edit this page View Source

    GlobalSettings

    Global color settings

    Declaration
    public static ColorSettings GlobalSettings { get; }
    Property Value
    Type Description
    ColorSettings

    Methods

    | Edit this page View Source

    GetGray(Color, ColorContrastType)

    Gets the gray color according to the brightness of the specified color

    Declaration
    public static Color GetGray(Color color, ColorContrastType contrastType = ColorContrastType.Light)
    Parameters
    Type Name Description
    Color color

    Target color to use when getting the gray color

    ColorContrastType contrastType

    Contrast type

    Returns
    Type Description
    Color
    | Edit this page View Source

    GetGray(ColorContrastType)

    Gets the gray color according to the brightness of the background color

    Declaration
    public static Color GetGray(ColorContrastType contrastType = ColorContrastType.Light)
    Parameters
    Type Name Description
    ColorContrastType contrastType

    Contrast type

    Returns
    Type Description
    Color
    | Edit this page View Source

    GetRandomColor(bool, ColorSettings?)

    Gets a random color instance (true color)

    Declaration
    public static Color GetRandomColor(bool selectBlack = true, ColorSettings? settings = null)
    Parameters
    Type Name Description
    bool selectBlack

    Whether to select the black color or not

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    Color

    A color instance

    | Edit this page View Source

    GetRandomColor(ColorType, bool, ColorSettings?)

    Gets a random color instance

    Declaration
    public static Color GetRandomColor(ColorType type, bool selectBlack = true, ColorSettings? settings = null)
    Parameters
    Type Name Description
    ColorType type

    Color type to generate

    bool selectBlack

    Whether to select the black color or not

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    Color

    A color instance

    | Edit this page View Source

    GetRandomColor(ColorType, int, int, int, int, int, int, int, int, ColorSettings?)

    Gets a random color instance

    Declaration
    public static Color GetRandomColor(ColorType type, int minColor, int maxColor, int minColorR, int maxColorR, int minColorG, int maxColorG, int minColorB, int maxColorB, ColorSettings? settings = null)
    Parameters
    Type Name Description
    ColorType type

    Color type to generate

    int minColor

    The minimum color level

    int maxColor

    The maximum color level

    int minColorR

    The minimum red color level

    int maxColorR

    The maximum red color level

    int minColorG

    The minimum green color level

    int maxColorG

    The maximum green color level

    int minColorB

    The minimum blue color level

    int maxColorB

    The maximum blue color level

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    Color

    A color instance

    | Edit this page View Source

    GetRgbFromColorCode(int)

    Gets the RGB instance from the color code

    Declaration
    public static RedGreenBlue GetRgbFromColorCode(int colorCode)
    Parameters
    Type Name Description
    int colorCode

    The color code to get the RGB specifier from

    Returns
    Type Description
    RedGreenBlue

    The RGB specifier string

    | Edit this page View Source

    GetRgbIntFromColorCode(int)

    Gets the RGB numbers from the color code

    Declaration
    public static (int R, int G, int B) GetRgbIntFromColorCode(int colorCode)
    Parameters
    Type Name Description
    int colorCode

    The color code to get the RGB specifier from

    Returns
    Type Description
    (int R, int G, int B)

    The RGB specifier string

    | Edit this page View Source

    GetRgbSpecifierFromColorCode(int)

    Gets the RGB specifier from the color code

    Declaration
    public static string GetRgbSpecifierFromColorCode(int colorCode)
    Parameters
    Type Name Description
    int colorCode

    The color code to get the RGB specifier from

    Returns
    Type Description
    string

    The RGB specifier string

    | Edit this page View Source

    LoadBack()

    Loads the background

    Declaration
    public static void LoadBack()
    | Edit this page View Source

    LoadBack(Color, bool)

    Loads the background

    Declaration
    public static void LoadBack(Color ColorSequence, bool Force = false)
    Parameters
    Type Name Description
    Color ColorSequence

    Color sequence used to load background

    bool Force

    Force set background even if background setting is disabled

    | Edit this page View Source

    LoadBackDry()

    Loads the background dryly

    Declaration
    public static void LoadBackDry()
    | Edit this page View Source

    LoadBackDry(Color, bool)

    Loads the background dryly

    Declaration
    public static void LoadBackDry(Color ColorSequence, bool Force = false)
    Parameters
    Type Name Description
    Color ColorSequence

    Color sequence used to load background

    bool Force

    Force set background even if background setting is disabled

    | Edit this page View Source

    RenderResetBackground()

    Gets a sequence that resets the background color without clearing screen

    Declaration
    public static string RenderResetBackground()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderResetColors()

    Gets a sequence that resets the console colors without clearing screen

    Declaration
    public static string RenderResetColors()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderResetForeground()

    Gets a sequence that resets the foreground color without clearing screen

    Declaration
    public static string RenderResetForeground()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderRevertBackground()

    Gets a sequence that reverts the background color without clearing screen

    Declaration
    public static string RenderRevertBackground()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderRevertColors()

    Gets a sequence that reverts the console colors without clearing screen

    Declaration
    public static string RenderRevertColors()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderRevertForeground()

    Gets a sequence that reverts the foreground color without clearing screen

    Declaration
    public static string RenderRevertForeground()
    Returns
    Type Description
    string
    | Edit this page View Source

    RenderSetConsoleColor(Color)

    Gets the console color setting sequence

    Declaration
    public static string RenderSetConsoleColor(Color ColorSequence)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    Returns
    Type Description
    string
    | Edit this page View Source

    RenderSetConsoleColor(Color, bool)

    Gets the console color setting sequence

    Declaration
    public static string RenderSetConsoleColor(Color ColorSequence, bool Background)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    Returns
    Type Description
    string
    | Edit this page View Source

    RenderSetConsoleColor(Color, bool, bool, bool)

    Gets the console color setting sequence

    Declaration
    public static string RenderSetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    bool ForceSet

    Force set background even if background setting is disabled or if the current background color doesn't match the provided color

    bool canSet

    Can the console set this color?

    Returns
    Type Description
    string
    | Edit this page View Source

    ResetBackground()

    Resets the background color without clearing screen

    Declaration
    public static void ResetBackground()
    | Edit this page View Source

    ResetColors()

    Resets the console colors without clearing screen

    Declaration
    public static void ResetColors()
    | Edit this page View Source

    ResetForeground()

    Resets the foreground color without clearing screen

    Declaration
    public static void ResetForeground()
    | Edit this page View Source

    RevertBackground()

    Reverts the background color without clearing screen

    Declaration
    public static void RevertBackground()
    | Edit this page View Source

    RevertColors()

    Reverts the console colors without clearing screen

    Declaration
    public static void RevertColors()
    | Edit this page View Source

    RevertForeground()

    Reverts the foreground color without clearing screen

    Declaration
    public static void RevertForeground()
    | Edit this page View Source

    SetConsoleColor(Color, bool)

    Sets the console color

    Declaration
    public static void SetConsoleColor(Color ColorSequence, bool Background)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    | Edit this page View Source

    SetConsoleColor(Color, bool, bool, bool)

    Sets the console color

    Declaration
    public static void SetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    bool ForceSet

    Force set background even if background setting is disabled or if the current background color doesn't match the provided color

    bool canSet

    Can the console set this color?

    | Edit this page View Source

    SetConsoleColorDry(Color, bool)

    Sets the console color dryly

    Declaration
    public static void SetConsoleColorDry(Color ColorSequence, bool Background)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    | Edit this page View Source

    SetConsoleColorDry(Color, bool, bool, bool)

    Sets the console color dryly

    Declaration
    public static void SetConsoleColorDry(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    bool ForceSet

    Force set background even if background setting is disabled or if the current background color doesn't match the provided color

    bool canSet

    Can the console set this color?

    | Edit this page View Source

    TryParseColor(int, int, int, ColorSettings?)

    Tries parsing the color from the specifier string

    Declaration
    public static bool TryParseColor(int R, int G, int B, ColorSettings? settings = null)
    Parameters
    Type Name Description
    int R

    The red level

    int G

    The green level

    int B

    The blue level

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    bool

    True if successful; False if failed

    | Edit this page View Source

    TryParseColor(int, ColorSettings?)

    Tries parsing the color from the specifier string

    Declaration
    public static bool TryParseColor(int ColorNum, ColorSettings? settings = null)
    Parameters
    Type Name Description
    int ColorNum

    The color number

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    bool

    True if successful; False if failed

    | Edit this page View Source

    TryParseColor(string, ColorSettings?)

    Tries parsing the color from the specifier string

    Declaration
    public static bool TryParseColor(string ColorSpecifier, ColorSettings? settings = null)
    Parameters
    Type Name Description
    string ColorSpecifier

    A color specifier. It must be a valid number from 0-255 if using 255-colors, or a VT sequence if using true color as follows: <R>;<G>;<B>

    ColorSettings settings

    Settings to use

    Returns
    Type Description
    bool

    True if successful; False if failed

    | Edit this page View Source

    TrySetConsoleColor(Color, bool, bool, bool)

    Sets the console color

    Declaration
    public static bool TrySetConsoleColor(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    bool ForceSet

    Force set background even if background setting is disabled or if the current background color doesn't match the provided color

    bool canSet

    Can the console set this color?

    Returns
    Type Description
    bool

    True if successful; False if unsuccessful

    | Edit this page View Source

    TrySetConsoleColorDry(Color, bool, bool, bool)

    Sets the console color dryly

    Declaration
    public static bool TrySetConsoleColorDry(Color ColorSequence, bool Background = false, bool ForceSet = false, bool canSet = true)
    Parameters
    Type Name Description
    Color ColorSequence

    The color instance

    bool Background

    Whether to set background or not

    bool ForceSet

    Force set background even if background setting is disabled or if the current background color doesn't match the provided color

    bool canSet

    Can the console set this color?

    Returns
    Type Description
    bool

    True if successful; False if unsuccessful

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX