예제 #1
0
        private void AddAction(ChangeAction action)
        {
            RedoHistory.Clear();
            UndoHistory.Add(action);
            action.ChangeID = ++CurrentChangeID;

            if (UndoHistory.Count > MaxHistory)
            {
                HistoryLimitExceeded = true;
                UndoHistory.RemoveAt(0);
            }

            UndoHistoryChanged?.Invoke(this, EventArgs.Empty);
        }
예제 #2
0
        public void Redo()
        {
            if (RedoHistory.Any())
            {
                BeginUndoRedo?.Invoke(this, EventArgs.Empty);

                var lastAction = RedoHistory.Last();
                CurrentChangeID = lastAction.ChangeID;

                RedoHistory.Remove(lastAction);
                UndoHistory.Add(lastAction);

                ExecutingUndoRedo = true;
                lastAction.Redo();
                ExecutingUndoRedo = false;

                EndUndoRedo?.Invoke(this, EventArgs.Empty);
                UndoHistoryChanged?.Invoke(this, EventArgs.Empty);
            }
        }
예제 #3
0
        private void ImageControl_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (IsEydropping)
            {
                UserEyedrops();
            }
            else
            {
                try
                {
                    UndoHistory.Add(new Bitmap(LayeredImage.SelectedBitmapLayer.Source));
                }
                catch (ArgumentOutOfRangeException)
                { }

                IsDrawing = true;
                UserDrawsOnBitmap();
                RedoHistory = new List <Bitmap>(MaxItemsInHistory);
            }
        }