Example #1
0
        public void CommitCommand(CommandBase command)
        {
            if (_undoCommands.Count == 0)
            {
                PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                var w = PocketPaintApplication.GetInstance().Bitmap.PixelWidth;
                var h = PocketPaintApplication.GetInstance().Bitmap.PixelHeight;
                _commandBitmapDict.Add(command, new WriteableBitmap(w, h));
            }

            if (HasNext())
            {
                _redoCommands.Clear();
                UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.DisableRedo);
            }

            if (_undoCommands.Count != 0 && command is EraserCommand)
            {
                var c = _undoCommands.Last();
                if (c.ToolType != ToolType.Eraser)
                {
                    //PocketPaintApplication.GetInstance().SaveAsWriteableBitmapToRam();
                    // TODO: _commandBitmapDict.Add(command, new WriteableBitmap(PocketPaintApplication.GetInstance().Bitmap));
                    var w = PocketPaintApplication.GetInstance().Bitmap.PixelWidth;
                    var h = PocketPaintApplication.GetInstance().Bitmap.PixelHeight;
                    _commandBitmapDict.Add(command, new WriteableBitmap(w, h));
                }
            }

            _undoCommands.AddLast(command);
            UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.EnableUndo);
            PocketPaintApplication.GetInstance().UnsavedChangesMade = true;
        }
Example #2
0
        public void UnDo()
        {
            System.Diagnostics.Debug.WriteLine("--UNDO--");
            if (HasCommands())
            {
                Spinner.StartSpinning();

                var command = _undoCommands.Last.Value;
                _undoCommands.RemoveLast();

                if (command is CropCommand || command is FlipCommand || command is MoveCommand || command is RotateCommand || command is RemoveCommand || command is ZoomCommand)
                {
                    var lastCommand = true;
                    foreach (var undoCommand in _undoCommands)
                    {
                        if (undoCommand.GetType() == command.GetType())
                        {
                            lastCommand = false;
                            break;
                        }
                    }

                    if (lastCommand || command is CropCommand || command is MoveCommand || command is RemoveCommand || command is RotateCommand || command is ZoomCommand)
                    {
                        command.UnDo();
                    }
                }

                if (!HasCommands())
                {
                    UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.DisableUndo);
                }
                _redoCommands.AddLast(command);
                UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.EnableRedo);

                DoUnDo();
            }
        }
Example #3
0
        public void ReDo()
        {
            System.Diagnostics.Debug.WriteLine("--REDO--");

            if (HasNext())
            {
                Spinner.StartSpinning();

                var command = _redoCommands.Last.Value;
                _redoCommands.RemoveLast();

                var redoCommandsList = new List <CommandBase>();

                if (!HasNext())
                {
                    UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.DisableRedo);
                }
                _undoCommands.AddLast(command);
                UndoRedoActionbarManager.GetInstance().Update(UndoRedoActionbarManager.UndoRedoButtonState.EnableUndo);

                redoCommandsList.Add(command);
                DoReDo(redoCommandsList);
            }
        }
Example #4
0
 public static UndoRedoActionbarManager GetInstance()
 {
     return(_instance ?? (_instance = new UndoRedoActionbarManager()));
 }