Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic MergeUndoRecords (Read 1997 times)
asloan
YaBB Newbies
*
Offline



Posts: 35
Joined: Mar 6th, 2006
MergeUndoRecords
Oct 4th, 2007 at 3:05pm
Print Post  
Can you explain how the MergeUndoRecords method is suppossed to work?

I have a function that allows a user to take a long branch and split it at a certain node into a couple of branches. This function makes many changes to the diagram including creating new boxes, creating new arrows, deleting existing arrows, and creating/destroying groups.

I want the user to be able to undo the entire process if they need to. The way I'm currently doing this is like this:

  • I set a long(lUnCnt) to 0 at the beginning of the function
  • In the UndoActionRecorded event, I increment the long each time that event is fired.
  • Before any manipulation starts, I call fc.BeginUndoRecord
  • When the manipulation is complete, I call fc.EndUndoRecord
  • I then call fc.MergeUndoRecords lUnCnt


After the process is complete, If I call fc.Undo, it seems to have no effect.

Am I doing something wrong?

*NOTE* fc.UndoDepth is set to 10000 (Usually only ever hit about 3500 undo records during this process). Also, if I call fc.Undo within this function after all of the above, it sucessfully Undoes everything. However, I need the user to make that determination AFTER the manipulation is complete and the function has ended.


Thanks,
Alan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: MergeUndoRecords
Reply #1 - Oct 4th, 2007 at 5:11pm
Print Post  
Enclosing all modifications between fc.BeginUndoRecord and fc.EndUndoRecord should be enough to make them undoable as a single operation. The actions executed between those two method calls create a single composite undo record. The Recorded event is not raised at all while recording the composite action, so you might be actually calling MergeUndoRecords(1) which does nothing. Make sure the undo buffer is not cleared at some point after your function returns.

Stoyan
  
Back to top
 
IP Logged
 
asloan
YaBB Newbies
*
Offline



Posts: 35
Joined: Mar 6th, 2006
Re: MergeUndoRecords
Reply #2 - Oct 5th, 2007 at 5:52pm
Print Post  
Ok, it works now.

There was an un-handled error in my GroupDestroyed event that was happening when the undo was issued that basically caused the Undo operation to abort.

Thanks,
Alan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint