Redid the tree again.
[Gitrdone.git] / OutputTextWriter.cs
blob98eb5c51fb232018b4872e5129a653e7a86c84ed
2 using System;
3 using System.Windows.Forms;
4 using System.IO;
5 using System.Threading;
6 using System.ComponentModel;
8 namespace Gitrdone
12 public class OutputTextWriter : System.IO.StringWriter
14 delegate void SetTextCallback(char[] buffer, int index, int count);
16 ListBox m_listBox;
17 TextWriter m_realConsole;
18 public OutputTextWriter(ListBox b, TextWriter w)
20 m_listBox = b;
21 m_realConsole = w;
24 public override void Write(char[] buffer, int index, int count)
26 if (!m_listBox.InvokeRequired)
28 string s = new string(buffer);
29 int start = index > -1 ? index : 0;
30 int newcount = count < ((buffer.Length - 1) - start) ? count : ((buffer.Length - 1) - start);
31 m_listBox.Items.Add(s.Substring(index, newcount).Trim());
32 Application.DoEvents();
35 m_realConsole.Write(buffer, index, count);
37 public override void Write(string value)
39 m_listBox.Items.Add(value);
40 m_realConsole.Write(value + System.Environment.NewLine);
41 Application.DoEvents();
44 public void DebugWrite(string value)
46 m_listBox.Items.Add(value);
47 Application.DoEvents();