Loading...
Searching...
No Matches
TextBoxBaseWriter.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6using System.Windows.Forms;
7using System.Diagnostics;
8
9namespace InterruptGui
10{
11 class TextBoxBaseWriter : TextWriter
12 {
13 private TextBoxBase _textBoxBase;
14 private Form _form;
15
16 public TextBoxBaseWriter(TextBoxBase textBoxBase, Form form)
17 {
18 _textBoxBase = textBoxBase;
19 _form = form;
20 }
21
22 public override void Write(String text)
23 {
24 MethodInvoker action = delegate
25 {
26 _textBoxBase.AppendText(text);
27 _textBoxBase.ScrollToCaret();
28 };
29 _form.BeginInvoke(action);
30 }
31
32 public override void Write(Char[] buffer, Int32 index, Int32 count)
33 {
34 String text = String.Empty;
35 for (int i = index; i < index + count; i++)
36 {
37 text += buffer[i];
38 }
39 Write(text);
40 }
41
42 public override Encoding Encoding
43 {
44 get { return System.Text.Encoding.UTF8; }
45 }
46 }
47}