/* * Paint a cell using the progression data */ private void ProgressCellPaint(object sender, DataGridViewCellPaintingEventArgs e) { if (e.ColumnIndex <= 0 || e.RowIndex < -1) { e.Handled = false; return; } if (ProgressionData != null) { if (e.RowIndex == -1) { e.PaintBackground(e.CellBounds, false); DrawScale(ProgressionData.StartTime, AgentApplication.Options.VisualiserZoomLevel, e.Graphics, e.CellBounds); } else { string Machine = ( string )VisualiserGridView.Rows[e.RowIndex].Cells[0].Value; Progression MachineProgression = null; if (ProgressionData.MachineProgressions.TryGetValue(Machine, out MachineProgression)) { BufferedGraphicsContext Current = BufferedGraphicsManager.Current; BufferedGraphics Offscreen = Current.Allocate(e.Graphics, e.CellBounds); // Fill the background dependent on whether the machine has finished or not MachineProgression.DrawBackground(Offscreen.Graphics, e.CellBounds); // Draw all the progress bars to the offscreen buffer MachineProgression.Draw(ProgressionData.StartTime, AgentApplication.Options.VisualiserZoomLevel, Offscreen.Graphics, e.CellBounds); // Copy the offscreen buffer to the screen Offscreen.Render(); Offscreen.Dispose(); } } } else { // Just clear if there's no progression data e.PaintBackground(e.CellBounds, false); } e.Handled = true; }