Page 1 of 1

Export.MetafileFormat.Enhanced obsolete warning

Posted: Tue Feb 01, 2011 2:56 pm
by 13046648
Hello,

I'm currently working on making our code warning-free, and because of that I would like to eliminate the obsolete warning generated by a teechart property:

tChart1.Export.Image.Metafile.Enhanced = false;


I didn't write this code, but if I'm right this way we export a Windows Metafile instead of EMF. But this generates the following warning:

warning CS0618: 'Steema.TeeChart.Export.MetafileFormat.Enhanced' is obsolete: 'Please use EMFFormat property.'


The problem is that the suggested EmfFormat property accepts EMFTypes values, which can only be:
- EmfOnly
- EmfPlusDual
- EmfPlusOnly

Obviously this is not the way to go if one wants to export to WMF. So my question is how to resolve the above obsolete warning?

Re: Export.MetafileFormat.Enhanced obsolete warning

Posted: Wed Feb 02, 2011 2:46 pm
by narcis
Hi DieterDHoker,

We have been investigating the issue. You'll probably need .NET Reflector to follow what I will explain here.

If you open TeeChart.dll and go to the class member Steema.TeeChart.Chart.Metafile(Graphics gRef, Stream stream, Chart aChart, int width, int height, EmfType type). There we use the .NET framework class System.Drawing.Imaging.Metafile. Have a look at this class in Reflector, specifically we use the public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type); constructor. If you look at it in the disassembler:

Code: Select all

public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) : this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual) { }
This constructor overload uses an EmfType anyway. In fact, looking at all the constructors of the System.Drawing.Imaging.Metafile class, they all use an EmfType. This means we can not use the System.Drawing.Imaging.Metafile class to create a WMF. Therefore we can not create a WMF using the .NET framework classes.

An otion would be using p/invoke on gdi32.dll to convert EMF to WMF files. You could use it that on your own code, based on the GetWinMetaFileBits function.