/// <summary> /// Processes a parser token with type <see cref="TextParserTokenType.Custom"/>. /// </summary> private void ProcessCustomCommandToken(TextLayoutCommandStream output, ref TextParserToken token, ref LayoutState state, ref Int32 index) { var commandID = (token.TokenType - TextParserTokenType.Custom); var commandValue = token.Text.IsEmpty ? default(Int32) : StringSegmentConversion.ParseInt32(token.Text); output.WriteCustomCommand(new TextLayoutCustomCommand(commandID, commandValue)); state.AdvanceLineToNextCommand(); index++; }
/// <summary> /// Parses a <see cref="Color"/> value from the specified string segment. /// </summary> private static Color ParseColor(StringSegment text) { if (text.Length != 8) { throw new FormatException(); } var a = StringSegmentConversion.ParseHexadecimalInt32(text.Substring(0, 2)); var r = StringSegmentConversion.ParseHexadecimalInt32(text.Substring(2, 2)); var g = StringSegmentConversion.ParseHexadecimalInt32(text.Substring(4, 2)); var b = StringSegmentConversion.ParseHexadecimalInt32(text.Substring(6, 2)); return(new Color(r, g, b, a)); }