Is there a way to save the orgchart as an image?
Because the the non public property NodesPanel has a property PreviewImage?
Or is there a way to access the OrgchartNodesPanel, I think then it is possible to create a writable bitmap myself?
Greetings,
Amko HartmanPerigon Vision bvhttp://www.perigonvision.eu
Hi Amko
I am really sorry but now I seem to be missing the PngEncode class.
I do appreciate your help on this.
Andrew
Hi guys,
I forgot to add the EditableImage class. It is attached in this post.
Amko Hartman
Many thanks for this. I tried to implement the code but get an error on 'new EditableImage' - it says that EditableImage is not defined and I cannot see any namespaces where it is included.
Am I missing some code?
I managed to save the OrgChart as an image, see the code below.
public static void SaveOrgChartAsImage(XamOrgChart orgChart, SaveFileDialog dialog) { try { //set overview plus detail pane visibility orgChart.OverviewPlusDetailPaneVisibility = Visibility.Collapsed;
int width = (int)orgChart.ActualWidth; int height = (int)orgChart.ActualHeight;
WriteableBitmap bitmap = new WriteableBitmap(width, height); bitmap.Render(orgChart, new TranslateTransform()); bitmap.Invalidate();
EditableImage imageData = new EditableImage(bitmap.PixelWidth, bitmap.PixelHeight);
for (int y = 0; y < bitmap.PixelHeight; ++y) {
for (int x = 0; x < bitmap.PixelWidth; ++x) {
int pixel = bitmap.Pixels[bitmap.PixelWidth * y + x]; imageData.SetPixel(x, y,
(byte)((pixel >> 16) & 0xFF), (byte)((pixel >> 8) & 0xFF),
(byte)(pixel & 0xFF), (byte)((pixel >> 24) & 0xFF)); } }
// Save it to disk Stream pngStream = imageData.GetStream();
StreamReader sr = new StreamReader(pngStream); byte[] binaryData = new Byte[pngStream.Length];
long bytesRead = pngStream.Read(binaryData, 0, (int)pngStream.Length); using (Stream stream = dialog.OpenFile()) { stream.Write(binaryData, 0, binaryData.Length); } } finally { orgChart.OverviewPlusDetailPaneVisibility = Visibility.Visible; } }
Hello Andrew,
I have already sent your feature request to our product management team as you wish in the thread below :
https://es.infragistics.com/community/forums/f/retired-products-and-controls/64653/org-chart-production-in-code/328288#328288