Custom Undo Action

Questions, comments and suggestions concerning VintaSoft Annotation .NET Plug-in.

Moderator: Alex

Post Reply
missionRoom
Posts: 18
Joined: Wed Jan 22, 2020 4:38 pm

Custom Undo Action

Post 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);
    }
}
Alex
Site Admin
Posts: 2319
Joined: Thu Jul 10, 2008 2:21 pm

Re: Custom Undo Action

Post 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
Post Reply