public List <IShape> OnUndo() { if (!IsStackEmpty()) { ToRedoStack.Push(ToUndoStack.Pop()); var copy = ToUndoStack.Peek().Select(shape => shape is CompoundShape compoundShape ? GetAllCompoundShapeClones(compoundShape) : shape.Clone() ).ToList(); return(copy); } return(null); }
private bool IsStackEmpty() { return(ToUndoStack.Count == 1 && ToUndoStack.Peek().Count == 0); }