To implement Undo, the simplest way is to use a MemoryStream object in your WaveDisplayForm (MDI Child) and simply serialize the Wave (which should be marked as [Serializable] to the stream and hold on to the stream object. private MemoryStream _undoStream = new MemoryStream(); private bool _canUndo = false; public void SaveForUndo() { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(_undoStream, wave); _undoStream.Flush(); // This rewinds the stream so that when it is used for deserialization, it's ready to use, // otherwise, the deserialization will start deserializing from the end of the stream and would fail. _undoStream.Position = 0; _canUndo = true; } public void Undo() { BinaryFormatter bf = new BinaryFormatter(); ...
I posted a comment last night, but for some reasons, it disappeared.
ReplyDeleteI don't remember you showing us how to do it but I know how.
Just right click on the project, add a new item, add the class diagram, and drag and drop the project from the solution explorer to the diagram.
Thank you. This is part of testing this blog site to see if it really would work for the future and if it is better or worse. thanks for participating Agatha.
ReplyDelete