Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic UndoManager - Layout action recording (Read 1443 times)
due
YaBB Newbies
*
Offline



Posts: 27
Joined: Jun 20th, 2007
UndoManager - Layout action recording
May 2nd, 2008 at 11:35am
Print Post  
The undo manager does not record the document resizing caused by automatic layouts.

The layout algorithm accordingly fits the diagram bounds to new layout size, but if you undo this action the original size will not be restored. Therefore, the user may see truncated diagrams (scrollbars are also unjustified).

However, undo calls will result in inconsistent diagram bounds (Diagram.Bounds). This invalid view state exists until diagram is resized (Diagram.ResizeToFitItems).

How can I handle this?  ???
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: UndoManager - Layout action recording
Reply #1 - May 2nd, 2008 at 3:11pm
Print Post  
Hi,

The Arrange methods do not change Diagram.Bounds; perhaps you are calling ResizeToFit after each Arrange? Anyway you can define your own commands to keep track of Bounds and other Diagram properties, e.g.

Code
Select All
public class DiagramState : Command
{
	public DiagramState(Diagram diagram, string title) : base(title)
	{
		this.diagram = diagram;
		oldBounds = diagram.Bounds;
	}

	RectangleF oldBounds, newBounds;
	Diagram diagram;

	protected override void Execute(bool undoEnabled)
	{
		newBounds = diagram.Bounds;
	}

	protected override void Undo()
	{
		diagram.Bounds = oldBounds;
	}

	protected override void Redo()
	{
		diagram.Bounds = newBounds;
	}
}
 



and use it like this:

DiagramState diagramState = new DiagramState(diagram, "Bounds changed");
diagram.ResizeToFitItems(5);
diagram.ExecuteCommand(diagramState);

If you are always calling ResizeToFitItems after Arrange, you might prefer to do that as well in the ActionUndone and ActionRedone event handlers when they are raised for layout commands, instead of using a custom command.

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