Class KeyGestureFormatInfo
Provides platform specific formatting information for the KeyGesture class
public sealed class KeyGestureFormatInfo : IFormatProvider
- Inheritance
-
KeyGestureFormatInfo
- Implements
- Inherited Members
Constructors
KeyGestureFormatInfo(IReadOnlyDictionary<Key, string>?, string, string, string, string)
Provides platform specific formatting information for the KeyGesture class
public KeyGestureFormatInfo(IReadOnlyDictionary<Key, string>? platformKeyOverrides = null, string meta = "Cmd", string ctrl = "Ctrl", string alt = "Alt", string shift = "Shift")
Parameters
platformKeyOverrides
IReadOnlyDictionary<Key, string>A dictionary of Key to String overrides for specific characters, for example Key.Left to "Left Arrow" or "←" on Mac. A null value is assumed to be the Invariant, so the included set of common overrides will be skipped if this is null. If only the common overrides are desired, pass an empty Dictionary instead.
meta
stringThe string to use for the Meta modifier, defaults to "Cmd"
ctrl
stringThe string to use for the Ctrl modifier, defaults to "Ctrl"
alt
stringThe string to use for the Alt modifier, defaults to "Alt"
shift
stringThe string to use for the Shift modifier, defaults to "Shift"
Properties
Alt
The string used to represent Alt on the appropriate platform. Defaults to "Alt".
public string Alt { get; }
Property Value
Ctrl
The string used to represent Ctrl on the appropriate platform. Defaults to "Ctrl".
public string Ctrl { get; }
Property Value
Invariant
The Invariant format. Only uses strings straight from the appropriate Enums.
public static KeyGestureFormatInfo Invariant { get; }
Property Value
Meta
The string used to represent Meta on the appropriate platform. Defaults to "Cmd".
public string Meta { get; }
Property Value
Shift
The string used to represent Shift on the appropriate platform. Defaults to "Shift".
public string Shift { get; }
Property Value
Methods
FormatKey(Key)
Checks the platformKeyOverrides and s_commonKeyOverrides Dictionaries, in order, for the appropriate string to represent the given Key on this platform. NOTE: If platformKeyOverrides is null, this is assumed to be the Invariant and the Dictionaries are not checked. The plain Enum string is returned instead.
public string FormatKey(Key key)
Parameters
key
KeyThe Key to format.
Returns
- string
The appropriate platform specific or common override if present, key.ToString() if not or this is the Invariant.
GetFormat(Type?)
public object? GetFormat(Type? formatType)
Parameters
formatType
Type
Returns
GetInstance(IFormatProvider?)
Gets the most appropriate KeyGestureFormatInfo for the IFormatProvider requested. This will be, in order:
- The provided IFormatProvider as a KeyGestureFormatInfo
- The currently registered platform specific KeyGestureFormatInfo, if present.
- The Invariant otherwise.
public static KeyGestureFormatInfo GetInstance(IFormatProvider? formatProvider)
Parameters
formatProvider
IFormatProviderThe IFormatProvider to get a KeyGestureFormatInfo for.