Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic WPF Diagram.CreateImage not generating correct image (Read 696 times)
Steve M
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Feb 29th, 2024
WPF Diagram.CreateImage not generating correct image
Feb 29th, 2024 at 7:42pm
Print Post  
I'm creating a very basic WPF Diagram with ShapeNode and DiagramLink. I use TreeLayout to arrange the nodes/links.

Everything looks great on screen, but CreateImage always creates an image that has all my Nodes on top of each other in in the top-left corner on the image that looks large enough to hold the correctly formatting tree.

Based on another post I found here, I tried adding this before the call to CreateImage, but it made no difference...

diagram.UpdateLayout();
diagram.Measure(diagram.Bounds.Size);
diagram.Arrange(diagram.Bounds);

I can try to extract all the relevant code into a small repro app, but I thought maybe I'm just missing something obvious since I'm pretty new to MindFusion.

One last thing... saving to an SVG with SvgExporter works fine.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: WPF Diagram.CreateImage not generating correct image
Reply #1 - Mar 1st, 2024 at 8:32am
Print Post  
Please try this build, without calling any layout functions -
https://mindfusion.eu/_beta/wpfdiag407.zip

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


I Love MindFusion!

Posts: 1
Joined: Mar 1st, 2024
Re: WPF Diagram.CreateImage not generating correct image
Reply #2 - Mar 1st, 2024 at 6:44pm
Print Post  
It worked! Looks great. Thanks for the beta.

One semi-unrelated question... The image that is captured has padding on the top/left sides that matches my TreeLayout.Margins, but no padding on the bottom/right sides. The description for 'Margins' does only mention top-left, so this is probably by design. Any way to add padding to the bottom/right of the image? I can easily do it myself when saving the PNG, but was curious if there is a more correct way.

Thanks again for the help. I'm loving Mindfusion - very well thought out architecture.

PS: I had to create a new account to post this. My password manager didn't save my password and I don't seem to be getting any Reset Password emails from Mindfusion (yep, checked my spam folder as well).
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3303
Joined: Oct 19th, 2005
Re: WPF Diagram.CreateImage not generating correct image
Reply #3 - Mar 2nd, 2024 at 3:32pm
Print Post  
Exported image should be as large as diagram.Bounds. You could call ResizeToFitItems method before exporting to add margins around the tree -

Code
Select All
diagram.Arrange(treeLayout);
diagram.ResizeToFitItems(margin);

var image = diagram.CreateImage();
Utilities.SaveImage(image, "test.png"); 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint