Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic UndoManager - ControlPoint changes (Read 4498 times)
due
YaBB Newbies
*
Offline



Posts: 27
Joined: Jun 20th, 2007
UndoManager - ControlPoint changes
Apr 15th, 2008 at 1:31pm
Print Post  
It seems that the undo manager does not correctly record the control point manipulations (readonly property DiagramLink.ControlPoints).

If a user change the control points via mouse (GUI) it will be recorded with no problems. But if you manipulate the control points programatically the changes won't be recorded accordingly.
(Perhaps changes are not recorded or older control point changes are overwritten in the undo history...)

Version: 5.0.3 Pro
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UndoManager - ControlPoint changes
Reply #1 - Apr 15th, 2008 at 1:51pm
Print Post  
Create a ChangeItemCmd instance before setting the points, and call its Execute method after that. Then undo/redo should work fine.

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



Posts: 27
Joined: Jun 20th, 2007
Re: UndoManager - ControlPoint changes
Reply #2 - Apr 16th, 2008 at 8:08am
Print Post  
Yes, it helps.

Additionally, you have to check the sequence of statements. At first the DiagramLink should be added to the diagram and after that you can modify the control points via ChangeItemCmd. Otherwise the changings are ignored by the undo manager.

By the way:
Is it possible to merge/append commands to already created commands. E.g., the handler of LinkCreated event formats the new created link instance. In this case two undo commands are created. The first one is the link creation (AddItemCmd) and the second one is the link modification (ChangeItemCmd).
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UndoManager - ControlPoint changes
Reply #3 - Apr 16th, 2008 at 3:44pm
Print Post  
I can't find any straight-forward way to do that. You could replace the last AddItemCmd instance in the UndoManager.History.Commands with another command that wraps AddItemCmd as a child, and also keeps track of the modifications done on the link. Since we already have a MergeRecords method in the ActiveX version of the control, we can port it in a few days to make that easier.

Stoyan
  
Back to top
 
IP Logged
 
due
YaBB Newbies
*
Offline



Posts: 27
Joined: Jun 20th, 2007
Re: UndoManager - ControlPoint changes
Reply #4 - Apr 17th, 2008 at 6:56am
Print Post  
Moreover, I forgot to mention it, after link creation a new node (with separate text) will be added and attached to new created link programatically. For these implicitly created records you have to use the UndoManager.StartComposite method.

1. How can I merge them to last undo command? (There is no further method except Execute()).

2. How can I rollback/drop an 'active' composite command? Apart from coding convention (clean up/release anything you do not require) issues, this is necessary to avoid empty composite commands (no changes effected or unexpected abort of diagram adaptation).

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UndoManager - ControlPoint changes
Reply #5 - Apr 17th, 2008 at 1:06pm
Print Post  
1. We'll add a MergeRecords method to let you do that.
2. I suppose calling Execute immediately followed by UndoManager.Undo will have the same effect as a rollback for an empty composite command.
  
Back to top
 
IP Logged
 
due
YaBB Newbies
*
Offline



Posts: 27
Joined: Jun 20th, 2007
Re: UndoManager - ControlPoint changes
Reply #6 - Apr 17th, 2008 at 2:48pm
Print Post  
1. Thx a lot, Stoyo!
2. Yes, it works!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UndoManager - ControlPoint changes
Reply #7 - Apr 22nd, 2008 at 6:49am
Print Post  
Hi,

We have added a MergeUndoRecords method. It can be used like this:

Code
Select All
private void diagram_LinkCreated(object sender, LinkEventArgs e)
{
	ChangeItemCmd linkChange = new ChangeItemCmd(e.Link, "Text changed");
	e.Link.Text = "test";
	linkChange.Execute();

	diagram.UndoManager.History.MergeUndoRecords(2, "Create link");
}
 



Take a look on the PM page for a link to download the licensed version of the fc.net assemblies.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint