Logs hour formatting switch to 24h format.
4 using System.Windows.Forms;
6 namespace SharpDisplayManager
8 public class RichTextBoxTextWriter : TextWriter
10 public delegate void WriteDelegate(char aChar);
12 RichTextBox iRichTextBox = null;
13 string iAccumulator = "";
14 private char iLastChar='\n';
16 public RichTextBoxTextWriter(RichTextBox aRichTextBox)
18 iRichTextBox = aRichTextBox;
21 public override void Write(char aChar)
29 //Put our time stamp if starting a new line
30 char previousChar = iLastChar;
32 if (previousChar == '\n')
34 //Write(DateTime.Now.ToString("yyyy/MM/dd - HH:mm:ss.fff: "));
35 Write(DateTime.Now.ToString("MM/dd HH:mm:ss.fff: "));
40 if (iRichTextBox.InvokeRequired)
44 iAccumulator += aChar;
47 //Invoke was not working from here
48 //WriteDelegate d = new WriteDelegate(Write);
49 //iRichTextBox.Invoke(d, new object[] { aChar });
54 iRichTextBox.AppendText(aChar.ToString()); // When character data is written, append it to the text box.
58 public override Encoding Encoding
60 get { return System.Text.Encoding.UTF8; }
66 public override void Flush()
72 if (!string.IsNullOrEmpty(iAccumulator))
74 iRichTextBox.AppendText(iAccumulator); // When character data is written, append it to the text box.