public override void Write(Gk3Main.ConsoleSeverity severity, string text, params object[] arg) { string result = string.Format(text, arg); if (_wrap) { if (Gk3Main.Gui.Font.MeasureString(_font, result).X > _wrapWidth) { wrapLine(result, severity); } else { _lines.Add(new ConsoleLine() { Severity = severity, Text = string.Format(text, arg) }); } } else { _lines.Add(new ConsoleLine() { Severity = severity, Text = string.Format(text, arg) }); } System.Console.WriteLine(result); }
public override void Write(Gk3Main.ConsoleSeverity severity, string text, params object[] arg) { if (severity >= MinSeverity) { _console.Write(text, arg); } }
public override void Write(Gk3Main.ConsoleSeverity severity, string text, params object[] arg) { if (severity >= MinSeverity) { Console.WriteLine(text, arg); System.Diagnostics.Trace.WriteLine(string.Format(text, arg)); } }
private static void wrapLine(string lineToWrap, Gk3Main.ConsoleSeverity severity) { string currentString = lineToWrap; StringBuilder currentLine = new StringBuilder(); int index = 0; while (true) { float lineWidth = _wrapWidth; int prevSpace = -1; currentLine.Length = 0; while (Gk3Main.Gui.Font.MeasureString(_font.Font.Instance, currentLine).X < lineWidth && index < currentString.Length) { if (currentString[index] == ' ') { prevSpace = currentLine.Length; } currentLine.Append(currentString[index++]); } // uh oh, too many characters! back up until we find a space if (index < currentString.Length) { if (prevSpace == -1) { // no spaces found, so just break in the middle of the line string line = currentLine.ToString(); line = line.Substring(0, line.Length - 1); _lines.Add(new ConsoleLine() { Text = line, Severity = severity }); index--; } else { string line = currentLine.ToString().Substring(0, prevSpace); _lines.Add(new ConsoleLine() { Text = line, Severity = severity }); index -= (currentLine.Length - prevSpace - 1); } } else { // apparently we're done! add this last line and exit _lines.Add(new ConsoleLine() { Text = currentLine.ToString(), Severity = severity }); break; } } }