コード例 #1
0
        public void Undo(InkCanvas inkCanvas)
        {
            if (UndoneOperations.Count > 0)
            {
                UndoneOperations.Last().Undo(inkCanvas);

                if (UndoneOperations.Last().GetUndoRedoOperation() == UndoRedoOperation.AddStroke)
                {
                    AddStrokeOperation aso  = UndoneOperations.Last() as AddStrokeOperation;
                    AddStrokeOperation ason = new AddStrokeOperation(aso.AddedStroke);
                    AddOperationToRedoneOperations(ason);
                }
                else if (UndoneOperations.Last().GetUndoRedoOperation() == UndoRedoOperation.EraseStroke)
                {
                    EraseStrokeOperation eso  = UndoneOperations.Last() as EraseStrokeOperation;
                    EraseStrokeOperation eson = new EraseStrokeOperation(eso.ErasedStroke);
                    AddOperationToRedoneOperations(eson);
                }
                else if (UndoneOperations.Last().GetUndoRedoOperation() == UndoRedoOperation.DeleteAll)
                {
                    DeleteAllOperation dao  = UndoneOperations.Last() as DeleteAllOperation;
                    DeleteAllOperation daon = new DeleteAllOperation(dao.DeletedStrokes);
                    AddOperationToRedoneOperations(daon);
                }
                else if (UndoneOperations.Last().GetUndoRedoOperation() == UndoRedoOperation.EraseByPoint)
                {
                    EraseByPointOperation ebpo  = UndoneOperations.Last() as EraseByPointOperation;
                    EraseByPointOperation ebpon = new EraseByPointOperation(ebpo.StrokesBefore, ebpo.StrokesAfter);
                    AddOperationToRedoneOperations(ebpon);
                }
                else
                {
                }
                RemoveLastUndoneOperation();
            }
        }
コード例 #2
0
 public void RemoveLastUndoneOperation()
 {
     UndoneOperations.Remove(UndoneOperations.Last());
     OnPropertyChanged(nameof(CanUndo));
 }