/// <summary> /// Add Message /// </summary> /// <param name="Message">Message to show</param> public string Add(string description, byte[] data, Color color = default(Color), bool withTime = true, bool input = true) { string text = ""; var now = DateTime.Now; var delay = now - LastLogTime; if (LastLogTime == DateTime.MinValue) { delay = new TimeSpan(); } LastLogTime = now; text = ConvertToText(data, !input); string header = CreateHeader(description, text, withTime, input); // ----- Add message ----- var record = new LogRecord(LastLogTime, header, text, data, color, withTime, input, delay); Recods.Add(record); // ----- Event ----- if (NewRecord != null) { NewRecord(record); } // ----- Save log to file ----- if (SaveToFile) { Save(text); } // ----- Add rich text ----- /* rtf.Select(rtf.TextLength, 0); * rtf.SelectionColor = color; * rtf.AppendText(text + Environment.NewLine);*/ // ----- Max records ----- if (MaxRecords > 0) { if (Recods.Count >= MaxRecords) { var RecordLength = Recods[0].text.Length; Recods.RemoveAt(0); /*rtf.Select(0, RecordLength + 1); * rtf.SelectedText = "";*/ } } return(text); }
public void SetPacketView(ePacketView packetView) { if (PacketView != packetView) { PacketView = packetView; for (int i = 0; i < Recods.Count; i++) { var item = Recods[i]; item.dataText = ConvertToText(item.data, !item.input); item.text = item.header + item.dataText; Recods.RemoveAt(i); Recods.Insert(i, item); } } }
/// <summary> /// Clear message /// </summary> public void ClearLog() { Recods.Clear(); }