File: Metafiles\RecordTypes\EMRINDEXRECORD.cs
Web Access
Project: src\src\System.Windows.Forms.Primitives\tests\TestUtilities\System.Windows.Forms.Primitives.TestUtilities.csproj (System.Windows.Forms.Primitives.TestUtilities)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
#nullable enable
 
using System.Runtime.InteropServices;
 
namespace System.Windows.Forms.Metafiles;
 
/// <summary>
///  Record that represents an index.
/// </summary>
/// <devdoc>
///   Not an actual Win32 define, encapsulates:
///
///   - EMRSELECTOBJECT
///   - EMRDELETEOBJECT
///   - EMRSELECTPALETTE
/// </devdoc>
[StructLayout(LayoutKind.Sequential)]
internal struct EMRINDEXRECORD
{
    public EMR emr;
    public uint index;
 
    public readonly bool IsStockObject => (index & 0x80000000) != 0;
    public readonly GET_STOCK_OBJECT_FLAGS StockObject => (GET_STOCK_OBJECT_FLAGS)(index & ~0x80000000);
 
    public override readonly string ToString()
        => IsStockObject
            ? $"[EMR{emr.iType}] StockObject: {StockObject}"
            : $"[EMR{emr.iType}] Index: {index}";
}