3 using System
.Windows
.Forms
;
5 using System
.Threading
;
6 using System
.ComponentModel
;
12 public class OutputTextWriter
: System
.IO
.StringWriter
14 delegate void SetTextCallback(char[] buffer
, int index
, int count
);
17 TextWriter m_realConsole
;
18 public OutputTextWriter(ListBox b
, TextWriter 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();