/// <summary> /// Remembers a point that is about to be moved /// </summary> /// <param name="p">The point that is about to move</param> internal void AddMove(PointFeature p) { UpdateUndoMarker um = m_Moves.Peek(); Debug.Assert(um != null); um.AddMove(p); }
/// <summary> /// Rolls back changes (moves) that have occurred since the last undo marker (as defined /// via a prior call to <see cref="SetUndoMarker"/>). /// </summary> /// <returns>True if an undo marker was rolled back. False if everything has already /// been undone.</returns> internal bool Undo() { if (m_Moves.Count == 0) { return(false); } UpdateUndoMarker um = m_Moves.Pop(); Debug.Assert(um != null); um.Undo(); return(true); }
/// <summary> /// Sets an undo marker to indicate a savepoint that the user may go back to /// while making a series of editing revisions. /// </summary> internal void SetUndoMarker() { UpdateUndoMarker um = new UpdateUndoMarker(); if (m_Moves.Count > 0) { UpdateUndoMarker lastMarker = m_Moves.Peek(); if (lastMarker != null && lastMarker.EditSequence == um.EditSequence) { // If the last marker is empty, just get rid of it (user may have cancelled // from previous edit) if (lastMarker.IsEmpty) { m_Moves.Pop(); } else { throw new InvalidOperationException("Attempt to create another undo marker for the same edit"); } } } m_Moves.Push(um); }