예제 #1
0
 private void lvCompare_DoubleClick(object sender, EventArgs e)
 {
     if (lvCompare.SelectedItems.Count > 0)
     {
         TypeEntryListViewItem item = (TypeEntryListViewItem)lvCompare.SelectedItems[0];
         SwapFilteredState(item);
     }
 }
예제 #2
0
 private void lvFiltered_DoubleClick(object sender, EventArgs e)
 {
     if (lvFiltered.SelectedItems.Count > 0)
     {
         TypeEntryListViewItem item  = (TypeEntryListViewItem)lvFiltered.SelectedItems[0];
         TypeEntry             entry = (TypeEntry)item.Tag;
         SwapFilteredState(GetItemFromEntry(lvCompare, entry));
     }
 }
예제 #3
0
        private void AddFilteredEntry(TypeEntry entry)
        {
            _filteredEntries.Add(entry);

            var item = new TypeEntryListViewItem(entry.Count.ToString("#,#"));

            item.Tag      = entry;
            item.Filtered = true;
            item.SubItems.Add(entry.TotalSize.ToString("#,#"));
            item.SubItems.Add(entry.Name);
            lvFiltered.Items.Add(item);
        }
예제 #4
0
        private void SwapFilteredState(TypeEntryListViewItem item)
        {
            item.Filtered = !item.Filtered;

            if (item.Filtered)
            {
                item.ImageIndex = 0;
                AddFilteredEntry((TypeEntry)item.Tag);
            }
            else
            {
                item.ImageIndex = -1;
                // Note: the item must be redrawn when the image is reset to -1
                lvCompare.RedrawItems(item.Index, item.Index, "force redraw" == null);

                RemoveFilteredEntry((TypeEntry)item.Tag);
            }
        }
예제 #5
0
        private void CompareSnapshots()
        {
            HeapSnapshot compare = HeapSnapshotFactory.Compare(_reference, _current);

            HeapSnapshotFactory.DumpSnapshot(compare);

            // if the check box is checked, don't show the System.* types
            bool dontShowBCLType = cbDontShowBCLTypes.Checked;

            // update the Raw UI
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("HeapSnapshot at {0}\r\n", compare.TimeStamp);
            sb.AppendFormat("  {0} objects for {1} bytes\r\n", compare.ObjectCount, compare.Size);
            var entries =
                from item in compare.TypeStats.AsParallel()
                where !dontShowBCLType || !IsBclType(item.Value.Name)
                orderby item.Value.Name
                select item.Value
            ;

            foreach (var entry in entries)
            {
                sb.AppendFormat("    {0}\r\n", entry);
            }
            tbResult.Text = sb.ToString();

            // update the List UI
            lvCompare.BeginUpdate();
            lvFiltered.BeginUpdate();
            lvCompare.Items.Clear();
            lvFiltered.Items.Clear();

            foreach (var entry in compare.TypeStats)
            {
                TypeEntryListViewItem item;

                // Create a wrapping ListViewItem for the filtered list if needed
                // Note: always present even though DontShowBCLType is checked
                if (IsFilteredType(entry.Value))
                {
                    AddFilteredEntry(entry.Value);
                }

                // skip BCL when needed
                if (dontShowBCLType)
                {
                    if (IsBclType(entry.Value.Name))
                    {
                        continue;
                    }
                }

                // Create a wrapping ListViewItem for the compare list
                item     = new TypeEntryListViewItem("");
                item.Tag = entry.Value;
                item.SubItems.Add(entry.Value.Count.ToString("#,#"));
                item.SubItems.Add(entry.Value.TotalSize.ToString("#,#"));
                item.SubItems.Add(entry.Value.Name);
                lvCompare.Items.Add(item);

                // Create a wrapping ListViewItem for the filtered list if needed
                if (IsFilteredType(entry.Value))
                {
                    item.Filtered   = true;
                    item.ImageIndex = 0;
                }
            }
            lvCompare.Sort();
            lvFiltered.Sort();
            lvFiltered.EndUpdate();
            lvCompare.EndUpdate();
        }