Metafile.PlayRecord(EmfPlusRecordType, Int32, Int32, Byte[]) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Lit un enregistrement de métafichier.
public:
void PlayRecord(System::Drawing::Imaging::EmfPlusRecordType recordType, int flags, int dataSize, cli::array <System::Byte> ^ data);
public void PlayRecord (System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
member this.PlayRecord : System.Drawing.Imaging.EmfPlusRecordType * int * int * byte[] -> unit
Public Sub PlayRecord (recordType As EmfPlusRecordType, flags As Integer, dataSize As Integer, data As Byte())
Paramètres
- recordType
- EmfPlusRecordType
Élément de EmfPlusRecordType qui spécifie le type d'enregistrement de métafichier en cours de lecture.
- flags
- Int32
Ensemble d'indicateurs qui spécifie des attributs de l'enregistrement.
- dataSize
- Int32
Nombre d'octets dans les données de l'enregistrement.
- data
- Byte[]
Tableau d'octets qui contient les données de l'enregistrement.
Exemples
L'exemple de code suivant illustre l'utilisation de la méthode PlayRecord.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
// for Marshal.Copy
using System.Runtime.InteropServices;
public class Form1 : Form
{
private Metafile metafile1;
private Graphics.EnumerateMetafileProc metafileDelegate;
private Point destPoint;
public Form1()
{
metafile1 = new Metafile(@"C:\Test.wmf");
metafileDelegate = new Graphics.EnumerateMetafileProc(MetafileCallback);
destPoint = new Point(20, 10);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.EnumerateMetafile(metafile1, destPoint, metafileDelegate);
}
private bool MetafileCallback(
EmfPlusRecordType recordType,
int flags,
int dataSize,
IntPtr data,
PlayRecordCallback callbackData)
{
byte[] dataArray = null;
if (data != IntPtr.Zero)
{
// Copy the unmanaged record to a managed byte buffer
// that can be used by PlayRecord.
dataArray = new byte[dataSize];
Marshal.Copy(data, dataArray, 0, dataSize);
}
metafile1.PlayRecord(recordType, flags, dataSize, dataArray);
return true;
}
static void Main()
{
Application.Run(new Form1());
}
}
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.Windows.Forms
' for Marshal.Copy
Imports System.Runtime.InteropServices
Public Class Form1
Inherits Form
Private metafile1 As Metafile
Private metafileDelegate As Graphics.EnumerateMetafileProc
Private destPoint As Point
Public Sub New()
metafile1 = New Metafile("C:\test.wmf")
metafileDelegate = New Graphics.EnumerateMetafileProc(AddressOf MetafileCallback)
destPoint = New Point(20, 10)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.EnumerateMetafile(metafile1, destPoint, metafileDelegate)
End Sub
Private Function MetafileCallback(ByVal recordType As _
EmfPlusRecordType, ByVal flags As Integer, ByVal dataSize As Integer, _
ByVal data As IntPtr, ByVal callbackData As PlayRecordCallback) As Boolean
Dim dataArray As Byte() = Nothing
If data <> IntPtr.Zero Then
' Copy the unmanaged record to a managed byte buffer
' that can be used by PlayRecord.
dataArray = New Byte(dataSize) {}
Marshal.Copy(data, dataArray, 0, dataSize)
End If
metafile1.PlayRecord(recordType, flags, dataSize, dataArray)
Return True
End Function
Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class