private void panel1_Paint(object sender, PaintEventArgs e) { // http://codesmesh.com/c-drawing-circlelinerectangle-and-ellipse-on-forms/ Graphics g = e.Graphics; e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; if (connected) { g.Clear(Color.Green); } else { g.Clear(Color.Red); } Pen pen = new Pen(Color.Black); foreach (Ball ball in balls) { ball.Draw(g); } foreach (Block block in blocks) { block.Draw(g); } pen.Dispose(); }