-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Interop code from System.Drawings.Common to Common directory (#7…
…7565) * Move Library names to Common directory * Move ExtractAssociatedIcon P/Invoke to Interop.ExtractAssociatedIcon.cs * Move PrintDlg P/Invoke to Interop.PrintDlg.cs * Move Kernel32 P/Invoke to Interop.*.cs * Move Winspool P/Invoke to Interop.*.cs * Move User32 P/Invoke to Interop.*.cs * Move Gdi32 P/Invoke to Interop.*.cs
- Loading branch information
Showing
37 changed files
with
796 additions
and
432 deletions.
There are no files selected for viewing
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AbortDoc.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.AddFontResourceEx.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.BITMAPINFO_FLAT.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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... | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateCompatibleBitmap.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.CreateDIBSection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.DEVMODE.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
+ "]"; | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndDoc.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.EndPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.ExtEscape.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetDIBits.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/libraries/Common/src/Interop/Windows/Gdi32/Interop.GetPaletteEntries.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
Oops, something went wrong.