Hi Walter.
<span id=“result_” =“short_text”>Can you show a more detailed example of working with UndoManager.
In my project, elements of diagram displays objects from tables.
<span id=“result_” =“medium_text”>Accordingly, deletion or addition of elements on the diagram changes the database. <span id=“result_” =“medium_text”>How should I handle events Undo / Redo?

Does the UpdateDemo sample answer your questions?

No. Sorry. <span id=“result_” =“short_text”>Do you have a more detailed example?

You haven’t provided the right details for me to be able to answer your question. But I’ll ask some questions and make some assumptions.

How are you updating the database based on user actions such as deleting a node? Are you just handling the Diagram.SelectionDeleting event?

Instead, it might be best to establish a DiagramModel.Changed event handler that is the only thing responsible for updating your database. That way no matter how or why a node (data) is removed from the model, you can remove the corresponding information from your database. Or if a node data is added to your model, you can add to your database.

You then have two choices: do you do updates immediately as they occur, or do you wait until a model transaction commits or an undo/redo happens? I’m guessing you’ll prefer the latter.

If you do choose the latter, you only need to check for the ModelChange.CommittedTransaction, FinishedUndo and FinishedRedo cases in your Model.Change event handler. This is how UpdateDemo is organized.

In your event handler you just need to look at the event args to find the list of changes that were committed or undone or redone. Iterate through those lists and make the database changes you want to make.

See also this topic, in case that helps.

Thanks. <span id=“result_” =“short_text”>I will try to understand