Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection (Read 3266 times)
Cyrinael
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 42
Joined: Jul 22nd, 2016
Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection
Aug 9th, 2016 at 12:27pm
Print Post  
Hi,

I have encountered a problem, where the following code lead to unreasonable behavior with the SubordinateGroup of a Node:

Code
Select All
ShapeNode master = new ShapeNode() {Text = "master" };
ShapeNode sub = new ShapeNode() {Text = "sub" };

diagram.Nodes.Add(master);
diagram.Nodes.Add(sub);

sub.AttachTo(master, AttachToNode.MiddleRight);

DiagramNodeCollection collection = diagram.Nodes.Clone();

diagram.ClearAll();

diagram.Nodes.Add(collection[0]);
diagram.Nodes.Add(collection[1]);
 



Interestingly, the SubordinateGroup of the master-Node is null after a diagram.ClearAll() is executed.

Best regards,

Cyrinael
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection
Reply #1 - Aug 9th, 2016 at 2:22pm
Print Post  
Hi,

ClearAll also clears and destroys all groups from Diagram.Groups collection (created implicitly by the AttachTo commands). I guess you'd have to rebuild them if you need to add nodes again after ClearAll.

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


I Love MindFusion!

Posts: 42
Joined: Jul 22nd, 2016
Re: Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection
Reply #2 - Aug 10th, 2016 at 8:22am
Print Post  
Hi Slavcho,

I am currently trying to do that, but the problem is, that I cannot create a Group that is independent of a Diagram object, neither can I actually set the attachedNodes, since they are only readable and can only be set with the attachTo-Method.

Both constructors generate a Group that link to the Diagram and if I delete the Diagram, the references to the MainItem and the attachedNodes will be null.

Is there another way to actually maintain a copy of the groups, even if the Diagram is cleared?

Best regards,

Cyrinael
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection
Reply #3 - Aug 10th, 2016 at 8:35am
Print Post  
Hi Cyrinael,

Maybe check if the CopySelection and PasteSelection methods will work for you - these are used internally by clipboard-support methods and can optionally copy groups too. If they will work for your scenario but you don't want to change selection, we could add overloads that take the list of nodes as argument.

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


I Love MindFusion!

Posts: 42
Joined: Jul 22nd, 2016
Re: Diagram.ClearAll() will delete the SubordinateGroup of a Node in the cloned DiagramNodeCollection
Reply #4 - Aug 10th, 2016 at 11:07am
Print Post  
Hi Slavcho,

I made my own Group Class in which I store the MainItem and the AttachedNodes. I now save all groups twice, so that I can restore the Diagram-Group after I cleared the diagram. This works pretty well, nevertheless it is not the nicest solution in my opinion.

Thank you for your effort,

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