public void SetGIFs(GIFSettings gifSettings) { this.gifSettings = gifSettings; }
private void GIFButton_Click(object sender, EventArgs e) { if (Animation == null) { return; } isPlaying = false; playButton.Text = "Play"; GIFSettings settings = new GIFSettings((int)totalFrame.Value, ScaleFactor, images.Count > 0); settings.ShowDialog(); if (settings.ClearFrames) { images.Clear(); } if (!settings.OK) { return; } ScaleFactor = settings.ScaleFactor; int cFrame = (int)currentFrame.Value; //Get current frame so at the end of capturing all frames of the animation it goes back to this frame //Disable controls this.Enabled = false; for (int i = settings.StartFrame; i <= settings.EndFrame + 1; i++) { currentFrame.Value = i; currentFrame.Refresh(); //Refresh the frame counter control Render(null, null); if (i != settings.StartFrame) //On i=StartFrame it captures the frame the user had before setting frame to it so ignore that one, the +1 on the for makes it so the last frame is captured { Bitmap cs = CaptureScreen(false); images.Add(new Bitmap(cs, new Size((int)(cs.Width / ScaleFactor), (int)(cs.Height / settings.ScaleFactor)))); //Resize images cs.Dispose(); } } if (images.Count > 0 && !settings.StoreFrames) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = "Render.gif"; sf.Filter = "GIF file (*.gif)|*.gif"; if (sf.ShowDialog() == DialogResult.OK) { GIFProgress g = new GIFProgress(images, sf.FileName, AnimationSpeed, settings.Repeat, settings.Quality); g.Show(); } images = new List <Bitmap>(); } //Enable controls this.Enabled = true; currentFrame.Value = cFrame; }