This is a migrated thread and some comments may be shown as answers.

Problems exporting multiple diagrams contained in different RadPanes

1 Answer 49 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Kim
Top achievements
Rank 1
Kim asked on 19 Mar 2015, 09:52 AM
Hello!

We have a scripting solution, which generates content for diagrams. The generated diagram content is published to a view model, which is bound to a RadDiagram component that is opened inside a docked RadPane by the script. The purpose of the script is to generate a possibly large number of diagrams, and then export each diagram to a file. What happens upon script execution is that each generated diagram is correctly opened in a docked RadPane, but the ExportToFile -method only works for the diagram that is created as the last one, ie the one that exists on the last opened RadPane, ie the only one that is actually visible. All other diagrams are generated as empty files.

In the script, the export command is invoked immediately after the RadDiagram has been shown, and specifically (hopefully) before the next RadDiagram (that covers the previous one) is being generated, so the diagram to be exported should be visible when the export command is invoked.

I found other threads having to do with the diagram control not being part of the visual tree, and this may be a related issue.

Help appreciated,

Kim Johnsson

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 20 Mar 2015, 10:03 AM
Hi Kim,

We are not exactly sure how is you application configured but one is sure - to export the diagram successfully it must have been property measured and arranged in a Visual Tree. 

If your application cannot stick to this rule, you can try an approach in which you force the measure and arrange of the Diagram inside a parent UserControl and export it without displaying it anywhere.
var diagram = new RadDiagram();
diagram.Items.Add(new RadDiagramShape() { Position = new Point(50, 100) });
diagram.Items.Add(new RadDiagramShape() { Position = new Point(30, 200) });
diagram.Items.Add(new RadDiagramShape());
  
var userControl = new UserControl();
userControl.Content = diagram;
userControl.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
userControl.Arrange(new Rect(0, 0, diagram.DesiredSize.Width, diagram.DesiredSize.Height));
  
using (var stream = File.Open(@"D:\temp2\xDiagram2.png", FileMode.Create))
{
    diagram.ExportToImage(stream);
}

We hope this could fit well in your scenario.


Regards,
Petar Mladenov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Diagram
Asked by
Kim
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or