using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Tps_LQ_Transmitter.com; namespace Tps_LQ_Transmitter.views { public partial class FrmMsg : Form { public FrmMsg() { InitializeComponent(); } private void BtnClear_Click(object sender, EventArgs e) { this.richTextBox1.Clear(); } List frmMainMsgs; int index = 1; public void ShowMsg(List msgs) { if (msgs == null) return; frmMainMsgs = msgs; if (this.Visible == true) { if(this.InvokeRequired) { this.Invoke(new Action(() => { if (this.richTextBox1.Text.Length > 1024000) this.richTextBox1.Clear(); foreach (var item in msgs) { richTextBox1.AppendText(string.Format("{0} {1}:{2}{3}", index.ToString(), item.type.ToString(), item.message, Environment.NewLine)); } index++; msgs.Clear(); })); } else { if (this.richTextBox1.Text.Length > 1024000) this.richTextBox1.Clear(); foreach (var item in msgs) { richTextBox1.AppendText(string.Format("{0} {1}:{2}{3}", index.ToString(), item.type.ToString(), item.message, Environment.NewLine)); } index++; msgs.Clear(); } } } public void ClearMsg() { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.richTextBox1.Clear(); })); } else { this.richTextBox1.Clear(); } index = 1; } private void FrmMsg_VisibleChanged(object sender, EventArgs e) { if(this.Visible) { ShowMsg(this.frmMainMsgs); } } } }