예제 #1
0
        private string MessageTooltip(Doc.LogEntry entry)
        {
            string tooltip;

            if (entry.Exception == null)
            {
                tooltip = entry.Message;
            }
            else
            {
                tooltip = string.Format(Strings.ErrorList.ExceptionTooltipFmt, entry.Exception);
            }
            return(tooltip);
        }
예제 #2
0
        public void AddLogEntry(Doc.LogEntry entry)
        {
            var severity = entry.Severity.ToString();
            var lastItem = _list.Items.Count > 0 ? _list.Items[_list.Items.Count - 1] : null;

            if (lastItem != null && lastItem.SubItems.Count == 3)
            {
                if (lastItem.SubItems[0].Text == severity && lastItem.SubItems[1].Text == entry.Message)
                {
                    int count;
                    if (!int.TryParse(lastItem.SubItems[2].Text, out count))
                    {
                        count = 0;
                    }
                    ++count;
                    lastItem.SubItems[2].Text = count.ToString();
                    lastItem.SubItems[2].Tag  = CountTooltip(severity, count);
                    return;
                }
            }
            var lvi = new ListViewItem(severity);

            lvi.ImageKey        = severity;
            lvi.SubItems[0].Tag = s_severityTooltips[entry.Severity];
            lvi.SubItems.Add(entry.Message);
            lvi.SubItems[1].Tag = MessageTooltip(entry);
            lvi.SubItems.Add("1");
            lvi.SubItems[2].Tag = CountTooltip(severity, 1);
            // item's own tag contains the info to copy to clipboard if requested (same but not html formatted):
            StringBuilder sb = new StringBuilder();

            sb.Append(severity);
            sb.Append(':');
            sb.AppendLine();
            if (entry.Exception == null)
            {
                sb.Append(entry.Message);
            }
            else
            {
                sb.Append(entry.Exception.ToString());
            }
            lvi.Tag = sb.ToString();
            _list.Items.Add(lvi);
            OnSelectionChanged();
        }