Extend this Class to Undo/Redo in a Listview

后端 未结 3 1845
生来不讨喜
生来不讨喜 2021-01-05 01:59

I\'m using a thir party code to manage undo/redo operations in a WindowsForm project.

I need to extend the Class to manage undo/redo operations in a Listview, this m

3条回答
  •  一向
    一向 (楼主)
    2021-01-05 02:29

    I see. It's a bit of how you define what a "Redo" should do. In your case you want to Redo an Undo operation. By default, a Redo repeats the last action. Even If you Undo something, the Redo Undos again. Try this approach: Understand the Code fragment only as building blocks. The "RemoveItem" Method don't add Code to Undo/Redo stack - Add this Undo Redo like in the Add - Method. If you don't need to 'Undo an Undo' - Operation, add a

    Property IsDoingUndo as boolean
    

    To UndoManager and set it true if doing an Undo. Check this Property in Add/Remove Method and don't add something to the Undo/Redo Stack. Like :

    If not _UndoManager.IsDoingUndo then 
    ...
    else
    ...
    endif
    

    With this you will get control of what should be undo-able and redo-able. Sorry that I can not provide sourcecode this time.

提交回复
热议问题