Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo/Redo for RotationAngle not working properly (Read 4569 times)
Thomson Tat
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Nov 21st, 2013
Undo/Redo for RotationAngle not working properly
Nov 26th, 2013 at 12:33am
Print Post  
Hi,

Whenever RotationAngle is changed in a shape node, it seems to break the UndoManager.

For example, if you move a shape node around, you can undo and redo and it behaves as expected.  As soon as the rotation angle is changed, you can undo once, but you can't redo any more.  It also doesn't undo the movement anymore, among other weird issues.

I checked this in the WPF Diagram Demo and it behaves just as erratic.  The demo I tried was titled "WPF Diagram Demo - Rotation."  It's the one with the traffic diagram.  If you rotate any of those shape nodes and try undo/redo, it won't behave correctly.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo/Redo for RotationAngle not working properly
Reply #1 - Nov 26th, 2013 at 10:42am
Print Post  
Hi,

That's a bug. If you are building the control from source code, find following two lines in DiagramNode.OnRotationAngleChanged:

Code
Select All
if (item.Parent != null) 



and replace them with

Code
Select All
if (item.Parent != null && !item.internalRotationSet) 



or let me know what version you are using if you prefer our developers to compile it for you.

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


I Love MindFusion!

Posts: 5
Joined: Nov 21st, 2013
Re: Undo/Redo for RotationAngle not working properly
Reply #2 - Nov 26th, 2013 at 4:04pm
Print Post  
Hi Stoyo,

Thanks for the quick reply.  It's better but it's still not working completely yet.

If I rotate once, undo only brings the links back.  It doesn't rotate the shape node.  Redo then leaves the shape node alone, but rotates the links.

If I rotate twice, the first undo brings the links back.  The second undo brings the shape node back.  So, if it was going from 0->90->0, the shape node and links are at 90 instead of 0 when undoing twice.  Then, when redoing, the first time it does nothing, and the second time it rotates it.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo/Redo for RotationAngle not working properly
Reply #3 - Nov 26th, 2013 at 7:15pm
Print Post  
Hi,

We could not reproduce that with current WpfDiagram version and OnRotationAngleChanged fix applied. What version of the control are you using, and could you attach a saved diagram file or test project that shows the problem?

Stoyan
  
Back to top
 
IP Logged
 
Thomson Tat
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Nov 21st, 2013
Re: Undo/Redo for RotationAngle not working properly
Reply #4 - Nov 26th, 2013 at 7:52pm
Print Post  
We're using version 3.0.2.21664.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo/Redo for RotationAngle not working properly
Reply #5 - Nov 27th, 2013 at 10:56am
Print Post  
We could not reproduce it with 3.0.2 either, please attach a saved file or test project so we can try this with your settings. By rotating the node, you mean you are using the adjustment handle at top to rotate interactively, right?
  
Back to top
 
IP Logged
 
Thomson Tat
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 5
Joined: Nov 21st, 2013
Re: Undo/Redo for RotationAngle not working properly
Reply #6 - Nov 27th, 2013 at 5:11pm
Print Post  
No, we are rotating it using the "RotationAngle" property of the node.

I attached a test project.  Please put the MindFusion DLLs in the "WpfDiagram" folder.

Simple test case:
1.  Set the combobox to "Create" and click on the diagram to create a node.
2.  Set the combobox to "Rotate" and click on the node.  It should rotate the node 45 degrees.
3.  Click "Undo" and "Redo."  It doesn't behave as expected.
  

DiagramRotate.zip (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Undo/Redo for RotationAngle not working properly
Reply #7 - Nov 27th, 2013 at 7:45pm
Print Post  
It seems we have not integrated our undo manager very well with WPF's dependency properties, and in this case it manages to save the new rotation value for undo when called from the property change callback, instead of the old value. We'll rewrite that part for next release; for the time being you can move the UndoManager calls from the OnRotationAngleChanged callback to RotationAngle setter to fix that for your use case:

Code
Select All
public Real RotationAngle
{
	get { return (double)GetValue(RotationAngleProperty); }
	set
	{
		// moved here from callback
		if (Parent != null && !internalRotationSet)
		{
			Parent.UndoManager.OnStartPlacementChange(this);
			//Parent.Invalidate(GetRepaintRect(true));
		}

		SetValue(RotationAngleProperty, value);

		// moved here from callback
		if (Parent != null && !internalRotationSet)
		{
			Parent.SetDirty();
			//Parent.Invalidate(GetRepaintRect(true));
			Repaint(true);
			Parent.UndoManager.OnEndPlacementChange();
		}
	}
} 



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


I Love MindFusion!

Posts: 5
Joined: Nov 21st, 2013
Re: Undo/Redo for RotationAngle not working properly
Reply #8 - Nov 27th, 2013 at 10:19pm
Print Post  
That worked great!  Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint