private void OnChange()
{
if (change != null)
{
//the top action on a stack may be the first of its kind and therefore
//needs to be skipped over; the first action of a kind is only needed
//when undoing the second action of that kind, via it's PreviousAction
//property
String redoDescription = null;
if(redoStack.Count > 0)
{
LinkedListNode<IAction> redo = redoStack.Last;
while (redo != null && redo.Value.PreviousAction == null)
redo = redo.Previous;
if (redo != null)
redoDescription = redo.Value.Description;
}
String undoDescription = null;
if (undoStack.Count > 0)
{
LinkedListNode<IAction> undo = undoStack.Last;
while (undo != null && undo.Value.PreviousAction == null)
undo = undo.Previous;
if (undo != null)
undoDescription = undo.Value.Description;
}
change(undoDescription, redoDescription);
}
}