Example #1
0
 /* Called by timer during every step of simulation of game. */
 private void timerTick(object sender, EventArgs e)
 {
     /* Save current frame before generating next generation. */
     GifUtils.SaveFrame(ref frames, pictureBox1);
     /* Generate next generation */
     Game.NewGeneration(ref currentGeneration);
     textBox1.Text = string.Format("{0}, Generation: {1}", Game.GetCellStats(currentGeneration), Game.generationCount++);
     pictureBox1.Invalidate();
 }
Example #2
0
        /* Export button click event handler. */
        private void ExportAsGif(object sender, EventArgs e)
        {
            saveFileDialog1.FileName         = DateTime.Now.ToString("HHmmss") + ".GIF";
            saveFileDialog1.InitialDirectory = "C:\\Users\\Public\\Pictures";
            saveFileDialog1.Filter           = "GIF files (*.GIF)|*.GIF";

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                /* Save last frame before exporting. */
                GifUtils.SaveFrame(ref frames, pictureBox1);
                GifUtils.ExportGif(frames, saveFileDialog1.FileName);
                textBox1.Text = "GIF Exported! " + saveFileDialog1.FileName;
            }
        }