Cancel repeat in WPF / C # in an already functional application

I have already done some research on how I can reach the title of this question. The application I'm working on has been under development for several years (slow progress, although you all know how this happens in the real world). Now for me it is necessary to add Undo / Redo functions to several levels. It's a little late to say “you should have thought about this before you started” ... well, we really thought about it - and we did nothing about it, and now here it is. From a search around SO (and external links), I see that the two most common methods look like ...

Command pattern

Memento pattern

The team template looks like it would be a lot of work, I can only imagine that it throws thousands of errors in the process, so I do not really like it.

The image of Memento is actually very similar to what I have in my head for this. I was wondering if there is a way to quickly take a snapshot of the object model currently in memory, then I can save it somewhere (maybe also in memory, maybe in a file). It seems like a great idea, the only problem I see for this is how it will integrate with what we have already written. You see the application, since with us it draws images on a large panel (potentially hundreds), and then allows the user to manipulate them either through the user interface or through a custom property grid. The entire application is associated with a large observer pattern. The second thing is changing, events are being fired, and everything that needs to be updated is done. This is good, but I cannot help thinkingthat if the user enters text in the tex field in the property grid, there will be a little delay before the user interface catches (it seems that every time the user presses a key, a new snapshot will be added to the undo list). So my question for you is ...

  • - Memento, .
  • , Memento .
  • Memento - , ( - )
  • ?

, . , , .

+3
4

/ -

  • ,
  • ,

undo/redo , - ( , , , , undo-friendly ).

, :

  • , "". - , ? , , , . , , . , , () , ( / ​​ ) () ( , - , API, , , ) (c) " ". , ( (b)), . , , , , .

    • , . , , , , . , , , (. ) , .

, , , , /.

+1

, .

1- /. , .

2- , , , Memento, . Memento - , .

, , .

Undo/Redo, , , , .

+5

, . , .

, , (.. , ,...), XmlSerializer JsonSerializers . Json.net , ( DateTimes, numbers,...), .

, protobuf - DTD ( .proto), , , .

BinaryFormatter , [Serializable]. , , . , .

+3

, Monitored Undo Framework . http://muf.codeplex.com/

- , , , , / .

, / , . ( ) . , , MUF "" , / .

, , , . , / , .

, . , , . .

codeplex http://muf.codeplex.com/. NuGet .NET 3.5, 4.0, SL4 WP7.

+1

Source: https://habr.com/ru/post/1778155/


All Articles