Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic ZOrder problem with Undo? (Read 2713 times)
rzanni
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 11
Joined: Mar 18th, 2009
ZOrder problem with Undo?
Mar 19th, 2009 at 5:59pm
Print Post  
Hi,

I have a Table Node and a Shape Node with an image Attached to the Table (AttachToNode.TopLeft)

The problem is when I delete the Table (AutoDeleteItems is True), everything is deleted right but when Undo is done, the table is back but the Shape node is invisible because is behind the table.

If I click the table the shape node with the image is visible again.

Any suggestions.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZOrder problem with Undo?
Reply #1 - Mar 19th, 2009 at 6:36pm
Print Post  
Hi,

I suppose you've used StartComposite when creating the group to create a composite undo record, right? Now, use the StartComposite overloaded method that takes a saveZOrder argument, and set it to true.

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


I love YaBB 1G - SP1!

Posts: 11
Joined: Mar 18th, 2009
Re: ZOrder problem with Undo?
Reply #2 - Mar 20th, 2009 at 1:40pm
Print Post  
No, I was not using StartComposite.

I'm testing with this example that comes in the help file:

' Implicitly created undo records will be saved here
Dim composite As CompositeCmd = diagram.UndoManager.StartComposite("Create group")

' Call methods that create undo records
Dim node1 As ShapeNode = diagram.Factory.CreateShapeNode(0, 0, 30, 30)
Dim node2 As ShapeNode = diagram.Factory.CreateShapeNode(0, 0, 15, 15)
Dim g As Group = diagram.Factory.CreateGroup(node1)
g.AttachToCorner(node2, 0)

' This goes to the active composite too
Dim change As ChangeItemCmd = New ChangeItemCmd(node2, "")
node2.Locked = True
change.Execute()

' Save the active composite in history
composite.Execute()


but I get an error in the composite.Execute call:
Object reference not set to an instance of an object.
Is there anything wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZOrder problem with Undo?
Reply #3 - Mar 20th, 2009 at 3:33pm
Print Post  
StartComposite returns null / Nothing if you haven't enabled the undo manager. Set diagram.UndoManager.UndoEnabled = true before running that code.

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


I love YaBB 1G - SP1!

Posts: 11
Joined: Mar 18th, 2009
Re: ZOrder problem with Undo?
Reply #4 - Mar 20th, 2009 at 4:56pm
Print Post  
Stoyan,

Thanks for your answer, but I still don't get it right.

Please try this simple code:

Private Sub CreateGroup()

doc.UndoManager.UndoEnabled = True

Dim composite As CompositeCmd = New CompositeCmd(doc, "Create Group", True)
Dim node1 As ShapeNode = doc.Factory.CreateShapeNode(0, 0, 30, 30)
Dim node2 As ShapeNode = doc.Factory.CreateShapeNode(0, 0, 15, 15)

Dim g As Group = doc.Factory.CreateGroup(node1)
g.AttachToCorner(node2, 0)

node2.Image = images.Images(5)
node2.Locked = True
node1.SubordinateGroup.AutoDeleteItems = True

composite.Execute()

End Sub

1. Use your own image in node 2
2. Now delete the group
3. Now Undo

You get the node 1 and node2 back , but node2 is behind node1.

If you click node1, you will see node2 and its image but if you click the view again, node2 will dissapear.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: ZOrder problem with Undo?
Reply #5 - Mar 21st, 2009 at 10:12am
Print Post  
If you use your own composite command instead of the one returned by UndoManager.StartComposite, it won't automatically accumulate the commands created by theFactory.Create methods. Anyway, even if you do that, this code affects only undoing or redoing the creation operation, and has nothing to do with undo of deleting the group. Try adding similar StartComposite(true) / Execute calls around the code that deletes the group.

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