Table of Contents

Method SetFlags

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

SetFlags(IReadOnlyDictionary<uint, string>)

Set the flags and flag names.

public void SetFlags(IReadOnlyDictionary<uint, string> flags)

Parameters

flags IReadOnlyDictionary<uint, string>

SetFlags<TEnum>()

Set the flags and flag names from an enum type.

public void SetFlags<TEnum>() where TEnum : struct, Enum

Type Parameters

TEnum

The enum type to extract flags from

Remarks

This is a convenience method that converts an enum to a dictionary of flag values and names. The enum values are converted to uint values and the enum names become the display text.

SetFlags<TEnum>(Func<TEnum, string>)

Set the flags and flag names from an enum type with custom display names.

public void SetFlags<TEnum>(Func<TEnum, string> nameSelector) where TEnum : struct, Enum

Parameters

nameSelector Func<TEnum, string>

A function that converts enum values to display names

Type Parameters

TEnum

The enum type to extract flags from

Examples

// Use enum values with custom display names
var flagSelector = new FlagSelector ();
flagSelector.SetFlags<FlagSelectorStyles>
     (f => f switch {
     FlagSelectorStyles.ShowNone => "Show None Value",
     FlagSelectorStyles.ShowValueEdit => "Show Value Editor",
     FlagSelectorStyles.All => "Everything",
     _ => f.ToString()
     });

Remarks

This is a convenience method that converts an enum to a dictionary of flag values and custom names. The enum values are converted to uint values and the display names are determined by the nameSelector function.