private void ink_StrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e) { // _undoStack.Add(e.Stroke, true); Models.UndoStack undo = new Models.UndoStack(); undo.isErase = true; undo.stroke = e.Stroke; _undoStackModel.Add(undo); }
private void UndoRedoCommand(bool isUndo) { try { if (isUndo) { Models.RedoStack redo = new Models.RedoStack(); redo.isErase = _undoStackModel.Last().isErase; redo.stroke = _undoStackModel.Last().stroke; _redoStackModel.Add(redo); if (!_undoStackModel.Last().isErase) { ink.Strokes.Remove(_undoStackModel.Last().stroke); } else { ink.Strokes.Add(_undoStackModel.Last().stroke); } _undoStackModel.Remove(_undoStackModel.Last()); } else { Models.UndoStack undo = new Models.UndoStack(); undo.isErase = _redoStackModel.Last().isErase; undo.stroke = _redoStackModel.Last().stroke; _undoStackModel.Add(undo); if (_undoStackModel.Last().isErase) { ink.Strokes.Remove(_undoStackModel.Last().stroke); } else { ink.Strokes.Add(_undoStackModel.Last().stroke); } _redoStackModel.Remove(_redoStackModel.Last()); } } catch (Exception e) { //Throw error message } }