public void LogAppend(string text) { if (!this.InvokeRequired) { if (text.Length > 0) { m_rtb.SelectionStart = m_rtb.Text.Length; m_rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Regular); if (text[0] == '1') { m_rtb.SelectionColor = Color.Black; } else if (text[0] == '2') { //m_rtb.SelectionFont.Bold = true; m_rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Bold); m_rtb.SelectionColor = Color.Red; } else { m_rtb.SelectionColor = Color.FromArgb(0x33, 0x66, 0x66); } m_rtb.SelectedText = text.Substring(1) + Environment.NewLine; m_rtb.AppendText(m_rtb.SelectedText); } } else { LogAppendCallback d = new LogAppendCallback(LogAppend); this.Invoke(d, new object[] { text }); } }
public void LogAppend(string text) { if (!this.InvokeRequired) { if (text.Length > 0) { m_rtb.SelectionStart = m_rtb.Text.Length; m_rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Regular); if (text[0] == '1') { m_rtb.SelectionColor = Color.Black; } else if (text[0] == '2') { //m_rtb.SelectionFont.Bold = true; m_rtb.SelectionFont = new Font("Courier New", 10, FontStyle.Bold); m_rtb.SelectionColor = Color.Red; } else m_rtb.SelectionColor = Color.FromArgb(0x33, 0x66, 0x66); m_rtb.SelectedText = text.Substring(1) + Environment.NewLine; m_rtb.AppendText(m_rtb.SelectedText); } } else { LogAppendCallback d = new LogAppendCallback(LogAppend); this.Invoke(d, new object[] { text }); } }
private void LogAppend(string txt, Color?color = null) { if (this.richTxtLog.InvokeRequired) { while (!this.richTxtLog.IsHandleCreated) { if (this.richTxtLog.Disposing || this.richTxtLog.IsDisposed) { return; } } LogAppendCallback callback = LogAppend; this.richTxtLog.Invoke(callback, txt, color); } else { richTxtLog.SelectionColor = color ?? Color.Black; this.richTxtLog.AppendText($"{txt}{Environment.NewLine}"); this.richTxtLog.ScrollToCaret(); } }