/// <summary> /// Writes the specified text to the results textbox indented by the specified number of tabs. /// Arguments may be inserted into the text, as in string.Format() and Console.WriteLine(). /// </summary> protected virtual void DisplayIndentedText(FormatTextMethod formatTextMethod, TextType textType, int indentLevel, string text, bool wrapText, bool includeNewLine, params object[] args) { if (!string.IsNullOrEmpty(text) && text.Trim().Length > 0 && args != null && args.Length > 0) { text = string.Format(text, args); } int indentWidth = _tabWidth * indentLevel; string indentedText = new string(' ', indentWidth) + text; int startOfTextPosition = this.TextBox.TextLength + indentWidth; int highlightedTextLength = text.IndexOf(" (type:"); if (highlightedTextLength == -1) { highlightedTextLength = text.IndexOf(':'); } if (highlightedTextLength == -1) { highlightedTextLength = text.Length; } this.TextBox.AppendText(indentedText); formatTextMethod(indentLevel, startOfTextPosition, highlightedTextLength, textType); if (includeNewLine) { this.TextBox.AppendText(Environment.NewLine); } }
/// <summary> /// Displays the specified text indented by the specified number of tabs. Similar to /// DisplayIndentedText but if the text is of the form "header: text" then the header may /// be formatted differently from the remaining text. /// </summary> public override void DisplayHeadedText(int indentLevel, string text, bool wrapText, bool includeNewLine, params object[] args) { FormatTextMethod formatTextMethod = new FormatTextMethod(this.FormatText); this.DisplayIndentedText(formatTextMethod, TextType.Headed, indentLevel, text, wrapText, includeNewLine, args); }
/// <summary> /// Displays the specified text formatted appropriately for the text type. /// </summary> protected void DisplayTitle(string titleText, TextType textType) { int titleLength = titleText.Length; bool wrapText = false; bool includeNewLine = true; FormatTextMethod formatTextMethod = new FormatTextMethod(FormatText); this.DisplayIndentedText(formatTextMethod, textType, 0, titleText, wrapText, includeNewLine); }