ScreenToGif.Modern.btnUndo_Click C# (CSharp) Method

btnUndo_Click() private method

private btnUndo_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void btnUndo_Click(object sender, EventArgs e)
        {
            StopPreview();

            int countDiff = _listFramesEdit.Count - _listFramesUndo.Count;

            #region Revert Alterations - This one is the oposite of ResetUndoProp()

            //Resets the list to a previous state
            _listFramesEdit.Clear();
            //_listFramesEdit = new List<string>(_listFramesUndo);

            foreach (var name in _listFramesUndo)
            {
                _listFramesEdit.Add(name.Replace("Undo", "Edit"));
                File.Copy(name, name.Replace("Undo", "Edit"), true);
            }

            //Resets the list to a previous state
            _listDelayEdit.Clear();
            _listDelayEdit = new List<int>(_listDelayUndo);

            #endregion

            trackBar.Maximum = _listFramesEdit.Count - 1;
            pictureBitmap.Image = _listFramesEdit[trackBar.Value].From();
            this.Text = Resources.Title_EditorFrame + trackBar.Value + " - " + (_listFramesEdit.Count - 1);

            btnUndo.Enabled = false;

            ResizeFormToImage();

            #region Update TreeView

            if (countDiff > 0)
            {
                //If Undo is smaller, it means that we need to remove
                tvFrames.Remove(countDiff);
            }
            else if (countDiff < 0)
            {
                //If Undo is greater, it means that we need to add
                tvFrames.Add(Math.Abs(countDiff));
            }

            #endregion

            DelayUpdate();
            GC.Collect();
        }
Modern