Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ShapeList and UndoManager (Read 3622 times)
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
ShapeList and UndoManager
Jul 24th, 2007 at 12:58pm
Print Post  
Hello,

I've encountered the following problem:

When I drag a new Shape from the ShapeList to the FlowChart, the ActionRecorded Event is fired.

How do I capture this to build a new CompositeCmd?

I tried creating a new CompositeCmd in the ActionRecording Event, but it keeps adding all following actions separatly in the UndoManager.

s.th. like this:

Code
Select All
        private void flowChart_ActionRecording(object sender, UndoConfirmEventArgs e)
        {
            //now start the composition depending on the Command
            if(e.Command.Title.Equals("Create"))
            {
                cmd = new CompositeCmd(FlowChart, "Erstellen");
                e.Confirm = true;
            }

        } 



cmd is a private variable of the class in which the FlowChart is defined.

After that, i try to execute the composite command at the end of the BoxCreated event, but this simply adds the CompositeCmd to the History after all other commands (which should be subCmds of this CompositeCmd).

Any ideas?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeList and UndoManager
Reply #1 - Jul 24th, 2007 at 1:33pm
Print Post  
Hello,

Try calling UndoManager.StartComposite from the FlowChart.DragDrop event handler.

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: ShapeList and UndoManager
Reply #2 - Jul 26th, 2007 at 9:46am
Print Post  
Hello,

thanks, this works perfectly. But now I have a question:

When I call the Undo() function of the UndoManager, this function is deleted from the CommandHistory. How can I change this, since a redo doesn't make any sense then? I didn't find a solution.

Alex
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeList and UndoManager
Reply #3 - Jul 26th, 2007 at 10:47am
Print Post  
Why do you think the command is deleted? Undo() should delete the oldest command in the undo buffer, and not the new one.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeList and UndoManager
Reply #4 - Jul 26th, 2007 at 11:43am
Print Post  
Actually recording a new command deletes the oldest one from the undo buffer only if the buffer is full. The Undo method only moves the "current command" pointer one position back in the buffer. However, if there is another command recorded after calling Undo(), it will overwrite the one that otherwise would be redone next.

Stoyan
  
Back to top
 
IP Logged
 
Alex
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Nov 21st, 2006
Re: ShapeList and UndoManager
Reply #5 - Jul 26th, 2007 at 12:10pm
Print Post  
Ok, now I think I get it.

When I call Undo() on my CompositeCmd, which is the only Command in the History and a new Command is executed, my old CompositeCmd is not deleted, but only the current pointer is moved, correct?

So if I call Undo() the NextRedo pointer should point to the Command I just undid (funny word Smiley), or not? But I debugged through the whole code and after the Undo() method is called, the NextRedo is null.

Hope this explanation is more detailed.

Thanks for your support!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ShapeList and UndoManager
Reply #6 - Jul 26th, 2007 at 12:29pm
Print Post  
Are you sure there isn't some other code executed after Undo? It might implicitly save its own record in the undo buffer and overwrite the CompositeCmd.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint