Пример #1
0
 public void Append([PexAssumeUnderTest] RTFBuilder target, string value)
 {
     target.Append(value);
     // TODO: add assertions to method RTFBuilderTest.Append(RTFBuilder, String)
 }
Пример #2
0
        /// <summary>
        /// Fills the rich edit.
        /// </summary>
        /// <param name="rich">The rich.</param>
        /// <param name="value">The value.</param>
        public void FillRichEdit(System.Windows.Forms.RichTextBox rich, string value)
        {
            rich.Text = string.Empty;
            this.Line = value;

            RTFBuilder sb = new RTFBuilder {
                BackColor = rich.BackColor
            };

            while (this.TokenId != TokenKind.tkNull)
            {
                Color forecolor;
                switch (this.TokenId)
                {
                case TokenKind.tkKey:
                    forecolor = Color.Blue;
                    break;

                case TokenKind.tkFunction:
                    forecolor = Color.Fuchsia;
                    break;

                case TokenKind.tkGreyKeyword:
                    forecolor = Color.Gray;
                    break;

                case TokenKind.tkFuKeyword:
                    forecolor = Color.Fuchsia;
                    break;

                case TokenKind.tkDatatype:
                    forecolor = Color.Blue;
                    break;

                case TokenKind.tkNumber:
                    forecolor = Color.Red;
                    break;

                case TokenKind.tkString:
                    forecolor = Color.Red;
                    break;

                case TokenKind.tkComment:
                    forecolor = Color.DarkGreen;
                    break;

                default:
                    forecolor = Color.Black;
                    break;
                }

                sb.ForeColor = forecolor;
                if (this.Token == Environment.NewLine || this.Token == "\r" || this.Token == "\n")
                {
                    sb.AppendLine();
                }
                else
                {
                    sb.Append(this.Token);
                }

                this.Next();
            }

            rich.Rtf = sb.ToString();
        }