示例#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);
            }
        }