Ejemplo n.º 1
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            //Generate it 4 times as big, to scale it down later and have nice anti-aliasing
            MandelbrotGenerator mg = new MandelbrotGenerator(mMandelbrotGeneratorTemplate, (int)widthUpDown.Value * 4, (int)heightUpDown.Value * 4);

            mg.FixAspect();
            mg.MandlebrotReady += delegate(Bitmap mandelbrot, bool is2Times)
            {
                mandelbrot = new Bitmap(mandelbrot, (int)widthUpDown.Value, (int)heightUpDown.Value);
                mandelbrot.Save(pathTextBox.Text, ImageFormat.Png);
                //Controls can't be changed from a different thread
                progressBar.Invoke((Action) delegate
                {
                    progressBar.Style = ProgressBarStyle.Blocks;
                    progressBar.Value = 100;
                });
                DialogResult = DialogResult.OK;
            };
            progressBar.Enabled  = true;
            progressBar.Style    = ProgressBarStyle.Marquee;
            cancelButton.Enabled = false;
            exportButton.Enabled = false;
            groupBox1.Enabled    = false;
            groupBox2.Enabled    = false;
            mg.StartGenerateMandelbrot();
        }
Ejemplo n.º 2
0
 //Displays the new image when one was being generated in the bg
 private void MMandelbrotGenerator_MandlebrotReady(Bitmap mandelbrot, bool is2Times)
 {
     //Wait for the animation to be finished (to prevent problems)
     while (mMandlebrotZoomer != null && !mMandlebrotZoomer.IsFinished)
     {
         ;
     }
     mMandlebrotZoomer   = null;
     mWaitingForBrot     = false;
     mMandelbrotBitmapX2 = is2Times;
     mMandelbrotBitmap   = mandelbrot;
     panel1.Invalidate();
     //When the 2 times bigger picture hasn't been generated yet,
     //do so
     if (!is2Times)
     {
         mMandelbrotGenerator.StartGenerateMandelbrot(true);
     }
 }