Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic A question about undo and redo (Read 1110 times)
chowy
Junior Member
**
Offline


I Love MindFusion!

Posts: 72
Joined: May 8th, 2017
A question about undo and redo
Dec 19th, 2017 at 8:38am
Print Post  
When I use diagramDraw.ActiveItem.ZTop (true);, how do I undo and restore it? Save the ZIndex property does not seem to solve the problem.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: A question about undo and redo
Reply #1 - Dec 19th, 2017 at 1:12pm
Print Post  
Try this -

Code
Select All
void OnObjectBringToFront(object sender, RoutedEventArgs e)
{
	if (diagram.ActiveItem != null)
	{
		var cmd = new BringToFrontCmd(diagram.ActiveItem);
		diagram.ExecuteCommand(cmd);
	}
}

class BringToFrontCmd : Command
{
	public BringToFrontCmd(DiagramItem item) : base("Bring to front")
	{
		this.item = item;
		zIndex = item.ZIndex;
	}

	protected override void Execute(bool undoEnabled)
	{
		item.ZTop(true);
	}

	protected override void Undo()
	{
		item.ZIndex = zIndex;
	}

	protected override void Redo()
	{
		item.ZTop(true);
	}

	DiagramItem item;
	int zIndex;
} 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint