Undo, Redo, Copy command with WPF

Hello,

I have a problem with Undo, Redo, Copy command.

When undo, redo, copy command is called, they affect my plugin data.

For example,

protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            byte[] bytes = archive.ReadByteArray();
            MemoryStream stream = new MemoryStream(bytes);
            IFormatter formatter = new BinaryFormatter();
            MyClass data = formatter.Deserialize(stream);
...

When I read documents, my plugin deserializes its data from the document.
After that, If I press CRTL + C (CopyToClipboard), deserialized data from ReadDocument are also copied to clipboards.
Then, if I press CRTL + P(Paste), my ReadDocument logic is called again.

Another example,
In my WPF ListView, ListViewItem has checkbox that it is checked when rhino mesh is selected.
And when selected mesh is deleted, checkbox is unchecked.

But if I press CRTL + Z (Undo), checkbox is checked.

I want to block Undo, Redo, Copy, Paste command in my rhino plugin.

Is it possible?

  • Kyungmin

Hi @kyungmin.so,

The CopyToClipboard and Paste command are file I/O operations, basically working like Export and Import. This is why your plug-in’s WriteDocument and ReadDocument members may be called. When then these plug-in members are called, use the FileWriteOptions and FileReadOptions parameters passed to these methods to determine your course of action.

– Dale

Hi @dale

Thank you for your help!

About CopyToClipboard and Paste command, I solved by your support.

And, can I block undoing of custom wpf data ?

  • Kyungmin

Hi @kyungmin.so,

You might conside subscribing to the Command.UndoRedo event and other document event that occur when an object “undone” or 'redone".

When you get a chance, run the SampleCsEventWatcher plug-in, which demonsrates all of Rhino’s events.

– Dale