//================================================== public string toClipboardString(bool includeParents, bool includeKids) { string outString = ""; if (includeParents) { Stack <string> parentStrings = new Stack <string>(); //walk parents of me. allocTreeNode parent = (allocTreeNode)this.Parent; while (parent != null) { parentStrings.Push(parent.getFileLineFunctionText() + ":" + " [" + MemoryNumber.convert(getInclusiveMemory()) + "]"); parent = (allocTreeNode)parent.Parent; } parentStrings.Pop();//we don't care about the topmost entry while (parentStrings.Count != 0) { outString += parentStrings.Pop() + "\n"; } } outString += getFullText(); if (includeKids) { for (int i = 0; i < Nodes.Count; i++) { allocTreeNode knode = Nodes[i] as allocTreeNode; if (knode == null) { continue; } outString += "\n" + knode.toClipboardString(false, includeKids); } } return(outString); }
//================================================== private void copyThisStackToolStripMenuItem_Click(object sender, EventArgs e) { TreeNode selNode = treeView1.SelectedNode; if (selNode == null) { return; } allocTreeNode atn = selNode as allocTreeNode; if (atn == null) { return; } Clipboard.SetDataObject(atn.toClipboardString(true, true), true); }