/// <summary> /// Undoes the last step. /// </summary> /// <param name="buffer">Buffer to use</param> /// <remarks>Used internally, don't use!</remarks> internal UndoStep Undo(ref BufferManager buffer) { if (UndoStack.Count > 0) { UndoStep step = (UndoStep)UndoStack.Peek(); RedoStack.Push(step); UndoStack.Pop(); switch (step.Action) { case UndoAction.Insert: buffer.SetBytes(step.Start, step.GetBytes(), false); break; case UndoAction.Remove: buffer.RemoveBytes(step.Start, step.GetBytes().Length); break; case UndoAction.Overwrite: buffer.SetBytes(step.Start, step.GetOldBytes(), true); break; } EventHandler <UndoEventArgs> temp = ActionUndone; if (temp != null) { temp(this, new UndoEventArgs(step, true)); } return(step); } return(null); }
/// <summary> /// Adds a step to the stack. /// </summary> /// <param name="step">The step to add.</param> internal void AddUndoStep(UndoStep step) { UndoStack.Push(step); RedoStack.Clear(); EventHandler<UndoEventArgs> temp = ActionUndone; if (temp != null) temp(this, new UndoEventArgs(step, false)); }
/// <summary> /// Adds a step to the stack. /// </summary> /// <param name="step">The step to add.</param> internal void AddUndoStep(UndoStep step) { UndoStack.Push(step); RedoStack.Clear(); EventHandler <UndoEventArgs> temp = ActionUndone; if (temp != null) { temp(this, new UndoEventArgs(step, false)); } }
public UndoEventArgs(UndoStep step, bool redo) { undostep = step; isRedo = redo; }