Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Undo more than one changes at a time in diagram control - silverlight (Read 4441 times)
lightsundar99
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 15
Joined: Nov 15th, 2016
Undo more than one changes at a time in diagram control - silverlight
Nov 15th, 2016 at 5:52am
Print Post  
Hi Stoy,

I am changing node and link position at a time. I want to capture and undo these changes.

How to do  that ?

Thanks,
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3142
Joined: Oct 19th, 2005
Re: Undo more than one changes at a time in diagram control - silverlight
Reply #1 - Nov 15th, 2016 at 7:26am
Print Post  
Hi,

Use the StartCompositeOperation and CommitCompositeOperation methods. Commands recorded between these calls are recorded as a single CompositeCommand instance in the undo history.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
lightsundar99
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 15
Joined: Nov 15th, 2016
Re: Undo more than one changes at a time in diagram control - silverlight
Reply #2 - Nov 15th, 2016 at 9:20am
Print Post  
thanks for your reply..

please give me code snippet for this..
i am bit confused to use command when to use.
thanks
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3142
Joined: Oct 19th, 2005
Re: Undo more than one changes at a time in diagram control - silverlight
Reply #3 - Nov 15th, 2016 at 10:13am
Print Post  
Here's an example that offsets selected items and later undoes the movement as a single operation -

Code
Select All
private void OnMoveSelection(object sender, RoutedEventArgs e)
{
	var dx = 10;
	var dy = 0;

	diagram.StartCompositeOperation();

	foreach (var link in diagram.Selection.Links)
	{
		for (int i = 0; i < link.ControlPoints.Count; i++)
		{
			var linkCmd = new ChangeItemCommand(diagram, link);
			var point = link.ControlPoints[i];
			point.X += dx;
			point.Y += dy;
			link.ControlPoints[i] = point;
			diagram.ExecuteCommand(linkCmd);
		}
	}

	foreach (var node in diagram.Selection.Nodes)
	{
		var nodeCmd = new ChangeItemCommand(diagram, node);
		var bounds = node.Bounds;
		bounds.X += dx;
		bounds.Y += dy;
		node.Bounds = bounds;
		diagram.ExecuteCommand(nodeCmd);
	}

	diagram.CommitCompositeOperation();
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint