Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo\Redo Methods (Read 3412 times)
ahmdsalh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Apr 16th, 2010
Undo\Redo Methods
Apr 16th, 2010 at 8:41am
Print Post  
Hi,
I'm a bit new to the forum.

can you give an example for using CustomUndo Method for recording a custom undo\redo record ?

and how can i call this record later and perform undo\redo actions?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo\Redo Methods
Reply #1 - Apr 16th, 2010 at 11:57am
Print Post  
Hi,

Do you mean the RecordCustomAction method? You must associate some integer id with the change you need to undo or redo, and pass this id to RecordCustomAction. Now when you call the Undo or Redo methods or the user hits Ctrl-Z, you will get the id as argument of the ActionUndone or ActionRedone events.

As a simplified example if you need to integrate the change of selection within a listbox into the FlowchartX undo/redo queue, you could pass the index of the previously selected item to RecordCustomAction, and select it again when ActionUndone is raised.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ahmdsalh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Apr 16th, 2010
Re: Undo\Redo Methods
Reply #2 - Apr 16th, 2010 at 12:17pm
Print Post  
Thank you for your quick reply.
but cann't i find any simple vb code for what you have mentioned as i'm a bit confused?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo\Redo Methods
Reply #3 - Apr 16th, 2010 at 3:36pm
Print Post  
Imagine you have some binary states associated with each box, and you need to toggle them when a box is double clicked. You could implement undo/redo for this as follows:

Code
Select All
Private Sub fcx_BoxDblClicked(ByVal box As FLOWCHARTLibCtl.IBoxItem, ByVal button As FLOWCHARTLibCtl.EMouseButton, ByVal x As Long, ByVal y As Long)
	ToggleState box.Tag
	fcx.RecordCustomAction box.Tag
End Sub

Private Sub fcx_ActionRedone(ByVal actionType As FLOWCHARTLibCtl.EActionType, ByVal obj As Object, ByVal ID As Long)
	If actionType = actCustom Then ToggleState ID
End Sub

Private Sub fcx_ActionUndone(ByVal actionType As FLOWCHARTLibCtl.EActionType, ByVal obj As Object, ByVal ID As Long)
	If actionType = actCustom Then ToggleState ID
End Sub

Sub ToggleState(i As Integer)
	'whatever
End Sub 



This is an oversimplified situation obviously. For more complex scenarios you will probably need to define classes that store more information about the changes, such as old value of something and new value of something. Then you could add instances of these classes to an array and set their array index as ID of the custom undo record. When ActionUnone or ActionRedone is raised you can get the record by its index/ID and bring your data to whatever its state was before or after the action.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ahmdsalh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 7
Joined: Apr 16th, 2010
Re: Undo\Redo Methods
Reply #4 - Apr 16th, 2010 at 5:07pm
Print Post  
Thank you so much, everything is clear now.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint