77 lines
2.1 KiB
C#
77 lines
2.1 KiB
C#
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 System.Threading;
|
|
|
|
using C4IT.DataHistoryProvider;
|
|
|
|
namespace C4IT_DataHistoryProvider_Test
|
|
{
|
|
public partial class ctrlProtocolBox : UserControl
|
|
{
|
|
public ctrlProtocolBox()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void ProcessMessage(string Message)
|
|
{
|
|
Invoke(new ThreadStart(() =>
|
|
{
|
|
try
|
|
{
|
|
lock (richTextBox1)
|
|
{
|
|
if (richTextBox1.Lines.Length > 512)
|
|
{
|
|
richTextBox1.ReadOnly = false;
|
|
richTextBox1.Select(0, richTextBox1.GetFirstCharIndexFromLine(richTextBox1.Lines.Length - 512));
|
|
richTextBox1.SelectedText = "";
|
|
richTextBox1.ReadOnly = true;
|
|
}
|
|
richTextBox1.AppendText(Message);
|
|
richTextBox1.AppendText(Environment.NewLine);
|
|
Application.DoEvents();
|
|
}
|
|
}
|
|
catch { }
|
|
}));
|
|
}
|
|
|
|
public void ProcessMessage(cDataHistoryUiStatusMessage Message)
|
|
{
|
|
string line = new string(' ', Message.Indent * 3) + Message.Message;
|
|
ProcessMessage(line);
|
|
}
|
|
|
|
public void ClearMessages()
|
|
{
|
|
Invoke(new ThreadStart(() =>
|
|
{
|
|
try
|
|
{
|
|
lock (richTextBox1)
|
|
{
|
|
richTextBox1.Text = "";
|
|
Application.DoEvents();
|
|
}
|
|
}
|
|
catch { }
|
|
}));
|
|
}
|
|
|
|
private void ctrlProtocolBox_Load(object sender, EventArgs e)
|
|
{
|
|
richTextBox1.HideSelection = false;
|
|
}
|
|
|
|
|
|
}
|
|
}
|