Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Items properties are not updated until diagram is loaded. (Read 996 times)
nullable
Junior Member
**
Offline


I Love MindFusion!

Posts: 86
Joined: Aug 25th, 2022
Items properties are not updated until diagram is loaded.
Nov 29th, 2022 at 12:13pm
Print Post  
Hi. I'm trying to export diagram into SVG straightaway after I created it. I have generation of the DiagramItems in the diagram constructor. After generation I'm calling diagram.ExportToSvg() and I get wrong Z positions of Items in the result SVG. Although after that I got diagram with the way items should be.

If I'll call diagram.ExportToSvg() on Initialized event, it gives me the same result, because BeginInit() and EndInit() placed in the constructor.

If I'll call diagram.ExportToSvg() on Loaded event, it gives me right result.

It happens not only with Zorder and layerIndexes. Positions of the Items also are not updated if I set them not in the Item's constructor, but in the code after I had created Item, positions will not update too until Loaded event is invoked.

Can you help with that? Is it possible to call ExportToSvg() right after I created Diagram even I don't see it and Loaded event is not invoked. Is there some method to update all Items properties?

See in attachments images. First image with the Red circle it is svg generated after diagram's constructor. The second image with the green circle is svg generated on diagram.Loaded event.
  

ConstructorGenerated.PNG ( 12 KB | 26 Downloads )
ConstructorGenerated.PNG
LoadedEventGenerated.PNG ( 13 KB | 31 Downloads )
LoadedEventGenerated.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Items properties are not updated until diagram is loaded.
Reply #1 - Nov 29th, 2022 at 2:21pm
Print Post  
Hi,

Maybe WPF layout pass hasn't completed yet. Is it any better if you call diagram.UpdateLayout before your ExportToSvg method?

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Junior Member
**
Offline


I Love MindFusion!

Posts: 86
Joined: Aug 25th, 2022
Re: Items properties are not updated until diagram is loaded.
Reply #2 - Nov 30th, 2022 at 3:33am
Print Post  
Unfortunately, call diagram.UpdateLayout before ExportToSvg method didn't help. Can I do something else? Should the diagram be on the screen to invoke Loaded event to make ExportToSvg work or can I somehow make export diagram to svg without visual appearance?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3154
Joined: Oct 19th, 2005
Re: Items properties are not updated until diagram is loaded.
Reply #3 - Nov 30th, 2022 at 7:08am
Print Post  
Is the diagram in WPF window's visual tree when it's not exporting?  You could try adding to a hidden window, updating layout, then exporting from there. For updating layout try calling all these in sequence:

diagram.Measure(PositiveInfinity);
diagram.Arrange(diagram.DesiredSize);
window.UpdateLayout();

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
nullable
Junior Member
**
Offline


I Love MindFusion!

Posts: 86
Joined: Aug 25th, 2022
Re: Items properties are not updated until diagram is loaded.
Reply #4 - Nov 30th, 2022 at 12:27pm
Print Post  
Seems to work, thanks a lot Cheesy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint