Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) WmfExporter does not render controlNodes (Read 8921 times)
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
WmfExporter does not render controlNodes
Jan 15th, 2013 at 10:37pm
Print Post  
Hi,

I'm having an issue with WmfExporter which does not render ControlNodes. The PaintControl event that I have for the drawing of the controlNode is not called when doing the WmfExport. Am I missing something? I couldn't find any render options to get it to work.

JF
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #1 - Jan 16th, 2013 at 9:34am
Print Post  
Hi,

If you have the source code, set renderOptions.PaintControls = true in WmfExporter.Export. We'll add this for next release.

Stoyan
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #2 - Jan 16th, 2013 at 3:22pm
Print Post  
Hi Stoyan,

Thanks for the answer! Yes we do have the source code but our internal policy prevents me to do changes to vendor components.  Can you please send me the updated Export.Wmf.dll?  We are currently using 5.8.0.19078.  It would really help me to get this solved ASAP.

JF
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #3 - Jan 17th, 2013 at 7:17am
Print Post  
Hi,

Use this class to export then:

Code
Select All
class DiagramEx : Diagram
{
	Diagram diagram;
	public DiagramEx(Diagram diagram)
	{
		this.diagram = diagram;
	}
	public override void Draw(IGraphics graphics,
		RenderOptions options, RectangleF clipRect, bool noModifiedItems)
	{
		options.PaintControls = true;
		diagram.Draw(graphics, options, clipRect, noModifiedItems);
	}
}

wmfExporter.Export(new DiagramEx(diagram), path); 



This should also work for PDF and SVG exporters.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #4 - Jan 17th, 2013 at 12:14pm
Print Post  
Stoyan,

It works perfect.  Many thanks for the great support
Smiley

JF
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #5 - Jan 22nd, 2013 at 9:28am
Print Post  
Actually, while this is working great for WMF, it doesn't seem to work for PDF.  I can export fine a diagram that doesn't contain a controlNode, but as soon as I try to export to PDF a diagram with a controlNode using DiagramEx  I get teh following exception
Code
Select All
System.Runtime.InteropServices.ExternalException occurred
  HResult=-2147467259
  Message=A generic error occurred in GDI+.
  Source=System.Drawing
  ErrorCode=-2147467259
  StackTrace:
       at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData)
       at System.Drawing.Bitmap.LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
       at MindFusion.Pdf.Tools.x3e30ee412360b69f(Bitmap xe058541ca798c059, Boolean x5ffbb4b34fae8a48)
       at MindFusion.Pdf.Tools.GetImageContentEx(Image imagesrc, Boolean IsGrayscale)
       at MindFusion.Pdf.PdfImage.GetContent()
       at MindFusion.Pdf.PdfObject.Save(PDFWriter writer)
       at MindFusion.Pdf.PdfPage.Save(PDFWriter writer)
       at MindFusion.Pdf.PdfDocument.Save(String fileName)
       at MindFusion.Pdf.PdfGraphics.SaveContent()
       at MindFusion.Pdf.PdfGraphics.Dispose()
       at MindFusion.Diagramming.Export.PdfExporter.Export(Diagram diagram, String filePath)
       at NATO.EB.Client.Views.Sketchpad2.SketchpadDiagram2.Export2PDF()
  InnerException:

 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #6 - Jan 22nd, 2013 at 10:32am
Print Post  
What does your PaintControl handler look like?
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #7 - Jan 22nd, 2013 at 12:31pm
Print Post  
Here it is:
Code (C++)
Select All
        private void flowChart_PaintControlHost(object sender, PaintControlEventArgs e)
        {
            e.Handled = false;
            var graphControl = e.Node.Control as MsChartBaseControl;
            if (graphControl != null)
            {
                var paintRect = diagramView.DocToClient(e.PaintRect);
                var bmp = graphControl.GetBitmap(paintRect.Size.Width, paintRect.Size.Height);
                e.Graphics.DrawImage(bmp, e.PaintRect);
                bmp.Dispose();
                e.Handled = true;
            }
        }
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #8 - Jan 22nd, 2013 at 12:59pm
Print Post  
Try commenting out the bmp.Dispose line to see if it will fix the problem. If it does, you will have to dispose the images only after the PDF is saved.
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #9 - Jan 22nd, 2013 at 1:31pm
Print Post  
No luck. It throws the same exception when commenting that line.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #10 - Jan 22nd, 2013 at 2:29pm
Print Post  
PdfGraphics.DrawImage works without problems in my test when drawing an image loaded from a file, so I suppose the image object returned by MsChartBaseControl.GetBitmap might be locked in some way and doesn't allow access to the bitmap bytes. Check if the work-arounds for unlocking images shown here will help:
http://www.kerrywong.com/2007/11/15/understanding-a-generic-error-occurred-in-gd...

The first one seems wrong though, I think the order should be slightly different:

Bitmap bmpNew = new Bitmap(bmp);
g = Graphics.FromImage(bmpNew);
g.DrawImage(bmp, new Point(0, 0));
  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #11 - Jan 22nd, 2013 at 5:50pm
Print Post  
Yes! this solves the issue:

Code (C++)
Select All
        private void flowChart_PaintControlHost(object sender, PaintControlEventArgs e)
        {
            e.Handled = false;
            var graphControl = e.Node.Control as MsChartBaseControl;
            if (graphControl != null)
            {
                var paintRect = diagramView.DocToClient(e.PaintRect);
                var bmp = graphControl.GetBitmap(paintRect.Size.Width, paintRect.Size.Height);
                var bmpNew = new Bitmap(bmp);
                var g = Graphics.FromImage(bmpNew);
                g.DrawImage(bmp, new Point(0, 0));
                g.Dispose();
                bmp.Dispose();
                e.Graphics.DrawImage(bmpNew, e.PaintRect);
                bmpNew.Dispose();
                e.Handled = true;
            }
        }
 

  
Back to top
 
IP Logged
 
jf2020
Junior Member
**
Offline


I love FlowChart!

Posts: 63
Joined: Feb 23rd, 2006
Re: WmfExporter does not render controlNodes
Reply #12 - Jan 23rd, 2013 at 2:22pm
Print Post  
Stoyan,

Using DiagramEx only kind of works. I have issues with the clipping which is not the same when doing the export directly through the initial or with DiagramEx. I tried to see if the bounds could be incorrectly set but I just stopped and I have now build the WMFExporter and PDFExporter dlls from teh source code with the additional RenderOptions as you initially suggested. This works with no issues so far. I have also made RenderOptions a public property of both exporters. Why not do that instead of providing specific properties as you do in PDFExporter Smiley?

JF
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: WmfExporter does not render controlNodes
Reply #13 - Jan 24th, 2013 at 12:05pm
Print Post  
I suppose DocToClient might not be working correctly for the second diagram if the view is scrolled or zoomed. We'll add export options properties for next release.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint