/// <summary> /// Initializes a new instance of the <see cref="PlaceholderTextSegment"/> class. /// </summary> /// <param name="textPlaceholder">The text placeholder to use.</param> /// <param name="flags">The text flags.</param> /// <param name="color">The text color.</param> public PlaceholderTextSegment(TextPlaceholder textPlaceholder, FormattedTextFlags flags, Color color) { Flags = flags; Color = color; Text = textPlaceholder.GetText(); textPlaceholder.TextChanged += TextPlaceholderTextChanged; _textPlaceholder = textPlaceholder; }
/// <summary> /// Attempts to create a <see cref="TextPlaceholder"/> based on the given tag. /// </summary> /// <param name="tag">The tag for the placeholder.</param> /// <param name="parameters">The parameters for the placeholder.</param> /// <param name="session">The audio session.</param> /// <param name="placeholder">The text placeholder.</param> /// <returns>True if the tag matches a placeholder.</returns> public static bool TryGetPlaceholder(string tag, IEnumerable <TextPlaceholderParameter> parameters, IAudioSession session, out TextPlaceholder placeholder) { if (PlaceholderMap.TryGetValue(tag, out var func)) { placeholder = func(parameters, session); return(true); } placeholder = null; return(false); }