Exemple #1
0
        internal StyleReset Apply(TextWriter output, RichTextBoxThemeStyle style, ref int invisibleCharacterCount)
        {
            invisibleCharacterCount += Set(output, style);
            invisibleCharacterCount += ResetCharCount;

            return(new StyleReset(this, output));
        }
        /// <inheritdoc/>
        public override int Set(TextWriter output, RichTextBoxThemeStyle style)
        {
            if (_styles.TryGetValue(style, out var runStyle))
            {
                var buffer = new StringBuilder();
                buffer.Append("<Run");

                var _ = 0;

                var backgroundColor = runStyle.Background;
                if (!string.IsNullOrWhiteSpace(backgroundColor))
                {
                    buffer.AppendFormat(" Background=\"{0}\"", SpecialCharsEscaping.Apply(backgroundColor, ref _));
                }

                var foregroundColor = runStyle.Foreground;
                if (!string.IsNullOrWhiteSpace(foregroundColor))
                {
                    buffer.AppendFormat(" Foreground=\"{0}\"", SpecialCharsEscaping.Apply(foregroundColor, ref _));
                }

                var fontWeight = runStyle.FontWeight;
                if (!string.IsNullOrWhiteSpace(fontWeight))
                {
                    buffer.AppendFormat(" FontWeight=\"{0}\"", SpecialCharsEscaping.Apply(fontWeight, ref _));
                }

                buffer.Append('>');

                output.Write(buffer);
                return(buffer.Length);
            }

            return(0);
        }
Exemple #3
0
        public override int Set(TextWriter output, RichTextBoxThemeStyle style)
        {
            var start = $"<{style.ToString().ToLowerInvariant()}>";

            output.Write(start);

            return(start.Length);
        }
Exemple #4
0
 /// <summary>
 /// Begin a span of text in the specified <paramref name="style"/>.
 /// </summary>
 /// <param name="output">Output destination.</param>
 /// <param name="style">Style to apply.</param>
 /// <returns> The number of characters written to <paramref name="output"/>. </returns>
 public abstract int Set(TextWriter output, RichTextBoxThemeStyle style);
 public override int Set(TextWriter output, RichTextBoxThemeStyle style) => 0;
 protected StyleReset ApplyStyle(TextWriter output, RichTextBoxThemeStyle style, ref int invisibleCharacterCount)
 {
     return(_theme.Apply(output, style, ref invisibleCharacterCount));
 }