private void OnTestExpandRow(object sender, Gtk.TestExpandRowArgs args)
        {
            bool          filled = (bool)store.GetValue(args.Iter, FilledCol);
            ReferenceNode parent = (ReferenceNode)store.GetValue(args.Iter, ReferenceCol);

            if (!filled)
            {
                store.SetValue(args.Iter, FilledCol, true);
                TreeIter iter;
                store.IterChildren(out iter, args.Iter);
                store.Remove(ref iter);
                if (parent.References.Count > 0 || parent.FieldReferences.Count > 0)
                {
                    int nr = 0;
                    foreach (ReferenceNode nod in parent.References)
                    {
                        if (!AddNode(args.Iter, nod).Equals(TreeIter.Zero))
                        {
                            nr++;
                        }
                    }
                    foreach (FieldReference fref in parent.FieldReferences)
                    {
                        if (!AddNode(args.Iter, fref).Equals(TreeIter.Zero))
                        {
                            nr++;
                        }
                    }
                    if (nr == 0)
                    {
                        args.RetVal = true;
                    }
                }
                else
                {
                    args.RetVal = true;
                }
            }
        }
Пример #2
0
		TreeIter AddNode (TreeIter parent, ReferenceNode node)
		{
			if (entryFilter.Text.Length > 0 && node.TypeName.IndexOf (entryFilter.Text) == -1)
				return TreeIter.Zero;
			
			TreeIter iter;
			if (parent.Equals (TreeIter.Zero)) {
				iter = store.AppendValues (node, "md-class", node.TypeName, !node.HasReferences, node.TotalMemory.ToString("n0"), node.AverageSize.ToString("n0"), node.RefCount.ToString ("n0"), "", "", "");
			} else {
				string refs = (InverseReferences ? node.RefsToParent.ToString ("n0") : "");
				string rootRefs = (InverseReferences ? node.RefsToRoot.ToString ("n0") : "");
				string rootMem = (InverseReferences ? node.RootMemory.ToString ("n0") : "");
				iter = store.AppendValues (parent, node, "md-class", node.TypeName, !node.HasReferences, node.TotalMemory.ToString("n0"), node.AverageSize.ToString("n0"), node.RefCount.ToString ("n0"), refs, rootRefs, rootMem);
			}

			if (node.HasReferences) {
				// Add a dummy element to make the expansion icon visible
				store.AppendValues (iter, null, "", "", true, "", "", "", "", "", "");
			}
			return iter;
		}
        string GetTipText(Gtk.TreeIter iter, int col, object ob)
        {
            ReferenceNode node = ob as ReferenceNode;

            if (node != null)
            {
                switch (col)
                {
                case 0:
                    return("Type " + node.TypeName);

                case 1: {
                    string pname = GetParentType(iter);
                    if (pname != null)
                    {
                        if (InverseReferences)
                        {
                            return(string.Format("There are <b>{0:n0}</b> instances of type <b>{1}</b> which contain references to objects of type <b>{2}</b>", node.RefCount, GetShortName(node.TypeName), pname));
                        }
                        else
                        {
                            return(string.Format("There are <b>{0:n0}</b> instances of type <b>{1}</b> referenced by objects of type <b>{2}</b>", node.RefCount, GetShortName(node.TypeName), pname));
                        }
                    }
                    else
                    {
                        return(string.Format("There are <b>{0:n0}</b> instances of type <b>{1}</b>.", node.RefCount, GetShortName(node.TypeName)));
                    }
                }

                case 2: {
                    string pname = GetParentType(iter);
                    if (pname != null)
                    {
                        return(string.Format("There are <b>{0:n0}</b> distinct references from objects of type <b>{1}</b> to objects of type <b>{2}</b>", node.RefsToParent, GetShortName(node.TypeName), pname));
                    }
                    else
                    {
                        return("");
                    }
                }

                case 3: {
                    string rname = GetRootType(iter);
                    if (rname != null)
                    {
                        return(string.Format("There are <b>{0:n0}</b> indirect references from objects of type <b>{1}</b> to objects of type <b>{2}</b>", node.RefsToRoot, GetShortName(node.TypeName), rname));
                    }
                    else
                    {
                        return("");
                    }
                }

                case 4: {
                    string rname = GetRootType(iter);
                    if (rname != null)
                    {
                        return(string.Format("There are <b>{0:n0}</b> bytes of <b>{1}</b> objects indirectly referenced by <b>{2}</b> objects", node.RootMemory, rname, GetShortName(node.TypeName)));
                    }
                    else
                    {
                        return("");
                    }
                }

                case 5: {
                    string pname = GetParentType(iter);
                    if (pname != null)
                    {
                        if (InverseReferences)
                        {
                            return(string.Format("There are <b>{0:n0}</b> bytes of <b>{1}</b> objects which have references to <b>{2}</b> objects", node.TotalMemory, GetShortName(node.TypeName), pname));
                        }
                        else
                        {
                            return(string.Format("There are <b>{0:n0}</b> bytes of <b>{1}</b> objects referenced by <b>{2}</b> objects", node.TotalMemory, GetShortName(node.TypeName), pname));
                        }
                    }
                    else
                    {
                        return(string.Format("There are <b>{0:n0}</b> bytes of <b>{1}</b> objects", node.TotalMemory, GetShortName(node.TypeName)));
                    }
                }

                case 6:
                    string pname = GetParentType(iter);
                    if (pname != null)
                    {
                        if (InverseReferences)
                        {
                            return(string.Format("Objects of type <b>{0}</b> which have references to <b>{2}</b> objects have an average size of <b>{1:n0}</b> bytes", GetShortName(node.TypeName), node.AverageSize, pname));
                        }
                        else
                        {
                            return(string.Format("Objects of type <b>{0}</b> referenced by <b>{2}</b> objects have an average size of <b>{1:n0}</b> bytes", GetShortName(node.TypeName), node.AverageSize, pname));
                        }
                    }
                    else
                    {
                        return(string.Format("Objects of type <b>{0}</b> have an average size of <b>{1:n0}</b> bytes", GetShortName(node.TypeName), node.AverageSize));
                    }
                }
            }
            else
            {
                FieldReference fr = (FieldReference)ob;
                return(fr.FiledName);
            }

            return("");
        }
        TreeIter InternalFillType(ObjectMapReader file, int type)
        {
            ReferenceNode node = file.GetReferenceTree(type, checkInverse.Active);

            return(AddNode(TreeIter.Zero, node));
        }
Пример #5
0
		public ReferenceNode GetReferenceNode (int obj)
		{
			string name = map.GetObjectTypeName (obj);
			foreach (ReferenceNode cnode in references) {
				if (cnode.TypeName == name)
					return cnode;
			}
			ReferenceNode nod = new ReferenceNode (map, map.GetObjectType (obj), inverse);
			references.Add (nod);
			return nod;
		}