public void WriteLine(string s) { if (memoEdit.InvokeRequired) { memoEdit.BeginInvoke(new Action <string>(WriteLine), s); } else { memoEdit.Text += s + "\r\n"; memoEdit.Select(memoEdit.Text.Length, memoEdit.Text.Length); memoEdit.ScrollToCaret(); } }
protected void AddLog(string msg) { if (mmeLog.Lines.Length > 100) { mmeLog.Text = ""; } if (msg == "") { mmeLog.Text += "\r\n"; } else { mmeLog.Text += string.Format( "{0}: {1}\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), msg); } mmeLog.SelectionStart = mmeLog.Text.Length; mmeLog.ScrollToCaret(); Thread.Sleep(100); WriteLog.Instance.Write(msg, className); }
/// <summary> /// 写日志 /// </summary> /// <param name="txbBlog"></param> /// <param name="blogContent"></param> internal static void WriteBlog(MemoEdit txbBlog, string blogContent) { //由于其他线程不可访问UI线程,故使用Dispatcher调度 //this.Dispatcher.Invoke(new Action(() => { this.txbBlog.AppendText(blogContent + Environment.NewLine); })); //this.Dispatcher.Invoke(new Action(() => { this.txbBlog.ScrollToEnd(); })); txbBlog.Invoke(new Action(() => { txbBlog.Text += blogContent; txbBlog.Text += Environment.NewLine; txbBlog.Text += Environment.NewLine; })); txbBlog.Invoke(new Action(() => { txbBlog.SelectionStart = txbBlog.Text.Length; txbBlog.ScrollToCaret(); })); }
void LogMessage(string message) { memo.Text += (message + Environment.NewLine); memo.SelectionStart = memo.Text.Length; memo.ScrollToCaret(); }
void OnCustomMessage(ViewModelWithCustomMessage.CustomMessage message) { memo.Text += (message.ToString() + Environment.NewLine); memo.SelectionStart = memo.Text.Length; memo.ScrollToCaret(); }