EtoPanel recording undo on panel content

Hi there,

I am working on an eto-panel and I would like to link an undo to an datagrid on this panel.

What I would do if I was operating on the model is this.

uint recordSerialNumber = RhinoDoc.ActiveDoc.BeginUndoRecord("Delete data");

// Do stuff

RhinoDoc.ActiveDoc.EndUndoRecord(recordSerialNumber);

As I am deleting stuff from a datagrid I suppose this is not working, right?
Does anybody have experience with this?

Thanks,

T.

Hi @tobias.stoltmann,

What is in your data grid?

– Dale

@dale

I store an IObservableCollection in this grid.

Hi @tobias.stoltmann,

Rhino can record changes that occur to the Rhino document. These change can be undone.

If you write Rhino commands, then Rhino will record changes that occur to the Rhino document automatically.

If you have some kind of “modeless” user interface, such as a docking panel or modeless dialog box - something that modifies the Rhino document outside of a Rhino command - then you will need to record changes to the Rhino document yourself if you want those modifications to be undoable.

You do with calls to RhinoDoc.BeginUndoRecord and RhinoDoc.EndUndoRecord.

Note carefully: If you call RhinoDoc.BeginUndoRecord then you must call RhinoDoc.EndUndoRecord, otherwise you will break undo recording.

Note, Rhino’s undo recording only applies to changes to the Rhino document. Anything else you want to track, you will have to code up yourself.

One option is to add a custom undo event to the Rhino document using RhinoDoc.AddCustomUndoEvent. After doing this, if a user run the Undo command, your custom undo event handler will be called, allowing you to “undo” whatever you want.

I’ve attached a sample for you to review:

SampleCsUndoDollars.cs (4.7 KB)

If this isn’t close to what you want, then please clarify in detail what you are trying to do and why.

Thanks,

– Dale

1 Like