//================================================== bool parseOpenXML(string filename) { try { XmlSerializer s = new XmlSerializer(typeof(memStatsXML), new Type[] { }); Stream st = File.OpenRead(filename); fsXML = (memStatsXML)s.Deserialize(st); st.Close(); } catch (Exception e) { MessageBox.Show(e.InnerException.ToString()); return(false); } //treeview //{ // populateTreeView(fsXML); // fsXML = null; //} //searchview { } return(true); }
//================================================== void populateTreeView(memStatsXML fsXML) { allocTreeNode tnRootNode = new allocTreeNode(); tnRootNode.function = "ALL"; tnRootNode.file = ""; tnRootNode.line = ""; tnRootNode.allocSize = 0; for (int allocIndex = 0; allocIndex < fsXML.allocations.Count; allocIndex++) { allocXML alloc = fsXML.allocations[allocIndex]; int allocSize = int.Parse(alloc.size); int stackIndex = 0; allocTreeNode lastNode = tnRootNode; bool added = false; while (stackIndex < alloc.stack.Count) { bool found = false; for (int i = 0; i < lastNode.Nodes.Count; i++) { allocTreeNode node = lastNode.Nodes[i] as allocTreeNode; if (node == null) { continue; } if (node.function == alloc.stack[stackIndex].function) { lastNode = node; stackIndex++; found = true; break; } } //we didn't find ourselves at this node, add us. if (!found) { added = true; allocTreeNode atn = new allocTreeNode(); atn.function = alloc.stack[stackIndex].function; atn.file = alloc.stack[stackIndex].file; atn.line = alloc.stack[stackIndex].line; atn.allocSize = allocSize; atn.samples = new List <allocTreeSampleData>(); foreach (sizeSampleXML sample in alloc.sizeSamples) { allocTreeSampleData sampleData = new allocTreeSampleData(); sampleData.size = Int32.Parse(sample.size); sampleData.sampleIndex = Int32.Parse(sample.sample); atn.samples.Add(sampleData); } atn.samples.Sort(SortBySamples); lastNode.Nodes.Add(atn); stackIndex++; lastNode = (allocTreeNode)lastNode.Nodes[lastNode.Nodes.Count - 1]; } } //if we never added, then this is a duplicate path, so add our memory to the leaf node if (!added) { lastNode.allocSize += allocSize; } } updateTreeNodes(tnRootNode); removeFilteredNodes(tnRootNode); sortTreeNodes(tnRootNode); treeView1.Nodes.Clear(); treeView1.Nodes.Add(tnRootNode); }