Ejemplo n.º 1
0
        private void cellSizeTracBar_Scroll(object sender, EventArgs e)
        {
            CELL_SIZE = 1 * cellSizeTracBar.Value;

            int maxSizeX = pictureBox1.Width / CELL_SIZE;
            int maxSizeY = pictureBox1.Height / CELL_SIZE;

            simulationBitmap = new Bitmap(maxSizeX * CELL_SIZE, maxSizeY * CELL_SIZE);
            g = Graphics.FromImage(simulationBitmap);

            grid.SetNewCellSizeAndDraw(pictureBox1, g, grainGrowth);
            grainGrowth.DisplayEnergy(g);

            pictureBox1.Image = simulationBitmap;

            widthBox.Text  = SIZE_X.ToString();
            heightBox.Text = SIZE_Y.ToString();
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // setting new sizes

            SET_SIZES(pictureBox1.Width / CELL_SIZE, pictureBox1.Height / CELL_SIZE);

            // --------

            grid        = new Grid();
            grainGrowth = new Simulation();
            monteCarlo  = new MonteCarlo();

            simulationBitmap = new Bitmap(SIZE_X * CELL_SIZE, SIZE_Y * CELL_SIZE);
            g = Graphics.FromImage(simulationBitmap);

            pictureBox1.Image = simulationBitmap;

            EnergyColors.InitializeColors();

            widthBox.Text  = SIZE_X.ToString();
            heightBox.Text = SIZE_Y.ToString();
        }
Ejemplo n.º 3
0
        private void Form1_ResizeEnd(object sender, System.EventArgs e)
        {
            if (!grid.ComputeBounds(pPictureBox, pictureBox1, grainGrowth))
            {
                flagResize = false;

                if (backgroundWorker != null && !flagStop)
                {
                    if (isPlaying)
                    {
                        Simulate();
                    }
                }

                return;
            }

            simulationBitmap = new Bitmap(SIZE_X * CELL_SIZE, SIZE_Y * CELL_SIZE);
            g = Graphics.FromImage(simulationBitmap);

            grid.Draw(g);
            grainGrowth.Display(g);
            grainGrowth.DisplayEnergy(g);

            pictureBox1.Image = simulationBitmap;

            widthBox.Text  = SIZE_X.ToString();
            heightBox.Text = SIZE_Y.ToString();

            if (flagResize && !flagStop)
            {
                flagResize = false;

                if (isPlaying)
                {
                    Simulate();
                }
            }
        }