// Experiment with drawing on Forms. This too is slow. // sestoft@dina.kvl.dk * 2005-05-03 using System; using System.Windows.Forms; using System.Drawing; class MyTest { public static void Main(String[] args) { Form form = new Form(); form.Text = "Inferial Bio"; TheatrePanel panel = new TheatrePanel(10, 15); form.Controls.Add(panel); form.ClientSize = panel.Size; form.StartPosition = FormStartPosition.CenterScreen; form.ShowDialog(); } } public class TheatrePanel : Panel { private int sw = 20, sh = 20; private bool[,] seats; public TheatrePanel(int rows, int cols) { this.seats = new bool[rows,cols]; // false = free, true = sold this.BackColor = Color.White; this.Size = new Size(seats.GetLength(1) * sw, seats.GetLength(0) * sh); // Use double buffering in graphics to avoid flickering on repaint: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); } protected override void OnPaint(PaintEventArgs e) { if (seats != null) { Graphics g = e.Graphics; SolidBrush brush = new SolidBrush(Color.Gray); for (int row=0; row