public void DrawFooterLabel() { if (NodesHovered.Length == 0) { return; } PointF pos = Renderer.GetCursorPosition(); //if (!ClientRectangle.Contains((int)pos.X, (int)pos.Y)) // return; float x = 0; var lastNode = NodesHovered.Last(); foreach (var node in NodesHovered) { DrawFooterPart(node.Name, XColors.ObjColors[(int)node.ObjType], ref x); if (node != lastNode) { DrawFooterPart(".", XColors.TextColor, ref x); } } DrawFooterPart(" (" + GetMetricForNode(lastNode) + ")", XColors.TextColor, ref x); }
public void DrawToolTip() { if (NodesHovered.Length == 0) { return; } PointF pos = Renderer.GetCursorPosition(); //if (!ClientRectangle.Contains((int)pos.X, (int)pos.Y)) // return; if (!LastHoverPoint.Equals(pos)) { LastHoverPoint = pos; LastHoverTime = DateTime.Now; return; } else if (DateTime.Now.Subtract(LastHoverTime).TotalSeconds < .5) { return; } // for each node selected, get size, figure out bg size and indents, then pass again and draw float bgWidth = 0; float bgHeight = 0; float lineHeight = 0; float indentAmount = 0; var labels = new List <Tuple <string, Color> >(); string indentStr = ""; // show all labels if showing just graph nodes, or show labels isnt on, or the label isnt displayed cause there's not enough room //foreach(var node in NodesHovered)//.Where(n => !ShowLabels || !n.RoomForLabel || n.LabelClipped)) //{ var n = NodesHovered.Last(); Color color = GuiHovered.Contains(n) ? XColors.ObjColors[(int)n.ObjType] : XColors.ObjDitheredColors[(int)n.ObjType]; labels.Add(new Tuple <string, Color>(indentStr + n.Name, color)); indentStr += " "; //} if (labels.Count == 0) { return; } var lastNode = NodesHovered.Last(); if (lastNode.ObjType == XObjType.Class) { int staticCount = 0; int instCount = 0; if (lastNode != null && lastNode.XNode.Record != null && lastNode.XNode.Record.Active.Count > 0) { var record = lastNode.XNode.Record; lock (record.Active) { for (int i = 0; i < record.Active.Count; i++) { var instance = record.Active[i]; if (instance.IsStatic) { staticCount++; } else { instCount++; } } } } string classInfo = "0 instances"; if (instCount > 0) { classInfo = instCount.ToString() + " instances"; } else if (staticCount > 0) { classInfo = "static instance"; } labels.Add(new Tuple <string, Color>(classInfo, XColors.TextColor)); } else if (lastNode.ObjType == XObjType.Method) { labels.Add(new Tuple <string, Color>(lastNode.XNode.GetMethodName(false), XColors.TextColor)); } else if (lastNode.ObjType == XObjType.Namespace) { labels.Clear(); labels.Add(new Tuple <string, Color>(lastNode.XNode.FullName(true), XColors.ObjColors[(int)lastNode.ObjType])); } else if (lastNode.ObjType == XObjType.Field) { foreach (var value in lastNode.GetFieldValues()) { labels.Add(new Tuple <string, Color>(value, XColors.TextColor)); } } // find the size of the background box foreach (var node in labels) { string label = node.Item1; //if (node == lastNode) // label += " (" + GetMetricForNode(node) + ")"; SizeF size = Renderer.MeasureString(label, TextFont); if (size.Width + indentAmount > bgWidth) { bgWidth = size.Width + indentAmount; } bgHeight += size.Height; lineHeight = size.Height; //indentAmount += indent; } // put box lower right corner at cursor if (pos.X + bgWidth > Renderer.ViewWidth) { pos.X = Renderer.ViewWidth - bgWidth; } pos.Y -= bgHeight; // ensure it doesnt go off screen if (pos.X < 0) { pos.X = 0; } if (pos.Y < 0) { pos.Y = 0; } // draw background Renderer.DrawTextBackground(XColors.TextBgColor, pos.X, pos.Y, bgWidth, bgHeight); //GraphDebuggingLabel(buffer, pos); foreach (var node in labels) { Renderer.DrawString(node.Item1, TextFont, node.Item2, pos.X, pos.Y, bgWidth, bgHeight); pos.Y += lineHeight; // pos.X += indent; } }