private void RemoveLogMessage(LogMessageItem item) { _logMessages.Remove(item); Group?.Items.Remove(item.Item); _logListView.Items.Remove(item.Item); }
internal LogMessageItem AddLogMessage(LogMessage logMsg) { var item = new LogMessageItem(this, logMsg); item.Enabled = Enabled; LogMessages.Add(item); // We may remove and add many items, disable the drawing one moment _logListView.BeginUpdate(); // Limit the number of displayed messages if necessary if (UserSettings.Instance.MessageCycleCount > 0 && LogMessages.Count > 1.1 * UserSettings.Instance.MessageCycleCount) { RemoveExtraLogMessages(UserSettings.Instance.MessageCycleCount); } // Set Previous item if (_logListView.Items.Count > 0) { item.Previous = _logListView.Items[_logListView.Items.Count - 1].Tag as LogMessageItem; } // Message if (Enabled) { // Add it to the main list _logListView.Items.Add(item.Item); // Add to the corresponding if necessary if (UserSettings.Instance.GroupLogMessages && (Group != null)) { Group.Items.Add(item.Item); } // Force the item to be visible if necessary if (UserSettings.Instance.AutoScrollToLastLog) { item.Item.EnsureVisible(); } } // Hide the item is is not in range or doesn't match the current text search if any if (!IsItemToBeEnabled(item)) { DisableLogMessage(item); } // Done! _logListView.EndUpdate(); return(item); }
private void RemoveLogMessage(LogMessageItem item) { LogMessages.Remove(item); if (Group != null) { Group.Items.Remove(item.Item); } _logListView.Items.Remove(item.Item); }
private void EnableLogMessage(LogMessageItem item) { if (item.Enabled) { return; } InsertLogMessageByDate(_logListView.Items, item); if (Group != null) { InsertLogMessageByDate(Group.Items, item); } }
private void DisableLogMessage(LogMessageItem item) { if (!item.Enabled) { return; } Group?.Items.Remove(item.Item); _logListView.Items.Remove(item.Item); // Mark the item as disabled item.Enabled = false; }
private void EnableLogMessage(LogMessageItem item, bool enable) { if ((item.Enabled && enable) || (!item.Enabled && !enable)) { return; } if (enable) { EnableLogMessage(item); } else { DisableLogMessage(item); } }
private void RemoveExtraLogMessages(int count) { // TODO: Buggy with Grouping....!!! int idx = 0; while (LogMessages.Count > count) { LogMessageItem item = LogMessages[idx]; if (!item.Enabled) { count++; idx++; } RemoveLogMessage(item); } }
private void InsertLogMessageByDate(ListView.ListViewItemCollection items, LogMessageItem refItem) { // Get previous item var prevItem = refItem; while ((prevItem != null) && !prevItem.Enabled) { prevItem = prevItem.Previous; } var pos = 0; if ((prevItem != null) && (prevItem.Item != null)) { pos = items.IndexOf(prevItem.Item) + 1; } items.Insert(pos, refItem.Item); // Mark the item as enabled refItem.Enabled = true; }
internal bool IsItemToBeEnabled(LogMessageItem item) { return (item.IsLevelInRange() && (!_hasSearchedText || item.HasSearchedText(_searchedText))); }
private void SetLogMessageDetail(LogMessageItem logMsgItem) { // Store the text to avoid editing without settings the control // as readonly... kind of ugly trick... if (logMsgItem == null) { logDetailTextBox.Text = string.Empty; _msgDetailText = String.Empty; PopulateExceptions(null); OpenSourceFile(null, 0); } else { StringBuilder sb = new StringBuilder(); sb.Append("CallSiteClass: "); sb.AppendLine(logMsgItem.Message.CallSiteClass); sb.Append("CallSiteMethod: "); sb.AppendLine(logMsgItem.Message.CallSiteMethod); sb.Append("File: "); sb.AppendLine(logMsgItem.Message.SourceFileName); sb.Append("Line: "); sb.AppendLine(logMsgItem.Message.SourceFileLineNr.ToString()); if (UserSettings.Instance.ShowMsgDetailsProperties) { // Append properties foreach (KeyValuePair<string, string> kvp in logMsgItem.Message.Properties) sb.AppendFormat("{0} = {1}{2}", kvp.Key, kvp.Value, Environment.NewLine); } // Append message sb.AppendLine(logMsgItem.Message.Message.Replace("\n", "\r\n")); // Append exception tbExceptions.Text = string.Empty; if (UserSettings.Instance.ShowMsgDetailsException && !String.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { //sb.AppendLine(logMsgItem.Message.ExceptionString); if (!string.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { PopulateExceptions(logMsgItem.Message.ExceptionString); } } _msgDetailText = sb.ToString(); logDetailTextBox.ForeColor = logMsgItem.Message.Level.Color; logDetailTextBox.Text = _msgDetailText; OpenSourceFile(logMsgItem.Message.SourceFileName, logMsgItem.Message.SourceFileLineNr); } }
private void RemoveLogMessage(LogMessageItem item) { LogMessages.Remove(item); if (Group != null) Group.Items.Remove(item.Item); _logListView.Items.Remove(item.Item); }
private void InsertLogMessageByDate(ListView.ListViewItemCollection items, LogMessageItem refItem) { // Get previous item LogMessageItem prevItem = refItem; while ((prevItem != null) && !prevItem.Enabled) prevItem = prevItem.Previous; int pos = 0; if ((prevItem != null) && (prevItem.Item != null)) pos = items.IndexOf(prevItem.Item) + 1; items.Insert(pos, refItem.Item); // Mark the item as enabled refItem.Enabled = true; }
private void EnableLogMessage(LogMessageItem item) { if (item.Enabled) return; InsertLogMessageByDate(_logListView.Items, item); if (Group != null) InsertLogMessageByDate(Group.Items, item); }
private void EnableLogMessage(LogMessageItem item, bool enable) { if ((item.Enabled && enable) || (!item.Enabled && !enable)) return; if (enable) EnableLogMessage(item); else DisableLogMessage(item); }
private void DisableLogMessage(LogMessageItem item) { if (!item.Enabled) return; if (Group != null) Group.Items.Remove(item.Item); _logListView.Items.Remove(item.Item); // Mark the item as disabled item.Enabled = false; }
internal bool IsItemToBeEnabled(LogMessageItem item) { return(item.IsLevelInRange() && (!_hasSearchedText || item.HasSearchedText(_searchedText))); }
internal LogMessageItem AddLogMessage(LogMessage logMsg) { LogMessageItem item = new LogMessageItem(this, logMsg) { Enabled = Enabled }; _logMessages.Add(item); // We may remove and add many items, disable the drawing one moment _logListView.BeginUpdate(); // Limit the number of displayed messages if necessary if (UserSettings.Instance.MessageCycleCount > 0) { RemoveExtraLogMessages(UserSettings.Instance.MessageCycleCount); } int index = 0; if (_logListView.Items.Count > 0) { for (index = _logListView.Items.Count; index > 0; --index) { item.Previous = _logListView.Items[index - 1].Tag as LogMessageItem; if (item.Previous.Message.TimeStamp.Ticks <= item.Message.TimeStamp.Ticks) { break; } } } // Message if (Enabled) { // Add it to the main list _logListView.Items.Insert(index, item.Item); // Add to the corresponding if necessary if (UserSettings.Instance.GroupLogMessages && Group != null) { Group.Items.Add(item.Item); } // Force the item to be visible if necessary if (UserSettings.Instance.AutoScrollToLastLog) { item.Item.EnsureVisible(); } } // Hide the item is is not in range or doesn't match the current text search if any if (!IsItemToBeEnabled(item)) { DisableLogMessage(item); } // Done! _logListView.EndUpdate(); return(item); }
private void SetLogMessageDetail(LogMessageItem logMsgItem) { // Store the text to avoid editing without settings the control // as readonly... kind of ugly trick... if (logMsgItem == null) { _msgDetailText = String.Empty; } else { StringBuilder sb = new StringBuilder(); if (UserSettings.Instance.ShowMsgDetailsProperties) { // Append properties foreach (KeyValuePair<string, string> kvp in logMsgItem.Message.Properties) sb.AppendFormat("{0} = {1}{2}", kvp.Key, kvp.Value, Environment.NewLine); } // Append message sb.AppendLine(logMsgItem.Message.Message.Replace("\n", "\r\n")); // Append exception if (UserSettings.Instance.ShowMsgDetailsException && !String.IsNullOrEmpty(logMsgItem.Message.ExceptionString)) { sb.AppendLine(logMsgItem.Message.ExceptionString); } _msgDetailText = sb.ToString(); logDetailTextBox.ForeColor = logMsgItem.Message.Level.Color; } logDetailTextBox.Text = _msgDetailText; }
internal LogMessageItem AddLogMessage(LogMessage logMsg) { LogMessageItem item = new LogMessageItem(this, logMsg); item.Enabled = Enabled; LogMessages.Add(item); // We may remove and add many items, disable the drawing one moment _logListView.BeginUpdate(); // Limit the number of displayed messages if necessary if (UserSettings.Instance.MessageCycleCount > 0) RemoveExtraLogMessages(UserSettings.Instance.MessageCycleCount); // Set Previous item if (_logListView.Items.Count > 0) item.Previous = _logListView.Items[_logListView.Items.Count - 1].Tag as LogMessageItem; // Message if (Enabled) { // Add it to the main list _logListView.Items.Add(item.Item); // Add to the corresponding if necessary if (UserSettings.Instance.GroupLogMessages && (Group != null)) Group.Items.Add(item.Item); // Force the item to be visible if necessary if (UserSettings.Instance.AutoScrollToLastLog) item.Item.EnsureVisible(); } // Hide the item is is not in range or doesn't match the current text search if any if (!IsItemToBeEnabled(item)) DisableLogMessage(item); // Done! _logListView.EndUpdate(); return item; }