12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- 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<TestMessage> frmMainMsgs;
- int index = 1;
- public void ShowMsg(List<TestMessage> 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);
- }
- }
- }
- }
|