Table of Contents

Method TryParse

Namespace
Terminal.Gui.Drawing
Assembly
Terminal.Gui.dll

TryParse(string, out Color?)

Converts the provided string to a new Color instance.

public static bool TryParse(string text, out Color? color)

Parameters

text string

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any of the ColorName16 string values.

color Color?

The parsed value.

Returns

bool

A boolean value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.

TryParse(string?, IFormatProvider?, out Color)

Converts the provided string to a new Color value.

static bool TryParse(string? text, IFormatProvider? formatProvider, out Color result)

Parameters

text string

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any of the Terminal.Gui.Drawing.Color.GetClosestNamedColor16(Terminal.Gui.Drawing.Color) string values.

formatProvider IFormatProvider

Optional IFormatProvider to provide formatting services for the input text.
Defaults to InvariantCulture if null.

result Color

The parsed value, if successful, or default(Color), if unsuccessful.

Returns

bool

A bool value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.

TryParse(ReadOnlySpan<char>, IFormatProvider?, out Color)

Converts the provided ReadOnlySpan<T> of char to a new Color value.

static bool TryParse(ReadOnlySpan<char> text, IFormatProvider? formatProvider, out Color color)

Parameters

text ReadOnlySpan<char>

The text to analyze. Formats supported are "#RGB", "#RRGGBB", "#ARGB", "#AARRGGBB", "rgb(r,g,b)", "rgb(r,g,b,a)", "rgba(r,g,b)", "rgba(r,g,b,a)", and any W3C color name."/> string values.

formatProvider IFormatProvider

If specified and not null, will be passed to Parse(ReadOnlySpan<char>, IFormatProvider?).

color Color

The parsed value, if successful, or default(Color), if unsuccessful.

Returns

bool

A bool value indicating whether parsing was successful.

Remarks

While Color supports the alpha channel A, Terminal.Gui does not.

TryParse(ReadOnlySpan<byte>, IFormatProvider?, out Color)

static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Color result)

Parameters

utf8Text ReadOnlySpan<byte>
provider IFormatProvider
result Color

Returns

bool