Completed
Last Updated: 13 Feb 2017 09:26 by ADMIN
ADMIN
Dimitar
Created on: 30 Aug 2016 08:21
Category: Diagram, DiagramRibbonBar, DiagramToolBox
Type: Bug Report
1
FIX. RadDiagram - the diagram is not correctly exported when the zoom is changed.
To reproduce:
- Add some shapes and zoom so only one is visible.
- Export to image.
- The image size is not correct.

Workaround:
private const int InflateValue = 7;
public System.Drawing.Image ExportToImage()
{
    RadDiagramElement diagram = radDiagram1.DiagramElement;
    var enclosingBounds = diagram.CalculateEnclosingBounds();

    using (Bitmap image = new Bitmap((int)(Math.Abs(enclosingBounds.Right) + InflateValue + Math.Abs( enclosingBounds.Left)), (int)(Math.Abs(enclosingBounds.Bottom) + InflateValue + Math.Abs(enclosingBounds.Top))))
    {
        System.Drawing.Graphics nativeGraphics = System.Drawing.Graphics.FromImage(image);
        nativeGraphics.FillRectangle(new System.Drawing.SolidBrush(diagram.ElementTree.RootElement.BackColor), 0, 0, image.Width, image.Height);
        Telerik.WinControls.Paint.RadGdiGraphics radGdi = new Telerik.WinControls.Paint.RadGdiGraphics(nativeGraphics);
        foreach (RadElement element in diagram.ItemsHost.GetChildren(ChildrenListOptions.ZOrdered))
        {
            element.Paint(radGdi, new System.Drawing.Rectangle(int.MinValue / 2, int.MinValue / 2, int.MaxValue, int.MaxValue), 0f, new System.Drawing.SizeF(1, 1), true);
        }

        System.Drawing.Image img = (System.Drawing.Image)image.Clone();
        nativeGraphics.Dispose();
        radGdi.Dispose();
        return img;
    }
}
0 comments