public void RePlot() { treemap = null; treemap = new TreeMapItem(); try { prm prm = new prm(); prm.treemap = this; prm.treemapitem = treemap; prm.fileitem = currentObject; prm.rect = new RectangleF(0, 0, this.Width, this.Height); Thread myThread; myThread = new Thread(new ParameterizedThreadStart(Plotter), 10000000); myThread.IsBackground = false; myThread.Start(prm); //treemap.Plot(currentObject, new RectangleF(0, 0, this.Width, this.Height)); } catch (Exception ex) { MessageBox.Show(ex.Message); } GC.Collect(); }
void Plotter(object prms) { if (diskReader == null) { return; } prm p = (prm)prms; copy = new Bitmap(this.Width, this.Height); using (Graphics offScreenDC = Graphics.FromImage(copy)) { using (Graphics g = Graphics.FromImage(Image)) { g.Clear(Color.White); WriteCaption(g, "Plotting " + " " + root.DisplayName, new Rectangle(0, 0, this.Width, this.Height), Color.Black, true, 30f); this.Invoke(new UpdateScreenCallback(this.Refresh), null); p.treemapitem.Plot(p.fileitem, new RectangleF(0, 0, this.Width, this.Height)); g.Clear(Color.White); WriteCaption(g, "Drawing " + " " + root.DisplayName, new Rectangle(0, 0, this.Width, this.Height), Color.Black, true, 30f); this.Invoke(new UpdateScreenCallback(this.Refresh), null); ReDraw(offScreenDC); g.Clear(Color.White); this.Image = new Bitmap(this.Width, this.Height); WriteCaption(g, "Refreshing " + " " + root.DisplayName, new Rectangle(0, 0, this.Width, this.Height), Color.Black, true, 30f); this.Invoke(new UpdateScreenCallback(this.Refresh), null); } using (Graphics clientDC = Graphics.FromImage(p.treemap.Image)) { clientDC.DrawImage(copy, 0, 0); } this.Invoke(new UpdateScreenCallback(this.Refresh), null); } }