示例#1
0
        private void BeginCaptureUndo()
        {
            _historyCommand = new CompositeUndoableCommand();
            DrawableUndoableCommand drawableUndoableCommand = new DrawableUndoableCommand(_imageBox);

            _imageBoxCommand            = new MemorableUndoableCommand(_imageBox);
            _imageBoxCommand.BeginState = _imageBox.CreateMemento();
            drawableUndoableCommand.Enqueue(_imageBoxCommand);
            _historyCommand.Enqueue(drawableUndoableCommand);
        }
示例#2
0
        private void EndCaptureUndo()
        {
            if (_imageBoxCommand != null)
            {
                _imageBoxCommand.EndState = _imageBox.CreateMemento();
                if (!_imageBoxCommand.BeginState.Equals(_imageBoxCommand.EndState))
                {
                    _historyCommand.Name = SR.CommandNameStackImageScroller;
                    _imageBox.ImageViewer.CommandHistory.AddCommand(_historyCommand);
                }
            }

            _imageBoxCommand = null;
            _historyCommand  = null;
        }
示例#3
0
            public CompositeCommandInfo(CompositeUndoableCommand command) : base(command)
            {
                _count = command.Count;

                List <CommandInfo>     commands    = new List <CommandInfo>();
                List <UndoableCommand> subcommands = _rfCommandsField.GetValue(command) as List <UndoableCommand>;

                if (subcommands != null)
                {
                    foreach (UndoableCommand subcommand in subcommands)
                    {
                        commands.Add(CreateCommandInfo(subcommand));
                    }
                }
                _commands = commands.AsReadOnly();
            }
        public void ShouldUnExecuteLayerSnapshotCommandsOnUnExecute()
        {
            TestableLayerSnapshotCommand layerSnapshotCommand        = new TestableLayerSnapshotCommand();
            TestableLayerSnapshotCommand anotherLayerSnapshotCommand = new TestableLayerSnapshotCommand();

            CompositeUndoableCommand <LayerSnapshotCommand> command = new CompositeUndoableCommand <LayerSnapshotCommand>(new List <LayerSnapshotCommand> {
                layerSnapshotCommand, anotherLayerSnapshotCommand
            });

            command.Execute();

            command.UnExecute();

            Assert.IsTrue(layerSnapshotCommand.UnExecuteCommandCalled);
            Assert.IsTrue(anotherLayerSnapshotCommand.UnExecuteCommandCalled);
        }