public static bool FilterItem(TracerItem item, string positiveFilterString, string[] negativeFilterStrings) { string message = item.PrintMessage().ToLower(); // Positive filter check. if (string.IsNullOrEmpty(positiveFilterString) == false && message.Contains(positiveFilterString.ToLower()) == false) { return false; } if (negativeFilterStrings != null) { // Negative filter check. foreach (string filter in negativeFilterStrings) { if (string.IsNullOrEmpty(filter) == false && message.Contains(filter.ToLower())) { return false; } } } // Pass. return true; }
public static bool FilterItem(TracerItem item, string positiveFilterString, string[] negativeFilterStrings) { string message = item.PrintMessage().ToLower(); // Positive filter check. if (string.IsNullOrEmpty(positiveFilterString) == false && message.Contains(positiveFilterString.ToLower()) == false) { return(false); } if (negativeFilterStrings != null) { // Negative filter check. foreach (string filter in negativeFilterStrings) { if (string.IsNullOrEmpty(filter) == false && message.Contains(filter.ToLower())) { return(false); } } } // Pass. return(true); }
protected void LoadTracerItem(TracerItem item) { if (item == null) { textBoxSelectedItemMessage.Text = string.Empty; } else { textBoxSelectedItemMessage.Text = item.PrintMessage(); } this.propertyGridItem.SelectedObject = item; }
private void listView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = new ListViewItem(); TracerItem tracerItem = null; // If we are in the last items, make sure to always leave them blank. if (e.ItemIndex <= listView.VirtualListSize - CleanVirtualItemsCount) { if (_itemKeeperSink != null) { tracerItem = _itemKeeperSink.GetFilteredItem(e.ItemIndex); } } if (tracerItem == null) { e.Item.SubItems.Clear(); for (int i = 0; i < listView.Columns.Count; i++) { e.Item.SubItems.Add(string.Empty); } return; } switch (tracerItem.FullType) { case TracerItem.TypeEnum.MethodEntry: e.Item.ImageIndex = 3; break; case TracerItem.TypeEnum.MethodExit: e.Item.ImageIndex = 4; break; case TracerItem.TypeEnum.Trace: e.Item.ImageIndex = 0; break; case TracerItem.TypeEnum.System: e.Item.ImageIndex = 6; break; case TracerItem.TypeEnum.Warning: case (TracerItem.TypeEnum.Warning | TracerItem.TypeEnum.Operation): e.Item.ImageIndex = 5; break; case (TracerItem.TypeEnum.Error | TracerItem.TypeEnum.Operation): case TracerItem.TypeEnum.Error: e.Item.ImageIndex = 2; break; default: // If there are only items with no images, the image column width gets // substraced from the Column.0 width and this causes a bug. e.Item.ImageIndex = 0; break; } if (e.Item.UseItemStyleForSubItems) { e.Item.UseItemStyleForSubItems = false; } Color color = GetPriorityColor(tracerItem.Priority); if (color != e.Item.SubItems[0].BackColor) { e.Item.SubItems[0].BackColor = color; } string day = tracerItem.DateTime.Day.ToString(); if (tracerItem.DateTime.Day == 1) { day += "st"; } else if (tracerItem.DateTime.Day == 2) { day += "nd"; } else if (tracerItem.DateTime.Day == 3) { day += "rd"; } else { day += "th"; } string time = string.Empty; Tracer tracer = _tracer; if (tracer != null) { if (tracer.TimeDisplayFormat == CommonSupport.Tracer.TimeDisplayFormatEnum.ApplicationTicks) {// Application time. time = Math.Round(((decimal)tracerItem.ApplicationTick / (decimal)Stopwatch.Frequency), 6).ToString(); } else if (tracer.TimeDisplayFormat == CommonSupport.Tracer.TimeDisplayFormatEnum.DateTime) {// Date time conventional. time = day + tracerItem.DateTime.ToString(", HH:mm:ss:ffff"); } else {// Combined. time = day + tracerItem.DateTime.ToString(", HH:mm:ss:ffff"); time += " | " + Math.Round(((decimal)tracerItem.ApplicationTick / (decimal)Stopwatch.Frequency), 6).ToString(); } } e.Item.Text = tracerItem.Index + ", " + time; e.Item.SubItems.Add(tracerItem.PrintMessage()); if (string.IsNullOrEmpty(_markingMatch) == false) { if (StringTracerFilter.FilterItem(tracerItem, _markingMatch, null)) { e.Item.BackColor = Color.PowderBlue; } } }
/// <summary> /// Helper, shows an item to constrol. /// Always call on UI thread. /// </summary> void ShowItem(TracerItem item) { _itemShown = item; if (item == null) { this.toolStripStatusLabelReport.Text = string.Empty; } else { if ((item.FullType & TracerItem.TypeEnum.Error) != 0) { toolStripStatusLabelReport.ForeColor = Color.DarkRed; } else if ((item.FullType & TracerItem.TypeEnum.Warning) != 0) { toolStripStatusLabelReport.ForeColor = Color.DarkBlue; } else { toolStripStatusLabelReport.ForeColor = SystemColors.ControlText; } _lastShow = DateTime.Now; this.toolStripStatusLabelReport.Text = "[" + _pendingMessageItems.Count.ToString() + "] " + item.PrintMessage(); } }
protected override bool OnReceiveItem(TracerItem item, bool isFilteredOutByTracer, bool isFilteredOutBySink) { System.Diagnostics.Trace.WriteLine(item.PrintPrefix(' ') + item.PrintMessage()); return(true); }
private void listView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { e.Item = new ListViewItem(); TracerItem tracerItem = null; // If we are in the last items, make sure to always leave them blank. if (e.ItemIndex <= listView.VirtualListSize - CleanVirtualItemsCount) { lock (_itemKeeperSink) {// Hold the tracer not allowing it to modify its collection before we read it. if (_itemKeeperSink != null && _itemKeeperSink.FilteredItemsCount > e.ItemIndex) { tracerItem = _itemKeeperSink.FilteredItemsUnsafe[e.ItemIndex]; } } } if (tracerItem == null) { e.Item.SubItems.Clear(); for (int i = 0; i < listView.Columns.Count; i++) { e.Item.SubItems.Add(string.Empty); } return; } switch (tracerItem.FullType) { case TracerItem.TypeEnum.MethodEntry: e.Item.ImageIndex = 3; break; case TracerItem.TypeEnum.MethodExit: e.Item.ImageIndex = 4; break; case TracerItem.TypeEnum.Trace: e.Item.ImageIndex = 0; break; case TracerItem.TypeEnum.System: e.Item.ImageIndex = 6; break; case TracerItem.TypeEnum.Warning: case (TracerItem.TypeEnum.Warning | TracerItem.TypeEnum.Operation): e.Item.ImageIndex = 5; break; case (TracerItem.TypeEnum.Error | TracerItem.TypeEnum.Operation): case TracerItem.TypeEnum.Error: e.Item.ImageIndex = 2; break; } if (e.Item.UseItemStyleForSubItems) { e.Item.UseItemStyleForSubItems = false; } Color color = GetPriorityColor(tracerItem.Priority); if (color != e.Item.SubItems[0].BackColor) { e.Item.SubItems[0].BackColor = color; } string day = tracerItem.DateTime.Day.ToString(); if (tracerItem.DateTime.Day == 1) { day += "st"; } else if (tracerItem.DateTime.Day == 2) { day += "nd"; } else if (tracerItem.DateTime.Day == 3) { day += "rd"; } else { day += "th"; } string time = day + tracerItem.DateTime.ToString(", HH:mm:ss:ffff"); e.Item.Text = tracerItem.Index /*(Tracer.TotalItemsCount - (Tracer.FilteredItemsCount - e.ItemIndex)).ToString()*/ + ", " + time; e.Item.SubItems.Add(tracerItem.PrintMessage()); if (string.IsNullOrEmpty(_markingMatch) == false) { if (StringTracerFilter.FilterItem(tracerItem, _markingMatch, null)) { e.Item.BackColor = Color.MistyRose; } } }
protected override bool OnReceiveItem(TracerItem item, bool isFilteredOutByTracer, bool isFilteredOutBySink) { System.Diagnostics.Trace.WriteLine(item.PrintPrefix(' ') + item.PrintMessage()); return true; }