I'm trying to implement a custom undo action. I want to add a custom action to chain on undos, so it happens at the relevant time
e.g. I draw an annotation, then I add my custom undo action, then I draw another annotation. If I press undo once, the annotation is undrawn, press it again and my custom undo is called, press it again and the final annotation is undrawn.
At the moment my custom undo action doesn't increment the undo count, and the undo method isn't called. I am passing an ICloneable collection of my own as the source, but as the code below shows I want to handle the undo separately. Any help would be appreciated.
Code: Select all
public class CustomUndoAction : UndoAction
{
private Messages.VMMessage _message;
public Messages.VMMessage Message
{
get => this._message;
}
public CustomUndoAction(ICloneable source, VMMessage message) : base(source)
{
this._message = message;
}
protected override void Undo()
{
WeakReferenceMessenger.Default.Send(this._message);
}
}