Пример #1
0
 private void Drawing()
 {
     while (true)
     {
         board.NextBoard();
         Bitmap   bipmap   = new Bitmap(500, 500);
         Graphics graphics = Graphics.FromImage(bipmap);
         graphics.FillRectangle(Brushes.White, 0, 0, 500, 500);
         for (int x = 0; x < 50; x++)
         {
             for (int y = 0; y < 50; y++)
             {
                 Cell cell = board.GetCellAt(x, y);
                 if (cell.IsAlive())
                 {
                     graphics.FillRectangle(Brushes.Green, cell.GetX() * 10, cell.GetY() * 10, 10, 10);
                 }
                 else
                 {
                     graphics.FillRectangle(Brushes.Black, cell.GetX() * 10, cell.GetY() * 10, 10, 10);
                 }
             }
         }
         pictureBox_LifeBoard.BeginInvoke((MethodInvoker) delegate
         {
             pictureBox_LifeBoard.Image = bipmap;
             pictureBox_LifeBoard.Refresh();
         });
         Thread.Sleep(100);
     }
 }