137 |
writer.Close(); |
writer.Close(); |
138 |
//string text = value.Replace(System.Environment.NewLine,""); |
//string text = value.Replace(System.Environment.NewLine,""); |
139 |
string text = value.Replace(System.Environment.NewLine, Log.NewLine); |
string text = value.Replace(System.Environment.NewLine, Log.NewLine); |
140 |
if (text.StartsWith(Log.NewLine)) |
//if (text.StartsWith(Log.NewLine)) |
141 |
{ |
//{ |
142 |
text = text.Remove(0, Log.NewLine.Length); |
// text = text.Remove(0, Log.NewLine.Length); |
143 |
} |
//} |
144 |
sw.Write(text); |
sw.Write(text); |
145 |
Application.DoEvents(); |
Application.DoEvents(); |
146 |
} |
} |
193 |
public LogStream() : this(null) { } |
public LogStream() : this(null) { } |
194 |
public LogStream(LogWriter text) : base() { _text_writer = text; this.NewLine = "\n"; } |
public LogStream(LogWriter text) : base() { _text_writer = text; this.NewLine = "\n"; } |
195 |
private LogWriter _text_writer; |
private LogWriter _text_writer; |
196 |
private void _write(string message) |
private void _write(string message) { if (_text_writer == null) return; _text_writer.SetLogText(string.Format("{0}", message)); } |
|
{ |
|
|
if (_text_writer == null) return; |
|
|
|
|
|
if (message.EndsWith(this.NewLine)) |
|
|
{ |
|
|
strMessage.Append(System.Environment.NewLine); |
|
|
//_text_writer.SetLogText(string.Format("{0}", strMessage.ToString())); |
|
|
while (_text_writer.logupdater.IsBusy) |
|
|
{ |
|
|
Application.DoEvents(); |
|
|
} |
|
|
_text_writer.logupdater.RunWorkerAsync((string.Format("{0}", strMessage.ToString()))); |
|
|
strMessage = new StringBuilder(); |
|
|
} |
|
|
strMessage.Append(message); |
|
|
} |
|
197 |
#region Overriden Methods |
#region Overriden Methods |
198 |
public override Encoding Encoding { get { return Encoding.UTF8; } } |
public override Encoding Encoding { get { return Encoding.UTF8; } } |
199 |
public override void Write(char value) { base.Write(value); _write(value.ToString()); if (!_text_writer.BeginUpdate) _text_writer.EndLogUpdate(); } |
public override void Write(char value) { base.Write(value); _write(value.ToString()); if (!_text_writer.BeginUpdate) _text_writer.EndLogUpdate(); } |
202 |
#endregion |
#endregion |
203 |
|
|
204 |
private void autoscroll_timer_Tick(object sender, EventArgs e) |
private void autoscroll_timer_Tick(object sender, EventArgs e) |
205 |
{ |
{ |
206 |
try |
try |
207 |
{ |
{ |
208 |
if (this.DesignMode) { return; } |
if (this.DesignMode) { return; } |
209 |
//txtLog.ScrollToEnd(); |
////txtLog.ScrollToEnd(); |
210 |
//txtLog.SelectionStart = txtLog.Text.Length-100; |
//txtLog.SelectionStart = txtLog.Text.Length - 100; |
211 |
//txtLog.ScrollToCaret(); |
//txtLog.ScrollToCaret(); |
212 |
//txtLog.Refresh(); |
//txtLog.Refresh(); |
213 |
|
|
222 |
string line = ""; |
string line = ""; |
223 |
while ((line = sr.ReadLine()) != null) |
while ((line = sr.ReadLine()) != null) |
224 |
{ |
{ |
225 |
position += (line.Length); |
position += (line.Length * 2); |
226 |
last_line_position = (line.Length * 2); |
last_line_position = (line.Length * 2); |
227 |
//if (line.EndsWith("/n")) |
//if (line.EndsWith("/n")) |
228 |
//{ |
//{ |
230 |
//} |
//} |
231 |
//logger.VerboseDebug.WriteLine("current line: {0}", line); |
//logger.VerboseDebug.WriteLine("current line: {0}", line); |
232 |
} |
} |
233 |
txtLog.SelectionStart = position; |
txtLog.SelectionStart = txtLog.Text.Length * 2; |
234 |
txtLog.ScrollToCaret(); |
txtLog.ScrollToCaret(); |
235 |
txtLog.Refresh(); |
txtLog.Refresh(); |
236 |
//autoscroll_timer.Enabled = false; |
//autoscroll_timer.Enabled = false; |
237 |
} |
} |
238 |
catch { } |
catch { } |
|
} |
|
|
|
|
|
private void logupdater_DoWork(object sender, DoWorkEventArgs e) |
|
|
{ |
|
|
string message = e.Argument.ToString(); |
|
|
SetLogText(string.Format("{0}", message)); |
|
|
} |
|
|
|
|
|
private void logupdater_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
|
|
{ |
|
239 |
|
|
240 |
} |
} |
241 |
} |
} |