private void panel1_Paint(object sender, PaintEventArgs e) { System.Drawing.Graphics formGraphics = e.Graphics; SolidBrush brush = new SolidBrush(Color.Black); if (gm.getActiveShape() != null) { Composite c = gm.getActiveShape(); brush = new SolidBrush(c.getColor()); Font drawFont = null; SolidBrush drawBrush = null; string drawString; StringFormat drawFormat = null; float x, y; if (labels == true) { drawString = ""; drawFont = new Font("Arial", 9); if (c.getColor() != Color.Yellow && c.getColor() != Color.Cyan) { drawBrush = new SolidBrush(Color.White); } else { drawBrush = new SolidBrush(Color.Black); } x = 0; y = 0; drawFormat = new StringFormat(); } foreach (Rectangle rect in c.getChildren()) { formGraphics.FillRectangle(brush, rect); if (outline == true) { formGraphics.DrawRectangle(new Pen(Color.Black), rect); } if (labels == true) { int column = (rect.X / 30) + 1; drawString = "" + column; x = rect.X + 10; y = rect.Y + 10; if (column >= 10) { x -= 3; } formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); } } } foreach (Composite comp in gm.getShapes()) { Font drawFont = null; SolidBrush drawBrush = null; string drawString; StringFormat drawFormat = null; float x, y; if (labels == true) { drawString = ""; drawFont = new Font("Arial", 9); if (comp.getColor() != Color.Yellow && comp.getColor() != Color.Cyan) { drawBrush = new SolidBrush(Color.White); } else { drawBrush = new SolidBrush(Color.Black); } x = 0; y = 0; drawFormat = new StringFormat(); } brush = new SolidBrush(comp.getColor()); foreach (Rectangle rect in comp.getChildren()) { formGraphics.FillRectangle(brush, rect); if (outline == true) { formGraphics.DrawRectangle(new Pen(Color.Black), rect); } if (labels == true) { int column = (rect.X / 30) + 1; drawString = "" + column; x = rect.X + 10; y = rect.Y + 10; if (column >= 10) { x -= 3; } formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); } } } if (gm.isPaused() == true) { string drawString = "P A U S E D"; System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 24); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); float x = 120; float y = 200; System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); drawFont.Dispose(); drawBrush.Dispose(); } if (gm.getGameEnd() == true) { string drawString = "G A M E O V E R"; System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 24); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White); float x = 80; float y = 200; System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); drawFont.Dispose(); drawBrush.Dispose(); } panel2.Refresh(); if (nextShape != gm.getNextShape()) { panel3.Refresh(); } brush.Dispose(); //formGraphics.Dispose(); }