diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Comdlg32.cs b/src/libraries/Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs similarity index 100% rename from src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Comdlg32.cs rename to src/libraries/Common/src/Interop/Windows/Comdlg32/Interop.PrintDlg.cs diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs new file mode 100644 index 0000000000000000000000000000000000000000..cca83bef74b6a403a2e5452527be911127bcaf70 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int AbortDoc( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs new file mode 100644 index 0000000000000000000000000000000000000000..10aa264b72938c8615f537c3c5dbd72e051a750b --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] + internal static partial int AddFontResourceEx(string lpszFilename, int fl, IntPtr pdv); + + internal static int AddFontFile(string fileName) + { + return AddFontResourceEx(fileName, /*FR_PRIVATE*/ 0x10, IntPtr.Zero); + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.BITMAPINFO_FLAT.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.BITMAPINFO_FLAT.cs new file mode 100644 index 0000000000000000000000000000000000000000..9cce923687de8436c99ee99fc829b5aa29110133 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.BITMAPINFO_FLAT.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + internal const int BITMAPINFO_MAX_COLORSIZE = 256; + + [StructLayout(LayoutKind.Sequential)] + internal unsafe struct BITMAPINFO_FLAT + { + public int bmiHeader_biSize; // = sizeof(BITMAPINFOHEADER) + public int bmiHeader_biWidth; + public int bmiHeader_biHeight; + public short bmiHeader_biPlanes; + public short bmiHeader_biBitCount; + public int bmiHeader_biCompression; + public int bmiHeader_biSizeImage; + public int bmiHeader_biXPelsPerMeter; + public int bmiHeader_biYPelsPerMeter; + public int bmiHeader_biClrUsed; + public int bmiHeader_biClrImportant; + + public fixed byte bmiColors[BITMAPINFO_MAX_COLORSIZE * 4]; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat... + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs new file mode 100644 index 0000000000000000000000000000000000000000..e051d8f8d700559e6a4f0a21e2942baec2ddb525 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial IntPtr CreateCompatibleBitmap( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, int width, int height); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca024801b4287edb311c9fcd8353747fde1d2086 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial IntPtr CreateDIBSection( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs new file mode 100644 index 0000000000000000000000000000000000000000..aa26afa85665fb83ea58b08e60864b9122a9a37a --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs @@ -0,0 +1,96 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public sealed class DEVMODE + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string? dmDeviceName; + public short dmSpecVersion; + public short dmDriverVersion; + public short dmSize; + public short dmDriverExtra; + public int dmFields; + public short dmOrientation; + public short dmPaperSize; + public short dmPaperLength; + public short dmPaperWidth; + public short dmScale; + public short dmCopies; + public short dmDefaultSource; + public short dmPrintQuality; + public short dmColor; + public short dmDuplex; + public short dmYResolution; + public short dmTTOption; + public short dmCollate; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] + public string? dmFormName; + public short dmLogPixels; + public int dmBitsPerPel; + public int dmPelsWidth; + public int dmPelsHeight; + public int dmDisplayFlags; + public int dmDisplayFrequency; + public int dmICMMethod; + public int dmICMIntent; + public int dmMediaType; + public int dmDitherType; + public int dmICCManufacturer; + public int dmICCModel; + public int dmPanningWidth; + public int dmPanningHeight; + + + public override string ToString() + { + return "[DEVMODE: " + + "dmDeviceName=" + dmDeviceName + + ", dmSpecVersion=" + dmSpecVersion + + ", dmDriverVersion=" + dmDriverVersion + + ", dmSize=" + dmSize + + ", dmDriverExtra=" + dmDriverExtra + + ", dmFields=" + dmFields + + ", dmOrientation=" + dmOrientation + + ", dmPaperSize=" + dmPaperSize + + ", dmPaperLength=" + dmPaperLength + + ", dmPaperWidth=" + dmPaperWidth + + ", dmScale=" + dmScale + + ", dmCopies=" + dmCopies + + ", dmDefaultSource=" + dmDefaultSource + + ", dmPrintQuality=" + dmPrintQuality + + ", dmColor=" + dmColor + + ", dmDuplex=" + dmDuplex + + ", dmYResolution=" + dmYResolution + + ", dmTTOption=" + dmTTOption + + ", dmCollate=" + dmCollate + + ", dmFormName=" + dmFormName + + ", dmLogPixels=" + dmLogPixels + + ", dmBitsPerPel=" + dmBitsPerPel + + ", dmPelsWidth=" + dmPelsWidth + + ", dmPelsHeight=" + dmPelsHeight + + ", dmDisplayFlags=" + dmDisplayFlags + + ", dmDisplayFrequency=" + dmDisplayFrequency + + ", dmICMMethod=" + dmICMMethod + + ", dmICMIntent=" + dmICMIntent + + ", dmMediaType=" + dmMediaType + + ", dmDitherType=" + dmDitherType + + ", dmICCManufacturer=" + dmICCManufacturer + + ", dmICCModel=" + dmICCModel + + ", dmPanningWidth=" + dmPanningWidth + + ", dmPanningHeight=" + dmPanningHeight + + "]"; + } + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs new file mode 100644 index 0000000000000000000000000000000000000000..b65d8106b3439256da99c13f6316f4c8d2f744a3 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int EndDoc( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs new file mode 100644 index 0000000000000000000000000000000000000000..f09232b01fbaccd24e46e7717d3343a32e4b3d4d --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int EndPage( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs new file mode 100644 index 0000000000000000000000000000000000000000..449ba1b934b333b13b3a5eed91e6af2d9b8aa73d --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + internal const int QUERYESCSUPPORT = 8; + internal const int CHECKJPEGFORMAT = 4119; + internal const int CHECKPNGFORMAT = 4120; + + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int ExtEscape( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData); + + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int ExtEscape( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs new file mode 100644 index 0000000000000000000000000000000000000000..03cbc74a846d5fb2497ca1fbd4c8aaba83e308c0 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32)] + internal static partial int GetDIBits( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hdc, +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5); + + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs new file mode 100644 index 0000000000000000000000000000000000000000..83fcfa6f9d235922f821b7f0a979fc9a06805ac6 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)] + internal static partial int GetObject( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hObject, int nSize, ref BITMAP bm); + + [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] + internal static partial int GetObject( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf); + + internal static unsafe int GetObject( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hObject, ref Interop.User32.LOGFONT lp) + => GetObject(hObject, sizeof(Interop.User32.LOGFONT), ref lp); + + [StructLayout(LayoutKind.Sequential)] + public struct BITMAP + { + public uint bmType; + public uint bmWidth; + public uint bmHeight; + public uint bmWidthBytes; + public ushort bmPlanes; + public ushort bmBitsPixel; + public IntPtr bmBits; + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs new file mode 100644 index 0000000000000000000000000000000000000000..4f2f2ed80359181318c9aa89edab021fa55a70ad --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32)] + internal static partial uint GetPaletteEntries( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs new file mode 100644 index 0000000000000000000000000000000000000000..a82d6c5514ed2f0b069f98fe116bf4fa6b9e8058 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.IntersectClipRect.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int IntersectClipRect( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, int x1, int y1, int x2, int y2); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs new file mode 100644 index 0000000000000000000000000000000000000000..3737f3f46699b167ae14901d634a4ff4a60fffd8 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ResetDC.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, EntryPoint = "ResetDCW", SetLastError = true)] + internal static partial IntPtr /*HDC*/ ResetDC( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef /*DEVMODE*/ lpDevMode); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs new file mode 100644 index 0000000000000000000000000000000000000000..c62da1844b8e6e3c487ca0b50f094aaa207ccbc7 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartDoc.cs @@ -0,0 +1,70 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, EntryPoint = "StartDocW", SetLastError = true)] + internal static partial int StartDoc( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, in DOCINFO lpDocInfo); + +#if NET7_0_OR_GREATER + [NativeMarshalling(typeof(Marshaller))] +#endif + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + internal struct DOCINFO + { + internal int cbSize = 20; + internal string? lpszDocName; + internal string? lpszOutput; + internal string? lpszDatatype; + internal int fwType; + + public DOCINFO() { } + +#if NET7_0_OR_GREATER + [CustomMarshaller(typeof(DOCINFO), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))] + public static class Marshaller + { + public static Native ConvertToUnmanaged(DOCINFO managed) => new(managed); + public static void Free(Native native) => native.FreeNative(); + + internal struct Native + { + internal int cbSize; + internal IntPtr lpszDocName; + internal IntPtr lpszOutput; + internal IntPtr lpszDatatype; + internal int fwType; + + public Native(DOCINFO docInfo) + { + cbSize = docInfo.cbSize; + lpszDocName = Marshal.StringToCoTaskMemAuto(docInfo.lpszDocName); + lpszOutput = Marshal.StringToCoTaskMemAuto(docInfo.lpszOutput); + lpszDatatype = Marshal.StringToCoTaskMemAuto(docInfo.lpszDatatype); + fwType = docInfo.fwType; + } + + public void FreeNative() + { + Marshal.FreeCoTaskMem(lpszDocName); + Marshal.FreeCoTaskMem(lpszOutput); + Marshal.FreeCoTaskMem(lpszDatatype); + } + } + } +#endif + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs new file mode 100644 index 0000000000000000000000000000000000000000..00ecc844d7e8a3be9bd353fb23dbd530a41b7255 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.StartPage.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [LibraryImport(Libraries.Gdi32, SetLastError = true)] + internal static partial int StartPage( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs b/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs index bc10bf0bea2c1d30cd31d9226bc7213ec88bb2d2..af66c1f796edc035be0fb5726ede598e556957d0 100644 --- a/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs +++ b/src/libraries/Common/src/Interop/Windows/Interop.Libraries.cs @@ -47,5 +47,9 @@ internal static partial class Libraries internal const string HostPolicy = "hostpolicy"; internal const string Ucrtbase = "ucrtbase.dll"; internal const string Xolehlp = "xolehlp.dll"; + internal const string Comdlg32 = "comdlg32.dll"; + internal const string Gdiplus = "gdiplus.dll"; + internal const string Oleaut32 = "oleaut32.dll"; + internal const string Winspool = "winspool.drv"; } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs new file mode 100644 index 0000000000000000000000000000000000000000..968f87ac8eaaa21ec4d9e634f0f914e3e68a5843 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDefaultLCID.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + [LibraryImport(Libraries.Kernel32, SetLastError = true)] + public static partial int GetSystemDefaultLCID(); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs new file mode 100644 index 0000000000000000000000000000000000000000..9e25a94365b886405622c5e5260ea966958b6137 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalAlloc.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + [LibraryImport(Libraries.Kernel32, EntryPoint = "GlobalAlloc", SetLastError = true)] + internal static partial IntPtr IntGlobalAlloc(int uFlags, UIntPtr dwBytes); // size should be 32/64bits compatible + + internal static IntPtr GlobalAlloc(int uFlags, uint dwBytes) + { + return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes)); + } + } +} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs similarity index 58% rename from src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs rename to src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs index 42d5a7c50230fec42dd73da8f34d072ee80e33e3..efcc90a00fb256717b279cba2e94caf37bc8af52 100644 --- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Kernel32.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SelectObject.cs @@ -11,17 +11,6 @@ internal static partial class Interop { internal static partial class Kernel32 { - [LibraryImport(Libraries.Kernel32, SetLastError = true)] - public static partial int GetSystemDefaultLCID(); - - [LibraryImport(Libraries.Kernel32, EntryPoint = "GlobalAlloc", SetLastError = true)] - internal static partial IntPtr IntGlobalAlloc(int uFlags, UIntPtr dwBytes); // size should be 32/64bits compatible - - internal static IntPtr GlobalAlloc(int uFlags, uint dwBytes) - { - return IntGlobalAlloc(uFlags, new UIntPtr(dwBytes)); - } - [LibraryImport(Libraries.Gdi32, SetLastError = true)] internal static partial IntPtr SelectObject( #if NET7_0_OR_GREATER diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs similarity index 100% rename from src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Shell32.cs rename to src/libraries/Common/src/Interop/Windows/Shell32/Interop.ExtractAssociatedIcon.cs diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs new file mode 100644 index 0000000000000000000000000000000000000000..4211c156c365528b891f4e5ac31f52a73a46904b --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CopyImage.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + internal static partial IntPtr CopyImage( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs new file mode 100644 index 0000000000000000000000000000000000000000..a295619f2ac4a3e8b338c3277f2788a78bea72a4 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.CreateIconFromResourceEx.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + internal static unsafe partial IntPtr CreateIconFromResourceEx(byte* pbIconBits, uint cbIconBits, [MarshalAs(UnmanagedType.Bool)] bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs new file mode 100644 index 0000000000000000000000000000000000000000..1528c6ae181eb3c89aca184ae1a1b57f9e202795 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DestroyIcon.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool DestroyIcon( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hIcon); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs new file mode 100644 index 0000000000000000000000000000000000000000..6ac69016bde602becf823f906a8bb4606cc5c40b --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.DrawIconEx.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool DrawIconEx( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hDC, int x, int y, +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hIcon, int width, int height, int iStepIfAniCursor, +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hBrushFlickerFree, int diFlags); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..e97f54e2e8f6eef097d39ee6b885df2f6dfeaccc --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetIconInfo.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool GetIconInfo( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hIcon, ref ICONINFO info); + + [StructLayout(LayoutKind.Sequential)] + internal struct ICONINFO + { + internal uint fIcon; + internal uint xHotspot; + internal uint yHotspot; + internal IntPtr hbmMask; + internal IntPtr hbmColor; + } + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs new file mode 100644 index 0000000000000000000000000000000000000000..761e69a4a2c829f061067981f7d66d5a5d323280 --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.GetSystemMetrics.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, SetLastError = true)] + public static partial int GetSystemMetrics(int nIndex); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs new file mode 100644 index 0000000000000000000000000000000000000000..f391366d89b125f44ead8ef0e031f9bf7e9c078c --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadIcon.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class User32 + { + [LibraryImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)] + internal static partial IntPtr LoadIcon( +#if NET7_0_OR_GREATER + [MarshalUsing(typeof(HandleRefMarshaller))] +#endif + HandleRef hInst, IntPtr iconId); + } +} diff --git a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs new file mode 100644 index 0000000000000000000000000000000000000000..5b2208f239d3f225b401a7f16652cf49eded18ad --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DeviceCapabilities.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Winspool + { + [LibraryImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] + internal static partial int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr /*DEVMODE*/ pDevMode); + } +} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs similarity index 71% rename from src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs rename to src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs index 60b611dd63f32a05d399a9708bc1819b5f0cb20b..bf54cfb1b5b90cb174f76f52cf488cfa1efb2d1a 100644 --- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Winspool.cs +++ b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.DocumentProperties.cs @@ -11,9 +11,6 @@ internal static partial class Interop { internal static partial class Winspool { - [LibraryImport(Libraries.Winspool, EntryPoint = "DeviceCapabilitiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - internal static partial int DeviceCapabilities(string pDevice, string pPort, short fwCapabilities, IntPtr pOutput, IntPtr /*DEVMODE*/ pDevMode); - [LibraryImport(Libraries.Winspool, EntryPoint = "DocumentPropertiesW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] internal static partial int DocumentProperties( #if NET7_0_OR_GREATER @@ -39,8 +36,5 @@ internal static partial class Winspool [MarshalUsing(typeof(HandleRefMarshaller))] #endif HandleRef hPrinter, string pDeviceName, IntPtr /*DEVMODE*/ pDevModeOutput, IntPtr /*DEVMODE*/ pDevModeInput, int fMode); - - [LibraryImport(Libraries.Winspool, EntryPoint = "EnumPrintersW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - internal static partial int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/, int cbBuf, out int pcbNeeded, out int pcReturned); } } diff --git a/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs new file mode 100644 index 0000000000000000000000000000000000000000..ca967e11d16d8690555db366a7d3cb23a171ac7b --- /dev/null +++ b/src/libraries/Common/src/Interop/Windows/Winspool/Interop.EnumPrinters.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; +#if NET7_0_OR_GREATER +using System.Runtime.InteropServices.Marshalling; +#endif + +internal static partial class Interop +{ + internal static partial class Winspool + { + [LibraryImport(Libraries.Winspool, EntryPoint = "EnumPrintersW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] + internal static partial int EnumPrinters(int flags, string? name, int level, IntPtr pPrinterEnum/*buffer*/, int cbBuf, out int pcbNeeded, out int pcReturned); + } +} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Unix/Interop.Libraries.cs b/src/libraries/System.Drawing.Common/src/Interop/Unix/Interop.Libraries.cs deleted file mode 100644 index b8330fee528b73a370e8598c81f8e4ce77395002..0000000000000000000000000000000000000000 --- a/src/libraries/System.Drawing.Common/src/Interop/Unix/Interop.Libraries.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -internal static partial class Interop -{ - internal static partial class Libraries - { - internal const string Gdiplus = "gdiplus"; - } -} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs deleted file mode 100644 index 192cc9b591fac1a3902d40da931c56ad490be2e6..0000000000000000000000000000000000000000 --- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Gdi32.cs +++ /dev/null @@ -1,309 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER -using System.Runtime.InteropServices.Marshalling; -#endif - -internal static partial class Interop -{ - internal static partial class Gdi32 - { - internal const int QUERYESCSUPPORT = 8; - internal const int CHECKJPEGFORMAT = 4119; - internal const int CHECKPNGFORMAT = 4120; - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial IntPtr CreateCompatibleBitmap( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, int width, int height); - - [LibraryImport(Libraries.Gdi32)] - internal static partial int GetDIBits( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hdc, -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hbm, int arg1, int arg2, IntPtr arg3, ref BITMAPINFO_FLAT bmi, int arg5); - - [LibraryImport(Libraries.Gdi32)] - internal static partial uint GetPaletteEntries( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hpal, int iStartIndex, int nEntries, byte[] lppe); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial IntPtr CreateDIBSection( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hdc, ref BITMAPINFO_FLAT bmi, int iUsage, ref IntPtr ppvBits, IntPtr hSection, int dwOffset); - - [LibraryImport(Libraries.Gdi32, EntryPoint = "StartDocW", SetLastError = true)] - internal static partial int StartDoc( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, in DOCINFO lpDocInfo); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int StartPage( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int EndPage( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int AbortDoc( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int EndDoc( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC); - - [LibraryImport(Libraries.Gdi32, EntryPoint = "ResetDCW", SetLastError = true)] - internal static partial IntPtr /*HDC*/ ResetDC( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef /*DEVMODE*/ lpDevMode); - - [LibraryImport(Libraries.Gdi32, EntryPoint = "AddFontResourceExW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - internal static partial int AddFontResourceEx(string lpszFilename, int fl, IntPtr pdv); - - internal static int AddFontFile(string fileName) - { - return AddFontResourceEx(fileName, /*FR_PRIVATE*/ 0x10, IntPtr.Zero); - } - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int ExtEscape( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, int nEscape, int cbInput, ref int inData, int cbOutput, out int outData); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int ExtEscape( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, int nEscape, int cbInput, byte[] inData, int cbOutput, out int outData); - - [LibraryImport(Libraries.Gdi32, SetLastError = true)] - internal static partial int IntersectClipRect( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, int x1, int y1, int x2, int y2); - - [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true)] - internal static partial int GetObject( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hObject, int nSize, ref BITMAP bm); - - [LibraryImport(Libraries.Gdi32, EntryPoint = "GetObjectW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - internal static partial int GetObject( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hObject, int nSize, ref Interop.User32.LOGFONT lf); - - internal static unsafe int GetObject( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hObject, ref Interop.User32.LOGFONT lp) - => GetObject(hObject, sizeof(Interop.User32.LOGFONT), ref lp); - - [StructLayout(LayoutKind.Sequential)] - public struct BITMAP - { - public uint bmType; - public uint bmWidth; - public uint bmHeight; - public uint bmWidthBytes; - public ushort bmPlanes; - public ushort bmBitsPixel; - public IntPtr bmBits; - } - - internal const int BITMAPINFO_MAX_COLORSIZE = 256; - - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct BITMAPINFO_FLAT - { - public int bmiHeader_biSize; // = sizeof(BITMAPINFOHEADER) - public int bmiHeader_biWidth; - public int bmiHeader_biHeight; - public short bmiHeader_biPlanes; - public short bmiHeader_biBitCount; - public int bmiHeader_biCompression; - public int bmiHeader_biSizeImage; - public int bmiHeader_biXPelsPerMeter; - public int bmiHeader_biYPelsPerMeter; - public int bmiHeader_biClrUsed; - public int bmiHeader_biClrImportant; - - public fixed byte bmiColors[BITMAPINFO_MAX_COLORSIZE * 4]; // RGBQUAD structs... Blue-Green-Red-Reserved, repeat... - } - -#if NET7_0_OR_GREATER - [NativeMarshalling(typeof(Marshaller))] -#endif - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - internal struct DOCINFO - { - internal int cbSize = 20; - internal string? lpszDocName; - internal string? lpszOutput; - internal string? lpszDatatype; - internal int fwType; - - public DOCINFO() { } - -#if NET7_0_OR_GREATER - [CustomMarshaller(typeof(DOCINFO), MarshalMode.ManagedToUnmanagedIn, typeof(Marshaller))] - public static class Marshaller - { - public static Native ConvertToUnmanaged(DOCINFO managed) => new(managed); - public static void Free(Native native) => native.FreeNative(); - - internal struct Native - { - internal int cbSize; - internal IntPtr lpszDocName; - internal IntPtr lpszOutput; - internal IntPtr lpszDatatype; - internal int fwType; - - public Native(DOCINFO docInfo) - { - cbSize = docInfo.cbSize; - lpszDocName = Marshal.StringToCoTaskMemAuto(docInfo.lpszDocName); - lpszOutput = Marshal.StringToCoTaskMemAuto(docInfo.lpszOutput); - lpszDatatype = Marshal.StringToCoTaskMemAuto(docInfo.lpszDatatype); - fwType = docInfo.fwType; - } - - public void FreeNative() - { - Marshal.FreeCoTaskMem(lpszDocName); - Marshal.FreeCoTaskMem(lpszOutput); - Marshal.FreeCoTaskMem(lpszDatatype); - } - } - } -#endif - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] - public sealed class DEVMODE - { - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string? dmDeviceName; - public short dmSpecVersion; - public short dmDriverVersion; - public short dmSize; - public short dmDriverExtra; - public int dmFields; - public short dmOrientation; - public short dmPaperSize; - public short dmPaperLength; - public short dmPaperWidth; - public short dmScale; - public short dmCopies; - public short dmDefaultSource; - public short dmPrintQuality; - public short dmColor; - public short dmDuplex; - public short dmYResolution; - public short dmTTOption; - public short dmCollate; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] - public string? dmFormName; - public short dmLogPixels; - public int dmBitsPerPel; - public int dmPelsWidth; - public int dmPelsHeight; - public int dmDisplayFlags; - public int dmDisplayFrequency; - public int dmICMMethod; - public int dmICMIntent; - public int dmMediaType; - public int dmDitherType; - public int dmICCManufacturer; - public int dmICCModel; - public int dmPanningWidth; - public int dmPanningHeight; - - - public override string ToString() - { - return "[DEVMODE: " - + "dmDeviceName=" + dmDeviceName - + ", dmSpecVersion=" + dmSpecVersion - + ", dmDriverVersion=" + dmDriverVersion - + ", dmSize=" + dmSize - + ", dmDriverExtra=" + dmDriverExtra - + ", dmFields=" + dmFields - + ", dmOrientation=" + dmOrientation - + ", dmPaperSize=" + dmPaperSize - + ", dmPaperLength=" + dmPaperLength - + ", dmPaperWidth=" + dmPaperWidth - + ", dmScale=" + dmScale - + ", dmCopies=" + dmCopies - + ", dmDefaultSource=" + dmDefaultSource - + ", dmPrintQuality=" + dmPrintQuality - + ", dmColor=" + dmColor - + ", dmDuplex=" + dmDuplex - + ", dmYResolution=" + dmYResolution - + ", dmTTOption=" + dmTTOption - + ", dmCollate=" + dmCollate - + ", dmFormName=" + dmFormName - + ", dmLogPixels=" + dmLogPixels - + ", dmBitsPerPel=" + dmBitsPerPel - + ", dmPelsWidth=" + dmPelsWidth - + ", dmPelsHeight=" + dmPelsHeight - + ", dmDisplayFlags=" + dmDisplayFlags - + ", dmDisplayFrequency=" + dmDisplayFrequency - + ", dmICMMethod=" + dmICMMethod - + ", dmICMIntent=" + dmICMIntent - + ", dmMediaType=" + dmMediaType - + ", dmDitherType=" + dmDitherType - + ", dmICCManufacturer=" + dmICCManufacturer - + ", dmICCModel=" + dmICCModel - + ", dmPanningWidth=" + dmPanningWidth - + ", dmPanningHeight=" + dmPanningHeight - + "]"; - } - } - } -} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Libraries.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Libraries.cs deleted file mode 100644 index 9d7c8110206f1126afa5fe0c0955f8098c0c875d..0000000000000000000000000000000000000000 --- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.Libraries.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -internal static partial class Interop -{ - internal static partial class Libraries - { - internal const string Comdlg32 = "comdlg32.dll"; - internal const string Gdiplus = "gdiplus.dll"; - internal const string Oleaut32 = "oleaut32.dll"; - internal const string Winspool = "winspool.drv"; - } -} diff --git a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs b/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs deleted file mode 100644 index 52ecb5f1ddde3ddd2c90fb7626a0e88d32ece5ed..0000000000000000000000000000000000000000 --- a/src/libraries/System.Drawing.Common/src/Interop/Windows/Interop.User32.cs +++ /dev/null @@ -1,76 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Runtime.InteropServices; -#if NET7_0_OR_GREATER -using System.Runtime.InteropServices.Marshalling; -#endif - -internal static partial class Interop -{ - internal static partial class User32 - { - [LibraryImport(Libraries.User32, EntryPoint = "LoadIconW", SetLastError = true)] - internal static partial IntPtr LoadIcon( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hInst, IntPtr iconId); - - [LibraryImport(Libraries.User32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static partial bool DestroyIcon( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hIcon); - - [LibraryImport(Libraries.User32, SetLastError = true)] - internal static partial IntPtr CopyImage( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hImage, int uType, int cxDesired, int cyDesired, int fuFlags); - - [LibraryImport(Libraries.User32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static partial bool GetIconInfo( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hIcon, ref ICONINFO info); - - [LibraryImport(Libraries.User32, SetLastError = true)] - public static partial int GetSystemMetrics(int nIndex); - - [LibraryImport(Libraries.User32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static partial bool DrawIconEx( -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hDC, int x, int y, -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hIcon, int width, int height, int iStepIfAniCursor, -#if NET7_0_OR_GREATER - [MarshalUsing(typeof(HandleRefMarshaller))] -#endif - HandleRef hBrushFlickerFree, int diFlags); - - [LibraryImport(Libraries.User32, SetLastError = true)] - internal static unsafe partial IntPtr CreateIconFromResourceEx(byte* pbIconBits, uint cbIconBits, [MarshalAs(UnmanagedType.Bool)] bool fIcon, int dwVersion, int csDesired, int cyDesired, int flags); - - [StructLayout(LayoutKind.Sequential)] - internal struct ICONINFO - { - internal uint fIcon; - internal uint xHotspot; - internal uint yHotspot; - internal IntPtr hbmMask; - internal IntPtr hbmColor; - } - } -} diff --git a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj b/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj index df9c7ef864aedeec20e1cc61b31cc7be20d6ae96..c800556093959ace88ad579cdff8cdefa8e70083 100644 --- a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj +++ b/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj @@ -214,24 +214,29 @@ Since .NET 7, non-Windows platforms are not supported, even with the runtime con - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +