public unsafe void TextRenderer_DrawText_DefaultBackground_RendersTransparent(Func <IDeviceContext, Action> func) { using var emf = EmfScope.Create(); DeviceContextState state = new DeviceContextState(emf); func(new HdcDeviceContextAdapter(emf)).Invoke(); bool success = false; emf.EnumerateWithState((ref EmfRecord record, DeviceContextState state) => { switch (record.Type) { case Gdi32.EMR.EXTTEXTOUTW: var textOut = record.ExtTextOutWRecord; Assert.Equal("Acrylic", textOut->emrtext.GetString().ToString()); Assert.Equal(Gdi32.MM.TEXT, state.MapMode); Assert.Equal(Gdi32.BKMODE.TRANSPARENT, state.BackgroundMode); Assert.Equal((COLORREF)Color.Blue, state.TextColor); Assert.Equal(SystemFonts.DefaultFont.Name, state.SelectedFont); success = true; return(false); } return(true); }, state); Assert.True(success, "Did not find the text out record."); }
public unsafe void CaptureButton() { using Button button = new Button(); using var emf = EmfScope.Create(); button.CreateMetafile(emf); var types = new List <Gdi32.EMR>(); var details = new List <string>(); emf.Enumerate((ref EmfRecord record) => { types.Add(record.Type); details.Add(record.ToString()); return(true); }); }