/// <summary> /// Append Log of the given color. /// </summary> /// <param name="inLog">new Log to add to the Log Control</param> void AppendLog(Log inLog) { if (!LogRTB.IsDisposed) { int lengthBefore = LogRTB.TextLength; string pad = ""; for (int i = 8 - inLog.Severity.ToString().Length; i > 0; i--) { pad += " "; } string log = String.Format("{0}{1}: {2}\r\n", inLog.Severity, pad, inLog.Text); LogRTB.SelectionLength = 0; // clear LogRTB.SelectionStart = 0; LogRTB.SelectedText = log; int length = LogRTB.TextLength - lengthBefore; // Textbox may transform chars, so (end-start) != text.Length LogRTB.Select(0, length); { LogRTB.SelectionColor = LogColors[inLog.Severity]; } } }