<Compile Include="System\Drawing\StringFormat.cs" />
<Compile Include="System\Drawing\SystemFonts.cs" />
<Compile Include="System\Drawing\SystemPens.cs" />
+ <Compile Include="System\Drawing\Imaging\Metafile.cs" />
<Compile Include="System\Drawing\Printing\PrinterUnit.cs" />
<Compile Include="System\Drawing\Printing\PreviewPageInfo.cs" />
<Compile Include="System\Drawing\Printing\PrintEventHandler.cs" />
internal static extern int GdipCreateFontFromHfont(IntPtr hdc, out IntPtr font, ref LOGFONT lf);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipCreateMetafileFromFile(string filename, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipCreateMetafileFromEmf(IntPtr hEmf, bool deleteEmf, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipCreateMetafileFromWmf(IntPtr hWmf, bool deleteWmf, WmfPlaceableFileHeader wmfPlaceableFileHeader, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
internal static extern int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipSetMetafileDownLevelRasterizationLimit(IntPtr metafile, uint metafileRasterizationLimitDpi);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipPlayMetafileRecord(IntPtr metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafile(IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileI(IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileName(string filename, IntPtr hdc, EmfType type, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileNameI(string filename, IntPtr hdc, EmfType type, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipCreateFromContext_macosx(IntPtr cgref, int width, int height, out IntPtr graphics);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipEnumerateMetafileSrcRectDestPointsI(HandleRef graphics, HandleRef metafile, Point* destPoints, int count, ref Rectangle srcRect, GraphicsUnit pageUnit, Graphics.EnumerateMetafileProc callback, HandleRef callbackdata, HandleRef imageattributes);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipPlayMetafileRecord(HandleRef graphics, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
-
- [DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipSaveGraphics(HandleRef graphics, out int state);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipRestoreGraphics(HandleRef graphics, int state);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipGetMetafileHeaderFromWmf(HandleRef hMetafile, WmfPlaceableFileHeader wmfplaceable, [In] [Out] MetafileHeaderWmf metafileHeaderWmf);
+ internal static extern int GdipGetMetafileHeaderFromWmf(IntPtr hMetafile, WmfPlaceableFileHeader wmfplaceable, [In] [Out] MetafileHeaderWmf metafileHeaderWmf);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipGetMetafileHeaderFromEmf(HandleRef hEnhMetafile, [In] [Out] MetafileHeaderEmf metafileHeaderEmf);
+ internal static extern int GdipGetMetafileHeaderFromEmf(IntPtr hEnhMetafile, [In] [Out] MetafileHeaderEmf metafileHeaderEmf);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
internal static extern int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
internal static extern int GdipGetHemfFromMetafile(HandleRef metafile, out IntPtr hEnhMetafile);
[DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipCreateMetafileFromWmf(HandleRef hMetafile, bool deleteWmf, WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipCreateMetafileFromEmf(HandleRef hEnhMetafile, bool deleteEmf, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipCreateMetafileFromStream(Interop.Ole32.IStream stream, out IntPtr metafile);
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipRecordMetafile(HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true)]
- internal static extern int GdipRecordMetafileI(HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileName(string fileName, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
- [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileFileNameI(string fileName, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
-
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, HandleRef pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStream(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
- internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, HandleRef referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+ internal static extern int GdipRecordMetafileStreamI(Interop.Ole32.IStream stream, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipComment(HandleRef graphics, int sizeData, byte[] data);
[DllImport(LibraryName, ExactSpelling = true)]
internal static extern int GdipImageGetFrameDimensionsList(HandleRef image, Guid* dimensionIDs, int count);
+
+ [DllImport(LibraryName, ExactSpelling = true)]
+ internal static extern int GdipCreateMetafileFromEmf(IntPtr hEnhMetafile, bool deleteEmf, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true)]
+ internal static extern int GdipCreateMetafileFromWmf(IntPtr hMetafile, bool deleteWmf, WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true)]
+ internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipRecordMetafileI(IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ internal static extern int GdipRecordMetafileFileNameI(string fileName, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string description, out IntPtr metafile);
+
+ [DllImport(LibraryName, ExactSpelling = true)]
+ internal static extern int GdipPlayMetafileRecord(HandleRef metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
}
[StructLayout(LayoutKind.Sequential)]
#if !NETCORE
[Editor ("System.Drawing.Design.MetafileEditor, " + Consts.AssemblySystem_Drawing_Design, typeof (System.Drawing.Design.UITypeEditor))]
#endif
- [Serializable]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed class Metafile : Image
+ public sealed partial class Metafile : Image
{
// constructors
Gdip.CheckStatus(status);
}
- public Metafile(string filename)
- {
- // Called in order to emulate exception behavior from netfx related to invalid file paths.
- Path.GetFullPath(filename);
-
- int status = Gdip.GdipCreateMetafileFromFile(filename, out nativeImage);
- if (status == Gdip.GenericError)
- throw new ExternalException("Couldn't load specified file.");
- Gdip.CheckStatus(status);
- }
-
- public Metafile(IntPtr henhmetafile, bool deleteEmf)
- {
- int status = Gdip.GdipCreateMetafileFromEmf(henhmetafile, deleteEmf, out nativeImage);
- Gdip.CheckStatus(status);
- }
-
- public Metafile(IntPtr referenceHdc, EmfType emfType) :
- this(referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, emfType, null)
- {
- }
-
- public Metafile(IntPtr referenceHdc, Rectangle frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(IntPtr referenceHdc, RectangleF frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader)
{
int status = Gdip.GdipCreateMetafileFromEmf(hmetafile, false, out nativeImage);
Gdip.CheckStatus(status);
}
- public Metafile(Stream stream, IntPtr referenceHdc) :
- this(stream, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc) :
- this(fileName, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual,
- null)
- {
- }
-
public Metafile(IntPtr referenceHdc, EmfType emfType, string description) :
this(referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, emfType, description)
{
}
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
- {
- int status = Gdip.GdipCreateMetafileFromEmf(hmetafile, deleteWmf, out nativeImage);
- Gdip.CheckStatus(status);
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, EmfType type) :
- this(stream, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, null)
- {
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type) :
- this(fileName, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string description) :
this(stream, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, description)
{
}
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string description) :
this(fileName, referenceHdc, new RectangleF(), MetafileFrameUnit.GdiCompatible, type, description)
{
}
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, null)
- {
- }
-
public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type,
string desc)
{
Gdip.CheckStatus(status);
}
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type,
- string description)
- {
- int status = Gdip.GdipRecordMetafile(referenceHdc, type, ref frameRect, frameUnit,
- description, out nativeImage);
- Gdip.CheckStatus(status);
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
- EmfType type) : this(stream, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit,
- EmfType type) : this(stream, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
- EmfType type) : this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
- string description) : this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, description)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit,
- EmfType type) : this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit,
- string desc) : this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual,
- desc)
- {
- }
-
public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit,
EmfType type, string description)
{
Gdip.CheckStatus(status);
}
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit,
- EmfType type, string description)
- {
- // Called in order to emulate exception behavior from netfx related to invalid file paths.
- Path.GetFullPath(fileName);
-
- int status = Gdip.GdipRecordMetafileFileName(fileName, referenceHdc, type, ref frameRect, frameUnit,
- description, out nativeImage);
- Gdip.CheckStatus(status);
- }
-
- private Metafile(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
// methods
public IntPtr GetHenhmetafile()
public static MetafileHeader GetMetafileHeader(string fileName)
{
- if (fileName == null)
- throw new ArgumentNullException(nameof(fileName));
+ // Called in order to emulate exception behavior from netfx related to invalid file paths.
+ Path.GetFullPath(fileName);
IntPtr header = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MetafileHeader)));
try
Marshal.FreeHGlobal(header);
}
}
-
- public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] data)
- {
- int status = Gdip.GdipPlayMetafileRecord(nativeImage, recordType, flags, dataSize, data);
- Gdip.CheckStatus(status);
- }
}
}
/// Defines a graphic metafile. A metafile contains records that describe a sequence of graphics operations that
/// can be recorded and played back.
/// </summary>
- [Serializable]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public sealed partial class Metafile : Image
{
- // GDI+ doesn't handle filenames over MAX_PATH very well
- private const int MaxPath = 260;
-
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle and
/// <see cref='WmfPlaceableFileHeader'/>.
/// </summary>
public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader) :
this(hmetafile, wmfHeader, false)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle and
- /// <see cref='WmfPlaceableFileHeader'/>.
- /// </summary>
- public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromWmf(new HandleRef(null, hmetafile), deleteWmf, wmfHeader, out IntPtr metafile));
- SetNativeImage(metafile);
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle and
- /// <see cref='WmfPlaceableFileHeader'/>.
- /// </summary>
- public Metafile(IntPtr henhmetafile, bool deleteEmf)
{
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromEmf(new HandleRef(null, henhmetafile), deleteEmf, out IntPtr metafile));
- SetNativeImage(metafile);
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified filename.
- /// </summary>
- public Metafile(string filename)
- {
- // Called in order to emulate exception behavior from netfx related to invalid file paths.
- Path.GetFullPath(filename);
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromFile(filename, out IntPtr metafile));
- SetNativeImage(metafile);
}
/// <summary>
public Metafile(Stream stream)
{
if (stream == null)
+ {
throw new ArgumentNullException(nameof(stream));
+ }
Gdip.CheckStatus(Gdip.GdipCreateMetafileFromStream(new GPStream(stream), out IntPtr metafile));
SetNativeImage(metafile);
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle to a device context.
/// </summary>
- public Metafile(IntPtr referenceHdc, EmfType emfType) :
- this(referenceHdc, emfType, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle to a device context.
- /// </summary>
public Metafile(IntPtr referenceHdc, EmfType emfType, string description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- new HandleRef(null, referenceHdc),
+ referenceHdc,
emfType,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
MetafileFrameUnit.GdiCompatible,
description,
out IntPtr metafile));
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
/// by the specified rectangle.
/// </summary>
- public Metafile(IntPtr referenceHdc, RectangleF frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- new HandleRef(null, referenceHdc),
- type,
- ref frameRect,
- frameUnit,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, Rectangle frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
- /// by the specified rectangle.
- /// </summary>
public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string desc)
{
IntPtr metafile = IntPtr.Zero;
if (frameRect.IsEmpty)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
MetafileFrameUnit.GdiCompatible,
desc,
out metafile));
else
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileI(
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
ref frameRect,
frameUnit,
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc) :
- this(fileName, referenceHdc, EmfType.EmfPlusDual, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type) :
- this(fileName, referenceHdc, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string description)
{
// Called in order to emulate exception behavior from netfx related to invalid file paths.
Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
fileName,
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
MetafileFrameUnit.GdiCompatible,
description,
out IntPtr metafile));
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string desc) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, desc)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
- {
- // Called in order to emulate exception behavior from netfx related to invalid file paths.
- Path.GetFullPath(fileName);
-
- if (fileName.Length > MaxPath)
- throw new PathTooLongException();
-
- Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
- fileName,
- new HandleRef(null, referenceHdc),
- type,
- ref frameRect,
- frameUnit,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string description) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, description)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
{
// Called in order to emulate exception behavior from netfx related to invalid file paths.
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
fileName,
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
frameUnit,
description,
out metafile));
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileFileNameI(
fileName,
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
ref frameRect,
frameUnit,
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
/// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc) :
- this(stream, referenceHdc, EmfType.EmfPlusDual, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, EmfType type) :
- this(stream, referenceHdc, type, null)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
- /// </summary>
public Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
new GPStream(stream),
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
MetafileFrameUnit.GdiCompatible,
description,
out IntPtr metafile));
}
/// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(stream, referenceHdc, frameRect, frameUnit, type, null)
- { }
-
- /// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
new GPStream(stream),
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
ref frameRect,
frameUnit,
SetNativeImage(metafile);
}
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- { }
-
- /// <summary>
- /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
- /// </summary>
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(stream, referenceHdc, frameRect, frameUnit, type, null)
- { }
-
+
/// <summary>
/// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
/// </summary>
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
new GPStream(stream),
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
- NativeMethods.NullHandleRef,
+ IntPtr.Zero,
frameUnit,
description,
out metafile));
{
Gdip.CheckStatus(Gdip.GdipRecordMetafileStreamI(
new GPStream(stream),
- new HandleRef(null, referenceHdc),
+ referenceHdc,
type,
ref frameRect,
frameUnit,
SetNativeImage(metafile);
}
- private Metafile(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
-
/// <summary>
/// Returns the <see cref='MetafileHeader'/> associated with the specified <see cref='Metafile'/>.
/// </summary>
wmf = new MetafileHeaderWmf()
};
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromWmf(new HandleRef(null, hmetafile), wmfHeader, header.wmf));
+ Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromWmf(hmetafile, wmfHeader, header.wmf));
return header;
}
emf = new MetafileHeaderEmf()
};
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromEmf(new HandleRef(null, henhmetafile), header.emf));
+ Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromEmf(henhmetafile, header.emf));
return header;
}
}
/// <summary>
- /// Plays an EMF+ file.
- /// </summary>
- public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] data)
- {
- // Used in conjunction with Graphics.EnumerateMetafile to play an EMF+
- // The data must be DWORD aligned if it's an EMF or EMF+. It must be
- // WORD aligned if it's a WMF.
-
- Gdip.CheckStatus(Gdip.GdipPlayMetafileRecord(
- new HandleRef(this, nativeImage),
- recordType,
- flags,
- dataSize,
- data));
- }
-
- /// <summary>
/// Create a new metafile object from a native metafile handle.
/// </summary>
internal static Metafile FromGDIplus(IntPtr nativeImage)
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.IO;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Serialization;
+using Gdip = System.Drawing.SafeNativeMethods.Gdip;
+
+namespace System.Drawing.Imaging
+{
+ /// <summary>
+ /// Defines a graphic metafile. A metafile contains records that describe a sequence of graphics operations that
+ /// can be recorded and played back.
+ /// </summary>
+ [Serializable]
+ [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
+ public sealed partial class Metafile : Image
+ {
+ // GDI+ doesn't handle filenames over MAX_PATH very well
+ private const int MaxPath = 260;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle and
+ /// <see cref='WmfPlaceableFileHeader'/>.
+ /// </summary>
+ public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
+ {
+ Gdip.CheckStatus(Gdip.GdipCreateMetafileFromWmf(hmetafile, deleteWmf, wmfHeader, out IntPtr metafile));
+ SetNativeImage(metafile);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle and
+ /// <see cref='WmfPlaceableFileHeader'/>.
+ /// </summary>
+ public Metafile(IntPtr henhmetafile, bool deleteEmf)
+ {
+ Gdip.CheckStatus(Gdip.GdipCreateMetafileFromEmf(henhmetafile, deleteEmf, out IntPtr metafile));
+ SetNativeImage(metafile);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified filename.
+ /// </summary>
+ public Metafile(string filename)
+ {
+ // Called in order to emulate exception behavior from netfx related to invalid file paths.
+ Path.GetFullPath(filename);
+ Gdip.CheckStatus(Gdip.GdipCreateMetafileFromFile(filename, out IntPtr metafile));
+ SetNativeImage(metafile);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, Rectangle frameRect) :
+ this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified handle to a device context.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, EmfType emfType) :
+ this(referenceHdc, emfType, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, RectangleF frameRect) :
+ this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
+ this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ Gdip.CheckStatus(Gdip.GdipRecordMetafile(
+ referenceHdc,
+ type,
+ ref frameRect,
+ frameUnit,
+ description,
+ out IntPtr metafile));
+
+ SetNativeImage(metafile);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
+ this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified device context, bounded
+ /// by the specified rectangle.
+ /// </summary>
+ public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc) :
+ this(fileName, referenceHdc, EmfType.EmfPlusDual, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, EmfType type) :
+ this(fileName, referenceHdc, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect) :
+ this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
+ this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(fileName, referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string desc) :
+ this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, desc)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string description)
+ {
+ // Called in order to emulate exception behavior from netfx related to invalid file paths.
+ Path.GetFullPath(fileName);
+ if (fileName.Length > MaxPath)
+ {
+ throw new PathTooLongException();
+ }
+
+ Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
+ fileName,
+ referenceHdc,
+ type,
+ ref frameRect,
+ frameUnit,
+ description,
+ out IntPtr metafile));
+
+ SetNativeImage(metafile);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect) :
+ this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
+ this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(fileName, referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string description) :
+ this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, description)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc) :
+ this(stream, referenceHdc, EmfType.EmfPlusDual, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, EmfType type) :
+ this(stream, referenceHdc, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect) :
+ this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
+ this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(stream, referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class from the specified data stream.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect) :
+ this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
+ this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref='Metafile'/> class with the specified filename.
+ /// </summary>
+ public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
+ this(stream, referenceHdc, frameRect, frameUnit, type, null)
+ {
+ }
+
+ private Metafile(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+
+ /// <summary>
+ /// Plays an EMF+ file.
+ /// </summary>
+ public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] data)
+ {
+ // Used in conjunction with Graphics.EnumerateMetafile to play an EMF+
+ // The data must be DWORD aligned if it's an EMF or EMF+. It must be
+ // WORD aligned if it's a WMF.
+
+ Gdip.CheckStatus(Gdip.GdipPlayMetafileRecord(
+ new HandleRef(this, nativeImage),
+ recordType,
+ flags,
+ dataSize,
+ data));
+ }
+ }
+}
AssertExtensions.Throws<ArgumentException>(null, () => bitmap.Clone(new RectangleF(0, 0, 1, 1), PixelFormat.Format32bppArgb));
}
+ [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetFrameCount_NewBitmap_ReturnsZero()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_String_Success()
{
yield return new object[] { string.Empty };
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData("bad\0name")]
[InlineData("")]
AssertExtensions.Throws<ArgumentException>("path", null, () => new Metafile(path));
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_Stream_Success()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_NullEmfType_ThrowsArgumentException()
{
File.Delete(fileName);
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_IntPtrZeroII_ThrowsArgumentException()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData("bad\0path")]
[InlineData("")]
}
}
- // Long paths aren't that much of a problem on Unix.
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PathTooLong_ThrowsPathTooLongException()
{
File.Delete(fileName);
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_IntPtrZeroIII_ThrowsArgumentException()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData("bad\0path")]
[InlineData("")]
}
}
- // Long paths aren't that much of a problem on Unix.
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_PathTooLongI_ThrowsPathTooLongException()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Ctor_IntPtrZeroIV_ThrowsArgumentException()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalTheory(Helpers.IsDrawingSupported)]
[InlineData("bad\0path")]
[InlineData("")]
AssertExtensions.Throws<ArgumentException>("path", null, () => Metafile.GetMetafileHeader(fileName));
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void Static_GetMetafileHeader_NullString_ThrowsArgumentNullException()
{
}
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetMetafileHeader_Disposed_ThrowsArgumentException()
{
AssertExtensions.Throws<ArgumentException>(null, () => metafile.GetMetafileHeader());
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void GetHenhmetafile_ReturnsExpected()
{
AssertExtensions.Throws<ArgumentException>(null, () => metafile.GetHenhmetafile());
}
- [ActiveIssue(20884, TestPlatforms.AnyUnix)]
[ConditionalFact(Helpers.IsDrawingSupported)]
public void PlayRecord_Disposed_ThrowsArgumentException()
{
public void LandscapeAngle_ReturnsExpected()
{
var printerSettings = new PrinterSettings();
- int[] validValues = new[] { 0, 90, 270 };
- Assert.True(validValues.Contains(printerSettings.LandscapeAngle), "PrinterSettings.LandscapeAngle must be 0, 90, or 270 degrees.");
+ int[] validValues = new[] { -90, 0, 90, 270 };
+ Assert.True(validValues.Contains(printerSettings.LandscapeAngle), $"PrinterSettings.LandscapeAngle ({printerSettings.LandscapeAngle}) must be 0, 90, or 270 degrees.");
}
[ConditionalFact(Helpers.AnyInstalledPrinters, Helpers.IsDrawingSupported)]
public void MaximumCopies_ReturnsExpected()
{
var printerSettings = new PrinterSettings();
- Assert.True(printerSettings.MaximumCopies >= 0, "PrinterSettings.MaximumCopies should not be negative.");
+ Assert.True(printerSettings.MaximumCopies >= 0, $"PrinterSettings.MaximumCopies ({printerSettings.MaximumCopies}) should not be negative.");
}
[Fact]