Page 1 of 1

Custom Undo Action

Posted: Wed Apr 03, 2024 11:45 am
by missionRoom
Hi,

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);
    }
}

Re: Custom Undo Action

Posted: Wed Apr 03, 2024 12:17 pm
by Alex
Hi,

Please send us (to support@vintasoft.com) a small console/WinForms/WPF project that demonstrates how you are working (create, undo, redo) with custom undo action. We need to analyze your code on our side.

Best regards, Alexander