Graphics() public abstract method

public abstract Graphics ( ) : Bitmap
return System.Drawing.Bitmap
Example #1
0
 private void cmdSaveImage_Click(object sender, EventArgs e)
 {
     saveFileDialog.Filter     = "PNG Image (*.png)|*.png";
     saveFileDialog.DefaultExt = "png";
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         model?.Graphics().Save(saveFileDialog.FileName);
     }
 }
Example #2
0
        void runCalc(object sender, DoWorkEventArgs args)
        {
            try
            {
                if (rSimpleTiled.Checked)
                {
                    model = new SimpleTiledModel(sName.Text, stSubset.Text, (int)sWidth.Value, (int)sHeight.Value, sPeriodic.Checked, stBlack.Checked);
                }
                else if (rOverlapping.Checked)
                {
                    model = new OverlappingModel(sName.Text, (int)oN.Value, (int)sWidth.Value, (int)sHeight.Value, oPeriodicInput.Checked, sPeriodic.Checked, (int)oSymmetry.Value, (int)oGround.Value);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            catch (Exception e)
            {
                log($"There was an error in your settings, aborting. ({e.ToString()})");
                return;
            }
            int seed = (int)numSeed.Value;

            for (int k = 0; k < sRetries.Value; k++)
            {
                bool finished = false;
                try
                {
                    finished = model.Run(seed, (int)sLimit.Value);
                }
                catch (Exception e)
                {
                    if (e is OutOfMemoryException)
                    {
                        log("Out of memory exception was thrown, try decreasing image size! Aborting.");
                        return;
                    }
                    else
                    {
                        log($"Exception was thrown, retrying. ({e.ToString()})");
                    }
                }

                if (finished)
                {
                    log("Finished");
                    img    = model.Graphics();
                    outstr = (model is SimpleTiledModel && sTextOutput.Checked) ? (model as SimpleTiledModel).TextOutput() : "";

                    break;
                }

                if (worker.CancellationPending)
                {
                    log("Cancelled");
                    return;
                }

                if (k + 1 == sRetries.Value)
                {
                    log("Contradiction, retry limit reached, aborting.");
                }
                else
                {
                    seed = random.Next();
                    log("Contradiction, retrying with random seed: " + seed);
                }
            }
        }