//========================================= // exportToCSV //========================================= public bool exportToCSV(string filename) { using (StreamWriter sw = new StreamWriter(filename, true)) { sw.WriteLine(" , currentAlloc (MB), maxAlloc (MB)"); for (int j = 0; j < mTreeView.Nodes.Count; j++) { if (!(mTreeView.Nodes[j] is GroupNode)) { continue; } GroupNode gn = mTreeView.Nodes[j] as GroupNode; sw.WriteLine(gn.getOutputString()); for (int i = 0; i < gn.Nodes.Count; i++) { if (!(gn.Nodes[i] is GroupFileNode)) { continue; } GroupFileNode gfn = gn.Nodes[i] as GroupFileNode; sw.WriteLine(" " + gfn.getOutputString()); } } } return(true); }
//========================================= // loadGroupList //========================================= public bool loadGroupList(string filename) { Stream st = null; try { XmlSerializer s = new XmlSerializer(typeof(GroupListXML), new Type[] { }); st = File.OpenRead(filename); GroupListXML wlXML = (GroupListXML)s.Deserialize(st); st.Close(); //do loading here.. for (int i = 0; i < wlXML.mGroups.Count; i++) { GroupNode gn = new GroupNode(wlXML.mGroups[i].GroupName); for (int j = 0; j < wlXML.mGroups[i].mFiles.Count; j++) { GroupFileNode fn = new GroupFileNode(wlXML.mGroups[i].mFiles[j].Filename); gn.addNode(fn); } mTreeView.addNode(gn); } } catch (Exception e) { MessageBox.Show("Error Loading " + filename + ":\n" + e.InnerException.ToString()); if (st != null) { st.Close(); } if (File.Exists(filename)) { File.Delete(filename); } return(false); } timer1_Tick(this, null); return(true); }
//========================================= // update //========================================= public void update() { uint totalBytes = 0; for (int i = 0; i < this.Nodes.Count; i++) { if (this.Nodes[i] is GroupFileNode) { GroupFileNode pNode = (GroupFileNode)this.Nodes[i]; totalBytes += pNode.update(); } } if (totalBytes > mMaxAllocatedBytes) { mMaxAllocatedBytes = totalBytes; } mCurrAllocatedBytes = totalBytes; this.Text = mGroupName + ", curr : " + MemoryNumber.convert(totalBytes) + " , max : " + MemoryNumber.convert(mMaxAllocatedBytes); }
//========================================= // GroupNode //========================================= void addWatchedFile(string filename) { GroupFileNode gfn = new GroupFileNode(filename); this.addNode(gfn); }