diff --git a/docs/area-owners.md b/docs/area-owners.md
index e686fc53f37a3..07f81f772a061 100644
--- a/docs/area-owners.md
+++ b/docs/area-owners.md
@@ -87,7 +87,7 @@ Note: Editing this file doesn't update the mapping used by `@msftbot` for area-s
| area-System.Diagnostics.Tracing | @tommcdon | @noahfalk @tommcdon @tarekgh | Included:
- System.Diagnostics.DiagnosticSource
|
| area-System.Diagnostics.TraceSource | @ericstj | @dotnet/area-system-diagnostics-tracesource | |
| area-System.DirectoryServices | @ericstj | @dotnet/area-system-directoryservices | Consultants: @BRDPM @grubioe @jay98014 |
-| area-System.Drawing | @ericstj | @dotnet/area-system-drawing | |
+| area-System.Drawing | @ericstj | @dotnet/area-system-drawing | Excluded:- System.Drawing.Common -> winforms
|
| area-System.Dynamic.Runtime | @jaredpar | @cston @333fred | Archived component - limited churn/contributions (see [#27790](https://github.com/dotnet/runtime/issues/27790)) |
| area-System.Formats.Asn1 | @jeffhandley | @dotnet/area-system-formats-asn1 | |
| area-System.Formats.Cbor | @jeffhandley | @dotnet/area-system-formats-cbor | |
diff --git a/eng/Versions.props b/eng/Versions.props
index 2a905374ec734..298dcac647b18 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -124,6 +124,7 @@
5.0.0
4.8.5
4.5.0
+ 7.0.0
5.0.0
5.0.0
4.5.5
diff --git a/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj b/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj
index cdc78f3092cba..eb632d22ebceb 100644
--- a/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj
+++ b/src/libraries/Microsoft.Windows.Compatibility/src/Microsoft.Windows.Compatibility.csproj
@@ -23,7 +23,6 @@
-
@@ -45,6 +44,7 @@
+
-
-
- windows
-
-
\ No newline at end of file
diff --git a/src/libraries/System.Drawing.Common/README.md b/src/libraries/System.Drawing.Common/README.md
deleted file mode 100644
index 08e253582f2a2..0000000000000
--- a/src/libraries/System.Drawing.Common/README.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# System.Drawing.Common
-This assembly provides access to GDI+ basic graphics functionality via types such as [`Bitmap`](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.bitmap) and [`Font`](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.font).
-
-Note that `System.Drawing.Common` is only supported on Windows: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only.
-
-Documentation can be found at https://learn.microsoft.com/en-us/dotnet/api/system.drawing.
-
-## Contribution Bar
-- [x] [We consider new features, new APIs and performance changes](../README.md#primary-bar)
-- [x] [We consider PRs that target this library for new source code analyzers](../README.md#secondary-bars)
-- [ ] [We don't accept refactoring changes due to new language features](../README.md#secondary-bars)
-
-See the [Help Wanted](https://github.com/dotnet/runtime/issues?q=is%3Aissue+is%3Aopen+label%3Aarea-System.Drawing+label%3A%22help+wanted%22) issues.
-
-## Deployment
-`System.Drawing.Common` is provided as a [NuGet package](https://www.nuget.org/packages/System.Drawing.Common) and part of the `Microsoft.WindowsDesktop.App` shared framework.
diff --git a/src/libraries/System.Drawing.Common/System.Drawing.Common.sln b/src/libraries/System.Drawing.Common/System.Drawing.Common.sln
deleted file mode 100644
index c8dc2bfe2edac..0000000000000
--- a/src/libraries/System.Drawing.Common/System.Drawing.Common.sln
+++ /dev/null
@@ -1,81 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestUtilities", "..\Common\tests\TestUtilities\TestUtilities.csproj", "{1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\ref\Microsoft.Win32.SystemEvents.csproj", "{83CA6F97-678B-40A7-A9DF-C94A46B8B18A}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Win32.SystemEvents", "..\Microsoft.Win32.SystemEvents\src\Microsoft.Win32.SystemEvents.csproj", "{4BBDE239-6D43-43C0-AF72-25116A49A9E0}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "ref\System.Drawing.Common.csproj", "{790BF98D-7616-410C-BEF8-2CBA7E7601BB}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common", "src\System.Drawing.Common.csproj", "{F1A41550-378D-4651-915F-263BD9AB460E}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Drawing.Common.Tests", "tests\System.Drawing.Common.Tests.csproj", "{F14479F4-611E-49DA-BB07-74C0AB096FB5}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibraryImportGenerator", "..\System.Runtime.InteropServices\gen\LibraryImportGenerator\LibraryImportGenerator.csproj", "{B6592EC7-9532-49C2-AC7E-FF83B9EBF943}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Interop.SourceGeneration", "..\System.Runtime.InteropServices\gen\Microsoft.Interop.SourceGeneration\Microsoft.Interop.SourceGeneration.csproj", "{958E19D9-4216-49C4-B7D6-5DAEA9166D35}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{92581ED8-E04A-4B49-8C25-A3A30942C819}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ref", "ref", "{7471DB83-C273-481B-9AD8-51B468C1F75E}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4C4E5584-A0CC-441D-89EF-C0EA125E7120}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{B09E2F78-85C8-4353-90B3-79DB869E83D5}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86}.Release|Any CPU.Build.0 = Release|Any CPU
- {83CA6F97-678B-40A7-A9DF-C94A46B8B18A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {83CA6F97-678B-40A7-A9DF-C94A46B8B18A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {83CA6F97-678B-40A7-A9DF-C94A46B8B18A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {83CA6F97-678B-40A7-A9DF-C94A46B8B18A}.Release|Any CPU.Build.0 = Release|Any CPU
- {4BBDE239-6D43-43C0-AF72-25116A49A9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4BBDE239-6D43-43C0-AF72-25116A49A9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4BBDE239-6D43-43C0-AF72-25116A49A9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4BBDE239-6D43-43C0-AF72-25116A49A9E0}.Release|Any CPU.Build.0 = Release|Any CPU
- {790BF98D-7616-410C-BEF8-2CBA7E7601BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {790BF98D-7616-410C-BEF8-2CBA7E7601BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {790BF98D-7616-410C-BEF8-2CBA7E7601BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {790BF98D-7616-410C-BEF8-2CBA7E7601BB}.Release|Any CPU.Build.0 = Release|Any CPU
- {F1A41550-378D-4651-915F-263BD9AB460E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F1A41550-378D-4651-915F-263BD9AB460E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F1A41550-378D-4651-915F-263BD9AB460E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F1A41550-378D-4651-915F-263BD9AB460E}.Release|Any CPU.Build.0 = Release|Any CPU
- {F14479F4-611E-49DA-BB07-74C0AB096FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F14479F4-611E-49DA-BB07-74C0AB096FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F14479F4-611E-49DA-BB07-74C0AB096FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F14479F4-611E-49DA-BB07-74C0AB096FB5}.Release|Any CPU.Build.0 = Release|Any CPU
- {B6592EC7-9532-49C2-AC7E-FF83B9EBF943}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B6592EC7-9532-49C2-AC7E-FF83B9EBF943}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B6592EC7-9532-49C2-AC7E-FF83B9EBF943}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B6592EC7-9532-49C2-AC7E-FF83B9EBF943}.Release|Any CPU.Build.0 = Release|Any CPU
- {958E19D9-4216-49C4-B7D6-5DAEA9166D35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {958E19D9-4216-49C4-B7D6-5DAEA9166D35}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {958E19D9-4216-49C4-B7D6-5DAEA9166D35}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {958E19D9-4216-49C4-B7D6-5DAEA9166D35}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {1C4EEE9D-AF5E-4C94-A5A7-3EFD83A19A86} = {92581ED8-E04A-4B49-8C25-A3A30942C819}
- {F14479F4-611E-49DA-BB07-74C0AB096FB5} = {92581ED8-E04A-4B49-8C25-A3A30942C819}
- {83CA6F97-678B-40A7-A9DF-C94A46B8B18A} = {7471DB83-C273-481B-9AD8-51B468C1F75E}
- {790BF98D-7616-410C-BEF8-2CBA7E7601BB} = {7471DB83-C273-481B-9AD8-51B468C1F75E}
- {4BBDE239-6D43-43C0-AF72-25116A49A9E0} = {4C4E5584-A0CC-441D-89EF-C0EA125E7120}
- {F1A41550-378D-4651-915F-263BD9AB460E} = {4C4E5584-A0CC-441D-89EF-C0EA125E7120}
- {B6592EC7-9532-49C2-AC7E-FF83B9EBF943} = {B09E2F78-85C8-4353-90B3-79DB869E83D5}
- {958E19D9-4216-49C4-B7D6-5DAEA9166D35} = {B09E2F78-85C8-4353-90B3-79DB869E83D5}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {FE976CDB-4464-48A7-86B9-04DB5E2258DA}
- EndGlobalSection
-EndGlobal
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.Forwards.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.Forwards.cs
deleted file mode 100644
index 54309b347dc68..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.Forwards.cs
+++ /dev/null
@@ -1,5 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SystemColors))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.ColorTranslator))]
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.cs
deleted file mode 100644
index 7dc6dce240296..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.cs
+++ /dev/null
@@ -1,3027 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the https://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-namespace System.Drawing
-{
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.BitmapEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed partial class Bitmap : System.Drawing.Image
- {
- public Bitmap(System.Drawing.Image original) { }
- public Bitmap(System.Drawing.Image original, System.Drawing.Size newSize) { }
- public Bitmap(System.Drawing.Image original, int width, int height) { }
- public Bitmap(int width, int height) { }
- public Bitmap(int width, int height, System.Drawing.Graphics g) { }
- public Bitmap(int width, int height, System.Drawing.Imaging.PixelFormat format) { }
- public Bitmap(int width, int height, int stride, System.Drawing.Imaging.PixelFormat format, System.IntPtr scan0) { }
- public Bitmap(System.IO.Stream stream) { }
- public Bitmap(System.IO.Stream stream, bool useIcm) { }
- public Bitmap(string filename) { }
- public Bitmap(string filename, bool useIcm) { }
- public Bitmap(System.Type type, string resource) { }
- public System.Drawing.Bitmap Clone(System.Drawing.Rectangle rect, System.Drawing.Imaging.PixelFormat format) { throw null; }
- public System.Drawing.Bitmap Clone(System.Drawing.RectangleF rect, System.Drawing.Imaging.PixelFormat format) { throw null; }
- public static System.Drawing.Bitmap FromHicon(System.IntPtr hicon) { throw null; }
- public static System.Drawing.Bitmap FromResource(System.IntPtr hinstance, string bitmapName) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public System.IntPtr GetHbitmap() { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public System.IntPtr GetHbitmap(System.Drawing.Color background) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public System.IntPtr GetHicon() { throw null; }
- public System.Drawing.Color GetPixel(int x, int y) { throw null; }
- public System.Drawing.Imaging.BitmapData LockBits(System.Drawing.Rectangle rect, System.Drawing.Imaging.ImageLockMode flags, System.Drawing.Imaging.PixelFormat format) { throw null; }
- public System.Drawing.Imaging.BitmapData LockBits(System.Drawing.Rectangle rect, System.Drawing.Imaging.ImageLockMode flags, System.Drawing.Imaging.PixelFormat format, System.Drawing.Imaging.BitmapData bitmapData) { throw null; }
- public void MakeTransparent() { }
- public void MakeTransparent(System.Drawing.Color transparentColor) { }
- public void SetPixel(int x, int y, System.Drawing.Color color) { }
- public void SetResolution(float xDpi, float yDpi) { }
- public void UnlockBits(System.Drawing.Imaging.BitmapData bitmapdata) { }
- }
- [System.AttributeUsageAttribute(System.AttributeTargets.Assembly)]
- public partial class BitmapSuffixInSameAssemblyAttribute : System.Attribute
- {
- public BitmapSuffixInSameAssemblyAttribute() { }
- }
- [System.AttributeUsageAttribute(System.AttributeTargets.Assembly)]
- public partial class BitmapSuffixInSatelliteAssemblyAttribute : System.Attribute
- {
- public BitmapSuffixInSatelliteAssemblyAttribute() { }
- }
- public abstract partial class Brush : System.MarshalByRefObject, System.ICloneable, System.IDisposable
- {
- protected Brush() { }
- public abstract object Clone();
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- ~Brush() { }
- protected internal void SetNativeBrush(System.IntPtr brush) { }
- }
- public static partial class Brushes
- {
- public static System.Drawing.Brush AliceBlue { get { throw null; } }
- public static System.Drawing.Brush AntiqueWhite { get { throw null; } }
- public static System.Drawing.Brush Aqua { get { throw null; } }
- public static System.Drawing.Brush Aquamarine { get { throw null; } }
- public static System.Drawing.Brush Azure { get { throw null; } }
- public static System.Drawing.Brush Beige { get { throw null; } }
- public static System.Drawing.Brush Bisque { get { throw null; } }
- public static System.Drawing.Brush Black { get { throw null; } }
- public static System.Drawing.Brush BlanchedAlmond { get { throw null; } }
- public static System.Drawing.Brush Blue { get { throw null; } }
- public static System.Drawing.Brush BlueViolet { get { throw null; } }
- public static System.Drawing.Brush Brown { get { throw null; } }
- public static System.Drawing.Brush BurlyWood { get { throw null; } }
- public static System.Drawing.Brush CadetBlue { get { throw null; } }
- public static System.Drawing.Brush Chartreuse { get { throw null; } }
- public static System.Drawing.Brush Chocolate { get { throw null; } }
- public static System.Drawing.Brush Coral { get { throw null; } }
- public static System.Drawing.Brush CornflowerBlue { get { throw null; } }
- public static System.Drawing.Brush Cornsilk { get { throw null; } }
- public static System.Drawing.Brush Crimson { get { throw null; } }
- public static System.Drawing.Brush Cyan { get { throw null; } }
- public static System.Drawing.Brush DarkBlue { get { throw null; } }
- public static System.Drawing.Brush DarkCyan { get { throw null; } }
- public static System.Drawing.Brush DarkGoldenrod { get { throw null; } }
- public static System.Drawing.Brush DarkGray { get { throw null; } }
- public static System.Drawing.Brush DarkGreen { get { throw null; } }
- public static System.Drawing.Brush DarkKhaki { get { throw null; } }
- public static System.Drawing.Brush DarkMagenta { get { throw null; } }
- public static System.Drawing.Brush DarkOliveGreen { get { throw null; } }
- public static System.Drawing.Brush DarkOrange { get { throw null; } }
- public static System.Drawing.Brush DarkOrchid { get { throw null; } }
- public static System.Drawing.Brush DarkRed { get { throw null; } }
- public static System.Drawing.Brush DarkSalmon { get { throw null; } }
- public static System.Drawing.Brush DarkSeaGreen { get { throw null; } }
- public static System.Drawing.Brush DarkSlateBlue { get { throw null; } }
- public static System.Drawing.Brush DarkSlateGray { get { throw null; } }
- public static System.Drawing.Brush DarkTurquoise { get { throw null; } }
- public static System.Drawing.Brush DarkViolet { get { throw null; } }
- public static System.Drawing.Brush DeepPink { get { throw null; } }
- public static System.Drawing.Brush DeepSkyBlue { get { throw null; } }
- public static System.Drawing.Brush DimGray { get { throw null; } }
- public static System.Drawing.Brush DodgerBlue { get { throw null; } }
- public static System.Drawing.Brush Firebrick { get { throw null; } }
- public static System.Drawing.Brush FloralWhite { get { throw null; } }
- public static System.Drawing.Brush ForestGreen { get { throw null; } }
- public static System.Drawing.Brush Fuchsia { get { throw null; } }
- public static System.Drawing.Brush Gainsboro { get { throw null; } }
- public static System.Drawing.Brush GhostWhite { get { throw null; } }
- public static System.Drawing.Brush Gold { get { throw null; } }
- public static System.Drawing.Brush Goldenrod { get { throw null; } }
- public static System.Drawing.Brush Gray { get { throw null; } }
- public static System.Drawing.Brush Green { get { throw null; } }
- public static System.Drawing.Brush GreenYellow { get { throw null; } }
- public static System.Drawing.Brush Honeydew { get { throw null; } }
- public static System.Drawing.Brush HotPink { get { throw null; } }
- public static System.Drawing.Brush IndianRed { get { throw null; } }
- public static System.Drawing.Brush Indigo { get { throw null; } }
- public static System.Drawing.Brush Ivory { get { throw null; } }
- public static System.Drawing.Brush Khaki { get { throw null; } }
- public static System.Drawing.Brush Lavender { get { throw null; } }
- public static System.Drawing.Brush LavenderBlush { get { throw null; } }
- public static System.Drawing.Brush LawnGreen { get { throw null; } }
- public static System.Drawing.Brush LemonChiffon { get { throw null; } }
- public static System.Drawing.Brush LightBlue { get { throw null; } }
- public static System.Drawing.Brush LightCoral { get { throw null; } }
- public static System.Drawing.Brush LightCyan { get { throw null; } }
- public static System.Drawing.Brush LightGoldenrodYellow { get { throw null; } }
- public static System.Drawing.Brush LightGray { get { throw null; } }
- public static System.Drawing.Brush LightGreen { get { throw null; } }
- public static System.Drawing.Brush LightPink { get { throw null; } }
- public static System.Drawing.Brush LightSalmon { get { throw null; } }
- public static System.Drawing.Brush LightSeaGreen { get { throw null; } }
- public static System.Drawing.Brush LightSkyBlue { get { throw null; } }
- public static System.Drawing.Brush LightSlateGray { get { throw null; } }
- public static System.Drawing.Brush LightSteelBlue { get { throw null; } }
- public static System.Drawing.Brush LightYellow { get { throw null; } }
- public static System.Drawing.Brush Lime { get { throw null; } }
- public static System.Drawing.Brush LimeGreen { get { throw null; } }
- public static System.Drawing.Brush Linen { get { throw null; } }
- public static System.Drawing.Brush Magenta { get { throw null; } }
- public static System.Drawing.Brush Maroon { get { throw null; } }
- public static System.Drawing.Brush MediumAquamarine { get { throw null; } }
- public static System.Drawing.Brush MediumBlue { get { throw null; } }
- public static System.Drawing.Brush MediumOrchid { get { throw null; } }
- public static System.Drawing.Brush MediumPurple { get { throw null; } }
- public static System.Drawing.Brush MediumSeaGreen { get { throw null; } }
- public static System.Drawing.Brush MediumSlateBlue { get { throw null; } }
- public static System.Drawing.Brush MediumSpringGreen { get { throw null; } }
- public static System.Drawing.Brush MediumTurquoise { get { throw null; } }
- public static System.Drawing.Brush MediumVioletRed { get { throw null; } }
- public static System.Drawing.Brush MidnightBlue { get { throw null; } }
- public static System.Drawing.Brush MintCream { get { throw null; } }
- public static System.Drawing.Brush MistyRose { get { throw null; } }
- public static System.Drawing.Brush Moccasin { get { throw null; } }
- public static System.Drawing.Brush NavajoWhite { get { throw null; } }
- public static System.Drawing.Brush Navy { get { throw null; } }
- public static System.Drawing.Brush OldLace { get { throw null; } }
- public static System.Drawing.Brush Olive { get { throw null; } }
- public static System.Drawing.Brush OliveDrab { get { throw null; } }
- public static System.Drawing.Brush Orange { get { throw null; } }
- public static System.Drawing.Brush OrangeRed { get { throw null; } }
- public static System.Drawing.Brush Orchid { get { throw null; } }
- public static System.Drawing.Brush PaleGoldenrod { get { throw null; } }
- public static System.Drawing.Brush PaleGreen { get { throw null; } }
- public static System.Drawing.Brush PaleTurquoise { get { throw null; } }
- public static System.Drawing.Brush PaleVioletRed { get { throw null; } }
- public static System.Drawing.Brush PapayaWhip { get { throw null; } }
- public static System.Drawing.Brush PeachPuff { get { throw null; } }
- public static System.Drawing.Brush Peru { get { throw null; } }
- public static System.Drawing.Brush Pink { get { throw null; } }
- public static System.Drawing.Brush Plum { get { throw null; } }
- public static System.Drawing.Brush PowderBlue { get { throw null; } }
- public static System.Drawing.Brush Purple { get { throw null; } }
- public static System.Drawing.Brush Red { get { throw null; } }
- public static System.Drawing.Brush RosyBrown { get { throw null; } }
- public static System.Drawing.Brush RoyalBlue { get { throw null; } }
- public static System.Drawing.Brush SaddleBrown { get { throw null; } }
- public static System.Drawing.Brush Salmon { get { throw null; } }
- public static System.Drawing.Brush SandyBrown { get { throw null; } }
- public static System.Drawing.Brush SeaGreen { get { throw null; } }
- public static System.Drawing.Brush SeaShell { get { throw null; } }
- public static System.Drawing.Brush Sienna { get { throw null; } }
- public static System.Drawing.Brush Silver { get { throw null; } }
- public static System.Drawing.Brush SkyBlue { get { throw null; } }
- public static System.Drawing.Brush SlateBlue { get { throw null; } }
- public static System.Drawing.Brush SlateGray { get { throw null; } }
- public static System.Drawing.Brush Snow { get { throw null; } }
- public static System.Drawing.Brush SpringGreen { get { throw null; } }
- public static System.Drawing.Brush SteelBlue { get { throw null; } }
- public static System.Drawing.Brush Tan { get { throw null; } }
- public static System.Drawing.Brush Teal { get { throw null; } }
- public static System.Drawing.Brush Thistle { get { throw null; } }
- public static System.Drawing.Brush Tomato { get { throw null; } }
- public static System.Drawing.Brush Transparent { get { throw null; } }
- public static System.Drawing.Brush Turquoise { get { throw null; } }
- public static System.Drawing.Brush Violet { get { throw null; } }
- public static System.Drawing.Brush Wheat { get { throw null; } }
- public static System.Drawing.Brush White { get { throw null; } }
- public static System.Drawing.Brush WhiteSmoke { get { throw null; } }
- public static System.Drawing.Brush Yellow { get { throw null; } }
- public static System.Drawing.Brush YellowGreen { get { throw null; } }
- }
- public sealed partial class BufferedGraphics : System.IDisposable
- {
- internal BufferedGraphics() { }
- public System.Drawing.Graphics Graphics { get { throw null; } }
- public void Dispose() { }
- public void Render() { }
- public void Render(System.Drawing.Graphics? target) { }
- public void Render(System.IntPtr targetDC) { }
- }
- public sealed partial class BufferedGraphicsContext : System.IDisposable
- {
- public BufferedGraphicsContext() { }
- public System.Drawing.Size MaximumBuffer { get { throw null; } set { } }
- public System.Drawing.BufferedGraphics Allocate(System.Drawing.Graphics targetGraphics, System.Drawing.Rectangle targetRectangle) { throw null; }
- public System.Drawing.BufferedGraphics Allocate(System.IntPtr targetDC, System.Drawing.Rectangle targetRectangle) { throw null; }
- public void Dispose() { }
- ~BufferedGraphicsContext() { }
- public void Invalidate() { }
- }
- public static partial class BufferedGraphicsManager
- {
- public static System.Drawing.BufferedGraphicsContext Current { get { throw null; } }
- }
- public partial struct CharacterRange
- {
- private int _dummyPrimitive;
- public CharacterRange(int First, int Length) { throw null; }
- public int First { get { throw null; } set { } }
- public int Length { get { throw null; } set { } }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
- public override int GetHashCode() { throw null; }
- public static bool operator ==(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw null; }
- public static bool operator !=(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2) { throw null; }
- }
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.ContentAlignmentEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public enum ContentAlignment
- {
- TopLeft = 1,
- TopCenter = 2,
- TopRight = 4,
- MiddleLeft = 16,
- MiddleCenter = 32,
- MiddleRight = 64,
- BottomLeft = 256,
- BottomCenter = 512,
- BottomRight = 1024,
- }
- public enum CopyPixelOperation
- {
- NoMirrorBitmap = -2147483648,
- Blackness = 66,
- NotSourceErase = 1114278,
- NotSourceCopy = 3342344,
- SourceErase = 4457256,
- DestinationInvert = 5570569,
- PatInvert = 5898313,
- SourceInvert = 6684742,
- SourceAnd = 8913094,
- MergePaint = 12255782,
- MergeCopy = 12583114,
- SourceCopy = 13369376,
- SourcePaint = 15597702,
- PatCopy = 15728673,
- PatPaint = 16452105,
- Whiteness = 16711778,
- CaptureBlt = 1073741824,
- }
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.FontEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter))]
- public sealed partial class Font : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
- {
- public Font(System.Drawing.Font prototype, System.Drawing.FontStyle newStyle) { }
- public Font(System.Drawing.FontFamily family, float emSize) { }
- public Font(System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style) { }
- public Font(System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit) { }
- public Font(System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet) { }
- public Font(System.Drawing.FontFamily family, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont) { }
- public Font(System.Drawing.FontFamily family, float emSize, System.Drawing.GraphicsUnit unit) { }
- public Font(string familyName, float emSize) { }
- public Font(string familyName, float emSize, System.Drawing.FontStyle style) { }
- public Font(string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit) { }
- public Font(string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet) { }
- public Font(string familyName, float emSize, System.Drawing.FontStyle style, System.Drawing.GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont) { }
- public Font(string familyName, float emSize, System.Drawing.GraphicsUnit unit) { }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public bool Bold { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.Drawing.FontFamily FontFamily { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public byte GdiCharSet { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public bool GdiVerticalFont { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public int Height { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public bool IsSystemFont { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public bool Italic { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.FontNameEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter.FontNameConverter))]
- public string Name { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public string? OriginalFontName { get { throw null; } }
- public float Size { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public float SizeInPoints { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public bool Strikeout { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.Drawing.FontStyle Style { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public string SystemFontName { get { throw null; } }
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public bool Underline { get { throw null; } }
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.FontConverter.FontUnitConverter))]
- public System.Drawing.GraphicsUnit Unit { get { throw null; } }
- public object Clone() { throw null; }
- public void Dispose() { }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
- ~Font() { }
- public static System.Drawing.Font FromHdc(System.IntPtr hdc) { throw null; }
- public static System.Drawing.Font FromHfont(System.IntPtr hfont) { throw null; }
- public static System.Drawing.Font FromLogFont(object lf) { throw null; }
- public static System.Drawing.Font FromLogFont(object lf, System.IntPtr hdc) { throw null; }
- public override int GetHashCode() { throw null; }
- public float GetHeight() { throw null; }
- public float GetHeight(System.Drawing.Graphics graphics) { throw null; }
- public float GetHeight(float dpi) { throw null; }
- void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { }
- public System.IntPtr ToHfont() { throw null; }
- public void ToLogFont(object logFont) { }
- public void ToLogFont(object logFont, System.Drawing.Graphics graphics) { }
- public override string ToString() { throw null; }
- }
- public partial class FontConverter : System.ComponentModel.TypeConverter
- {
- public FontConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) { throw null; }
- public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override object? ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
- public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues) { throw null; }
- public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- [Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- public override System.ComponentModel.PropertyDescriptorCollection? GetProperties(System.ComponentModel.ITypeDescriptorContext? context, object? value, System.Attribute[]? attributes) { throw null; }
- public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- public sealed partial class FontNameConverter : System.ComponentModel.TypeConverter, System.IDisposable
- {
- public FontNameConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- public override bool GetStandardValuesExclusive(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- void System.IDisposable.Dispose() { }
- }
- public partial class FontUnitConverter : System.ComponentModel.EnumConverter
- {
- public FontUnitConverter() : base (default(System.Type)) { }
- public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- }
- }
- public sealed partial class FontFamily : System.MarshalByRefObject, System.IDisposable
- {
- public FontFamily(System.Drawing.Text.GenericFontFamilies genericFamily) { }
- public FontFamily(string name) { }
- public FontFamily(string name, System.Drawing.Text.FontCollection? fontCollection) { }
- public static System.Drawing.FontFamily[] Families { get { throw null; } }
- public static System.Drawing.FontFamily GenericMonospace { get { throw null; } }
- public static System.Drawing.FontFamily GenericSansSerif { get { throw null; } }
- public static System.Drawing.FontFamily GenericSerif { get { throw null; } }
- public string Name { get { throw null; } }
- public void Dispose() { }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
- ~FontFamily() { }
- public int GetCellAscent(System.Drawing.FontStyle style) { throw null; }
- public int GetCellDescent(System.Drawing.FontStyle style) { throw null; }
- public int GetEmHeight(System.Drawing.FontStyle style) { throw null; }
- [System.ObsoleteAttribute("FontFamily.GetFamilies has been deprecated. Use Families instead.")]
- public static System.Drawing.FontFamily[] GetFamilies(System.Drawing.Graphics graphics) { throw null; }
- public override int GetHashCode() { throw null; }
- public int GetLineSpacing(System.Drawing.FontStyle style) { throw null; }
- public string GetName(int language) { throw null; }
- public bool IsStyleAvailable(System.Drawing.FontStyle style) { throw null; }
- public override string ToString() { throw null; }
- }
- [System.FlagsAttribute]
- public enum FontStyle
- {
- Regular = 0,
- Bold = 1,
- Italic = 2,
- Underline = 4,
- Strikeout = 8,
- }
- public sealed partial class Graphics : System.MarshalByRefObject, System.Drawing.IDeviceContext, System.IDisposable
- {
- internal Graphics() { }
- public System.Drawing.Region Clip { get { throw null; } set { } }
- public System.Drawing.RectangleF ClipBounds { get { throw null; } }
- public System.Drawing.Drawing2D.CompositingMode CompositingMode { get { throw null; } set { } }
- public System.Drawing.Drawing2D.CompositingQuality CompositingQuality { get { throw null; } set { } }
- public float DpiX { get { throw null; } }
- public float DpiY { get { throw null; } }
- public System.Drawing.Drawing2D.InterpolationMode InterpolationMode { get { throw null; } set { } }
- public bool IsClipEmpty { get { throw null; } }
- public bool IsVisibleClipEmpty { get { throw null; } }
- public float PageScale { get { throw null; } set { } }
- public System.Drawing.GraphicsUnit PageUnit { get { throw null; } set { } }
- public System.Drawing.Drawing2D.PixelOffsetMode PixelOffsetMode { get { throw null; } set { } }
- public System.Drawing.Point RenderingOrigin { get { throw null; } set { } }
- public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { get { throw null; } set { } }
- public int TextContrast { get { throw null; } set { } }
- public System.Drawing.Text.TextRenderingHint TextRenderingHint { get { throw null; } set { } }
- public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
- public System.Drawing.RectangleF VisibleClipBounds { get { throw null; } }
- public void AddMetafileComment(byte[] data) { }
- public System.Drawing.Drawing2D.GraphicsContainer BeginContainer() { throw null; }
- public System.Drawing.Drawing2D.GraphicsContainer BeginContainer(System.Drawing.Rectangle dstrect, System.Drawing.Rectangle srcrect, System.Drawing.GraphicsUnit unit) { throw null; }
- public System.Drawing.Drawing2D.GraphicsContainer BeginContainer(System.Drawing.RectangleF dstrect, System.Drawing.RectangleF srcrect, System.Drawing.GraphicsUnit unit) { throw null; }
- public void Clear(System.Drawing.Color color) { }
- public void CopyFromScreen(System.Drawing.Point upperLeftSource, System.Drawing.Point upperLeftDestination, System.Drawing.Size blockRegionSize) { }
- public void CopyFromScreen(System.Drawing.Point upperLeftSource, System.Drawing.Point upperLeftDestination, System.Drawing.Size blockRegionSize, System.Drawing.CopyPixelOperation copyPixelOperation) { }
- public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int destinationY, System.Drawing.Size blockRegionSize) { }
- public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int destinationY, System.Drawing.Size blockRegionSize, System.Drawing.CopyPixelOperation copyPixelOperation) { }
- public void Dispose() { }
- public void DrawArc(System.Drawing.Pen pen, System.Drawing.Rectangle rect, float startAngle, float sweepAngle) { }
- public void DrawArc(System.Drawing.Pen pen, System.Drawing.RectangleF rect, float startAngle, float sweepAngle) { }
- public void DrawArc(System.Drawing.Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) { }
- public void DrawArc(System.Drawing.Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) { }
- public void DrawBezier(System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2, System.Drawing.Point pt3, System.Drawing.Point pt4) { }
- public void DrawBezier(System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2, System.Drawing.PointF pt3, System.Drawing.PointF pt4) { }
- public void DrawBezier(System.Drawing.Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { }
- public void DrawBeziers(System.Drawing.Pen pen, System.Drawing.PointF[] points) { }
- public void DrawBeziers(System.Drawing.Pen pen, System.Drawing.Point[] points) { }
- public void DrawClosedCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points) { }
- public void DrawClosedCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode) { }
- public void DrawClosedCurve(System.Drawing.Pen pen, System.Drawing.Point[] points) { }
- public void DrawClosedCurve(System.Drawing.Pen pen, System.Drawing.Point[] points, float tension, System.Drawing.Drawing2D.FillMode fillmode) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points, int offset, int numberOfSegments) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points, int offset, int numberOfSegments, float tension) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.PointF[] points, float tension) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.Point[] points) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.Point[] points, int offset, int numberOfSegments, float tension) { }
- public void DrawCurve(System.Drawing.Pen pen, System.Drawing.Point[] points, float tension) { }
- public void DrawEllipse(System.Drawing.Pen pen, System.Drawing.Rectangle rect) { }
- public void DrawEllipse(System.Drawing.Pen pen, System.Drawing.RectangleF rect) { }
- public void DrawEllipse(System.Drawing.Pen pen, int x, int y, int width, int height) { }
- public void DrawEllipse(System.Drawing.Pen pen, float x, float y, float width, float height) { }
- public void DrawIcon(System.Drawing.Icon icon, System.Drawing.Rectangle targetRect) { }
- public void DrawIcon(System.Drawing.Icon icon, int x, int y) { }
- public void DrawIconUnstretched(System.Drawing.Icon icon, System.Drawing.Rectangle targetRect) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point point) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF point) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback, int callbackData) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback, int callbackData) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle rect) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttr, System.Drawing.Graphics.DrawImageAbort? callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback, System.IntPtr callbackData) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Imaging.ImageAttributes? imageAttrs, System.Drawing.Graphics.DrawImageAbort? callback, System.IntPtr callbackData) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.RectangleF rect) { }
- public void DrawImage(System.Drawing.Image image, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, int x, int y) { }
- public void DrawImage(System.Drawing.Image image, int x, int y, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, int x, int y, int width, int height) { }
- public void DrawImage(System.Drawing.Image image, float x, float y) { }
- public void DrawImage(System.Drawing.Image image, float x, float y, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit) { }
- public void DrawImage(System.Drawing.Image image, float x, float y, float width, float height) { }
- public void DrawImageUnscaled(System.Drawing.Image image, System.Drawing.Point point) { }
- public void DrawImageUnscaled(System.Drawing.Image image, System.Drawing.Rectangle rect) { }
- public void DrawImageUnscaled(System.Drawing.Image image, int x, int y) { }
- public void DrawImageUnscaled(System.Drawing.Image image, int x, int y, int width, int height) { }
- public void DrawImageUnscaledAndClipped(System.Drawing.Image image, System.Drawing.Rectangle rect) { }
- public void DrawLine(System.Drawing.Pen pen, System.Drawing.Point pt1, System.Drawing.Point pt2) { }
- public void DrawLine(System.Drawing.Pen pen, System.Drawing.PointF pt1, System.Drawing.PointF pt2) { }
- public void DrawLine(System.Drawing.Pen pen, int x1, int y1, int x2, int y2) { }
- public void DrawLine(System.Drawing.Pen pen, float x1, float y1, float x2, float y2) { }
- public void DrawLines(System.Drawing.Pen pen, System.Drawing.PointF[] points) { }
- public void DrawLines(System.Drawing.Pen pen, System.Drawing.Point[] points) { }
- public void DrawPath(System.Drawing.Pen pen, System.Drawing.Drawing2D.GraphicsPath path) { }
- public void DrawPie(System.Drawing.Pen pen, System.Drawing.Rectangle rect, float startAngle, float sweepAngle) { }
- public void DrawPie(System.Drawing.Pen pen, System.Drawing.RectangleF rect, float startAngle, float sweepAngle) { }
- public void DrawPie(System.Drawing.Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) { }
- public void DrawPie(System.Drawing.Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) { }
- public void DrawPolygon(System.Drawing.Pen pen, System.Drawing.PointF[] points) { }
- public void DrawPolygon(System.Drawing.Pen pen, System.Drawing.Point[] points) { }
- public void DrawRectangle(System.Drawing.Pen pen, System.Drawing.Rectangle rect) { }
- public void DrawRectangle(System.Drawing.Pen pen, int x, int y, int width, int height) { }
- public void DrawRectangle(System.Drawing.Pen pen, float x, float y, float width, float height) { }
- public void DrawRectangles(System.Drawing.Pen pen, System.Drawing.RectangleF[] rects) { }
- public void DrawRectangles(System.Drawing.Pen pen, System.Drawing.Rectangle[] rects) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.PointF point, System.Drawing.StringFormat? format) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, System.Drawing.RectangleF layoutRectangle, System.Drawing.StringFormat? format) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y) { }
- public void DrawString(string? s, System.Drawing.Font font, System.Drawing.Brush brush, float x, float y, System.Drawing.StringFormat? format) { }
- public void EndContainer(System.Drawing.Drawing2D.GraphicsContainer container) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point destPoint, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF destPoint, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Point[] destPoints, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.Rectangle destRect, System.Drawing.Rectangle srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit srcUnit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData) { }
- public void EnumerateMetafile(System.Drawing.Imaging.Metafile metafile, System.Drawing.RectangleF destRect, System.Drawing.RectangleF srcRect, System.Drawing.GraphicsUnit unit, System.Drawing.Graphics.EnumerateMetafileProc callback, System.IntPtr callbackData, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public void ExcludeClip(System.Drawing.Rectangle rect) { }
- public void ExcludeClip(System.Drawing.Region region) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.PointF[] points) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.PointF[] points, System.Drawing.Drawing2D.FillMode fillmode) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.PointF[] points, System.Drawing.Drawing2D.FillMode fillmode, float tension) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.Point[] points) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.Point[] points, System.Drawing.Drawing2D.FillMode fillmode) { }
- public void FillClosedCurve(System.Drawing.Brush brush, System.Drawing.Point[] points, System.Drawing.Drawing2D.FillMode fillmode, float tension) { }
- public void FillEllipse(System.Drawing.Brush brush, System.Drawing.Rectangle rect) { }
- public void FillEllipse(System.Drawing.Brush brush, System.Drawing.RectangleF rect) { }
- public void FillEllipse(System.Drawing.Brush brush, int x, int y, int width, int height) { }
- public void FillEllipse(System.Drawing.Brush brush, float x, float y, float width, float height) { }
- public void FillPath(System.Drawing.Brush brush, System.Drawing.Drawing2D.GraphicsPath path) { }
- public void FillPie(System.Drawing.Brush brush, System.Drawing.Rectangle rect, float startAngle, float sweepAngle) { }
- public void FillPie(System.Drawing.Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle) { }
- public void FillPie(System.Drawing.Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle) { }
- public void FillPolygon(System.Drawing.Brush brush, System.Drawing.PointF[] points) { }
- public void FillPolygon(System.Drawing.Brush brush, System.Drawing.PointF[] points, System.Drawing.Drawing2D.FillMode fillMode) { }
- public void FillPolygon(System.Drawing.Brush brush, System.Drawing.Point[] points) { }
- public void FillPolygon(System.Drawing.Brush brush, System.Drawing.Point[] points, System.Drawing.Drawing2D.FillMode fillMode) { }
- public void FillRectangle(System.Drawing.Brush brush, System.Drawing.Rectangle rect) { }
- public void FillRectangle(System.Drawing.Brush brush, System.Drawing.RectangleF rect) { }
- public void FillRectangle(System.Drawing.Brush brush, int x, int y, int width, int height) { }
- public void FillRectangle(System.Drawing.Brush brush, float x, float y, float width, float height) { }
- public void FillRectangles(System.Drawing.Brush brush, System.Drawing.RectangleF[] rects) { }
- public void FillRectangles(System.Drawing.Brush brush, System.Drawing.Rectangle[] rects) { }
- public void FillRegion(System.Drawing.Brush brush, System.Drawing.Region region) { }
- ~Graphics() { }
- public void Flush() { }
- public void Flush(System.Drawing.Drawing2D.FlushIntention intention) { }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public static System.Drawing.Graphics FromHdc(System.IntPtr hdc) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public static System.Drawing.Graphics FromHdc(System.IntPtr hdc, System.IntPtr hdevice) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public static System.Drawing.Graphics FromHdcInternal(System.IntPtr hdc) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public static System.Drawing.Graphics FromHwnd(System.IntPtr hwnd) { throw null; }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public static System.Drawing.Graphics FromHwndInternal(System.IntPtr hwnd) { throw null; }
- public static System.Drawing.Graphics FromImage(System.Drawing.Image image) { throw null; }
- public static System.IntPtr GetHalftonePalette() { throw null; }
- public System.IntPtr GetHdc() { throw null; }
- public System.Drawing.Color GetNearestColor(System.Drawing.Color color) { throw null; }
- public void IntersectClip(System.Drawing.Rectangle rect) { }
- public void IntersectClip(System.Drawing.RectangleF rect) { }
- public void IntersectClip(System.Drawing.Region region) { }
- public bool IsVisible(System.Drawing.Point point) { throw null; }
- public bool IsVisible(System.Drawing.PointF point) { throw null; }
- public bool IsVisible(System.Drawing.Rectangle rect) { throw null; }
- public bool IsVisible(System.Drawing.RectangleF rect) { throw null; }
- public bool IsVisible(int x, int y) { throw null; }
- public bool IsVisible(int x, int y, int width, int height) { throw null; }
- public bool IsVisible(float x, float y) { throw null; }
- public bool IsVisible(float x, float y, float width, float height) { throw null; }
- public System.Drawing.Region[] MeasureCharacterRanges(string? text, System.Drawing.Font font, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.PointF origin, System.Drawing.StringFormat? stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat? stringFormat) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, System.Drawing.SizeF layoutArea, System.Drawing.StringFormat? stringFormat, out int charactersFitted, out int linesFilled) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, int width) { throw null; }
- public System.Drawing.SizeF MeasureString(string? text, System.Drawing.Font font, int width, System.Drawing.StringFormat? format) { throw null; }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ReleaseHdc() { }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
- public void ReleaseHdc(System.IntPtr hdc) { }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public void ReleaseHdcInternal(System.IntPtr hdc) { }
- public void ResetClip() { }
- public void ResetTransform() { }
- public void Restore(System.Drawing.Drawing2D.GraphicsState gstate) { }
- public void RotateTransform(float angle) { }
- public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public System.Drawing.Drawing2D.GraphicsState Save() { throw null; }
- public void ScaleTransform(float sx, float sy) { }
- public void ScaleTransform(float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void SetClip(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void SetClip(System.Drawing.Drawing2D.GraphicsPath path, System.Drawing.Drawing2D.CombineMode combineMode) { }
- public void SetClip(System.Drawing.Graphics g) { }
- public void SetClip(System.Drawing.Graphics g, System.Drawing.Drawing2D.CombineMode combineMode) { }
- public void SetClip(System.Drawing.Rectangle rect) { }
- public void SetClip(System.Drawing.Rectangle rect, System.Drawing.Drawing2D.CombineMode combineMode) { }
- public void SetClip(System.Drawing.RectangleF rect) { }
- public void SetClip(System.Drawing.RectangleF rect, System.Drawing.Drawing2D.CombineMode combineMode) { }
- public void SetClip(System.Drawing.Region region, System.Drawing.Drawing2D.CombineMode combineMode) { }
- public void TransformPoints(System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.PointF[] pts) { }
- public void TransformPoints(System.Drawing.Drawing2D.CoordinateSpace destSpace, System.Drawing.Drawing2D.CoordinateSpace srcSpace, System.Drawing.Point[] pts) { }
- public void TranslateClip(int dx, int dy) { }
- public void TranslateClip(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public delegate bool DrawImageAbort(System.IntPtr callbackdata);
- public delegate bool EnumerateMetafileProc(System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, System.IntPtr data, System.Drawing.Imaging.PlayRecordCallback? callbackData);
- }
- public enum GraphicsUnit
- {
- World = 0,
- Display = 1,
- Pixel = 2,
- Point = 3,
- Inch = 4,
- Document = 5,
- Millimeter = 6,
- }
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.IconEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.IconConverter))]
- public sealed partial class Icon : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
- {
- public Icon(System.Drawing.Icon original, System.Drawing.Size size) { }
- public Icon(System.Drawing.Icon original, int width, int height) { }
- public Icon(System.IO.Stream stream) { }
- public Icon(System.IO.Stream stream, System.Drawing.Size size) { }
- public Icon(System.IO.Stream stream, int width, int height) { }
- public Icon(string fileName) { }
- public Icon(string fileName, System.Drawing.Size size) { }
- public Icon(string fileName, int width, int height) { }
- public Icon(System.Type type, string resource) { }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.IntPtr Handle { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public int Height { get { throw null; } }
- public System.Drawing.Size Size { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public int Width { get { throw null; } }
- public object Clone() { throw null; }
- public void Dispose() { }
- public static System.Drawing.Icon? ExtractAssociatedIcon(string filePath) { throw null; }
- ~Icon() { }
- public static System.Drawing.Icon FromHandle(System.IntPtr handle) { throw null; }
- public void Save(System.IO.Stream outputStream) { }
- void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { }
- public System.Drawing.Bitmap ToBitmap() { throw null; }
- public override string ToString() { throw null; }
- }
- public partial class IconConverter : System.ComponentModel.ExpandableObjectConverter
- {
- public IconConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) { throw null; }
- public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override object? ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
- }
- public partial interface IDeviceContext : System.IDisposable
- {
- System.IntPtr GetHdc();
- void ReleaseHdc();
- }
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.ImageEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [System.ComponentModel.ImmutableObjectAttribute(true)]
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.ImageConverter))]
- public abstract partial class Image : System.MarshalByRefObject, System.ICloneable, System.IDisposable, System.Runtime.Serialization.ISerializable
- {
- internal Image() { }
- [System.ComponentModel.BrowsableAttribute(false)]
- public int Flags { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.Guid[] FrameDimensionsList { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- [System.ComponentModel.DefaultValueAttribute(false)]
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public int Height { get { throw null; } }
- public float HorizontalResolution { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.Drawing.Imaging.ColorPalette Palette { get { throw null; } set { } }
- public System.Drawing.SizeF PhysicalDimension { get { throw null; } }
- public System.Drawing.Imaging.PixelFormat PixelFormat { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public int[] PropertyIdList { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- public System.Drawing.Imaging.PropertyItem[] PropertyItems { get { throw null; } }
- public System.Drawing.Imaging.ImageFormat RawFormat { get { throw null; } }
- public System.Drawing.Size Size { get { throw null; } }
- [System.ComponentModel.DefaultValueAttribute(null)]
- [System.ComponentModel.LocalizableAttribute(false)]
- public object? Tag { get { throw null; } set { } }
- public float VerticalResolution { get { throw null; } }
- [System.ComponentModel.BrowsableAttribute(false)]
- [System.ComponentModel.DefaultValueAttribute(false)]
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public int Width { get { throw null; } }
- public object Clone() { throw null; }
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- ~Image() { }
- public static System.Drawing.Image FromFile(string filename) { throw null; }
- public static System.Drawing.Image FromFile(string filename, bool useEmbeddedColorManagement) { throw null; }
- public static System.Drawing.Bitmap FromHbitmap(System.IntPtr hbitmap) { throw null; }
- public static System.Drawing.Bitmap FromHbitmap(System.IntPtr hbitmap, System.IntPtr hpalette) { throw null; }
- public static System.Drawing.Image FromStream(System.IO.Stream stream) { throw null; }
- public static System.Drawing.Image FromStream(System.IO.Stream stream, bool useEmbeddedColorManagement) { throw null; }
- public static System.Drawing.Image FromStream(System.IO.Stream stream, bool useEmbeddedColorManagement, bool validateImageData) { throw null; }
- public System.Drawing.RectangleF GetBounds(ref System.Drawing.GraphicsUnit pageUnit) { throw null; }
- public System.Drawing.Imaging.EncoderParameters? GetEncoderParameterList(System.Guid encoder) { throw null; }
- public int GetFrameCount(System.Drawing.Imaging.FrameDimension dimension) { throw null; }
- public static int GetPixelFormatSize(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
- public System.Drawing.Imaging.PropertyItem? GetPropertyItem(int propid) { throw null; }
- public System.Drawing.Image GetThumbnailImage(int thumbWidth, int thumbHeight, System.Drawing.Image.GetThumbnailImageAbort? callback, System.IntPtr callbackData) { throw null; }
- public static bool IsAlphaPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
- public static bool IsCanonicalPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
- public static bool IsExtendedPixelFormat(System.Drawing.Imaging.PixelFormat pixfmt) { throw null; }
- public void RemovePropertyItem(int propid) { }
- public void RotateFlip(System.Drawing.RotateFlipType rotateFlipType) { }
- public void Save(System.IO.Stream stream, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
- public void Save(System.IO.Stream stream, System.Drawing.Imaging.ImageFormat format) { }
- public void Save(string filename) { }
- public void Save(string filename, System.Drawing.Imaging.ImageCodecInfo encoder, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
- public void Save(string filename, System.Drawing.Imaging.ImageFormat format) { }
- public void SaveAdd(System.Drawing.Image image, System.Drawing.Imaging.EncoderParameters? encoderParams) { }
- public void SaveAdd(System.Drawing.Imaging.EncoderParameters? encoderParams) { }
- public int SelectActiveFrame(System.Drawing.Imaging.FrameDimension dimension, int frameIndex) { throw null; }
- public void SetPropertyItem(System.Drawing.Imaging.PropertyItem propitem) { }
- void System.Runtime.Serialization.ISerializable.GetObjectData(System.Runtime.Serialization.SerializationInfo si, System.Runtime.Serialization.StreamingContext context) { }
- public delegate bool GetThumbnailImageAbort();
- }
- public sealed partial class ImageAnimator
- {
- internal ImageAnimator() { }
- public static void Animate(System.Drawing.Image image, System.EventHandler onFrameChangedHandler) { }
- public static bool CanAnimate([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Drawing.Image? image) { throw null; }
- public static void StopAnimate(System.Drawing.Image image, System.EventHandler onFrameChangedHandler) { }
- public static void UpdateFrames() { }
- public static void UpdateFrames(System.Drawing.Image? image) { }
- }
- public partial class ImageConverter : System.ComponentModel.TypeConverter
- {
- public ImageConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) { throw null; }
- public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
- [Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- public override System.ComponentModel.PropertyDescriptorCollection GetProperties(System.ComponentModel.ITypeDescriptorContext? context, object? value, System.Attribute[]? attributes) { throw null; }
- public override bool GetPropertiesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- }
- public partial class ImageFormatConverter : System.ComponentModel.TypeConverter
- {
- public ImageFormatConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type? sourceType) { throw null; }
- public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override object? ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
- public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- }
- public sealed partial class Pen : System.MarshalByRefObject, System.ICloneable, System.IDisposable
- {
- public Pen(System.Drawing.Brush brush) { }
- public Pen(System.Drawing.Brush brush, float width) { }
- public Pen(System.Drawing.Color color) { }
- public Pen(System.Drawing.Color color, float width) { }
- public System.Drawing.Drawing2D.PenAlignment Alignment { get { throw null; } set { } }
- public System.Drawing.Brush Brush { get { throw null; } set { } }
- public System.Drawing.Color Color { get { throw null; } set { } }
- public float[] CompoundArray { get { throw null; } set { } }
- public System.Drawing.Drawing2D.CustomLineCap CustomEndCap { get { throw null; } set { } }
- public System.Drawing.Drawing2D.CustomLineCap CustomStartCap { get { throw null; } set { } }
- public System.Drawing.Drawing2D.DashCap DashCap { get { throw null; } set { } }
- public float DashOffset { get { throw null; } set { } }
- public float[] DashPattern { get { throw null; } set { } }
- public System.Drawing.Drawing2D.DashStyle DashStyle { get { throw null; } set { } }
- public System.Drawing.Drawing2D.LineCap EndCap { get { throw null; } set { } }
- public System.Drawing.Drawing2D.LineJoin LineJoin { get { throw null; } set { } }
- public float MiterLimit { get { throw null; } set { } }
- public System.Drawing.Drawing2D.PenType PenType { get { throw null; } }
- public System.Drawing.Drawing2D.LineCap StartCap { get { throw null; } set { } }
- public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
- public float Width { get { throw null; } set { } }
- public object Clone() { throw null; }
- public void Dispose() { }
- ~Pen() { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ResetTransform() { }
- public void RotateTransform(float angle) { }
- public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ScaleTransform(float sx, float sy) { }
- public void ScaleTransform(float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void SetLineCap(System.Drawing.Drawing2D.LineCap startCap, System.Drawing.Drawing2D.LineCap endCap, System.Drawing.Drawing2D.DashCap dashCap) { }
- public void TranslateTransform(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
- }
- public static partial class Pens
- {
- public static System.Drawing.Pen AliceBlue { get { throw null; } }
- public static System.Drawing.Pen AntiqueWhite { get { throw null; } }
- public static System.Drawing.Pen Aqua { get { throw null; } }
- public static System.Drawing.Pen Aquamarine { get { throw null; } }
- public static System.Drawing.Pen Azure { get { throw null; } }
- public static System.Drawing.Pen Beige { get { throw null; } }
- public static System.Drawing.Pen Bisque { get { throw null; } }
- public static System.Drawing.Pen Black { get { throw null; } }
- public static System.Drawing.Pen BlanchedAlmond { get { throw null; } }
- public static System.Drawing.Pen Blue { get { throw null; } }
- public static System.Drawing.Pen BlueViolet { get { throw null; } }
- public static System.Drawing.Pen Brown { get { throw null; } }
- public static System.Drawing.Pen BurlyWood { get { throw null; } }
- public static System.Drawing.Pen CadetBlue { get { throw null; } }
- public static System.Drawing.Pen Chartreuse { get { throw null; } }
- public static System.Drawing.Pen Chocolate { get { throw null; } }
- public static System.Drawing.Pen Coral { get { throw null; } }
- public static System.Drawing.Pen CornflowerBlue { get { throw null; } }
- public static System.Drawing.Pen Cornsilk { get { throw null; } }
- public static System.Drawing.Pen Crimson { get { throw null; } }
- public static System.Drawing.Pen Cyan { get { throw null; } }
- public static System.Drawing.Pen DarkBlue { get { throw null; } }
- public static System.Drawing.Pen DarkCyan { get { throw null; } }
- public static System.Drawing.Pen DarkGoldenrod { get { throw null; } }
- public static System.Drawing.Pen DarkGray { get { throw null; } }
- public static System.Drawing.Pen DarkGreen { get { throw null; } }
- public static System.Drawing.Pen DarkKhaki { get { throw null; } }
- public static System.Drawing.Pen DarkMagenta { get { throw null; } }
- public static System.Drawing.Pen DarkOliveGreen { get { throw null; } }
- public static System.Drawing.Pen DarkOrange { get { throw null; } }
- public static System.Drawing.Pen DarkOrchid { get { throw null; } }
- public static System.Drawing.Pen DarkRed { get { throw null; } }
- public static System.Drawing.Pen DarkSalmon { get { throw null; } }
- public static System.Drawing.Pen DarkSeaGreen { get { throw null; } }
- public static System.Drawing.Pen DarkSlateBlue { get { throw null; } }
- public static System.Drawing.Pen DarkSlateGray { get { throw null; } }
- public static System.Drawing.Pen DarkTurquoise { get { throw null; } }
- public static System.Drawing.Pen DarkViolet { get { throw null; } }
- public static System.Drawing.Pen DeepPink { get { throw null; } }
- public static System.Drawing.Pen DeepSkyBlue { get { throw null; } }
- public static System.Drawing.Pen DimGray { get { throw null; } }
- public static System.Drawing.Pen DodgerBlue { get { throw null; } }
- public static System.Drawing.Pen Firebrick { get { throw null; } }
- public static System.Drawing.Pen FloralWhite { get { throw null; } }
- public static System.Drawing.Pen ForestGreen { get { throw null; } }
- public static System.Drawing.Pen Fuchsia { get { throw null; } }
- public static System.Drawing.Pen Gainsboro { get { throw null; } }
- public static System.Drawing.Pen GhostWhite { get { throw null; } }
- public static System.Drawing.Pen Gold { get { throw null; } }
- public static System.Drawing.Pen Goldenrod { get { throw null; } }
- public static System.Drawing.Pen Gray { get { throw null; } }
- public static System.Drawing.Pen Green { get { throw null; } }
- public static System.Drawing.Pen GreenYellow { get { throw null; } }
- public static System.Drawing.Pen Honeydew { get { throw null; } }
- public static System.Drawing.Pen HotPink { get { throw null; } }
- public static System.Drawing.Pen IndianRed { get { throw null; } }
- public static System.Drawing.Pen Indigo { get { throw null; } }
- public static System.Drawing.Pen Ivory { get { throw null; } }
- public static System.Drawing.Pen Khaki { get { throw null; } }
- public static System.Drawing.Pen Lavender { get { throw null; } }
- public static System.Drawing.Pen LavenderBlush { get { throw null; } }
- public static System.Drawing.Pen LawnGreen { get { throw null; } }
- public static System.Drawing.Pen LemonChiffon { get { throw null; } }
- public static System.Drawing.Pen LightBlue { get { throw null; } }
- public static System.Drawing.Pen LightCoral { get { throw null; } }
- public static System.Drawing.Pen LightCyan { get { throw null; } }
- public static System.Drawing.Pen LightGoldenrodYellow { get { throw null; } }
- public static System.Drawing.Pen LightGray { get { throw null; } }
- public static System.Drawing.Pen LightGreen { get { throw null; } }
- public static System.Drawing.Pen LightPink { get { throw null; } }
- public static System.Drawing.Pen LightSalmon { get { throw null; } }
- public static System.Drawing.Pen LightSeaGreen { get { throw null; } }
- public static System.Drawing.Pen LightSkyBlue { get { throw null; } }
- public static System.Drawing.Pen LightSlateGray { get { throw null; } }
- public static System.Drawing.Pen LightSteelBlue { get { throw null; } }
- public static System.Drawing.Pen LightYellow { get { throw null; } }
- public static System.Drawing.Pen Lime { get { throw null; } }
- public static System.Drawing.Pen LimeGreen { get { throw null; } }
- public static System.Drawing.Pen Linen { get { throw null; } }
- public static System.Drawing.Pen Magenta { get { throw null; } }
- public static System.Drawing.Pen Maroon { get { throw null; } }
- public static System.Drawing.Pen MediumAquamarine { get { throw null; } }
- public static System.Drawing.Pen MediumBlue { get { throw null; } }
- public static System.Drawing.Pen MediumOrchid { get { throw null; } }
- public static System.Drawing.Pen MediumPurple { get { throw null; } }
- public static System.Drawing.Pen MediumSeaGreen { get { throw null; } }
- public static System.Drawing.Pen MediumSlateBlue { get { throw null; } }
- public static System.Drawing.Pen MediumSpringGreen { get { throw null; } }
- public static System.Drawing.Pen MediumTurquoise { get { throw null; } }
- public static System.Drawing.Pen MediumVioletRed { get { throw null; } }
- public static System.Drawing.Pen MidnightBlue { get { throw null; } }
- public static System.Drawing.Pen MintCream { get { throw null; } }
- public static System.Drawing.Pen MistyRose { get { throw null; } }
- public static System.Drawing.Pen Moccasin { get { throw null; } }
- public static System.Drawing.Pen NavajoWhite { get { throw null; } }
- public static System.Drawing.Pen Navy { get { throw null; } }
- public static System.Drawing.Pen OldLace { get { throw null; } }
- public static System.Drawing.Pen Olive { get { throw null; } }
- public static System.Drawing.Pen OliveDrab { get { throw null; } }
- public static System.Drawing.Pen Orange { get { throw null; } }
- public static System.Drawing.Pen OrangeRed { get { throw null; } }
- public static System.Drawing.Pen Orchid { get { throw null; } }
- public static System.Drawing.Pen PaleGoldenrod { get { throw null; } }
- public static System.Drawing.Pen PaleGreen { get { throw null; } }
- public static System.Drawing.Pen PaleTurquoise { get { throw null; } }
- public static System.Drawing.Pen PaleVioletRed { get { throw null; } }
- public static System.Drawing.Pen PapayaWhip { get { throw null; } }
- public static System.Drawing.Pen PeachPuff { get { throw null; } }
- public static System.Drawing.Pen Peru { get { throw null; } }
- public static System.Drawing.Pen Pink { get { throw null; } }
- public static System.Drawing.Pen Plum { get { throw null; } }
- public static System.Drawing.Pen PowderBlue { get { throw null; } }
- public static System.Drawing.Pen Purple { get { throw null; } }
- public static System.Drawing.Pen Red { get { throw null; } }
- public static System.Drawing.Pen RosyBrown { get { throw null; } }
- public static System.Drawing.Pen RoyalBlue { get { throw null; } }
- public static System.Drawing.Pen SaddleBrown { get { throw null; } }
- public static System.Drawing.Pen Salmon { get { throw null; } }
- public static System.Drawing.Pen SandyBrown { get { throw null; } }
- public static System.Drawing.Pen SeaGreen { get { throw null; } }
- public static System.Drawing.Pen SeaShell { get { throw null; } }
- public static System.Drawing.Pen Sienna { get { throw null; } }
- public static System.Drawing.Pen Silver { get { throw null; } }
- public static System.Drawing.Pen SkyBlue { get { throw null; } }
- public static System.Drawing.Pen SlateBlue { get { throw null; } }
- public static System.Drawing.Pen SlateGray { get { throw null; } }
- public static System.Drawing.Pen Snow { get { throw null; } }
- public static System.Drawing.Pen SpringGreen { get { throw null; } }
- public static System.Drawing.Pen SteelBlue { get { throw null; } }
- public static System.Drawing.Pen Tan { get { throw null; } }
- public static System.Drawing.Pen Teal { get { throw null; } }
- public static System.Drawing.Pen Thistle { get { throw null; } }
- public static System.Drawing.Pen Tomato { get { throw null; } }
- public static System.Drawing.Pen Transparent { get { throw null; } }
- public static System.Drawing.Pen Turquoise { get { throw null; } }
- public static System.Drawing.Pen Violet { get { throw null; } }
- public static System.Drawing.Pen Wheat { get { throw null; } }
- public static System.Drawing.Pen White { get { throw null; } }
- public static System.Drawing.Pen WhiteSmoke { get { throw null; } }
- public static System.Drawing.Pen Yellow { get { throw null; } }
- public static System.Drawing.Pen YellowGreen { get { throw null; } }
- }
- public sealed partial class Region : System.MarshalByRefObject, System.IDisposable
- {
- public Region() { }
- public Region(System.Drawing.Drawing2D.GraphicsPath path) { }
- public Region(System.Drawing.Drawing2D.RegionData rgnData) { }
- public Region(System.Drawing.Rectangle rect) { }
- public Region(System.Drawing.RectangleF rect) { }
- public System.Drawing.Region Clone() { throw null; }
- public void Complement(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void Complement(System.Drawing.Rectangle rect) { }
- public void Complement(System.Drawing.RectangleF rect) { }
- public void Complement(System.Drawing.Region region) { }
- public void Dispose() { }
- public bool Equals(System.Drawing.Region region, System.Drawing.Graphics g) { throw null; }
- public void Exclude(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void Exclude(System.Drawing.Rectangle rect) { }
- public void Exclude(System.Drawing.RectangleF rect) { }
- public void Exclude(System.Drawing.Region region) { }
- ~Region() { }
- public static System.Drawing.Region FromHrgn(System.IntPtr hrgn) { throw null; }
- public System.Drawing.RectangleF GetBounds(System.Drawing.Graphics g) { throw null; }
- public System.IntPtr GetHrgn(System.Drawing.Graphics g) { throw null; }
- public System.Drawing.Drawing2D.RegionData? GetRegionData() { throw null; }
- public System.Drawing.RectangleF[] GetRegionScans(System.Drawing.Drawing2D.Matrix matrix) { throw null; }
- public void Intersect(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void Intersect(System.Drawing.Rectangle rect) { }
- public void Intersect(System.Drawing.RectangleF rect) { }
- public void Intersect(System.Drawing.Region region) { }
- public bool IsEmpty(System.Drawing.Graphics g) { throw null; }
- public bool IsInfinite(System.Drawing.Graphics g) { throw null; }
- public bool IsVisible(System.Drawing.Point point) { throw null; }
- public bool IsVisible(System.Drawing.Point point, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(System.Drawing.PointF point) { throw null; }
- public bool IsVisible(System.Drawing.PointF point, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(System.Drawing.Rectangle rect) { throw null; }
- public bool IsVisible(System.Drawing.Rectangle rect, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(System.Drawing.RectangleF rect) { throw null; }
- public bool IsVisible(System.Drawing.RectangleF rect, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(int x, int y, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(int x, int y, int width, int height) { throw null; }
- public bool IsVisible(int x, int y, int width, int height, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(float x, float y) { throw null; }
- public bool IsVisible(float x, float y, System.Drawing.Graphics? g) { throw null; }
- public bool IsVisible(float x, float y, float width, float height) { throw null; }
- public bool IsVisible(float x, float y, float width, float height, System.Drawing.Graphics? g) { throw null; }
- public void MakeEmpty() { }
- public void MakeInfinite() { }
- public void ReleaseHrgn(System.IntPtr regionHandle) { }
- public void Transform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void Translate(int dx, int dy) { }
- public void Translate(float dx, float dy) { }
- public void Union(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void Union(System.Drawing.Rectangle rect) { }
- public void Union(System.Drawing.RectangleF rect) { }
- public void Union(System.Drawing.Region region) { }
- public void Xor(System.Drawing.Drawing2D.GraphicsPath path) { }
- public void Xor(System.Drawing.Rectangle rect) { }
- public void Xor(System.Drawing.RectangleF rect) { }
- public void Xor(System.Drawing.Region region) { }
- }
- public enum RotateFlipType
- {
- Rotate180FlipXY = 0,
- RotateNoneFlipNone = 0,
- Rotate270FlipXY = 1,
- Rotate90FlipNone = 1,
- Rotate180FlipNone = 2,
- RotateNoneFlipXY = 2,
- Rotate270FlipNone = 3,
- Rotate90FlipXY = 3,
- Rotate180FlipY = 4,
- RotateNoneFlipX = 4,
- Rotate270FlipY = 5,
- Rotate90FlipX = 5,
- Rotate180FlipX = 6,
- RotateNoneFlipY = 6,
- Rotate270FlipX = 7,
- Rotate90FlipY = 7,
- }
- public sealed partial class SolidBrush : System.Drawing.Brush
- {
- public SolidBrush(System.Drawing.Color color) { }
- public System.Drawing.Color Color { get { throw null; } set { } }
- public override object Clone() { throw null; }
- protected override void Dispose(bool disposing) { }
- }
- public enum StringAlignment
- {
- Near = 0,
- Center = 1,
- Far = 2,
- }
- public enum StringDigitSubstitute
- {
- User = 0,
- None = 1,
- National = 2,
- Traditional = 3,
- }
- public sealed partial class StringFormat : System.MarshalByRefObject, System.ICloneable, System.IDisposable
- {
- public StringFormat() { }
- public StringFormat(System.Drawing.StringFormat format) { }
- public StringFormat(System.Drawing.StringFormatFlags options) { }
- public StringFormat(System.Drawing.StringFormatFlags options, int language) { }
- public System.Drawing.StringAlignment Alignment { get { throw null; } set { } }
- public int DigitSubstitutionLanguage { get { throw null; } }
- public System.Drawing.StringDigitSubstitute DigitSubstitutionMethod { get { throw null; } }
- public System.Drawing.StringFormatFlags FormatFlags { get { throw null; } set { } }
- public static System.Drawing.StringFormat GenericDefault { get { throw null; } }
- public static System.Drawing.StringFormat GenericTypographic { get { throw null; } }
- public System.Drawing.Text.HotkeyPrefix HotkeyPrefix { get { throw null; } set { } }
- public System.Drawing.StringAlignment LineAlignment { get { throw null; } set { } }
- public System.Drawing.StringTrimming Trimming { get { throw null; } set { } }
- public object Clone() { throw null; }
- public void Dispose() { }
- ~StringFormat() { }
- public float[] GetTabStops(out float firstTabOffset) { throw null; }
- public void SetDigitSubstitution(int language, System.Drawing.StringDigitSubstitute substitute) { }
- public void SetMeasurableCharacterRanges(System.Drawing.CharacterRange[] ranges) { }
- public void SetTabStops(float firstTabOffset, float[] tabStops) { }
- public override string ToString() { throw null; }
- }
- [System.FlagsAttribute]
- public enum StringFormatFlags
- {
- DirectionRightToLeft = 1,
- DirectionVertical = 2,
- FitBlackBox = 4,
- DisplayFormatControl = 32,
- NoFontFallback = 1024,
- MeasureTrailingSpaces = 2048,
- NoWrap = 4096,
- LineLimit = 8192,
- NoClip = 16384,
- }
- public enum StringTrimming
- {
- None = 0,
- Character = 1,
- Word = 2,
- EllipsisCharacter = 3,
- EllipsisWord = 4,
- EllipsisPath = 5,
- }
- public enum StringUnit
- {
- World = 0,
- Display = 1,
- Pixel = 2,
- Point = 3,
- Inch = 4,
- Document = 5,
- Millimeter = 6,
- Em = 32,
- }
- public static partial class SystemBrushes
- {
- public static System.Drawing.Brush ActiveBorder { get { throw null; } }
- public static System.Drawing.Brush ActiveCaption { get { throw null; } }
- public static System.Drawing.Brush ActiveCaptionText { get { throw null; } }
- public static System.Drawing.Brush AppWorkspace { get { throw null; } }
- public static System.Drawing.Brush ButtonFace { get { throw null; } }
- public static System.Drawing.Brush ButtonHighlight { get { throw null; } }
- public static System.Drawing.Brush ButtonShadow { get { throw null; } }
- public static System.Drawing.Brush Control { get { throw null; } }
- public static System.Drawing.Brush ControlDark { get { throw null; } }
- public static System.Drawing.Brush ControlDarkDark { get { throw null; } }
- public static System.Drawing.Brush ControlLight { get { throw null; } }
- public static System.Drawing.Brush ControlLightLight { get { throw null; } }
- public static System.Drawing.Brush ControlText { get { throw null; } }
- public static System.Drawing.Brush Desktop { get { throw null; } }
- public static System.Drawing.Brush GradientActiveCaption { get { throw null; } }
- public static System.Drawing.Brush GradientInactiveCaption { get { throw null; } }
- public static System.Drawing.Brush GrayText { get { throw null; } }
- public static System.Drawing.Brush Highlight { get { throw null; } }
- public static System.Drawing.Brush HighlightText { get { throw null; } }
- public static System.Drawing.Brush HotTrack { get { throw null; } }
- public static System.Drawing.Brush InactiveBorder { get { throw null; } }
- public static System.Drawing.Brush InactiveCaption { get { throw null; } }
- public static System.Drawing.Brush InactiveCaptionText { get { throw null; } }
- public static System.Drawing.Brush Info { get { throw null; } }
- public static System.Drawing.Brush InfoText { get { throw null; } }
- public static System.Drawing.Brush Menu { get { throw null; } }
- public static System.Drawing.Brush MenuBar { get { throw null; } }
- public static System.Drawing.Brush MenuHighlight { get { throw null; } }
- public static System.Drawing.Brush MenuText { get { throw null; } }
- public static System.Drawing.Brush ScrollBar { get { throw null; } }
- public static System.Drawing.Brush Window { get { throw null; } }
- public static System.Drawing.Brush WindowFrame { get { throw null; } }
- public static System.Drawing.Brush WindowText { get { throw null; } }
- public static System.Drawing.Brush FromSystemColor(System.Drawing.Color c) { throw null; }
- }
- public static partial class SystemFonts
- {
- public static System.Drawing.Font? CaptionFont { get { throw null; } }
- public static System.Drawing.Font DefaultFont { get { throw null; } }
- public static System.Drawing.Font DialogFont { get { throw null; } }
- public static System.Drawing.Font? IconTitleFont { get { throw null; } }
- public static System.Drawing.Font? MenuFont { get { throw null; } }
- public static System.Drawing.Font? MessageBoxFont { get { throw null; } }
- public static System.Drawing.Font? SmallCaptionFont { get { throw null; } }
- public static System.Drawing.Font? StatusFont { get { throw null; } }
- public static System.Drawing.Font? GetFontByName(string systemFontName) { throw null; }
- }
- public static partial class SystemIcons
- {
- public static System.Drawing.Icon Application { get { throw null; } }
- public static System.Drawing.Icon Asterisk { get { throw null; } }
- public static System.Drawing.Icon Error { get { throw null; } }
- public static System.Drawing.Icon Exclamation { get { throw null; } }
- public static System.Drawing.Icon Hand { get { throw null; } }
- public static System.Drawing.Icon Information { get { throw null; } }
- public static System.Drawing.Icon Question { get { throw null; } }
- public static System.Drawing.Icon Shield { get { throw null; } }
- public static System.Drawing.Icon Warning { get { throw null; } }
- public static System.Drawing.Icon WinLogo { get { throw null; } }
- }
- public static partial class SystemPens
- {
- public static System.Drawing.Pen ActiveBorder { get { throw null; } }
- public static System.Drawing.Pen ActiveCaption { get { throw null; } }
- public static System.Drawing.Pen ActiveCaptionText { get { throw null; } }
- public static System.Drawing.Pen AppWorkspace { get { throw null; } }
- public static System.Drawing.Pen ButtonFace { get { throw null; } }
- public static System.Drawing.Pen ButtonHighlight { get { throw null; } }
- public static System.Drawing.Pen ButtonShadow { get { throw null; } }
- public static System.Drawing.Pen Control { get { throw null; } }
- public static System.Drawing.Pen ControlDark { get { throw null; } }
- public static System.Drawing.Pen ControlDarkDark { get { throw null; } }
- public static System.Drawing.Pen ControlLight { get { throw null; } }
- public static System.Drawing.Pen ControlLightLight { get { throw null; } }
- public static System.Drawing.Pen ControlText { get { throw null; } }
- public static System.Drawing.Pen Desktop { get { throw null; } }
- public static System.Drawing.Pen GradientActiveCaption { get { throw null; } }
- public static System.Drawing.Pen GradientInactiveCaption { get { throw null; } }
- public static System.Drawing.Pen GrayText { get { throw null; } }
- public static System.Drawing.Pen Highlight { get { throw null; } }
- public static System.Drawing.Pen HighlightText { get { throw null; } }
- public static System.Drawing.Pen HotTrack { get { throw null; } }
- public static System.Drawing.Pen InactiveBorder { get { throw null; } }
- public static System.Drawing.Pen InactiveCaption { get { throw null; } }
- public static System.Drawing.Pen InactiveCaptionText { get { throw null; } }
- public static System.Drawing.Pen Info { get { throw null; } }
- public static System.Drawing.Pen InfoText { get { throw null; } }
- public static System.Drawing.Pen Menu { get { throw null; } }
- public static System.Drawing.Pen MenuBar { get { throw null; } }
- public static System.Drawing.Pen MenuHighlight { get { throw null; } }
- public static System.Drawing.Pen MenuText { get { throw null; } }
- public static System.Drawing.Pen ScrollBar { get { throw null; } }
- public static System.Drawing.Pen Window { get { throw null; } }
- public static System.Drawing.Pen WindowFrame { get { throw null; } }
- public static System.Drawing.Pen WindowText { get { throw null; } }
- public static System.Drawing.Pen FromSystemColor(System.Drawing.Color c) { throw null; }
- }
- public sealed partial class TextureBrush : System.Drawing.Brush
- {
- public TextureBrush(System.Drawing.Image bitmap) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Drawing2D.WrapMode wrapMode) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Drawing2D.WrapMode wrapMode, System.Drawing.Rectangle dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Drawing2D.WrapMode wrapMode, System.Drawing.RectangleF dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Rectangle dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.Rectangle dstRect, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.RectangleF dstRect) { }
- public TextureBrush(System.Drawing.Image image, System.Drawing.RectangleF dstRect, System.Drawing.Imaging.ImageAttributes? imageAttr) { }
- public System.Drawing.Image Image { get { throw null; } }
- public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
- public System.Drawing.Drawing2D.WrapMode WrapMode { get { throw null; } set { } }
- public override object Clone() { throw null; }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ResetTransform() { }
- public void RotateTransform(float angle) { }
- public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ScaleTransform(float sx, float sy) { }
- public void ScaleTransform(float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void TranslateTransform(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
- }
- [System.AttributeUsageAttribute(System.AttributeTargets.Class)]
- public partial class ToolboxBitmapAttribute : System.Attribute
- {
- public static readonly System.Drawing.ToolboxBitmapAttribute Default;
- public ToolboxBitmapAttribute(string imageFile) { }
- public ToolboxBitmapAttribute(System.Type t) { }
- public ToolboxBitmapAttribute(System.Type t, string name) { }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? value) { throw null; }
- public override int GetHashCode() { throw null; }
- public System.Drawing.Image? GetImage(object? component) { throw null; }
- public System.Drawing.Image? GetImage(object? component, bool large) { throw null; }
- public System.Drawing.Image? GetImage(System.Type type) { throw null; }
- public System.Drawing.Image? GetImage(System.Type type, bool large) { throw null; }
- public System.Drawing.Image? GetImage(System.Type type, string? imgName, bool large) { throw null; }
- public static System.Drawing.Image? GetImageFromResource(System.Type t, string? imageName, bool large) { throw null; }
- }
-}
-namespace System.Drawing.Design
-{
- public sealed partial class CategoryNameCollection : System.Collections.ReadOnlyCollectionBase
- {
- public CategoryNameCollection(System.Drawing.Design.CategoryNameCollection value) { }
- public CategoryNameCollection(string[] value) { }
- public string this[int index] { get { throw null; } }
- public bool Contains(string value) { throw null; }
- public void CopyTo(string[] array, int index) { }
- public int IndexOf(string value) { throw null; }
- }
-}
-namespace System.Drawing.Drawing2D
-{
- public sealed partial class AdjustableArrowCap : System.Drawing.Drawing2D.CustomLineCap
- {
- public AdjustableArrowCap(float width, float height) : base (default(System.Drawing.Drawing2D.GraphicsPath), default(System.Drawing.Drawing2D.GraphicsPath)) { }
- public AdjustableArrowCap(float width, float height, bool isFilled) : base (default(System.Drawing.Drawing2D.GraphicsPath), default(System.Drawing.Drawing2D.GraphicsPath)) { }
- public bool Filled { get { throw null; } set { } }
- public float Height { get { throw null; } set { } }
- public float MiddleInset { get { throw null; } set { } }
- public float Width { get { throw null; } set { } }
- }
- public sealed partial class Blend
- {
- public Blend() { }
- public Blend(int count) { }
- public float[] Factors { get { throw null; } set { } }
- public float[] Positions { get { throw null; } set { } }
- }
- public sealed partial class ColorBlend
- {
- public ColorBlend() { }
- public ColorBlend(int count) { }
- public System.Drawing.Color[] Colors { get { throw null; } set { } }
- public float[] Positions { get { throw null; } set { } }
- }
- public enum CombineMode
- {
- Replace = 0,
- Intersect = 1,
- Union = 2,
- Xor = 3,
- Exclude = 4,
- Complement = 5,
- }
- public enum CompositingMode
- {
- SourceOver = 0,
- SourceCopy = 1,
- }
- public enum CompositingQuality
- {
- Invalid = -1,
- Default = 0,
- HighSpeed = 1,
- HighQuality = 2,
- GammaCorrected = 3,
- AssumeLinear = 4,
- }
- public enum CoordinateSpace
- {
- World = 0,
- Page = 1,
- Device = 2,
- }
- public partial class CustomLineCap : System.MarshalByRefObject, System.ICloneable, System.IDisposable
- {
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath) { }
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap) { }
- public CustomLineCap(System.Drawing.Drawing2D.GraphicsPath? fillPath, System.Drawing.Drawing2D.GraphicsPath? strokePath, System.Drawing.Drawing2D.LineCap baseCap, float baseInset) { }
- public System.Drawing.Drawing2D.LineCap BaseCap { get { throw null; } set { } }
- public float BaseInset { get { throw null; } set { } }
- public System.Drawing.Drawing2D.LineJoin StrokeJoin { get { throw null; } set { } }
- public float WidthScale { get { throw null; } set { } }
- public object Clone() { throw null; }
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- ~CustomLineCap() { }
- public void GetStrokeCaps(out System.Drawing.Drawing2D.LineCap startCap, out System.Drawing.Drawing2D.LineCap endCap) { throw null; }
- public void SetStrokeCaps(System.Drawing.Drawing2D.LineCap startCap, System.Drawing.Drawing2D.LineCap endCap) { }
- }
- public enum DashCap
- {
- Flat = 0,
- Round = 2,
- Triangle = 3,
- }
- public enum DashStyle
- {
- Solid = 0,
- Dash = 1,
- Dot = 2,
- DashDot = 3,
- DashDotDot = 4,
- Custom = 5,
- }
- public enum FillMode
- {
- Alternate = 0,
- Winding = 1,
- }
- public enum FlushIntention
- {
- Flush = 0,
- Sync = 1,
- }
- public sealed partial class GraphicsContainer : System.MarshalByRefObject
- {
- internal GraphicsContainer() { }
- }
- public sealed partial class GraphicsPath : System.MarshalByRefObject, System.ICloneable, System.IDisposable
- {
- public GraphicsPath() { }
- public GraphicsPath(System.Drawing.Drawing2D.FillMode fillMode) { }
- public GraphicsPath(System.Drawing.PointF[] pts, byte[] types) { }
- public GraphicsPath(System.Drawing.PointF[] pts, byte[] types, System.Drawing.Drawing2D.FillMode fillMode) { }
- public GraphicsPath(System.Drawing.Point[] pts, byte[] types) { }
- public GraphicsPath(System.Drawing.Point[] pts, byte[] types, System.Drawing.Drawing2D.FillMode fillMode) { }
- public System.Drawing.Drawing2D.FillMode FillMode { get { throw null; } set { } }
- public System.Drawing.Drawing2D.PathData PathData { get { throw null; } }
- public System.Drawing.PointF[] PathPoints { get { throw null; } }
- public byte[] PathTypes { get { throw null; } }
- public int PointCount { get { throw null; } }
- public void AddArc(System.Drawing.Rectangle rect, float startAngle, float sweepAngle) { }
- public void AddArc(System.Drawing.RectangleF rect, float startAngle, float sweepAngle) { }
- public void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle) { }
- public void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle) { }
- public void AddBezier(System.Drawing.Point pt1, System.Drawing.Point pt2, System.Drawing.Point pt3, System.Drawing.Point pt4) { }
- public void AddBezier(System.Drawing.PointF pt1, System.Drawing.PointF pt2, System.Drawing.PointF pt3, System.Drawing.PointF pt4) { }
- public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { }
- public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { }
- public void AddBeziers(System.Drawing.PointF[] points) { }
- public void AddBeziers(params System.Drawing.Point[] points) { }
- public void AddClosedCurve(System.Drawing.PointF[] points) { }
- public void AddClosedCurve(System.Drawing.PointF[] points, float tension) { }
- public void AddClosedCurve(System.Drawing.Point[] points) { }
- public void AddClosedCurve(System.Drawing.Point[] points, float tension) { }
- public void AddCurve(System.Drawing.PointF[] points) { }
- public void AddCurve(System.Drawing.PointF[] points, int offset, int numberOfSegments, float tension) { }
- public void AddCurve(System.Drawing.PointF[] points, float tension) { }
- public void AddCurve(System.Drawing.Point[] points) { }
- public void AddCurve(System.Drawing.Point[] points, int offset, int numberOfSegments, float tension) { }
- public void AddCurve(System.Drawing.Point[] points, float tension) { }
- public void AddEllipse(System.Drawing.Rectangle rect) { }
- public void AddEllipse(System.Drawing.RectangleF rect) { }
- public void AddEllipse(int x, int y, int width, int height) { }
- public void AddEllipse(float x, float y, float width, float height) { }
- public void AddLine(System.Drawing.Point pt1, System.Drawing.Point pt2) { }
- public void AddLine(System.Drawing.PointF pt1, System.Drawing.PointF pt2) { }
- public void AddLine(int x1, int y1, int x2, int y2) { }
- public void AddLine(float x1, float y1, float x2, float y2) { }
- public void AddLines(System.Drawing.PointF[] points) { }
- public void AddLines(System.Drawing.Point[] points) { }
- public void AddPath(System.Drawing.Drawing2D.GraphicsPath addingPath, bool connect) { }
- public void AddPie(System.Drawing.Rectangle rect, float startAngle, float sweepAngle) { }
- public void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle) { }
- public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle) { }
- public void AddPolygon(System.Drawing.PointF[] points) { }
- public void AddPolygon(System.Drawing.Point[] points) { }
- public void AddRectangle(System.Drawing.Rectangle rect) { }
- public void AddRectangle(System.Drawing.RectangleF rect) { }
- public void AddRectangles(System.Drawing.RectangleF[] rects) { }
- public void AddRectangles(System.Drawing.Rectangle[] rects) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat? format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat? format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat? format) { }
- public void AddString(string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? format) { }
- public void ClearMarkers() { }
- public object Clone() { throw null; }
- public void CloseAllFigures() { }
- public void CloseFigure() { }
- public void Dispose() { }
- ~GraphicsPath() { }
- public void Flatten() { }
- public void Flatten(System.Drawing.Drawing2D.Matrix? matrix) { }
- public void Flatten(System.Drawing.Drawing2D.Matrix? matrix, float flatness) { }
- public System.Drawing.RectangleF GetBounds() { throw null; }
- public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix? matrix) { throw null; }
- public System.Drawing.RectangleF GetBounds(System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Pen? pen) { throw null; }
- public System.Drawing.PointF GetLastPoint() { throw null; }
- public bool IsOutlineVisible(System.Drawing.Point point, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(System.Drawing.Point pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsOutlineVisible(System.Drawing.PointF point, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(System.Drawing.PointF pt, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(int x, int y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen) { throw null; }
- public bool IsOutlineVisible(float x, float y, System.Drawing.Pen pen, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsVisible(System.Drawing.Point point) { throw null; }
- public bool IsVisible(System.Drawing.Point pt, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsVisible(System.Drawing.PointF point) { throw null; }
- public bool IsVisible(System.Drawing.PointF pt, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsVisible(int x, int y) { throw null; }
- public bool IsVisible(int x, int y, System.Drawing.Graphics? graphics) { throw null; }
- public bool IsVisible(float x, float y) { throw null; }
- public bool IsVisible(float x, float y, System.Drawing.Graphics? graphics) { throw null; }
- public void Reset() { }
- public void Reverse() { }
- public void SetMarkers() { }
- public void StartFigure() { }
- public void Transform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode) { }
- public void Warp(System.Drawing.PointF[] destPoints, System.Drawing.RectangleF srcRect, System.Drawing.Drawing2D.Matrix? matrix, System.Drawing.Drawing2D.WarpMode warpMode, float flatness) { }
- public void Widen(System.Drawing.Pen pen) { }
- public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix) { }
- public void Widen(System.Drawing.Pen pen, System.Drawing.Drawing2D.Matrix? matrix, float flatness) { }
- }
- public sealed partial class GraphicsPathIterator : System.MarshalByRefObject, System.IDisposable
- {
- public GraphicsPathIterator(System.Drawing.Drawing2D.GraphicsPath? path) { }
- public int Count { get { throw null; } }
- public int SubpathCount { get { throw null; } }
- public int CopyData(ref System.Drawing.PointF[] points, ref byte[] types, int startIndex, int endIndex) { throw null; }
- public void Dispose() { }
- public int Enumerate(ref System.Drawing.PointF[] points, ref byte[] types) { throw null; }
- ~GraphicsPathIterator() { }
- public bool HasCurve() { throw null; }
- public int NextMarker(System.Drawing.Drawing2D.GraphicsPath path) { throw null; }
- public int NextMarker(out int startIndex, out int endIndex) { throw null; }
- public int NextPathType(out byte pathType, out int startIndex, out int endIndex) { throw null; }
- public int NextSubpath(System.Drawing.Drawing2D.GraphicsPath path, out bool isClosed) { throw null; }
- public int NextSubpath(out int startIndex, out int endIndex, out bool isClosed) { throw null; }
- public void Rewind() { }
- }
- public sealed partial class GraphicsState : System.MarshalByRefObject
- {
- internal GraphicsState() { }
- }
- public sealed partial class HatchBrush : System.Drawing.Brush
- {
- public HatchBrush(System.Drawing.Drawing2D.HatchStyle hatchstyle, System.Drawing.Color foreColor) { }
- public HatchBrush(System.Drawing.Drawing2D.HatchStyle hatchstyle, System.Drawing.Color foreColor, System.Drawing.Color backColor) { }
- public System.Drawing.Color BackgroundColor { get { throw null; } }
- public System.Drawing.Color ForegroundColor { get { throw null; } }
- public System.Drawing.Drawing2D.HatchStyle HatchStyle { get { throw null; } }
- public override object Clone() { throw null; }
- }
- public enum HatchStyle
- {
- Horizontal = 0,
- Min = 0,
- Vertical = 1,
- ForwardDiagonal = 2,
- BackwardDiagonal = 3,
- Cross = 4,
- LargeGrid = 4,
- Max = 4,
- DiagonalCross = 5,
- Percent05 = 6,
- Percent10 = 7,
- Percent20 = 8,
- Percent25 = 9,
- Percent30 = 10,
- Percent40 = 11,
- Percent50 = 12,
- Percent60 = 13,
- Percent70 = 14,
- Percent75 = 15,
- Percent80 = 16,
- Percent90 = 17,
- LightDownwardDiagonal = 18,
- LightUpwardDiagonal = 19,
- DarkDownwardDiagonal = 20,
- DarkUpwardDiagonal = 21,
- WideDownwardDiagonal = 22,
- WideUpwardDiagonal = 23,
- LightVertical = 24,
- LightHorizontal = 25,
- NarrowVertical = 26,
- NarrowHorizontal = 27,
- DarkVertical = 28,
- DarkHorizontal = 29,
- DashedDownwardDiagonal = 30,
- DashedUpwardDiagonal = 31,
- DashedHorizontal = 32,
- DashedVertical = 33,
- SmallConfetti = 34,
- LargeConfetti = 35,
- ZigZag = 36,
- Wave = 37,
- DiagonalBrick = 38,
- HorizontalBrick = 39,
- Weave = 40,
- Plaid = 41,
- Divot = 42,
- DottedGrid = 43,
- DottedDiamond = 44,
- Shingle = 45,
- Trellis = 46,
- Sphere = 47,
- SmallGrid = 48,
- SmallCheckerBoard = 49,
- LargeCheckerBoard = 50,
- OutlinedDiamond = 51,
- SolidDiamond = 52,
- }
- public enum InterpolationMode
- {
- Invalid = -1,
- Default = 0,
- Low = 1,
- High = 2,
- Bilinear = 3,
- Bicubic = 4,
- NearestNeighbor = 5,
- HighQualityBilinear = 6,
- HighQualityBicubic = 7,
- }
- public sealed partial class LinearGradientBrush : System.Drawing.Brush
- {
- public LinearGradientBrush(System.Drawing.Point point1, System.Drawing.Point point2, System.Drawing.Color color1, System.Drawing.Color color2) { }
- public LinearGradientBrush(System.Drawing.PointF point1, System.Drawing.PointF point2, System.Drawing.Color color1, System.Drawing.Color color2) { }
- public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, System.Drawing.Color color2, System.Drawing.Drawing2D.LinearGradientMode linearGradientMode) { }
- public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle) { }
- public LinearGradientBrush(System.Drawing.Rectangle rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle, bool isAngleScaleable) { }
- public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, System.Drawing.Drawing2D.LinearGradientMode linearGradientMode) { }
- public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle) { }
- public LinearGradientBrush(System.Drawing.RectangleF rect, System.Drawing.Color color1, System.Drawing.Color color2, float angle, bool isAngleScaleable) { }
- public System.Drawing.Drawing2D.Blend? Blend { get { throw null; } set { } }
- public bool GammaCorrection { get { throw null; } set { } }
- public System.Drawing.Drawing2D.ColorBlend InterpolationColors { get { throw null; } set { } }
- public System.Drawing.Color[] LinearColors { get { throw null; } set { } }
- public System.Drawing.RectangleF Rectangle { get { throw null; } }
- public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
- public System.Drawing.Drawing2D.WrapMode WrapMode { get { throw null; } set { } }
- public override object Clone() { throw null; }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ResetTransform() { }
- public void RotateTransform(float angle) { }
- public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ScaleTransform(float sx, float sy) { }
- public void ScaleTransform(float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void SetBlendTriangularShape(float focus) { }
- public void SetBlendTriangularShape(float focus, float scale) { }
- public void SetSigmaBellShape(float focus) { }
- public void SetSigmaBellShape(float focus, float scale) { }
- public void TranslateTransform(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
- }
- public enum LinearGradientMode
- {
- Horizontal = 0,
- Vertical = 1,
- ForwardDiagonal = 2,
- BackwardDiagonal = 3,
- }
- public enum LineCap
- {
- Flat = 0,
- Square = 1,
- Round = 2,
- Triangle = 3,
- NoAnchor = 16,
- SquareAnchor = 17,
- RoundAnchor = 18,
- DiamondAnchor = 19,
- ArrowAnchor = 20,
- AnchorMask = 240,
- Custom = 255,
- }
- public enum LineJoin
- {
- Miter = 0,
- Bevel = 1,
- Round = 2,
- MiterClipped = 3,
- }
- public sealed partial class Matrix : System.MarshalByRefObject, System.IDisposable
- {
- public Matrix() { }
- public Matrix(System.Drawing.Rectangle rect, System.Drawing.Point[] plgpts) { }
- public Matrix(System.Drawing.RectangleF rect, System.Drawing.PointF[] plgpts) { }
- public Matrix(float m11, float m12, float m21, float m22, float dx, float dy) { }
- public float[] Elements { get { throw null; } }
- public bool IsIdentity { get { throw null; } }
- public bool IsInvertible { get { throw null; } }
- public float OffsetX { get { throw null; } }
- public float OffsetY { get { throw null; } }
- public System.Drawing.Drawing2D.Matrix Clone() { throw null; }
- public void Dispose() { }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
- ~Matrix() { }
- public override int GetHashCode() { throw null; }
- public void Invert() { }
- public void Multiply(System.Drawing.Drawing2D.Matrix matrix) { }
- public void Multiply(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void Reset() { }
- public void Rotate(float angle) { }
- public void Rotate(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void RotateAt(float angle, System.Drawing.PointF point) { }
- public void RotateAt(float angle, System.Drawing.PointF point, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void Scale(float scaleX, float scaleY) { }
- public void Scale(float scaleX, float scaleY, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void Shear(float shearX, float shearY) { }
- public void Shear(float shearX, float shearY, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void TransformPoints(System.Drawing.PointF[] pts) { }
- public void TransformPoints(System.Drawing.Point[] pts) { }
- public void TransformVectors(System.Drawing.PointF[] pts) { }
- public void TransformVectors(System.Drawing.Point[] pts) { }
- public void Translate(float offsetX, float offsetY) { }
- public void Translate(float offsetX, float offsetY, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void VectorTransformPoints(System.Drawing.Point[] pts) { }
- }
- public enum MatrixOrder
- {
- Prepend = 0,
- Append = 1,
- }
- public sealed partial class PathData
- {
- public PathData() { }
- public System.Drawing.PointF[]? Points { get { throw null; } set { } }
- public byte[]? Types { get { throw null; } set { } }
- }
- public sealed partial class PathGradientBrush : System.Drawing.Brush
- {
- public PathGradientBrush(System.Drawing.Drawing2D.GraphicsPath path) { }
- public PathGradientBrush(System.Drawing.PointF[] points) { }
- public PathGradientBrush(System.Drawing.PointF[] points, System.Drawing.Drawing2D.WrapMode wrapMode) { }
- public PathGradientBrush(System.Drawing.Point[] points) { }
- public PathGradientBrush(System.Drawing.Point[] points, System.Drawing.Drawing2D.WrapMode wrapMode) { }
- public System.Drawing.Drawing2D.Blend Blend { get { throw null; } set { } }
- public System.Drawing.Color CenterColor { get { throw null; } set { } }
- public System.Drawing.PointF CenterPoint { get { throw null; } set { } }
- public System.Drawing.PointF FocusScales { get { throw null; } set { } }
- public System.Drawing.Drawing2D.ColorBlend InterpolationColors { get { throw null; } set { } }
- public System.Drawing.RectangleF Rectangle { get { throw null; } }
- public System.Drawing.Color[] SurroundColors { get { throw null; } set { } }
- public System.Drawing.Drawing2D.Matrix Transform { get { throw null; } set { } }
- public System.Drawing.Drawing2D.WrapMode WrapMode { get { throw null; } set { } }
- public override object Clone() { throw null; }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix) { }
- public void MultiplyTransform(System.Drawing.Drawing2D.Matrix matrix, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ResetTransform() { }
- public void RotateTransform(float angle) { }
- public void RotateTransform(float angle, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void ScaleTransform(float sx, float sy) { }
- public void ScaleTransform(float sx, float sy, System.Drawing.Drawing2D.MatrixOrder order) { }
- public void SetBlendTriangularShape(float focus) { }
- public void SetBlendTriangularShape(float focus, float scale) { }
- public void SetSigmaBellShape(float focus) { }
- public void SetSigmaBellShape(float focus, float scale) { }
- public void TranslateTransform(float dx, float dy) { }
- public void TranslateTransform(float dx, float dy, System.Drawing.Drawing2D.MatrixOrder order) { }
- }
- public enum PathPointType
- {
- Start = 0,
- Line = 1,
- Bezier = 3,
- Bezier3 = 3,
- PathTypeMask = 7,
- DashMode = 16,
- PathMarker = 32,
- CloseSubpath = 128,
- }
- public enum PenAlignment
- {
- Center = 0,
- Inset = 1,
- Outset = 2,
- Left = 3,
- Right = 4,
- }
- public enum PenType
- {
- SolidColor = 0,
- HatchFill = 1,
- TextureFill = 2,
- PathGradient = 3,
- LinearGradient = 4,
- }
- public enum PixelOffsetMode
- {
- Invalid = -1,
- Default = 0,
- HighSpeed = 1,
- HighQuality = 2,
- None = 3,
- Half = 4,
- }
- public enum QualityMode
- {
- Invalid = -1,
- Default = 0,
- Low = 1,
- High = 2,
- }
- public sealed partial class RegionData
- {
- internal RegionData() { }
- public byte[] Data { get { throw null; } set { } }
- }
- public enum SmoothingMode
- {
- Invalid = -1,
- Default = 0,
- HighSpeed = 1,
- HighQuality = 2,
- None = 3,
- AntiAlias = 4,
- }
- public enum WarpMode
- {
- Perspective = 0,
- Bilinear = 1,
- }
- public enum WrapMode
- {
- Tile = 0,
- TileFlipX = 1,
- TileFlipY = 2,
- TileFlipXY = 3,
- Clamp = 4,
- }
-}
-namespace System.Drawing.Imaging
-{
- public sealed partial class BitmapData
- {
- public BitmapData() { }
- public int Height { get { throw null; } set { } }
- public System.Drawing.Imaging.PixelFormat PixelFormat { get { throw null; } set { } }
- public int Reserved { get { throw null; } set { } }
- public System.IntPtr Scan0 { get { throw null; } set { } }
- public int Stride { get { throw null; } set { } }
- public int Width { get { throw null; } set { } }
- }
- public enum ColorAdjustType
- {
- Default = 0,
- Bitmap = 1,
- Brush = 2,
- Pen = 3,
- Text = 4,
- Count = 5,
- Any = 6,
- }
- public enum ColorChannelFlag
- {
- ColorChannelC = 0,
- ColorChannelM = 1,
- ColorChannelY = 2,
- ColorChannelK = 3,
- ColorChannelLast = 4,
- }
- public sealed partial class ColorMap
- {
- public ColorMap() { }
- public System.Drawing.Color NewColor { get { throw null; } set { } }
- public System.Drawing.Color OldColor { get { throw null; } set { } }
- }
- public enum ColorMapType
- {
- Default = 0,
- Brush = 1,
- }
- public sealed partial class ColorMatrix
- {
- public ColorMatrix() { }
- [System.CLSCompliantAttribute(false)]
- public ColorMatrix(float[][] newColorMatrix) { }
- public float this[int row, int column] { get { throw null; } set { } }
- public float Matrix00 { get { throw null; } set { } }
- public float Matrix01 { get { throw null; } set { } }
- public float Matrix02 { get { throw null; } set { } }
- public float Matrix03 { get { throw null; } set { } }
- public float Matrix04 { get { throw null; } set { } }
- public float Matrix10 { get { throw null; } set { } }
- public float Matrix11 { get { throw null; } set { } }
- public float Matrix12 { get { throw null; } set { } }
- public float Matrix13 { get { throw null; } set { } }
- public float Matrix14 { get { throw null; } set { } }
- public float Matrix20 { get { throw null; } set { } }
- public float Matrix21 { get { throw null; } set { } }
- public float Matrix22 { get { throw null; } set { } }
- public float Matrix23 { get { throw null; } set { } }
- public float Matrix24 { get { throw null; } set { } }
- public float Matrix30 { get { throw null; } set { } }
- public float Matrix31 { get { throw null; } set { } }
- public float Matrix32 { get { throw null; } set { } }
- public float Matrix33 { get { throw null; } set { } }
- public float Matrix34 { get { throw null; } set { } }
- public float Matrix40 { get { throw null; } set { } }
- public float Matrix41 { get { throw null; } set { } }
- public float Matrix42 { get { throw null; } set { } }
- public float Matrix43 { get { throw null; } set { } }
- public float Matrix44 { get { throw null; } set { } }
- }
- public enum ColorMatrixFlag
- {
- Default = 0,
- SkipGrays = 1,
- AltGrays = 2,
- }
- public enum ColorMode
- {
- Argb32Mode = 0,
- Argb64Mode = 1,
- }
- public sealed partial class ColorPalette
- {
- internal ColorPalette() { }
- public System.Drawing.Color[] Entries { get { throw null; } }
- public int Flags { get { throw null; } }
- }
- public enum EmfPlusRecordType
- {
- EmfHeader = 1,
- EmfMin = 1,
- EmfPolyBezier = 2,
- EmfPolygon = 3,
- EmfPolyline = 4,
- EmfPolyBezierTo = 5,
- EmfPolyLineTo = 6,
- EmfPolyPolyline = 7,
- EmfPolyPolygon = 8,
- EmfSetWindowExtEx = 9,
- EmfSetWindowOrgEx = 10,
- EmfSetViewportExtEx = 11,
- EmfSetViewportOrgEx = 12,
- EmfSetBrushOrgEx = 13,
- EmfEof = 14,
- EmfSetPixelV = 15,
- EmfSetMapperFlags = 16,
- EmfSetMapMode = 17,
- EmfSetBkMode = 18,
- EmfSetPolyFillMode = 19,
- EmfSetROP2 = 20,
- EmfSetStretchBltMode = 21,
- EmfSetTextAlign = 22,
- EmfSetColorAdjustment = 23,
- EmfSetTextColor = 24,
- EmfSetBkColor = 25,
- EmfOffsetClipRgn = 26,
- EmfMoveToEx = 27,
- EmfSetMetaRgn = 28,
- EmfExcludeClipRect = 29,
- EmfIntersectClipRect = 30,
- EmfScaleViewportExtEx = 31,
- EmfScaleWindowExtEx = 32,
- EmfSaveDC = 33,
- EmfRestoreDC = 34,
- EmfSetWorldTransform = 35,
- EmfModifyWorldTransform = 36,
- EmfSelectObject = 37,
- EmfCreatePen = 38,
- EmfCreateBrushIndirect = 39,
- EmfDeleteObject = 40,
- EmfAngleArc = 41,
- EmfEllipse = 42,
- EmfRectangle = 43,
- EmfRoundRect = 44,
- EmfRoundArc = 45,
- EmfChord = 46,
- EmfPie = 47,
- EmfSelectPalette = 48,
- EmfCreatePalette = 49,
- EmfSetPaletteEntries = 50,
- EmfResizePalette = 51,
- EmfRealizePalette = 52,
- EmfExtFloodFill = 53,
- EmfLineTo = 54,
- EmfArcTo = 55,
- EmfPolyDraw = 56,
- EmfSetArcDirection = 57,
- EmfSetMiterLimit = 58,
- EmfBeginPath = 59,
- EmfEndPath = 60,
- EmfCloseFigure = 61,
- EmfFillPath = 62,
- EmfStrokeAndFillPath = 63,
- EmfStrokePath = 64,
- EmfFlattenPath = 65,
- EmfWidenPath = 66,
- EmfSelectClipPath = 67,
- EmfAbortPath = 68,
- EmfReserved069 = 69,
- EmfGdiComment = 70,
- EmfFillRgn = 71,
- EmfFrameRgn = 72,
- EmfInvertRgn = 73,
- EmfPaintRgn = 74,
- EmfExtSelectClipRgn = 75,
- EmfBitBlt = 76,
- EmfStretchBlt = 77,
- EmfMaskBlt = 78,
- EmfPlgBlt = 79,
- EmfSetDIBitsToDevice = 80,
- EmfStretchDIBits = 81,
- EmfExtCreateFontIndirect = 82,
- EmfExtTextOutA = 83,
- EmfExtTextOutW = 84,
- EmfPolyBezier16 = 85,
- EmfPolygon16 = 86,
- EmfPolyline16 = 87,
- EmfPolyBezierTo16 = 88,
- EmfPolylineTo16 = 89,
- EmfPolyPolyline16 = 90,
- EmfPolyPolygon16 = 91,
- EmfPolyDraw16 = 92,
- EmfCreateMonoBrush = 93,
- EmfCreateDibPatternBrushPt = 94,
- EmfExtCreatePen = 95,
- EmfPolyTextOutA = 96,
- EmfPolyTextOutW = 97,
- EmfSetIcmMode = 98,
- EmfCreateColorSpace = 99,
- EmfSetColorSpace = 100,
- EmfDeleteColorSpace = 101,
- EmfGlsRecord = 102,
- EmfGlsBoundedRecord = 103,
- EmfPixelFormat = 104,
- EmfDrawEscape = 105,
- EmfExtEscape = 106,
- EmfStartDoc = 107,
- EmfSmallTextOut = 108,
- EmfForceUfiMapping = 109,
- EmfNamedEscpae = 110,
- EmfColorCorrectPalette = 111,
- EmfSetIcmProfileA = 112,
- EmfSetIcmProfileW = 113,
- EmfAlphaBlend = 114,
- EmfSetLayout = 115,
- EmfTransparentBlt = 116,
- EmfReserved117 = 117,
- EmfGradientFill = 118,
- EmfSetLinkedUfis = 119,
- EmfSetTextJustification = 120,
- EmfColorMatchToTargetW = 121,
- EmfCreateColorSpaceW = 122,
- EmfMax = 122,
- EmfPlusRecordBase = 16384,
- Invalid = 16384,
- Header = 16385,
- Min = 16385,
- EndOfFile = 16386,
- Comment = 16387,
- GetDC = 16388,
- MultiFormatStart = 16389,
- MultiFormatSection = 16390,
- MultiFormatEnd = 16391,
- Object = 16392,
- Clear = 16393,
- FillRects = 16394,
- DrawRects = 16395,
- FillPolygon = 16396,
- DrawLines = 16397,
- FillEllipse = 16398,
- DrawEllipse = 16399,
- FillPie = 16400,
- DrawPie = 16401,
- DrawArc = 16402,
- FillRegion = 16403,
- FillPath = 16404,
- DrawPath = 16405,
- FillClosedCurve = 16406,
- DrawClosedCurve = 16407,
- DrawCurve = 16408,
- DrawBeziers = 16409,
- DrawImage = 16410,
- DrawImagePoints = 16411,
- DrawString = 16412,
- SetRenderingOrigin = 16413,
- SetAntiAliasMode = 16414,
- SetTextRenderingHint = 16415,
- SetTextContrast = 16416,
- SetInterpolationMode = 16417,
- SetPixelOffsetMode = 16418,
- SetCompositingMode = 16419,
- SetCompositingQuality = 16420,
- Save = 16421,
- Restore = 16422,
- BeginContainer = 16423,
- BeginContainerNoParams = 16424,
- EndContainer = 16425,
- SetWorldTransform = 16426,
- ResetWorldTransform = 16427,
- MultiplyWorldTransform = 16428,
- TranslateWorldTransform = 16429,
- ScaleWorldTransform = 16430,
- RotateWorldTransform = 16431,
- SetPageTransform = 16432,
- ResetClip = 16433,
- SetClipRect = 16434,
- SetClipPath = 16435,
- SetClipRegion = 16436,
- OffsetClip = 16437,
- DrawDriverString = 16438,
- Max = 16438,
- Total = 16439,
- WmfRecordBase = 65536,
- WmfSaveDC = 65566,
- WmfRealizePalette = 65589,
- WmfSetPalEntries = 65591,
- WmfCreatePalette = 65783,
- WmfSetBkMode = 65794,
- WmfSetMapMode = 65795,
- WmfSetROP2 = 65796,
- WmfSetRelAbs = 65797,
- WmfSetPolyFillMode = 65798,
- WmfSetStretchBltMode = 65799,
- WmfSetTextCharExtra = 65800,
- WmfRestoreDC = 65831,
- WmfInvertRegion = 65834,
- WmfPaintRegion = 65835,
- WmfSelectClipRegion = 65836,
- WmfSelectObject = 65837,
- WmfSetTextAlign = 65838,
- WmfResizePalette = 65849,
- WmfDibCreatePatternBrush = 65858,
- WmfSetLayout = 65865,
- WmfDeleteObject = 66032,
- WmfCreatePatternBrush = 66041,
- WmfSetBkColor = 66049,
- WmfSetTextColor = 66057,
- WmfSetTextJustification = 66058,
- WmfSetWindowOrg = 66059,
- WmfSetWindowExt = 66060,
- WmfSetViewportOrg = 66061,
- WmfSetViewportExt = 66062,
- WmfOffsetWindowOrg = 66063,
- WmfOffsetViewportOrg = 66065,
- WmfLineTo = 66067,
- WmfMoveTo = 66068,
- WmfOffsetCilpRgn = 66080,
- WmfFillRegion = 66088,
- WmfSetMapperFlags = 66097,
- WmfSelectPalette = 66100,
- WmfCreatePenIndirect = 66298,
- WmfCreateFontIndirect = 66299,
- WmfCreateBrushIndirect = 66300,
- WmfPolygon = 66340,
- WmfPolyline = 66341,
- WmfScaleWindowExt = 66576,
- WmfScaleViewportExt = 66578,
- WmfExcludeClipRect = 66581,
- WmfIntersectClipRect = 66582,
- WmfEllipse = 66584,
- WmfFloodFill = 66585,
- WmfRectangle = 66587,
- WmfSetPixel = 66591,
- WmfFrameRegion = 66601,
- WmfAnimatePalette = 66614,
- WmfTextOut = 66849,
- WmfPolyPolygon = 66872,
- WmfExtFloodFill = 66888,
- WmfRoundRect = 67100,
- WmfPatBlt = 67101,
- WmfEscape = 67110,
- WmfCreateRegion = 67327,
- WmfArc = 67607,
- WmfPie = 67610,
- WmfChord = 67632,
- WmfBitBlt = 67874,
- WmfDibBitBlt = 67904,
- WmfExtTextOut = 68146,
- WmfStretchBlt = 68387,
- WmfDibStretchBlt = 68417,
- WmfSetDibToDev = 68915,
- WmfStretchDib = 69443,
- }
- public enum EmfType
- {
- EmfOnly = 3,
- EmfPlusOnly = 4,
- EmfPlusDual = 5,
- }
- public sealed partial class Encoder
- {
- public static readonly System.Drawing.Imaging.Encoder ChrominanceTable;
- public static readonly System.Drawing.Imaging.Encoder ColorDepth;
- public static readonly System.Drawing.Imaging.Encoder ColorSpace;
- public static readonly System.Drawing.Imaging.Encoder Compression;
- public static readonly System.Drawing.Imaging.Encoder ImageItems;
- public static readonly System.Drawing.Imaging.Encoder LuminanceTable;
- public static readonly System.Drawing.Imaging.Encoder Quality;
- public static readonly System.Drawing.Imaging.Encoder RenderMethod;
- public static readonly System.Drawing.Imaging.Encoder SaveAsCmyk;
- public static readonly System.Drawing.Imaging.Encoder SaveFlag;
- public static readonly System.Drawing.Imaging.Encoder ScanMethod;
- public static readonly System.Drawing.Imaging.Encoder Transformation;
- public static readonly System.Drawing.Imaging.Encoder Version;
- public Encoder(System.Guid guid) { }
- public System.Guid Guid { get { throw null; } }
- }
- public sealed partial class EncoderParameter : System.IDisposable
- {
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, byte value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, byte value, bool undefined) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, byte[] value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, byte[] value, bool undefined) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, short value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, short[] value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int numberValues, System.Drawing.Imaging.EncoderParameterValueType type, System.IntPtr value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int numerator, int denominator) { }
- [System.ObsoleteAttribute("This constructor has been deprecated. Use EncoderParameter(Encoder encoder, int numberValues, EncoderParameterValueType type, IntPtr value) instead.")]
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int NumberOfValues, int Type, int Value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int numerator1, int demoninator1, int numerator2, int demoninator2) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int[] numerator, int[] denominator) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, int[] numerator1, int[] denominator1, int[] numerator2, int[] denominator2) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, long value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, long rangebegin, long rangeend) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, long[] value) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, long[] rangebegin, long[] rangeend) { }
- public EncoderParameter(System.Drawing.Imaging.Encoder encoder, string value) { }
- public System.Drawing.Imaging.Encoder Encoder { get { throw null; } set { } }
- public int NumberOfValues { get { throw null; } }
- public System.Drawing.Imaging.EncoderParameterValueType Type { get { throw null; } }
- public System.Drawing.Imaging.EncoderParameterValueType ValueType { get { throw null; } }
- public void Dispose() { }
- ~EncoderParameter() { }
- }
- public sealed partial class EncoderParameters : System.IDisposable
- {
- public EncoderParameters() { }
- public EncoderParameters(int count) { }
- public System.Drawing.Imaging.EncoderParameter[] Param { get { throw null; } set { } }
- public void Dispose() { }
- }
- public enum EncoderParameterValueType
- {
- ValueTypeByte = 1,
- ValueTypeAscii = 2,
- ValueTypeShort = 3,
- ValueTypeLong = 4,
- ValueTypeRational = 5,
- ValueTypeLongRange = 6,
- ValueTypeUndefined = 7,
- ValueTypeRationalRange = 8,
- ValueTypePointer = 9,
- }
- public enum EncoderValue
- {
- ColorTypeCMYK = 0,
- ColorTypeYCCK = 1,
- CompressionLZW = 2,
- CompressionCCITT3 = 3,
- CompressionCCITT4 = 4,
- CompressionRle = 5,
- CompressionNone = 6,
- ScanMethodInterlaced = 7,
- ScanMethodNonInterlaced = 8,
- VersionGif87 = 9,
- VersionGif89 = 10,
- RenderProgressive = 11,
- RenderNonProgressive = 12,
- TransformRotate90 = 13,
- TransformRotate180 = 14,
- TransformRotate270 = 15,
- TransformFlipHorizontal = 16,
- TransformFlipVertical = 17,
- MultiFrame = 18,
- LastFrame = 19,
- Flush = 20,
- FrameDimensionTime = 21,
- FrameDimensionResolution = 22,
- FrameDimensionPage = 23,
- }
- public sealed partial class FrameDimension
- {
- public FrameDimension(System.Guid guid) { }
- public System.Guid Guid { get { throw null; } }
- public static System.Drawing.Imaging.FrameDimension Page { get { throw null; } }
- public static System.Drawing.Imaging.FrameDimension Resolution { get { throw null; } }
- public static System.Drawing.Imaging.FrameDimension Time { get { throw null; } }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; }
- public override int GetHashCode() { throw null; }
- public override string ToString() { throw null; }
- }
- public sealed partial class ImageAttributes : System.ICloneable, System.IDisposable
- {
- public ImageAttributes() { }
- public void ClearBrushRemapTable() { }
- public void ClearColorKey() { }
- public void ClearColorKey(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearColorMatrix() { }
- public void ClearColorMatrix(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearGamma() { }
- public void ClearGamma(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearNoOp() { }
- public void ClearNoOp(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearOutputChannel() { }
- public void ClearOutputChannel(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearOutputChannelColorProfile() { }
- public void ClearOutputChannelColorProfile(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearRemapTable() { }
- public void ClearRemapTable(System.Drawing.Imaging.ColorAdjustType type) { }
- public void ClearThreshold() { }
- public void ClearThreshold(System.Drawing.Imaging.ColorAdjustType type) { }
- public object Clone() { throw null; }
- public void Dispose() { }
- ~ImageAttributes() { }
- public void GetAdjustedPalette(System.Drawing.Imaging.ColorPalette palette, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetBrushRemapTable(System.Drawing.Imaging.ColorMap[] map) { }
- public void SetColorKey(System.Drawing.Color colorLow, System.Drawing.Color colorHigh) { }
- public void SetColorKey(System.Drawing.Color colorLow, System.Drawing.Color colorHigh, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix, System.Drawing.Imaging.ColorMatrixFlag flags) { }
- public void SetColorMatrices(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrix? grayMatrix, System.Drawing.Imaging.ColorMatrixFlag mode, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix) { }
- public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrixFlag flags) { }
- public void SetColorMatrix(System.Drawing.Imaging.ColorMatrix newColorMatrix, System.Drawing.Imaging.ColorMatrixFlag mode, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetGamma(float gamma) { }
- public void SetGamma(float gamma, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetNoOp() { }
- public void SetNoOp(System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetOutputChannel(System.Drawing.Imaging.ColorChannelFlag flags) { }
- public void SetOutputChannel(System.Drawing.Imaging.ColorChannelFlag flags, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetOutputChannelColorProfile(string colorProfileFilename) { }
- public void SetOutputChannelColorProfile(string colorProfileFilename, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetRemapTable(System.Drawing.Imaging.ColorMap[] map) { }
- public void SetRemapTable(System.Drawing.Imaging.ColorMap[] map, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetThreshold(float threshold) { }
- public void SetThreshold(float threshold, System.Drawing.Imaging.ColorAdjustType type) { }
- public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode) { }
- public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color) { }
- public void SetWrapMode(System.Drawing.Drawing2D.WrapMode mode, System.Drawing.Color color, bool clamp) { }
- }
- [System.FlagsAttribute]
- public enum ImageCodecFlags
- {
- Encoder = 1,
- Decoder = 2,
- SupportBitmap = 4,
- SupportVector = 8,
- SeekableEncode = 16,
- BlockingDecode = 32,
- Builtin = 65536,
- System = 131072,
- User = 262144,
- }
- public sealed partial class ImageCodecInfo
- {
- internal ImageCodecInfo() { }
- public System.Guid Clsid { get { throw null; } set { } }
- public string? CodecName { get { throw null; } set { } }
- public string? DllName { get { throw null; } set { } }
- public string? FilenameExtension { get { throw null; } set { } }
- public System.Drawing.Imaging.ImageCodecFlags Flags { get { throw null; } set { } }
- public string? FormatDescription { get { throw null; } set { } }
- public System.Guid FormatID { get { throw null; } set { } }
- public string? MimeType { get { throw null; } set { } }
- [System.CLSCompliantAttribute(false)]
- public byte[][]? SignatureMasks { get { throw null; } set { } }
- [System.CLSCompliantAttribute(false)]
- public byte[][]? SignaturePatterns { get { throw null; } set { } }
- public int Version { get { throw null; } set { } }
- public static System.Drawing.Imaging.ImageCodecInfo[] GetImageDecoders() { throw null; }
- public static System.Drawing.Imaging.ImageCodecInfo[] GetImageEncoders() { throw null; }
- }
- [System.FlagsAttribute]
- public enum ImageFlags
- {
- None = 0,
- Scalable = 1,
- HasAlpha = 2,
- HasTranslucent = 4,
- PartiallyScalable = 8,
- ColorSpaceRgb = 16,
- ColorSpaceCmyk = 32,
- ColorSpaceGray = 64,
- ColorSpaceYcbcr = 128,
- ColorSpaceYcck = 256,
- HasRealDpi = 4096,
- HasRealPixelSize = 8192,
- ReadOnly = 65536,
- Caching = 131072,
- }
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.ImageFormatConverter))]
- public sealed partial class ImageFormat
- {
- public ImageFormat(System.Guid guid) { }
- public static System.Drawing.Imaging.ImageFormat Bmp { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Emf { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Exif { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Gif { get { throw null; } }
- public System.Guid Guid { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Icon { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Jpeg { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat MemoryBmp { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Png { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Tiff { get { throw null; } }
- public static System.Drawing.Imaging.ImageFormat Wmf { get { throw null; } }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; }
- public override int GetHashCode() { throw null; }
- public override string ToString() { throw null; }
- }
- public enum ImageLockMode
- {
- ReadOnly = 1,
- WriteOnly = 2,
- ReadWrite = 3,
- UserInputBuffer = 4,
- }
- [System.ComponentModel.EditorAttribute("System.Drawing.Design.MetafileEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed partial class Metafile : System.Drawing.Image
- {
- public Metafile(System.IntPtr henhmetafile, bool deleteEmf) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType emfType) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType emfType, string? description) { }
- public Metafile(System.IntPtr hmetafile, System.Drawing.Imaging.WmfPlaceableFileHeader wmfHeader) { }
- public Metafile(System.IntPtr hmetafile, System.Drawing.Imaging.WmfPlaceableFileHeader wmfHeader, bool deleteWmf) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? desc) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(System.IO.Stream stream) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(System.IO.Stream stream, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(string filename) { }
- public Metafile(string fileName, System.IntPtr referenceHdc) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.Rectangle frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string? description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, System.Drawing.Imaging.EmfType type, string? description) { }
- public Metafile(string fileName, System.IntPtr referenceHdc, System.Drawing.RectangleF frameRect, System.Drawing.Imaging.MetafileFrameUnit frameUnit, string? desc) { }
- public System.IntPtr GetHenhmetafile() { throw null; }
- public System.Drawing.Imaging.MetafileHeader GetMetafileHeader() { throw null; }
- public static System.Drawing.Imaging.MetafileHeader GetMetafileHeader(System.IntPtr henhmetafile) { throw null; }
- public static System.Drawing.Imaging.MetafileHeader GetMetafileHeader(System.IntPtr hmetafile, System.Drawing.Imaging.WmfPlaceableFileHeader wmfHeader) { throw null; }
- public static System.Drawing.Imaging.MetafileHeader GetMetafileHeader(System.IO.Stream stream) { throw null; }
- public static System.Drawing.Imaging.MetafileHeader GetMetafileHeader(string fileName) { throw null; }
- public void PlayRecord(System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, byte[] data) { }
- }
- public enum MetafileFrameUnit
- {
- Pixel = 2,
- Point = 3,
- Inch = 4,
- Document = 5,
- Millimeter = 6,
- GdiCompatible = 7,
- }
- public sealed partial class MetafileHeader
- {
- internal MetafileHeader() { }
- public System.Drawing.Rectangle Bounds { get { throw null; } }
- public float DpiX { get { throw null; } }
- public float DpiY { get { throw null; } }
- public int EmfPlusHeaderSize { get { throw null; } }
- public int LogicalDpiX { get { throw null; } }
- public int LogicalDpiY { get { throw null; } }
- public int MetafileSize { get { throw null; } }
- public System.Drawing.Imaging.MetafileType Type { get { throw null; } }
- public int Version { get { throw null; } }
- public System.Drawing.Imaging.MetaHeader WmfHeader { get { throw null; } }
- public bool IsDisplay() { throw null; }
- public bool IsEmf() { throw null; }
- public bool IsEmfOrEmfPlus() { throw null; }
- public bool IsEmfPlus() { throw null; }
- public bool IsEmfPlusDual() { throw null; }
- public bool IsEmfPlusOnly() { throw null; }
- public bool IsWmf() { throw null; }
- public bool IsWmfPlaceable() { throw null; }
- }
- public enum MetafileType
- {
- Invalid = 0,
- Wmf = 1,
- WmfPlaceable = 2,
- Emf = 3,
- EmfPlusOnly = 4,
- EmfPlusDual = 5,
- }
- public sealed partial class MetaHeader
- {
- public MetaHeader() { }
- public short HeaderSize { get { throw null; } set { } }
- public int MaxRecord { get { throw null; } set { } }
- public short NoObjects { get { throw null; } set { } }
- public short NoParameters { get { throw null; } set { } }
- public int Size { get { throw null; } set { } }
- public short Type { get { throw null; } set { } }
- public short Version { get { throw null; } set { } }
- }
- [System.FlagsAttribute]
- public enum PaletteFlags
- {
- HasAlpha = 1,
- GrayScale = 2,
- Halftone = 4,
- }
- public enum PixelFormat
- {
- DontCare = 0,
- Undefined = 0,
- Max = 15,
- Indexed = 65536,
- Gdi = 131072,
- Format16bppRgb555 = 135173,
- Format16bppRgb565 = 135174,
- Format24bppRgb = 137224,
- Format32bppRgb = 139273,
- Format1bppIndexed = 196865,
- Format4bppIndexed = 197634,
- Format8bppIndexed = 198659,
- Alpha = 262144,
- Format16bppArgb1555 = 397319,
- PAlpha = 524288,
- Format32bppPArgb = 925707,
- Extended = 1048576,
- Format16bppGrayScale = 1052676,
- Format48bppRgb = 1060876,
- Format64bppPArgb = 1851406,
- Canonical = 2097152,
- Format32bppArgb = 2498570,
- Format64bppArgb = 3424269,
- }
- public delegate void PlayRecordCallback(System.Drawing.Imaging.EmfPlusRecordType recordType, int flags, int dataSize, System.IntPtr recordData);
- public sealed partial class PropertyItem
- {
- internal PropertyItem() { }
- public int Id { get { throw null; } set { } }
- public int Len { get { throw null; } set { } }
- public short Type { get { throw null; } set { } }
- public byte[]? Value { get { throw null; } set { } }
- }
- public sealed partial class WmfPlaceableFileHeader
- {
- public WmfPlaceableFileHeader() { }
- public short BboxBottom { get { throw null; } set { } }
- public short BboxLeft { get { throw null; } set { } }
- public short BboxRight { get { throw null; } set { } }
- public short BboxTop { get { throw null; } set { } }
- public short Checksum { get { throw null; } set { } }
- public short Hmf { get { throw null; } set { } }
- public short Inch { get { throw null; } set { } }
- public int Key { get { throw null; } set { } }
- public int Reserved { get { throw null; } set { } }
- }
-}
-namespace System.Drawing.Printing
-{
- public enum Duplex
- {
- Default = -1,
- Simplex = 1,
- Vertical = 2,
- Horizontal = 3,
- }
- public partial class InvalidPrinterException : System.SystemException
- {
- public InvalidPrinterException(System.Drawing.Printing.PrinterSettings settings) { }
- protected InvalidPrinterException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- }
- [System.ComponentModel.TypeConverterAttribute(typeof(System.Drawing.Printing.MarginsConverter))]
- public partial class Margins : System.ICloneable
- {
- public Margins() { }
- public Margins(int left, int right, int top, int bottom) { }
- public int Bottom { get { throw null; } set { } }
- public int Left { get { throw null; } set { } }
- public int Right { get { throw null; } set { } }
- public int Top { get { throw null; } set { } }
- public object Clone() { throw null; }
- public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; }
- public override int GetHashCode() { throw null; }
- public static bool operator ==(System.Drawing.Printing.Margins? m1, System.Drawing.Printing.Margins? m2) { throw null; }
- public static bool operator !=(System.Drawing.Printing.Margins? m1, System.Drawing.Printing.Margins? m2) { throw null; }
- public override string ToString() { throw null; }
- }
- public partial class MarginsConverter : System.ComponentModel.ExpandableObjectConverter
- {
- public MarginsConverter() { }
- public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Type sourceType) { throw null; }
- public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext? context, [System.Diagnostics.CodeAnalysis.NotNullWhen(true)] System.Type? destinationType) { throw null; }
- public override object? ConvertFrom(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value) { throw null; }
- public override object? ConvertTo(System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object? value, System.Type destinationType) { throw null; }
- public override object CreateInstance(System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues) { throw null; }
- public override bool GetCreateInstanceSupported(System.ComponentModel.ITypeDescriptorContext? context) { throw null; }
- }
- public partial class PageSettings : System.ICloneable
- {
- public PageSettings() { }
- public PageSettings(System.Drawing.Printing.PrinterSettings printerSettings) { }
- public System.Drawing.Rectangle Bounds { get { throw null; } }
- public bool Color { get { throw null; } set { } }
- public float HardMarginX { get { throw null; } }
- public float HardMarginY { get { throw null; } }
- public bool Landscape { get { throw null; } set { } }
- public System.Drawing.Printing.Margins Margins { get { throw null; } set { } }
- public System.Drawing.Printing.PaperSize PaperSize { get { throw null; } set { } }
- public System.Drawing.Printing.PaperSource PaperSource { get { throw null; } set { } }
- public System.Drawing.RectangleF PrintableArea { get { throw null; } }
- public System.Drawing.Printing.PrinterResolution PrinterResolution { get { throw null; } set { } }
- public System.Drawing.Printing.PrinterSettings PrinterSettings { get { throw null; } set { } }
- public object Clone() { throw null; }
- public void CopyToHdevmode(System.IntPtr hdevmode) { }
- public void SetHdevmode(System.IntPtr hdevmode) { }
- public override string ToString() { throw null; }
- }
- public enum PaperKind
- {
- Custom = 0,
- Letter = 1,
- LetterSmall = 2,
- Tabloid = 3,
- Ledger = 4,
- Legal = 5,
- Statement = 6,
- Executive = 7,
- A3 = 8,
- A4 = 9,
- A4Small = 10,
- A5 = 11,
- B4 = 12,
- B5 = 13,
- Folio = 14,
- Quarto = 15,
- Standard10x14 = 16,
- Standard11x17 = 17,
- Note = 18,
- Number9Envelope = 19,
- Number10Envelope = 20,
- Number11Envelope = 21,
- Number12Envelope = 22,
- Number14Envelope = 23,
- CSheet = 24,
- DSheet = 25,
- ESheet = 26,
- DLEnvelope = 27,
- C5Envelope = 28,
- C3Envelope = 29,
- C4Envelope = 30,
- C6Envelope = 31,
- C65Envelope = 32,
- B4Envelope = 33,
- B5Envelope = 34,
- B6Envelope = 35,
- ItalyEnvelope = 36,
- MonarchEnvelope = 37,
- PersonalEnvelope = 38,
- USStandardFanfold = 39,
- GermanStandardFanfold = 40,
- GermanLegalFanfold = 41,
- IsoB4 = 42,
- JapanesePostcard = 43,
- Standard9x11 = 44,
- Standard10x11 = 45,
- Standard15x11 = 46,
- InviteEnvelope = 47,
- LetterExtra = 50,
- LegalExtra = 51,
- TabloidExtra = 52,
- A4Extra = 53,
- LetterTransverse = 54,
- A4Transverse = 55,
- LetterExtraTransverse = 56,
- APlus = 57,
- BPlus = 58,
- LetterPlus = 59,
- A4Plus = 60,
- A5Transverse = 61,
- B5Transverse = 62,
- A3Extra = 63,
- A5Extra = 64,
- B5Extra = 65,
- A2 = 66,
- A3Transverse = 67,
- A3ExtraTransverse = 68,
- JapaneseDoublePostcard = 69,
- A6 = 70,
- JapaneseEnvelopeKakuNumber2 = 71,
- JapaneseEnvelopeKakuNumber3 = 72,
- JapaneseEnvelopeChouNumber3 = 73,
- JapaneseEnvelopeChouNumber4 = 74,
- LetterRotated = 75,
- A3Rotated = 76,
- A4Rotated = 77,
- A5Rotated = 78,
- B4JisRotated = 79,
- B5JisRotated = 80,
- JapanesePostcardRotated = 81,
- JapaneseDoublePostcardRotated = 82,
- A6Rotated = 83,
- JapaneseEnvelopeKakuNumber2Rotated = 84,
- JapaneseEnvelopeKakuNumber3Rotated = 85,
- JapaneseEnvelopeChouNumber3Rotated = 86,
- JapaneseEnvelopeChouNumber4Rotated = 87,
- B6Jis = 88,
- B6JisRotated = 89,
- Standard12x11 = 90,
- JapaneseEnvelopeYouNumber4 = 91,
- JapaneseEnvelopeYouNumber4Rotated = 92,
- Prc16K = 93,
- Prc32K = 94,
- Prc32KBig = 95,
- PrcEnvelopeNumber1 = 96,
- PrcEnvelopeNumber2 = 97,
- PrcEnvelopeNumber3 = 98,
- PrcEnvelopeNumber4 = 99,
- PrcEnvelopeNumber5 = 100,
- PrcEnvelopeNumber6 = 101,
- PrcEnvelopeNumber7 = 102,
- PrcEnvelopeNumber8 = 103,
- PrcEnvelopeNumber9 = 104,
- PrcEnvelopeNumber10 = 105,
- Prc16KRotated = 106,
- Prc32KRotated = 107,
- Prc32KBigRotated = 108,
- PrcEnvelopeNumber1Rotated = 109,
- PrcEnvelopeNumber2Rotated = 110,
- PrcEnvelopeNumber3Rotated = 111,
- PrcEnvelopeNumber4Rotated = 112,
- PrcEnvelopeNumber5Rotated = 113,
- PrcEnvelopeNumber6Rotated = 114,
- PrcEnvelopeNumber7Rotated = 115,
- PrcEnvelopeNumber8Rotated = 116,
- PrcEnvelopeNumber9Rotated = 117,
- PrcEnvelopeNumber10Rotated = 118,
- }
- public partial class PaperSize
- {
- public PaperSize() { }
- public PaperSize(string name, int width, int height) { }
- public int Height { get { throw null; } set { } }
- public System.Drawing.Printing.PaperKind Kind { get { throw null; } }
- public string PaperName { get { throw null; } set { } }
- public int RawKind { get { throw null; } set { } }
- public int Width { get { throw null; } set { } }
- public override string ToString() { throw null; }
- }
- public partial class PaperSource
- {
- public PaperSource() { }
- public System.Drawing.Printing.PaperSourceKind Kind { get { throw null; } }
- public int RawKind { get { throw null; } set { } }
- public string SourceName { get { throw null; } set { } }
- public override string ToString() { throw null; }
- }
- public enum PaperSourceKind
- {
- Upper = 1,
- Lower = 2,
- Middle = 3,
- Manual = 4,
- Envelope = 5,
- ManualFeed = 6,
- AutomaticFeed = 7,
- TractorFeed = 8,
- SmallFormat = 9,
- LargeFormat = 10,
- LargeCapacity = 11,
- Cassette = 14,
- FormSource = 15,
- Custom = 257,
- }
- public sealed partial class PreviewPageInfo
- {
- public PreviewPageInfo(System.Drawing.Image image, System.Drawing.Size physicalSize) { }
- public System.Drawing.Image Image { get { throw null; } }
- public System.Drawing.Size PhysicalSize { get { throw null; } }
- }
- public partial class PreviewPrintController : System.Drawing.Printing.PrintController
- {
- public PreviewPrintController() { }
- public override bool IsPreview { get { throw null; } }
- public virtual bool UseAntiAlias { get { throw null; } set { } }
- public System.Drawing.Printing.PreviewPageInfo[] GetPreviewPageInfo() { throw null; }
- public override void OnEndPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { }
- public override void OnEndPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- public override System.Drawing.Graphics OnStartPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { throw null; }
- public override void OnStartPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- }
- public enum PrintAction
- {
- PrintToFile = 0,
- PrintToPreview = 1,
- PrintToPrinter = 2,
- }
- public abstract partial class PrintController
- {
- protected PrintController() { }
- public virtual bool IsPreview { get { throw null; } }
- public virtual void OnEndPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { }
- public virtual void OnEndPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- public virtual System.Drawing.Graphics? OnStartPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { throw null; }
- public virtual void OnStartPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- }
- [System.ComponentModel.DefaultEventAttribute("PrintPage")]
- [System.ComponentModel.DefaultPropertyAttribute("DocumentName")]
- public partial class PrintDocument : System.ComponentModel.Component
- {
- public PrintDocument() { }
- [System.ComponentModel.BrowsableAttribute(false)]
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public System.Drawing.Printing.PageSettings DefaultPageSettings { get { throw null; } set { } }
- [System.ComponentModel.DefaultValueAttribute("document")]
- public string DocumentName { get { throw null; } set { } }
- [System.ComponentModel.DefaultValueAttribute(false)]
- public bool OriginAtMargins { get { throw null; } set { } }
- [System.ComponentModel.BrowsableAttribute(false)]
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public System.Drawing.Printing.PrintController PrintController { get { throw null; } set { } }
- [System.ComponentModel.BrowsableAttribute(false)]
- [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
- public System.Drawing.Printing.PrinterSettings PrinterSettings { get { throw null; } set { } }
- public event System.Drawing.Printing.PrintEventHandler BeginPrint { add { } remove { } }
- public event System.Drawing.Printing.PrintEventHandler EndPrint { add { } remove { } }
- public event System.Drawing.Printing.PrintPageEventHandler PrintPage { add { } remove { } }
- public event System.Drawing.Printing.QueryPageSettingsEventHandler QueryPageSettings { add { } remove { } }
- protected internal virtual void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) { }
- protected internal virtual void OnEndPrint(System.Drawing.Printing.PrintEventArgs e) { }
- protected internal virtual void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { }
- protected internal virtual void OnQueryPageSettings(System.Drawing.Printing.QueryPageSettingsEventArgs e) { }
- public void Print() { }
- public override string ToString() { throw null; }
- }
- public partial class PrinterResolution
- {
- public PrinterResolution() { }
- public System.Drawing.Printing.PrinterResolutionKind Kind { get { throw null; } set { } }
- public int X { get { throw null; } set { } }
- public int Y { get { throw null; } set { } }
- public override string ToString() { throw null; }
- }
- public enum PrinterResolutionKind
- {
- High = -4,
- Medium = -3,
- Low = -2,
- Draft = -1,
- Custom = 0,
- }
- public partial class PrinterSettings : System.ICloneable
- {
- public PrinterSettings() { }
- public bool CanDuplex { get { throw null; } }
- public bool Collate { get { throw null; } set { } }
- public short Copies { get { throw null; } set { } }
- public System.Drawing.Printing.PageSettings DefaultPageSettings { get { throw null; } }
- public System.Drawing.Printing.Duplex Duplex { get { throw null; } set { } }
- public int FromPage { get { throw null; } set { } }
- public static System.Drawing.Printing.PrinterSettings.StringCollection InstalledPrinters { get { throw null; } }
- public bool IsDefaultPrinter { get { throw null; } }
- public bool IsPlotter { get { throw null; } }
- public bool IsValid { get { throw null; } }
- public int LandscapeAngle { get { throw null; } }
- public int MaximumCopies { get { throw null; } }
- public int MaximumPage { get { throw null; } set { } }
- public int MinimumPage { get { throw null; } set { } }
- public System.Drawing.Printing.PrinterSettings.PaperSizeCollection PaperSizes { get { throw null; } }
- public System.Drawing.Printing.PrinterSettings.PaperSourceCollection PaperSources { get { throw null; } }
- public string PrinterName { get { throw null; } set { } }
- public System.Drawing.Printing.PrinterSettings.PrinterResolutionCollection PrinterResolutions { get { throw null; } }
- public string PrintFileName { get { throw null; } set { } }
- public System.Drawing.Printing.PrintRange PrintRange { get { throw null; } set { } }
- public bool PrintToFile { get { throw null; } set { } }
- public bool SupportsColor { get { throw null; } }
- public int ToPage { get { throw null; } set { } }
- public object Clone() { throw null; }
- public System.Drawing.Graphics CreateMeasurementGraphics() { throw null; }
- public System.Drawing.Graphics CreateMeasurementGraphics(bool honorOriginAtMargins) { throw null; }
- public System.Drawing.Graphics CreateMeasurementGraphics(System.Drawing.Printing.PageSettings pageSettings) { throw null; }
- public System.Drawing.Graphics CreateMeasurementGraphics(System.Drawing.Printing.PageSettings pageSettings, bool honorOriginAtMargins) { throw null; }
- public System.IntPtr GetHdevmode() { throw null; }
- public System.IntPtr GetHdevmode(System.Drawing.Printing.PageSettings pageSettings) { throw null; }
- public System.IntPtr GetHdevnames() { throw null; }
- public bool IsDirectPrintingSupported(System.Drawing.Image image) { throw null; }
- public bool IsDirectPrintingSupported(System.Drawing.Imaging.ImageFormat imageFormat) { throw null; }
- public void SetHdevmode(System.IntPtr hdevmode) { }
- public void SetHdevnames(System.IntPtr hdevnames) { }
- public override string ToString() { throw null; }
- public partial class PaperSizeCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- public PaperSizeCollection(System.Drawing.Printing.PaperSize[] array) { }
- public int Count { get { throw null; } }
- public virtual System.Drawing.Printing.PaperSize this[int index] { get { throw null; } }
- int System.Collections.ICollection.Count { get { throw null; } }
- bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
- object System.Collections.ICollection.SyncRoot { get { throw null; } }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public int Add(System.Drawing.Printing.PaperSize paperSize) { throw null; }
- public void CopyTo(System.Drawing.Printing.PaperSize[] paperSizes, int index) { }
- public System.Collections.IEnumerator GetEnumerator() { throw null; }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
- }
- public partial class PaperSourceCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- public PaperSourceCollection(System.Drawing.Printing.PaperSource[] array) { }
- public int Count { get { throw null; } }
- public virtual System.Drawing.Printing.PaperSource this[int index] { get { throw null; } }
- int System.Collections.ICollection.Count { get { throw null; } }
- bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
- object System.Collections.ICollection.SyncRoot { get { throw null; } }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public int Add(System.Drawing.Printing.PaperSource paperSource) { throw null; }
- public void CopyTo(System.Drawing.Printing.PaperSource[] paperSources, int index) { }
- public System.Collections.IEnumerator GetEnumerator() { throw null; }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
- }
- public partial class PrinterResolutionCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- public PrinterResolutionCollection(System.Drawing.Printing.PrinterResolution[] array) { }
- public int Count { get { throw null; } }
- public virtual System.Drawing.Printing.PrinterResolution this[int index] { get { throw null; } }
- int System.Collections.ICollection.Count { get { throw null; } }
- bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
- object System.Collections.ICollection.SyncRoot { get { throw null; } }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public int Add(System.Drawing.Printing.PrinterResolution printerResolution) { throw null; }
- public void CopyTo(System.Drawing.Printing.PrinterResolution[] printerResolutions, int index) { }
- public System.Collections.IEnumerator GetEnumerator() { throw null; }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
- }
- public partial class StringCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- public StringCollection(string[] array) { }
- public int Count { get { throw null; } }
- public virtual string this[int index] { get { throw null; } }
- int System.Collections.ICollection.Count { get { throw null; } }
- bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
- object System.Collections.ICollection.SyncRoot { get { throw null; } }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public int Add(string value) { throw null; }
- public void CopyTo(string[] strings, int index) { }
- public System.Collections.IEnumerator GetEnumerator() { throw null; }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
- }
- }
- public enum PrinterUnit
- {
- Display = 0,
- ThousandthsOfAnInch = 1,
- HundredthsOfAMillimeter = 2,
- TenthsOfAMillimeter = 3,
- }
- public sealed partial class PrinterUnitConvert
- {
- internal PrinterUnitConvert() { }
- public static double Convert(double value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- public static System.Drawing.Point Convert(System.Drawing.Point value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- public static System.Drawing.Printing.Margins Convert(System.Drawing.Printing.Margins value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- public static System.Drawing.Rectangle Convert(System.Drawing.Rectangle value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- public static System.Drawing.Size Convert(System.Drawing.Size value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- public static int Convert(int value, System.Drawing.Printing.PrinterUnit fromUnit, System.Drawing.Printing.PrinterUnit toUnit) { throw null; }
- }
- public partial class PrintEventArgs : System.ComponentModel.CancelEventArgs
- {
- public PrintEventArgs() { }
- public System.Drawing.Printing.PrintAction PrintAction { get { throw null; } }
- }
- public delegate void PrintEventHandler(object sender, System.Drawing.Printing.PrintEventArgs e);
- public partial class PrintPageEventArgs : System.EventArgs
- {
- public PrintPageEventArgs(System.Drawing.Graphics? graphics, System.Drawing.Rectangle marginBounds, System.Drawing.Rectangle pageBounds, System.Drawing.Printing.PageSettings pageSettings) { }
- public bool Cancel { get { throw null; } set { } }
- public System.Drawing.Graphics? Graphics { get { throw null; } }
- public bool HasMorePages { get { throw null; } set { } }
- public System.Drawing.Rectangle MarginBounds { get { throw null; } }
- public System.Drawing.Rectangle PageBounds { get { throw null; } }
- public System.Drawing.Printing.PageSettings PageSettings { get { throw null; } }
- }
- public delegate void PrintPageEventHandler(object sender, System.Drawing.Printing.PrintPageEventArgs e);
- public enum PrintRange
- {
- AllPages = 0,
- Selection = 1,
- SomePages = 2,
- CurrentPage = 4194304,
- }
- public partial class QueryPageSettingsEventArgs : System.Drawing.Printing.PrintEventArgs
- {
- public QueryPageSettingsEventArgs(System.Drawing.Printing.PageSettings pageSettings) { }
- public System.Drawing.Printing.PageSettings PageSettings { get { throw null; } set { } }
- }
- public delegate void QueryPageSettingsEventHandler(object sender, System.Drawing.Printing.QueryPageSettingsEventArgs e);
- public partial class StandardPrintController : System.Drawing.Printing.PrintController
- {
- public StandardPrintController() { }
- public override void OnEndPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { }
- public override void OnEndPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- public override System.Drawing.Graphics OnStartPage(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintPageEventArgs e) { throw null; }
- public override void OnStartPrint(System.Drawing.Printing.PrintDocument document, System.Drawing.Printing.PrintEventArgs e) { }
- }
-}
-namespace System.Drawing.Text
-{
- public abstract partial class FontCollection : System.IDisposable
- {
- internal FontCollection() { }
- public System.Drawing.FontFamily[] Families { get { throw null; } }
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- ~FontCollection() { }
- }
- public enum GenericFontFamilies
- {
- Serif = 0,
- SansSerif = 1,
- Monospace = 2,
- }
- public enum HotkeyPrefix
- {
- None = 0,
- Show = 1,
- Hide = 2,
- }
- public sealed partial class InstalledFontCollection : System.Drawing.Text.FontCollection
- {
- public InstalledFontCollection() { }
- }
- public sealed partial class PrivateFontCollection : System.Drawing.Text.FontCollection
- {
- public PrivateFontCollection() { }
- public void AddFontFile(string filename) { }
- public void AddMemoryFont(System.IntPtr memory, int length) { }
- protected override void Dispose(bool disposing) { }
- }
- public enum TextRenderingHint
- {
- SystemDefault = 0,
- SingleBitPerPixelGridFit = 1,
- SingleBitPerPixel = 2,
- AntiAliasGridFit = 3,
- AntiAlias = 4,
- ClearTypeGridFit = 5,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.csproj b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.csproj
deleted file mode 100644
index 88c8b34bbf491..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
deleted file mode 100644
index 389223c06e17d..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netcoreapp.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the https://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-namespace System.Drawing
-{
- public partial struct CharacterRange : System.IEquatable
- {
- public bool Equals(System.Drawing.CharacterRange other) { throw null; }
- }
- public sealed partial class Graphics
- {
- public void DrawRectangle(System.Drawing.Pen pen, System.Drawing.RectangleF rect) { }
- public void FillPie(System.Drawing.Brush brush, System.Drawing.RectangleF rect, float startAngle, float sweepAngle) { }
- public System.Numerics.Matrix3x2 TransformElements { get { throw null; } set { } }
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
- [System.ObsoleteAttribute("Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.", DiagnosticId = "SYSLIB0016", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
- public object GetContextInfo() { throw null; }
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public void GetContextInfo(out PointF offset) { throw null; }
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
- [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public void GetContextInfo(out PointF offset, out Region? clip) { throw null; }
- }
-}
-namespace System.Drawing.Drawing2D
-{
- public sealed partial class Matrix
- {
- public Matrix(System.Numerics.Matrix3x2 matrix) { }
- public System.Numerics.Matrix3x2 MatrixElements { get { throw null; } set { } }
- }
-}
-namespace System.Drawing.Imaging
-{
- public sealed partial class ImageFormat
- {
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows10.0.17763.0")]
- public static ImageFormat Heif { get { throw null; } }
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows10.0.17763.0")]
- public static ImageFormat Webp { get { throw null; } }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netframework.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netframework.cs
deleted file mode 100644
index 1f82e953c74ce..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netframework.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the https://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-using System.Runtime.CompilerServices;
-
-[assembly: TypeForwardedTo(typeof(System.Drawing.Bitmap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.BitmapSuffixInSameAssemblyAttribute))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.BitmapSuffixInSatelliteAssemblyAttribute))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Brush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Brushes))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.BufferedGraphics))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.BufferedGraphicsContext))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.BufferedGraphicsManager))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.CharacterRange))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.ColorTranslator))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.ContentAlignment))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.CopyPixelOperation))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Font))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.FontFamily))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.FontStyle))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Graphics))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.GraphicsUnit))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Icon))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.IDeviceContext))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Image))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.ImageAnimator))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Pen))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Pens))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Region))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.RotateFlipType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SolidBrush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringAlignment))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringDigitSubstitute))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringFormat))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringFormatFlags))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringTrimming))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.StringUnit))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SystemBrushes))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SystemColors))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SystemFonts))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SystemIcons))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.SystemPens))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.TextureBrush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.ToolboxBitmapAttribute))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.FontCollection))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.GenericFontFamilies))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.HotkeyPrefix))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.InstalledFontCollection))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.PrivateFontCollection))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Text.TextRenderingHint))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.Duplex))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.InvalidPrinterException))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.Margins))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PageSettings))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PaperKind))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PaperSize))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PaperSource))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PaperSourceKind))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PreviewPageInfo))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PreviewPrintController))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintAction))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintController))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintDocument))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrinterResolution))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrinterResolutionKind))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrinterSettings))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrinterUnit))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrinterUnitConvert))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintEventArgs))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintEventHandler))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintPageEventArgs))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintPageEventHandler))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.PrintRange))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.QueryPageSettingsEventArgs))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.QueryPageSettingsEventHandler))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Printing.StandardPrintController))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.BitmapData))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorAdjustType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorChannelFlag))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorMap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorMapType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorMatrix))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorMatrixFlag))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ColorPalette))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EmfPlusRecordType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EmfType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.Encoder))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EncoderParameter))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EncoderParameters))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EncoderParameterValueType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.EncoderValue))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.FrameDimension))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageAttributes))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageCodecFlags))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageCodecInfo))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageFlags))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageFormat))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.ImageLockMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.Metafile))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.MetafileFrameUnit))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.MetafileHeader))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.MetafileType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.MetaHeader))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.PaletteFlags))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.PixelFormat))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.PlayRecordCallback))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.PropertyItem))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Imaging.WmfPlaceableFileHeader))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.AdjustableArrowCap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.Blend))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.ColorBlend))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.CombineMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.CompositingMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.CompositingQuality))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.CoordinateSpace))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.CustomLineCap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.DashCap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.DashStyle))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.FillMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.FlushIntention))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.GraphicsContainer))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.GraphicsPath))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.GraphicsPathIterator))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.GraphicsState))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.HatchBrush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.HatchStyle))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.InterpolationMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.LinearGradientBrush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.LinearGradientMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.LineCap))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.LineJoin))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.Matrix))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.MatrixOrder))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PathData))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PathGradientBrush))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PathPointType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PenAlignment))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PenType))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.PixelOffsetMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.QualityMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.RegionData))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.SmoothingMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.WarpMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Drawing2D.WrapMode))]
-[assembly: TypeForwardedTo(typeof(System.Drawing.Design.CategoryNameCollection))]
diff --git a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs b/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs
deleted file mode 100644
index caa2811da3b95..0000000000000
--- a/src/libraries/System.Drawing.Common/ref/System.Drawing.Common.netstandard.cs
+++ /dev/null
@@ -1,59 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the https://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-namespace System.Drawing
-{
- public static partial class ColorTranslator
- {
- public static System.Drawing.Color FromHtml(string htmlColor) { throw null; }
- public static System.Drawing.Color FromOle(int oleColor) { throw null; }
- public static System.Drawing.Color FromWin32(int win32Color) { throw null; }
- public static string ToHtml(System.Drawing.Color c) { throw null; }
- public static int ToOle(System.Drawing.Color c) { throw null; }
- public static int ToWin32(System.Drawing.Color c) { throw null; }
- }
- public sealed partial class Graphics
- {
- [System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
- public object GetContextInfo() { throw null; }
- }
- public static partial class SystemColors
- {
- public static System.Drawing.Color ActiveBorder { get { throw null; } }
- public static System.Drawing.Color ActiveCaption { get { throw null; } }
- public static System.Drawing.Color ActiveCaptionText { get { throw null; } }
- public static System.Drawing.Color AppWorkspace { get { throw null; } }
- public static System.Drawing.Color ButtonFace { get { throw null; } }
- public static System.Drawing.Color ButtonHighlight { get { throw null; } }
- public static System.Drawing.Color ButtonShadow { get { throw null; } }
- public static System.Drawing.Color Control { get { throw null; } }
- public static System.Drawing.Color ControlDark { get { throw null; } }
- public static System.Drawing.Color ControlDarkDark { get { throw null; } }
- public static System.Drawing.Color ControlLight { get { throw null; } }
- public static System.Drawing.Color ControlLightLight { get { throw null; } }
- public static System.Drawing.Color ControlText { get { throw null; } }
- public static System.Drawing.Color Desktop { get { throw null; } }
- public static System.Drawing.Color GradientActiveCaption { get { throw null; } }
- public static System.Drawing.Color GradientInactiveCaption { get { throw null; } }
- public static System.Drawing.Color GrayText { get { throw null; } }
- public static System.Drawing.Color Highlight { get { throw null; } }
- public static System.Drawing.Color HighlightText { get { throw null; } }
- public static System.Drawing.Color HotTrack { get { throw null; } }
- public static System.Drawing.Color InactiveBorder { get { throw null; } }
- public static System.Drawing.Color InactiveCaption { get { throw null; } }
- public static System.Drawing.Color InactiveCaptionText { get { throw null; } }
- public static System.Drawing.Color Info { get { throw null; } }
- public static System.Drawing.Color InfoText { get { throw null; } }
- public static System.Drawing.Color Menu { get { throw null; } }
- public static System.Drawing.Color MenuBar { get { throw null; } }
- public static System.Drawing.Color MenuHighlight { get { throw null; } }
- public static System.Drawing.Color MenuText { get { throw null; } }
- public static System.Drawing.Color ScrollBar { get { throw null; } }
- public static System.Drawing.Color Window { get { throw null; } }
- public static System.Drawing.Color WindowFrame { get { throw null; } }
- public static System.Drawing.Color WindowText { get { throw null; } }
- }
-}
\ No newline at end of file
diff --git a/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml b/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml
deleted file mode 100644
index a20c679664646..0000000000000
--- a/src/libraries/System.Drawing.Common/src/CompatibilitySuppressions.xml
+++ /dev/null
@@ -1,244 +0,0 @@
-
-
-
- CP0001
- T:System.Drawing.FontConverter
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.IconConverter
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.ImageConverter
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.ImageFormatConverter
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Printing.MarginsConverter
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
-
- CP0001
- T:System.Drawing.Color
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.KnownColor
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Point
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.PointF
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Rectangle
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.RectangleF
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Size
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.SizeF
- ref/net6.0/System.Drawing.Common.dll
- lib/net6.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Color
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.KnownColor
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Point
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.PointF
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Rectangle
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.RectangleF
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Size
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.SizeF
- ref/net7.0/System.Drawing.Common.dll
- lib/net7.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Color
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.KnownColor
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Point
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.PointF
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Rectangle
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.RectangleF
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.Size
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0001
- T:System.Drawing.SizeF
- ref/net8.0/System.Drawing.Common.dll
- lib/net8.0/System.Drawing.Common.dll
-
-
- CP0002
- F:System.Drawing.Imaging.Encoder.ColorSpace
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0002
- F:System.Drawing.Imaging.Encoder.ImageItems
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0002
- F:System.Drawing.Imaging.Encoder.SaveAsCmyk
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0002
- F:System.Drawing.Imaging.EncoderParameterValueType.ValueTypePointer
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- P:System.Drawing.Font.Name:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.Bitmap:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.ContentAlignment:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.Font:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.Icon:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.Image:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
- CP0015
- T:System.Drawing.Imaging.Metafile:[T:System.ComponentModel.EditorAttribute]
- lib/netstandard2.0/System.Drawing.Common.dll
- lib/net462/System.Drawing.Common.dll
-
-
diff --git a/src/libraries/System.Drawing.Common/src/Resources/Strings.resx b/src/libraries/System.Drawing.Common/src/Resources/Strings.resx
deleted file mode 100644
index eb89ee9ebb7a5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/Resources/Strings.resx
+++ /dev/null
@@ -1,431 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- (printer name protected due to security restrictions)
-
-
- Changes cannot be made to {0} because permissions are not valid.
-
-
- Bitmaps that are icons cannot be made transparent. Icons natively support transparency. Use the Icon constructor to create an icon.
-
-
- The color {0} is not a system color.
-
-
- Function was ended.
-
-
- File access is denied.
-
-
- A Graphics object cannot be created from an image that has an indexed pixel format.
-
-
- SetPixel is not supported for images with indexed pixel formats.
-
-
- Destination points define a parallelogram which must have a length of 3. These points will represent the upper-left, upper-right, and lower-left coordinates (defined in that order).
-
-
- Destination points must be an array with a length of 3 or 4. A length of 3 defines a parallelogram with the upper-left, upper-right, and lower-left corners. A length of 4 defines a quadrilateral with the fourth element of the array specifying the lower-right coordinate.
-
-
- File not found.
-
-
- Font '{0}' cannot be found.
-
-
- Font '{0}' does not support style '{1}'.
-
-
- A generic error occurred in GDI+.
-
-
- Buffer is too small (internal GDI+ error).
-
-
- Parameter is not valid.
-
-
- Rectangle '{0}' cannot have a width or height equal to 0.
-
-
- Operation requires a transformation of the image from GDI+ to GDI. GDI does not support images with a width or height greater than 32767.
-
-
- Out of memory.
-
-
- Not implemented.
-
-
- GDI+ is not properly initialized (internal GDI+ error).
-
-
- Only TrueType fonts are supported. '{0}' is not a TrueType font.
-
-
- Only TrueType fonts are supported. This is not a TrueType font.
-
-
- Object is currently in use elsewhere.
-
-
- Overflow error.
-
-
- Property cannot be found.
-
-
- Property is not supported.
-
-
- Unknown GDI+ error occurred.
-
-
- Image format is unknown.
-
-
- Current version of GDI+ does not support this feature.
-
-
- Bitmap region is already locked.
-
-
- (Global Assembly Cache)
-
-
- BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
-
-
- Screen-compatible bitmap cannot be created. The screen bitmap format cannot be determined.
-
-
- '{0}' data length expected {1}, read {2}
-
-
- Internal state of the {0} class is invalid.
-
-
- Property must be set to a valid ColorBlend object to use interpolation colors.
-
-
- {0}{1} ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.
-
-
- ColorBlend object that was set is not valid.
-
-
- Position's first element must be equal to 0.
-
-
- Position's last element must be equal to 1.0.
-
-
- Array of colors and positions must contain at least two elements.
-
-
- Colors and positions do not have the same number of elements.
-
-
- Value of '{1}' is not valid for '{0}'.
-
-
- Value of '{0}' is not valid for font size unit.
-
-
- Value of '{1}' is not valid for '{0}'. '{0}' should be greater than {2} and less than or equal to {3}.
-
-
- Color '{0}' is not valid.
-
-
- DashPattern value is not valid.
-
-
- Value of '{1}' is not valid for '{0}'. '{0}' should be greater than or equal to {2} and less than or equal to {3}.
-
-
- Win32 handle that was passed to {0} is not valid or is the wrong type.
-
-
- Image type is unknown.
-
-
- Value of '{1}' is not valid for '{0}'. '{0}' must be greater than or equal to {2}.
-
-
- Permission state is not valid.
-
-
- Argument '{0}' must be a picture that can be used as a {1}.
-
-
- Settings to access printer '{0}' are not valid.
-
-
- No printers are installed.
-
-
- Handle {0} is not valid.
-
-
- Parameter must be positive and < Width.
-
-
- Parameter must be positive and < Height.
-
-
- Native handle is 0.
-
-
- Default printer is not set.
-
-
- Not implemented.
-
-
- Occurs when the document is about to be printed.
-
-
- The name of the document shown to the user.
-
-
- The page settings of the page currently being printed.
-
-
- Occurs after the document has been printed.
-
-
- Indicates that the graphics origin is located at the user-specified page margins.
-
-
- Retrieves the print controller for this document.
-
-
- Occurs once for each page to be printed.
-
-
- Retrieves the settings for the printer the document is currently being printed to.
-
-
- Occurs before each page is printed. Useful for changing PageSettings for a particular page.
-
-
- System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
-
-
- Defines an object that sends output to a printer.
-
-
- IDictionary parameter contains at least one entry that is not valid. Ensure all values are consistent with the object's properties.
-
-
- PaperSize cannot be changed unless the Kind property is set to Custom.
-
-
- Resource '{1}' cannot be found in class '{0}'.
-
-
- Text "{0}" cannot be parsed. The expected text format is "{1}".
-
-
- TriState.Default cannot be converted into a Boolean.
-
-
- (Icon)
-
-
- (none)
-
-
- GetObjectType on this dc returned an invalid value.
-
-
- The value of argument '{0}' ({1}) is invalid for Enum type '{2}'.
-
-
- {0} is not a valid value for {1}.
-
-
- Invalid Blend object. It should have at least 2 elements in each of the factors and positions arrays.
-
-
- Invalid Blend object. The positions array must have 0.0 as its first element.
-
-
- Invalid Blend object. The positions array must have 1.0 as its last element.
-
-
- {0} only available on WMF files.
-
-
- Cannot create Graphics from an indexed bitmap.
-
-
- Could not open display (X-Server required. Check your DISPLAY environment variable)
-
-
- Couldn't find specified file.
-
-
- Icon instance was disposed.
-
-
- Invalid GraphicsUnit
-
-
- Invalid thumbnail size
-
-
- No codec available for format:{0}
-
-
- Operation not implemented under X11
-
-
- (none)
-
-
- No valid icon image found
-
-
- Null or empty path.
-
-
- Invalid parameter passed. Number of points and types must be same.
-
-
- Object has been disposed.
-
-
- The value of the {0} property is less than zero.
-
-
- The value of the {0} property is not one of the {1} values
-
-
- The directory {0} of the filename {1} does not exist.
-
-
- System.Drawing.Common is not supported on this platform.
-
-
diff --git a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/DefaultComponent.bmp b/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/DefaultComponent.bmp
deleted file mode 100644
index e7a9eb9331ace..0000000000000
Binary files a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/DefaultComponent.bmp and /dev/null differ
diff --git a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Error.ico b/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Error.ico
deleted file mode 100644
index 8648d511f49b1..0000000000000
Binary files a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Error.ico and /dev/null differ
diff --git a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Printing/PrintDocument.bmp b/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Printing/PrintDocument.bmp
deleted file mode 100644
index 9473fc5a52b6b..0000000000000
Binary files a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/Printing/PrintDocument.bmp and /dev/null differ
diff --git a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/ShieldIcon.ico b/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/ShieldIcon.ico
deleted file mode 100644
index 0bc48439a1171..0000000000000
Binary files a/src/libraries/System.Drawing.Common/src/Resources/System/Drawing/ShieldIcon.ico and /dev/null differ
diff --git a/src/libraries/System.Drawing.Common/src/SRDescriptionAttribute.cs b/src/libraries/System.Drawing.Common/src/SRDescriptionAttribute.cs
deleted file mode 100644
index 6e81b29eba15a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/SRDescriptionAttribute.cs
+++ /dev/null
@@ -1,30 +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.ComponentModel;
-
-namespace System.Drawing
-{
- [AttributeUsage(AttributeTargets.All)]
- internal sealed class SRDescriptionAttribute : DescriptionAttribute
- {
- private bool _replaced;
-
- public override string Description
- {
- get
- {
- if (!_replaced)
- {
- _replaced = true;
- DescriptionValue = SR.Format(base.Description);
- }
- return base.Description;
- }
- }
-
- public SRDescriptionAttribute(string description) : base(description)
- {
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.Forwards.cs b/src/libraries/System.Drawing.Common/src/System.Drawing.Common.Forwards.cs
deleted file mode 100644
index 82ba631d1ce22..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.Forwards.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This is required for back-compatibility with legacy Xamarin which had these types in System.Drawing.Common.dll
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Color))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.ColorTranslator))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.KnownColor))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Point))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.PointF))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Rectangle))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.RectangleF))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.Size))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SizeF))]
-[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Drawing.SystemColors))]
diff --git a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj b/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj
deleted file mode 100644
index 0cb66ee946665..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System.Drawing.Common.csproj
+++ /dev/null
@@ -1,388 +0,0 @@
-
-
- $(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)
- $(DefineConstants);DRAWING_NAMESPACE
- true
- CS0618
- false
- true
- true
- true
- Provides access to GDI+ graphics functionality.
-
-Commonly Used Types:
-System.Drawing.Bitmap
-System.Drawing.BitmapData
-System.Drawing.Brush
-System.Drawing.Font
-System.Drawing.Graphics
-System.Drawing.Icon
-
-Since .NET 7, non-Windows platforms are not supported, even with the runtime configuration switch. See https://aka.ms/systemdrawingnonwindows for more information.
-
-
-
-
- $(DefineConstants);FEATURE_WINDOWS_SYSTEM_COLORS;FEATURE_SYSTEM_EVENTS
- true
- SR.SystemDrawingCommon_PlatformNotSupported
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
deleted file mode 100644
index 85a5a8012197c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
+++ /dev/null
@@ -1,369 +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.ComponentModel;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.IO;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-using System.Runtime.Serialization;
-
-namespace System.Drawing
-{
- [Editor("System.Drawing.Design.BitmapEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [Serializable]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed class Bitmap : Image
- {
- private static readonly Color s_defaultTransparentColor = Color.LightGray;
-
- private Bitmap() { }
-
- internal Bitmap(IntPtr ptr) => SetNativeImage(ptr);
-
- public Bitmap(string filename) : this(filename, useIcm: false) { }
-
- public Bitmap(string filename, bool useIcm)
- {
- // GDI+ will read this file multiple times. Get the fully qualified path
- // so if the app's default directory changes we won't get an error.
- filename = Path.GetFullPath(filename);
-
- IntPtr bitmap;
- int status;
-
- if (useIcm)
- {
- status = Gdip.GdipCreateBitmapFromFileICM(filename, out bitmap);
- }
- else
- {
- status = Gdip.GdipCreateBitmapFromFile(filename, out bitmap);
- }
- Gdip.CheckStatus(status);
-
- ValidateImage(bitmap);
-
- SetNativeImage(bitmap);
- EnsureSave(this, filename, null);
- }
-
- public Bitmap(Stream stream) : this(stream, false)
- {
- }
-
- public unsafe Bitmap(Stream stream, bool useIcm)
- {
- ArgumentNullException.ThrowIfNull(stream);
-
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
-
- IntPtr bitmap = IntPtr.Zero;
- if (useIcm)
- {
- Gdip.CheckStatus(Gdip.GdipCreateBitmapFromStreamICM(streamWrapper.Ptr, &bitmap));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipCreateBitmapFromStream(streamWrapper.Ptr, &bitmap));
- }
-
- ValidateImage(bitmap);
-
- SetNativeImage(bitmap);
- EnsureSave(this, null, stream);
- }
-
- public Bitmap(Type type, string resource) : this(GetResourceStream(type, resource))
- {
- }
-
- private static Stream GetResourceStream(Type type, string resource)
- {
- ArgumentNullException.ThrowIfNull(type);
- ArgumentNullException.ThrowIfNull(resource);
-
- Stream? stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
- if (stream == null)
- {
- throw new ArgumentException(SR.Format(SR.ResourceNotFound, type, resource));
- }
-
- return stream;
- }
-
- public Bitmap(int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
- {
- }
-
- public Bitmap(int width, int height, Graphics g)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- IntPtr bitmap;
- int status = Gdip.GdipCreateBitmapFromGraphics(width, height, new HandleRef(g, g.NativeGraphics), out bitmap);
- Gdip.CheckStatus(status);
-
- SetNativeImage(bitmap);
- }
-
- public Bitmap(int width, int height, int stride, PixelFormat format, IntPtr scan0)
- {
- IntPtr bitmap;
- int status = Gdip.GdipCreateBitmapFromScan0(width, height, stride, unchecked((int)format), scan0, out bitmap);
- Gdip.CheckStatus(status);
-
- SetNativeImage(bitmap);
- }
-
- public Bitmap(int width, int height, PixelFormat format)
- {
- IntPtr bitmap;
- int status = Gdip.GdipCreateBitmapFromScan0(width, height, 0, unchecked((int)format), IntPtr.Zero, out bitmap);
- Gdip.CheckStatus(status);
-
- SetNativeImage(bitmap);
- }
-
- public Bitmap(Image original) : this(original, original.Width, original.Height)
- {
- }
-
- public Bitmap(Image original, Size newSize) : this(original, newSize.Width, newSize.Height)
- {
- }
-
- public Bitmap(Image original, int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
- {
- ArgumentNullException.ThrowIfNull(original);
-
- using (Graphics g = Graphics.FromImage(this))
- {
- g.Clear(Color.Transparent);
- g.DrawImage(original, 0, 0, width, height);
- }
- }
-
- private Bitmap(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
- public static Bitmap FromHicon(IntPtr hicon)
- {
- Gdip.CheckStatus(Gdip.GdipCreateBitmapFromHICON(hicon, out IntPtr bitmap));
- return new Bitmap(bitmap);
- }
-
- public static Bitmap FromResource(IntPtr hinstance, string bitmapName)
- {
- IntPtr name = Marshal.StringToHGlobalUni(bitmapName);
- try
- {
- Gdip.CheckStatus(Gdip.GdipCreateBitmapFromResource(hinstance, name, out IntPtr bitmap));
- return new Bitmap(bitmap);
- }
- finally
- {
- Marshal.FreeHGlobal(name);
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public IntPtr GetHbitmap() => GetHbitmap(Color.LightGray);
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public IntPtr GetHbitmap(Color background)
- {
- IntPtr hBitmap;
- int status = Gdip.GdipCreateHBITMAPFromBitmap(new HandleRef(this, nativeImage), out hBitmap,
- ColorTranslator.ToWin32(background));
- if (status == 2 /* invalid parameter*/ && (Width >= short.MaxValue || Height >= short.MaxValue))
- {
- throw new ArgumentException(SR.GdiplusInvalidSize);
- }
-
- Gdip.CheckStatus(status);
-
- return hBitmap;
- }
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public IntPtr GetHicon()
- {
- IntPtr hIcon;
- int status = Gdip.GdipCreateHICONFromBitmap(new HandleRef(this, nativeImage), out hIcon);
- Gdip.CheckStatus(status);
-
- return hIcon;
- }
-
- public Bitmap Clone(RectangleF rect, PixelFormat format)
- {
- if (rect.Width == 0 || rect.Height == 0)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
- }
-
- IntPtr dstHandle;
-
- int status = Gdip.GdipCloneBitmapArea(
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height,
- unchecked((int)format),
- new HandleRef(this, nativeImage),
- out dstHandle);
-
- if (status != Gdip.Ok || dstHandle == IntPtr.Zero)
- throw Gdip.StatusException(status);
-
- return new Bitmap(dstHandle);
- }
-
- public void MakeTransparent()
- {
- Color transparent = s_defaultTransparentColor;
- if (Height > 0 && Width > 0)
- {
- transparent = GetPixel(0, Size.Height - 1);
- }
- if (transparent.A < 255)
- {
- // It's already transparent, and if we proceeded, we will do something
- // unintended like making black transparent
- return;
- }
-
- MakeTransparent(transparent);
- }
-
- public void MakeTransparent(Color transparentColor)
- {
- if (RawFormat.Guid == ImageFormat.Icon.Guid)
- {
- throw new InvalidOperationException(SR.CantMakeIconTransparent);
- }
-
- Size size = Size;
-
- // The new bitmap must be in 32bppARGB format, because that's the only
- // thing that supports alpha. (And that's what the image is initialized to -- transparent)
- using (var result = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb))
- using (Graphics graphics = Graphics.FromImage(result))
- {
- graphics.Clear(Color.Transparent);
- Rectangle rectangle = new Rectangle(0, 0, size.Width, size.Height);
-
- using (var attributes = new ImageAttributes())
- {
- attributes.SetColorKey(transparentColor, transparentColor);
- graphics.DrawImage(this, rectangle,
- 0, 0, size.Width, size.Height,
- GraphicsUnit.Pixel, attributes, null, IntPtr.Zero);
- }
-
- // Swap nativeImage pointers to make it look like we modified the image in place
- IntPtr temp = nativeImage;
- nativeImage = result.nativeImage;
- result.nativeImage = temp;
- }
- }
-
- public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
- {
- return LockBits(rect, flags, format, new BitmapData());
- }
-
- public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format, BitmapData bitmapData)
- {
- int status = Gdip.GdipBitmapLockBits(
- new HandleRef(this, nativeImage), ref rect, flags, format, bitmapData);
-
- // libgdiplus has the wrong error code mapping for this state.
- if (status == 7)
- {
- status = 8;
- }
- Gdip.CheckStatus(status);
-
- return bitmapData;
- }
-
- public void UnlockBits(BitmapData bitmapdata)
- {
- int status = Gdip.GdipBitmapUnlockBits(new HandleRef(this, nativeImage), bitmapdata);
- Gdip.CheckStatus(status);
- }
-
- public Color GetPixel(int x, int y)
- {
- if (x < 0 || x >= Width)
- {
- throw new ArgumentOutOfRangeException(nameof(x), SR.ValidRangeX);
- }
-
- if (y < 0 || y >= Height)
- {
- throw new ArgumentOutOfRangeException(nameof(y), SR.ValidRangeY);
- }
-
- int color;
- int status = Gdip.GdipBitmapGetPixel(new HandleRef(this, nativeImage), x, y, out color);
- Gdip.CheckStatus(status);
-
- return Color.FromArgb(color);
- }
-
- public void SetPixel(int x, int y, Color color)
- {
- if ((PixelFormat & PixelFormat.Indexed) != 0)
- {
- throw new InvalidOperationException(SR.GdiplusCannotSetPixelFromIndexedPixelFormat);
- }
-
- if (x < 0 || x >= Width)
- {
- throw new ArgumentOutOfRangeException(nameof(x), SR.ValidRangeX);
- }
-
- if (y < 0 || y >= Height)
- {
- throw new ArgumentOutOfRangeException(nameof(y), SR.ValidRangeY);
- }
-
- int status = Gdip.GdipBitmapSetPixel(new HandleRef(this, nativeImage), x, y, color.ToArgb());
- Gdip.CheckStatus(status);
- }
-
- public void SetResolution(float xDpi, float yDpi)
- {
- int status = Gdip.GdipBitmapSetResolution(new HandleRef(this, nativeImage), xDpi, yDpi);
- Gdip.CheckStatus(status);
- }
- public Bitmap Clone(Rectangle rect, PixelFormat format)
- {
- if (rect.Width == 0 || rect.Height == 0)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
- }
-
- IntPtr dstHandle;
- int status = Gdip.GdipCloneBitmapAreaI(
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height,
- unchecked((int)format),
- new HandleRef(this, nativeImage),
- out dstHandle);
-
- if (status != Gdip.Ok || dstHandle == IntPtr.Zero)
- throw Gdip.StatusException(status);
-
- return new Bitmap(dstHandle);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSelector.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSelector.cs
deleted file mode 100644
index b5daa033aa805..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSelector.cs
+++ /dev/null
@@ -1,43 +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.IO;
-using System.Reflection;
-
-namespace System.Drawing
-{
- ///
- /// Provides methods to select bitmaps.
- ///
- internal static class BitmapSelector
- {
- ///
- /// Returns a resource stream loaded from the appropriate location according to the current
- /// suffix.
- ///
- /// The assembly from which the stream is loaded
- /// The type whose namespace is used to scope the manifest resource name
- /// The name of the manifest resource being requested
- ///
- /// The manifest resource stream corresponding to .
- ///
- public static Stream? GetResourceStream(Assembly assembly, Type type, string originalName)
- {
- return assembly.GetManifestResourceStream(type, originalName);
- }
-
- ///
- /// Returns a resource stream loaded from the appropriate location according to the current
- /// suffix.
- ///
- /// The type from whose assembly the stream is loaded and whose namespace is used to scope the resource name
- /// The name of the manifest resource being requested
- ///
- /// The manifest resource stream corresponding to .
- ///
- public static Stream? GetResourceStream(Type type, string originalName)
- {
- return GetResourceStream(type.Module.Assembly, type, originalName);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSameAssemblyAttribute.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSameAssemblyAttribute.cs
deleted file mode 100644
index ea2a306ed7a61..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSameAssemblyAttribute.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Opt-In flag to look for resources in the same assembly but with the "bitmapSuffix" config setting.
- /// i.e. System.Web.UI.WebControl.Button.bmp -> System.Web.UI.WebControl.Button.VisualStudio.11.0.bmp
- ///
- [AttributeUsage(AttributeTargets.Assembly)]
- public class BitmapSuffixInSameAssemblyAttribute : Attribute
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
deleted file mode 100644
index 8e72f54fbd8fb..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BitmapSuffixInSatelliteAssemblyAttribute.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Opt-In flag to look for resources in the another assembly with the "bitmapSuffix" config setting
- /// i.e. System.Web.dll -> System.Web.VisualStudio.11.0.dll
- ///
- [AttributeUsage(AttributeTargets.Assembly)]
- public class BitmapSuffixInSatelliteAssemblyAttribute : Attribute
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Brush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Brush.cs
deleted file mode 100644
index de964a2b13d33..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Brush.cs
+++ /dev/null
@@ -1,67 +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.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public abstract class Brush : MarshalByRefObject, ICloneable, IDisposable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
- // Handle to native GDI+ brush object to be used on demand.
- private IntPtr _nativeBrush;
-
- public abstract object Clone();
-
- protected internal void SetNativeBrush(IntPtr brush) => SetNativeBrushInternal(brush);
- internal void SetNativeBrushInternal(IntPtr brush) => _nativeBrush = brush;
-
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- internal IntPtr NativeBrush => _nativeBrush;
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
-#if FINALIZATION_WATCH
- if (!disposing && nativeBrush != IntPtr.Zero )
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
-#endif
-
- if (_nativeBrush != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteBrush(new HandleRef(this, _nativeBrush));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- // Catch all non fatal exceptions. This includes exceptions like EntryPointNotFoundException, that is thrown
- // on Windows Nano.
- }
- finally
- {
- _nativeBrush = IntPtr.Zero;
- }
- }
- }
-
- ~Brush() => Dispose(false);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs
deleted file mode 100644
index f3de18a41c07b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Brushes.cs
+++ /dev/null
@@ -1,324 +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 Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public static class Brushes
- {
- private static readonly object s_transparentKey = new object();
- private static readonly object s_aliceBlueKey = new object();
- private static readonly object s_antiqueWhiteKey = new object();
- private static readonly object s_aquaKey = new object();
- private static readonly object s_aquamarineKey = new object();
- private static readonly object s_azureKey = new object();
- private static readonly object s_beigeKey = new object();
- private static readonly object s_bisqueKey = new object();
- private static readonly object s_blackKey = new object();
- private static readonly object s_blanchedAlmondKey = new object();
- private static readonly object s_blueKey = new object();
- private static readonly object s_blueVioletKey = new object();
- private static readonly object s_brownKey = new object();
- private static readonly object s_burlyWoodKey = new object();
- private static readonly object s_cadetBlueKey = new object();
- private static readonly object s_chartreuseKey = new object();
- private static readonly object s_chocolateKey = new object();
- private static readonly object s_coralKey = new object();
- private static readonly object s_cornflowerBlueKey = new object();
- private static readonly object s_cornsilkKey = new object();
- private static readonly object s_crimsonKey = new object();
- private static readonly object s_cyanKey = new object();
- private static readonly object s_darkBlueKey = new object();
- private static readonly object s_darkCyanKey = new object();
- private static readonly object s_darkGoldenrodKey = new object();
- private static readonly object s_darkGrayKey = new object();
- private static readonly object s_darkGreenKey = new object();
- private static readonly object s_darkKhakiKey = new object();
- private static readonly object s_darkMagentaKey = new object();
- private static readonly object s_darkOliveGreenKey = new object();
- private static readonly object s_darkOrangeKey = new object();
- private static readonly object s_darkOrchidKey = new object();
- private static readonly object s_darkRedKey = new object();
- private static readonly object s_darkSalmonKey = new object();
- private static readonly object s_darkSeaGreenKey = new object();
- private static readonly object s_darkSlateBlueKey = new object();
- private static readonly object s_darkSlateGrayKey = new object();
- private static readonly object s_darkTurquoiseKey = new object();
- private static readonly object s_darkVioletKey = new object();
- private static readonly object s_deepPinkKey = new object();
- private static readonly object s_deepSkyBlueKey = new object();
- private static readonly object s_dimGrayKey = new object();
- private static readonly object s_dodgerBlueKey = new object();
- private static readonly object s_firebrickKey = new object();
- private static readonly object s_floralWhiteKey = new object();
- private static readonly object s_forestGreenKey = new object();
- private static readonly object s_fuchsiaKey = new object();
- private static readonly object s_gainsboroKey = new object();
- private static readonly object s_ghostWhiteKey = new object();
- private static readonly object s_goldKey = new object();
- private static readonly object s_goldenrodKey = new object();
- private static readonly object s_grayKey = new object();
- private static readonly object s_greenKey = new object();
- private static readonly object s_greenYellowKey = new object();
- private static readonly object s_honeydewKey = new object();
- private static readonly object s_hotPinkKey = new object();
- private static readonly object s_indianRedKey = new object();
- private static readonly object s_indigoKey = new object();
- private static readonly object s_ivoryKey = new object();
- private static readonly object s_khakiKey = new object();
- private static readonly object s_lavenderKey = new object();
- private static readonly object s_lavenderBlushKey = new object();
- private static readonly object s_lawnGreenKey = new object();
- private static readonly object s_lemonChiffonKey = new object();
- private static readonly object s_lightBlueKey = new object();
- private static readonly object s_lightCoralKey = new object();
- private static readonly object s_lightCyanKey = new object();
- private static readonly object s_lightGoldenrodYellowKey = new object();
- private static readonly object s_lightGreenKey = new object();
- private static readonly object s_lightGrayKey = new object();
- private static readonly object s_lightPinkKey = new object();
- private static readonly object s_lightSalmonKey = new object();
- private static readonly object s_lightSeaGreenKey = new object();
- private static readonly object s_lightSkyBlueKey = new object();
- private static readonly object s_lightSlateGrayKey = new object();
- private static readonly object s_lightSteelBlueKey = new object();
- private static readonly object s_lightYellowKey = new object();
- private static readonly object s_limeKey = new object();
- private static readonly object s_limeGreenKey = new object();
- private static readonly object s_linenKey = new object();
- private static readonly object s_magentaKey = new object();
- private static readonly object s_maroonKey = new object();
- private static readonly object s_mediumAquamarineKey = new object();
- private static readonly object s_mediumBlueKey = new object();
- private static readonly object s_mediumOrchidKey = new object();
- private static readonly object s_mediumPurpleKey = new object();
- private static readonly object s_mediumSeaGreenKey = new object();
- private static readonly object s_mediumSlateBlueKey = new object();
- private static readonly object s_mediumSpringGreenKey = new object();
- private static readonly object s_mediumTurquoiseKey = new object();
- private static readonly object s_mediumVioletRedKey = new object();
- private static readonly object s_midnightBlueKey = new object();
- private static readonly object s_mintCreamKey = new object();
- private static readonly object s_mistyRoseKey = new object();
- private static readonly object s_moccasinKey = new object();
- private static readonly object s_navajoWhiteKey = new object();
- private static readonly object s_navyKey = new object();
- private static readonly object s_oldLaceKey = new object();
- private static readonly object s_oliveKey = new object();
- private static readonly object s_oliveDrabKey = new object();
- private static readonly object s_orangeKey = new object();
- private static readonly object s_orangeRedKey = new object();
- private static readonly object s_orchidKey = new object();
- private static readonly object s_paleGoldenrodKey = new object();
- private static readonly object s_paleGreenKey = new object();
- private static readonly object s_paleTurquoiseKey = new object();
- private static readonly object s_paleVioletRedKey = new object();
- private static readonly object s_papayaWhipKey = new object();
- private static readonly object s_peachPuffKey = new object();
- private static readonly object s_peruKey = new object();
- private static readonly object s_pinkKey = new object();
- private static readonly object s_plumKey = new object();
- private static readonly object s_powderBlueKey = new object();
- private static readonly object s_purpleKey = new object();
- private static readonly object s_redKey = new object();
- private static readonly object s_rosyBrownKey = new object();
- private static readonly object s_royalBlueKey = new object();
- private static readonly object s_saddleBrownKey = new object();
- private static readonly object s_salmonKey = new object();
- private static readonly object s_sandyBrownKey = new object();
- private static readonly object s_seaGreenKey = new object();
- private static readonly object s_seaShellKey = new object();
- private static readonly object s_siennaKey = new object();
- private static readonly object s_silverKey = new object();
- private static readonly object s_skyBlueKey = new object();
- private static readonly object s_slateBlueKey = new object();
- private static readonly object s_slateGrayKey = new object();
- private static readonly object s_snowKey = new object();
- private static readonly object s_springGreenKey = new object();
- private static readonly object s_steelBlueKey = new object();
- private static readonly object s_tanKey = new object();
- private static readonly object s_tealKey = new object();
- private static readonly object s_thistleKey = new object();
- private static readonly object s_tomatoKey = new object();
- private static readonly object s_turquoiseKey = new object();
- private static readonly object s_violetKey = new object();
- private static readonly object s_wheatKey = new object();
- private static readonly object s_whiteKey = new object();
- private static readonly object s_whiteSmokeKey = new object();
- private static readonly object s_yellowKey = new object();
- private static readonly object s_yellowGreenKey = new object();
-
- public static Brush Transparent => GetBrush(s_transparentKey, Color.Transparent);
-
- public static Brush AliceBlue => GetBrush(s_aliceBlueKey, Color.AliceBlue);
- public static Brush AntiqueWhite => GetBrush(s_antiqueWhiteKey, Color.AntiqueWhite);
- public static Brush Aqua => GetBrush(s_aquaKey, Color.Aqua);
- public static Brush Aquamarine => GetBrush(s_aquamarineKey, Color.Aquamarine);
- public static Brush Azure => GetBrush(s_azureKey, Color.Azure);
-
- public static Brush Beige => GetBrush(s_beigeKey, Color.Beige);
- public static Brush Bisque => GetBrush(s_bisqueKey, Color.Bisque);
- public static Brush Black => GetBrush(s_blackKey, Color.Black);
- public static Brush BlanchedAlmond => GetBrush(s_blanchedAlmondKey, Color.BlanchedAlmond);
- public static Brush Blue => GetBrush(s_blueKey, Color.Blue);
- public static Brush BlueViolet => GetBrush(s_blueVioletKey, Color.BlueViolet);
- public static Brush Brown => GetBrush(s_brownKey, Color.Brown);
- public static Brush BurlyWood => GetBrush(s_burlyWoodKey, Color.BurlyWood);
-
- public static Brush CadetBlue => GetBrush(s_cadetBlueKey, Color.CadetBlue);
- public static Brush Chartreuse => GetBrush(s_chartreuseKey, Color.Chartreuse);
- public static Brush Chocolate => GetBrush(s_chocolateKey, Color.Chocolate);
- public static Brush Coral => GetBrush(s_coralKey, Color.Coral);
- public static Brush CornflowerBlue => GetBrush(s_cornflowerBlueKey, Color.CornflowerBlue);
- public static Brush Cornsilk => GetBrush(s_cornsilkKey, Color.Cornsilk);
- public static Brush Crimson => GetBrush(s_crimsonKey, Color.Crimson);
- public static Brush Cyan => GetBrush(s_cyanKey, Color.Cyan);
-
- public static Brush DarkBlue => GetBrush(s_darkBlueKey, Color.DarkBlue);
- public static Brush DarkCyan => GetBrush(s_darkCyanKey, Color.DarkCyan);
- public static Brush DarkGoldenrod => GetBrush(s_darkGoldenrodKey, Color.DarkGoldenrod);
- public static Brush DarkGray => GetBrush(s_darkGrayKey, Color.DarkGray);
- public static Brush DarkGreen => GetBrush(s_darkGreenKey, Color.DarkGreen);
- public static Brush DarkKhaki => GetBrush(s_darkKhakiKey, Color.DarkKhaki);
- public static Brush DarkMagenta => GetBrush(s_darkMagentaKey, Color.DarkMagenta);
- public static Brush DarkOliveGreen => GetBrush(s_darkOliveGreenKey, Color.DarkOliveGreen);
- public static Brush DarkOrange => GetBrush(s_darkOrangeKey, Color.DarkOrange);
- public static Brush DarkOrchid => GetBrush(s_darkOrchidKey, Color.DarkOrchid);
- public static Brush DarkRed => GetBrush(s_darkRedKey, Color.DarkRed);
- public static Brush DarkSalmon => GetBrush(s_darkSalmonKey, Color.DarkSalmon);
- public static Brush DarkSeaGreen => GetBrush(s_darkSeaGreenKey, Color.DarkSeaGreen);
- public static Brush DarkSlateBlue => GetBrush(s_darkSlateBlueKey, Color.DarkSlateBlue);
- public static Brush DarkSlateGray => GetBrush(s_darkSlateGrayKey, Color.DarkSlateGray);
- public static Brush DarkTurquoise => GetBrush(s_darkTurquoiseKey, Color.DarkTurquoise);
- public static Brush DarkViolet => GetBrush(s_darkVioletKey, Color.DarkViolet);
- public static Brush DeepPink => GetBrush(s_deepPinkKey, Color.DeepPink);
- public static Brush DeepSkyBlue => GetBrush(s_deepSkyBlueKey, Color.DeepSkyBlue);
- public static Brush DimGray => GetBrush(s_dimGrayKey, Color.DimGray);
- public static Brush DodgerBlue => GetBrush(s_dodgerBlueKey, Color.DodgerBlue);
-
- public static Brush Firebrick => GetBrush(s_firebrickKey, Color.Firebrick);
- public static Brush FloralWhite => GetBrush(s_floralWhiteKey, Color.FloralWhite);
- public static Brush ForestGreen => GetBrush(s_forestGreenKey, Color.ForestGreen);
- public static Brush Fuchsia => GetBrush(s_fuchsiaKey, Color.Fuchsia);
-
- public static Brush Gainsboro => GetBrush(s_gainsboroKey, Color.Gainsboro);
- public static Brush GhostWhite => GetBrush(s_ghostWhiteKey, Color.GhostWhite);
- public static Brush Gold => GetBrush(s_goldKey, Color.Gold);
- public static Brush Goldenrod => GetBrush(s_goldenrodKey, Color.Goldenrod);
- public static Brush Gray => GetBrush(s_grayKey, Color.Gray);
- public static Brush Green => GetBrush(s_greenKey, Color.Green);
- public static Brush GreenYellow => GetBrush(s_greenYellowKey, Color.GreenYellow);
-
- public static Brush Honeydew => GetBrush(s_honeydewKey, Color.Honeydew);
- public static Brush HotPink => GetBrush(s_hotPinkKey, Color.HotPink);
-
- public static Brush IndianRed => GetBrush(s_indianRedKey, Color.IndianRed);
- public static Brush Indigo => GetBrush(s_indigoKey, Color.Indigo);
- public static Brush Ivory => GetBrush(s_ivoryKey, Color.Ivory);
-
- public static Brush Khaki => GetBrush(s_khakiKey, Color.Khaki);
-
- public static Brush Lavender => GetBrush(s_lavenderKey, Color.Lavender);
- public static Brush LavenderBlush => GetBrush(s_lavenderBlushKey, Color.LavenderBlush);
- public static Brush LawnGreen => GetBrush(s_lawnGreenKey, Color.LawnGreen);
- public static Brush LemonChiffon => GetBrush(s_lemonChiffonKey, Color.LemonChiffon);
- public static Brush LightBlue => GetBrush(s_lightBlueKey, Color.LightBlue);
- public static Brush LightCoral => GetBrush(s_lightCoralKey, Color.LightCoral);
- public static Brush LightCyan => GetBrush(s_lightCyanKey, Color.LightCyan);
- public static Brush LightGoldenrodYellow => GetBrush(s_lightGoldenrodYellowKey, Color.LightGoldenrodYellow);
- public static Brush LightGreen => GetBrush(s_lightGreenKey, Color.LightGreen);
- public static Brush LightGray => GetBrush(s_lightGrayKey, Color.LightGray);
- public static Brush LightPink => GetBrush(s_lightPinkKey, Color.LightPink);
- public static Brush LightSalmon => GetBrush(s_lightSalmonKey, Color.LightSalmon);
- public static Brush LightSeaGreen => GetBrush(s_lightSeaGreenKey, Color.LightSeaGreen);
- public static Brush LightSkyBlue => GetBrush(s_lightSkyBlueKey, Color.LightSkyBlue);
- public static Brush LightSlateGray => GetBrush(s_lightSlateGrayKey, Color.LightSlateGray);
- public static Brush LightSteelBlue => GetBrush(s_lightSteelBlueKey, Color.LightSteelBlue);
- public static Brush LightYellow => GetBrush(s_lightYellowKey, Color.LightYellow);
- public static Brush Lime => GetBrush(s_limeKey, Color.Lime);
- public static Brush LimeGreen => GetBrush(s_limeGreenKey, Color.LimeGreen);
- public static Brush Linen => GetBrush(s_linenKey, Color.Linen);
-
- public static Brush Magenta => GetBrush(s_magentaKey, Color.Magenta);
- public static Brush Maroon => GetBrush(s_maroonKey, Color.Maroon);
- public static Brush MediumAquamarine => GetBrush(s_mediumAquamarineKey, Color.MediumAquamarine);
- public static Brush MediumBlue => GetBrush(s_mediumBlueKey, Color.MediumBlue);
- public static Brush MediumOrchid => GetBrush(s_mediumOrchidKey, Color.MediumOrchid);
- public static Brush MediumPurple => GetBrush(s_mediumPurpleKey, Color.MediumPurple);
- public static Brush MediumSeaGreen => GetBrush(s_mediumSeaGreenKey, Color.MediumSeaGreen);
- public static Brush MediumSlateBlue => GetBrush(s_mediumSlateBlueKey, Color.MediumSlateBlue);
- public static Brush MediumSpringGreen => GetBrush(s_mediumSpringGreenKey, Color.MediumSpringGreen);
- public static Brush MediumTurquoise => GetBrush(s_mediumTurquoiseKey, Color.MediumTurquoise);
- public static Brush MediumVioletRed => GetBrush(s_mediumVioletRedKey, Color.MediumVioletRed);
- public static Brush MidnightBlue => GetBrush(s_midnightBlueKey, Color.MidnightBlue);
- public static Brush MintCream => GetBrush(s_mintCreamKey, Color.MintCream);
- public static Brush MistyRose => GetBrush(s_mistyRoseKey, Color.MistyRose);
- public static Brush Moccasin => GetBrush(s_moccasinKey, Color.Moccasin);
-
- public static Brush NavajoWhite => GetBrush(s_navajoWhiteKey, Color.NavajoWhite);
- public static Brush Navy => GetBrush(s_navyKey, Color.Navy);
-
- public static Brush OldLace => GetBrush(s_oldLaceKey, Color.OldLace);
- public static Brush Olive => GetBrush(s_oliveKey, Color.Olive);
- public static Brush OliveDrab => GetBrush(s_oliveDrabKey, Color.OliveDrab);
- public static Brush Orange => GetBrush(s_orangeKey, Color.Orange);
- public static Brush OrangeRed => GetBrush(s_orangeRedKey, Color.OrangeRed);
- public static Brush Orchid => GetBrush(s_orchidKey, Color.Orchid);
-
- public static Brush PaleGoldenrod => GetBrush(s_paleGoldenrodKey, Color.PaleGoldenrod);
- public static Brush PaleGreen => GetBrush(s_paleGreenKey, Color.PaleGreen);
- public static Brush PaleTurquoise => GetBrush(s_paleTurquoiseKey, Color.PaleTurquoise);
- public static Brush PaleVioletRed => GetBrush(s_paleVioletRedKey, Color.PaleVioletRed);
- public static Brush PapayaWhip => GetBrush(s_papayaWhipKey, Color.PapayaWhip);
- public static Brush PeachPuff => GetBrush(s_peachPuffKey, Color.PeachPuff);
- public static Brush Peru => GetBrush(s_peruKey, Color.Peru);
- public static Brush Pink => GetBrush(s_pinkKey, Color.Pink);
- public static Brush Plum => GetBrush(s_plumKey, Color.Plum);
- public static Brush PowderBlue => GetBrush(s_powderBlueKey, Color.PowderBlue);
- public static Brush Purple => GetBrush(s_purpleKey, Color.Purple);
-
- public static Brush Red => GetBrush(s_redKey, Color.Red);
- public static Brush RosyBrown => GetBrush(s_rosyBrownKey, Color.RosyBrown);
- public static Brush RoyalBlue => GetBrush(s_royalBlueKey, Color.RoyalBlue);
-
- public static Brush SaddleBrown => GetBrush(s_saddleBrownKey, Color.SaddleBrown);
- public static Brush Salmon => GetBrush(s_salmonKey, Color.Salmon);
- public static Brush SandyBrown => GetBrush(s_sandyBrownKey, Color.SandyBrown);
- public static Brush SeaGreen => GetBrush(s_seaGreenKey, Color.SeaGreen);
- public static Brush SeaShell => GetBrush(s_seaShellKey, Color.SeaShell);
- public static Brush Sienna => GetBrush(s_siennaKey, Color.Sienna);
- public static Brush Silver => GetBrush(s_silverKey, Color.Silver);
- public static Brush SkyBlue => GetBrush(s_skyBlueKey, Color.SkyBlue);
- public static Brush SlateBlue => GetBrush(s_slateBlueKey, Color.SlateBlue);
- public static Brush SlateGray => GetBrush(s_slateGrayKey, Color.SlateGray);
- public static Brush Snow => GetBrush(s_snowKey, Color.Snow);
- public static Brush SpringGreen => GetBrush(s_springGreenKey, Color.SpringGreen);
- public static Brush SteelBlue => GetBrush(s_steelBlueKey, Color.SteelBlue);
-
- public static Brush Tan => GetBrush(s_tanKey, Color.Tan);
- public static Brush Teal => GetBrush(s_tealKey, Color.Teal);
- public static Brush Thistle => GetBrush(s_thistleKey, Color.Thistle);
- public static Brush Tomato => GetBrush(s_tomatoKey, Color.Tomato);
- public static Brush Turquoise => GetBrush(s_turquoiseKey, Color.Turquoise);
-
- public static Brush Violet => GetBrush(s_violetKey, Color.Violet);
-
- public static Brush Wheat => GetBrush(s_wheatKey, Color.Wheat);
- public static Brush White => GetBrush(s_whiteKey, Color.White);
- public static Brush WhiteSmoke => GetBrush(s_whiteSmokeKey, Color.WhiteSmoke);
-
- public static Brush Yellow => GetBrush(s_yellowKey, Color.Yellow);
- public static Brush YellowGreen => GetBrush(s_yellowGreenKey, Color.YellowGreen);
-
- private static Brush GetBrush(object key, Color color)
- {
- Brush? brush = (Brush?)Gdip.ThreadData[key];
- if (brush == null)
- {
- brush = new SolidBrush(color);
- Gdip.ThreadData[key] = brush;
- }
- return brush;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphics.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphics.cs
deleted file mode 100644
index 4224959597a8d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphics.cs
+++ /dev/null
@@ -1,133 +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.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- ///
- /// The BufferedGraphics class can be thought of as a "Token" or "Reference" to the buffer that a
- /// BufferedGraphicsContext creates. While a BufferedGraphics is outstanding, the memory associated with the
- /// buffer is locked. The general design is such that under normal conditions a single BufferedGraphics will be in
- /// use at one time for a given BufferedGraphicsContext.
- ///
- public sealed class BufferedGraphics : IDisposable
- {
- private readonly Graphics? _targetGraphics;
- private readonly IntPtr _targetDC;
- private Graphics _bufferedGraphicsSurface;
- private BufferedGraphicsContext _context;
- private readonly Point _targetLoc;
- private readonly Size _virtualSize;
-
- ///
- /// Internal constructor, this class is created by BufferedGraphicsContext.
- ///
- internal BufferedGraphics(Graphics bufferedGraphicsSurface, BufferedGraphicsContext context, Graphics? targetGraphics,
- IntPtr targetDC, Point targetLoc, Size virtualSize)
- {
- _context = context;
- _bufferedGraphicsSurface = bufferedGraphicsSurface;
- _targetDC = targetDC;
- _targetGraphics = targetGraphics;
- _targetLoc = targetLoc;
- _virtualSize = virtualSize;
- }
-
- public void Dispose()
- {
- if (_context != null)
- {
- _context.ReleaseBuffer();
-
- if (DisposeContext)
- {
- _context.Dispose();
- _context = null!;
- }
- }
-
- if (_bufferedGraphicsSurface != null)
- {
- _bufferedGraphicsSurface.Dispose();
- _bufferedGraphicsSurface = null!;
- }
- }
-
- ///
- /// Allows access to the Graphics wrapper for the buffer.
- ///
- public Graphics Graphics => _bufferedGraphicsSurface;
-
- ///
- /// Renders the buffer to the specified target graphics.
- ///
- public void Render(Graphics? target)
- {
- if (target != null)
- {
- IntPtr targetDC = target.GetHdc();
-
- try
- {
- RenderInternal(new HandleRef(target, targetDC));
- }
- finally
- {
- target.ReleaseHdcInternal(targetDC);
- }
- }
- }
-
- ///
- /// Internal method that renders the specified buffer into the target.
- ///
- private void RenderInternal(HandleRef refTargetDC)
- {
- IntPtr sourceDC = Graphics.GetHdc();
-
- try
- {
- Interop.Gdi32.BitBlt(
- refTargetDC,
- _targetLoc.X,
- _targetLoc.Y,
- _virtualSize.Width,
- _virtualSize.Height,
- new HandleRef(Graphics, sourceDC),
- 0,
- 0,
- Interop.Gdi32.RasterOp.SRCCOPY);
- }
- finally
- {
- Graphics.ReleaseHdcInternal(sourceDC);
- }
- }
-
- ///
- /// Determines if we need to dispose of the Context when this is disposed.
- ///
- internal bool DisposeContext { get; set; }
-
- ///
- /// Renders the buffer to the original graphics used to allocate the buffer.
- ///
- public void Render()
- {
- if (_targetGraphics != null)
- {
- Render(_targetGraphics);
- }
- else
- {
- RenderInternal(new HandleRef(Graphics, _targetDC));
- }
- }
-
- ///
- /// Renders the buffer to the specified target HDC.
- ///
- public void Render(IntPtr targetDC) => RenderInternal(new HandleRef(null, targetDC));
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsContext.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsContext.cs
deleted file mode 100644
index 22e9eb0b9b3a5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsContext.cs
+++ /dev/null
@@ -1,542 +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.ComponentModel;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-namespace System.Drawing
-{
- ///
- /// The BufferedGraphicsContext class can be used to perform standard double buffer rendering techniques.
- ///
- public sealed class BufferedGraphicsContext : IDisposable
- {
- private Size _maximumBuffer;
- private Size _bufferSize = Size.Empty;
- private Size _virtualSize;
- private Point _targetLoc;
- private IntPtr _compatDC;
- private IntPtr _dib;
- private IntPtr _oldBitmap;
- private Graphics? _compatGraphics;
- private BufferedGraphics? _buffer;
- private int _busy;
- private bool _invalidateWhenFree;
-
- private const int BufferFree = 0; // The graphics buffer is free to use.
- private const int BufferBusyPainting = 1; // The graphics buffer is busy being created/painting.
- private const int BufferBusyDisposing = 2; // The graphics buffer is busy disposing.
-
- ///
- /// Basic constructor.
- ///
- public BufferedGraphicsContext()
- {
- // By defualt, the size of our maxbuffer will be 3 x standard button size.
- _maximumBuffer.Width = 75 * 3;
- _maximumBuffer.Height = 32 * 3;
- }
-
- ///
- /// Allows you to set the maximum width and height of the buffer that will be retained in memory.
- /// You can allocate a buffer of any size, however any request for a buffer that would have a total
- /// memory footprint larger that the maximum size will be allocated temporarily and then discarded
- /// with the BufferedGraphics is released.
- ///
- public Size MaximumBuffer
- {
- get => _maximumBuffer;
- set
- {
- if (value.Width <= 0 || value.Height <= 0)
- {
- throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, nameof(MaximumBuffer), value), nameof(value));
- }
-
- // If we've been asked to decrease the size of the maximum buffer,
- // then invalidate the older & larger buffer.
- if (value.Width * value.Height < _maximumBuffer.Width * _maximumBuffer.Height)
- {
- Invalidate();
- }
-
- _maximumBuffer = value;
- }
- }
-
- ~BufferedGraphicsContext() => Dispose(false);
-
- ///
- /// Returns a BufferedGraphics that is matched for the specified target Graphics object.
- ///
- public BufferedGraphics Allocate(Graphics targetGraphics, Rectangle targetRectangle)
- {
- if (ShouldUseTempManager(targetRectangle))
- {
- return AllocBufferInTempManager(targetGraphics, IntPtr.Zero, targetRectangle);
- }
-
- return AllocBuffer(targetGraphics, IntPtr.Zero, targetRectangle);
- }
-
- ///
- /// Returns a BufferedGraphics that is matched for the specified target HDC object.
- ///
- public BufferedGraphics Allocate(IntPtr targetDC, Rectangle targetRectangle)
- {
- if (ShouldUseTempManager(targetRectangle))
- {
- return AllocBufferInTempManager(null, targetDC, targetRectangle);
- }
-
- return AllocBuffer(null, targetDC, targetRectangle);
- }
-
- ///
- /// Returns a BufferedGraphics that is matched for the specified target HDC object.
- ///
- private BufferedGraphics AllocBuffer(Graphics? targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
- {
- int oldBusy = Interlocked.CompareExchange(ref _busy, BufferBusyPainting, BufferFree);
-
- // In the case were we have contention on the buffer - i.e. two threads
- // trying to use the buffer at the same time, we just create a temp
- // buffermanager and have the buffer dispose of it when it is done.
- //
- if (oldBusy != BufferFree)
- {
- return AllocBufferInTempManager(targetGraphics, targetDC, targetRectangle);
- }
-
- Graphics surface;
- _targetLoc = new Point(targetRectangle.X, targetRectangle.Y);
-
- try
- {
- if (targetGraphics != null)
- {
- IntPtr destDc = targetGraphics.GetHdc();
- try
- {
- surface = CreateBuffer(destDc, targetRectangle.Width, targetRectangle.Height);
- }
- finally
- {
- targetGraphics.ReleaseHdcInternal(destDc);
- }
- }
- else
- {
- surface = CreateBuffer(targetDC, targetRectangle.Width, targetRectangle.Height);
- }
-
- _buffer = new BufferedGraphics(surface, this, targetGraphics, targetDC, _targetLoc, _virtualSize);
- }
- catch
- {
- // Free the buffer so it can be disposed.
- _busy = BufferFree;
- throw;
- }
-
- return _buffer;
- }
-
- ///
- /// Returns a BufferedGraphics that is matched for the specified target HDC object.
- ///
- private static BufferedGraphics AllocBufferInTempManager(Graphics? targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
- {
- BufferedGraphicsContext? tempContext = null;
- BufferedGraphics? tempBuffer = null;
-
- try
- {
- tempContext = new BufferedGraphicsContext();
- tempBuffer = tempContext.AllocBuffer(targetGraphics, targetDC, targetRectangle);
- tempBuffer.DisposeContext = true;
- }
- finally
- {
- if (tempContext != null && (tempBuffer == null || (tempBuffer != null && !tempBuffer.DisposeContext)))
- {
- tempContext.Dispose();
- }
- }
-
- return tempBuffer;
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// This routine allows us to control the point were we start using throw away
- /// managers for painting. Since the buffer manager stays around (by default)
- /// for the life of the app, we don't want to consume too much memory
- /// in the buffer. However, re-allocating the buffer for small things (like
- /// buttons, labels, etc) will hit us on runtime performance.
- ///
- private bool ShouldUseTempManager(Rectangle targetBounds)
- {
- return (targetBounds.Width * targetBounds.Height) > (MaximumBuffer.Width * MaximumBuffer.Height);
- }
-
- ///
- /// Fills in the fields of a BITMAPINFO so that we can create a bitmap
- /// that matches the format of the display.
- ///
- /// This is done by creating a compatible bitmap and calling GetDIBits
- /// to return the color masks. This is done with two calls. The first
- /// call passes in biBitCount = 0 to GetDIBits which will fill in the
- /// base BITMAPINFOHEADER data. The second call to GetDIBits (passing
- /// in the BITMAPINFO filled in by the first call) will return the color
- /// table or bitmasks, as appropriate.
- ///
- /// True if successful, false otherwise.
- private unsafe bool FillBitmapInfo(IntPtr hdc, IntPtr hpal, ref Interop.Gdi32.BITMAPINFO_FLAT pbmi)
- {
- IntPtr hbm = IntPtr.Zero;
- bool bRet = false;
- try
- {
- // Create a dummy bitmap from which we can query color format info
- // about the device surface.
- hbm = Interop.Gdi32.CreateCompatibleBitmap(new HandleRef(null, hdc), 1, 1);
-
- if (hbm == IntPtr.Zero)
- {
- throw new OutOfMemoryException(SR.GraphicsBufferQueryFail);
- }
-
- pbmi.bmiHeader_biSize = sizeof(NativeMethods.BITMAPINFOHEADER);
-
- // Call first time to fill in BITMAPINFO header.
- Interop.Gdi32.GetDIBits(new HandleRef(null, hdc),
- new HandleRef(null, hbm),
- 0,
- 0,
- IntPtr.Zero,
- ref pbmi,
- NativeMethods.DIB_RGB_COLORS);
-
- if (pbmi.bmiHeader_biBitCount <= 8)
- {
- bRet = FillColorTable(hdc, hpal, ref pbmi);
- }
- else
- {
- if (pbmi.bmiHeader_biCompression == NativeMethods.BI_BITFIELDS)
- {
- // Call a second time to get the color masks.
- Interop.Gdi32.GetDIBits(new HandleRef(null, hdc),
- new HandleRef(null, hbm),
- 0,
- pbmi.bmiHeader_biHeight,
- IntPtr.Zero,
- ref pbmi,
- NativeMethods.DIB_RGB_COLORS);
- }
- bRet = true;
- }
- }
- finally
- {
- if (hbm != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteObject(hbm);
- }
- }
- return bRet;
- }
-
- ///
- /// Initialize the color table of the BITMAPINFO pointed to by pbmi. Colors
- /// are set to the current system palette.
- ///
- /// Note: call only valid for displays of 8bpp or less.
- ///
- /// True is successful, false otherwise.
- private unsafe bool FillColorTable(IntPtr hdc, IntPtr hpal, ref Interop.Gdi32.BITMAPINFO_FLAT pbmi)
- {
- byte[] aj = new byte[sizeof(NativeMethods.PALETTEENTRY) * 256];
-
- fixed (byte* pcolors = pbmi.bmiColors)
- {
- fixed (byte* ppal = aj)
- {
- NativeMethods.RGBQUAD* prgb = (NativeMethods.RGBQUAD*)pcolors;
- NativeMethods.PALETTEENTRY* lppe = (NativeMethods.PALETTEENTRY*)ppal;
-
- int cColors = 1 << pbmi.bmiHeader_biBitCount;
- if (cColors <= 256)
- {
- // Note: we don't support 4bpp displays.
- uint palRet;
- IntPtr palHalftone = IntPtr.Zero;
- if (hpal == IntPtr.Zero)
- {
- palHalftone = Graphics.GetHalftonePalette();
- palRet = Interop.Gdi32.GetPaletteEntries(new HandleRef(null, palHalftone), 0, cColors, aj);
- }
- else
- {
- palRet = Interop.Gdi32.GetPaletteEntries(new HandleRef(null, hpal), 0, cColors, aj);
- }
-
- if (palRet != 0)
- {
- for (int i = 0; i < cColors; i++)
- {
- prgb[i].rgbRed = lppe[i].peRed;
- prgb[i].rgbGreen = lppe[i].peGreen;
- prgb[i].rgbBlue = lppe[i].peBlue;
- prgb[i].rgbReserved = 0;
- }
-
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- ///
- /// Returns a Graphics object representing a buffer.
- ///
- private Graphics CreateBuffer(IntPtr src, int width, int height)
- {
- // Create the compat DC.
- _busy = BufferBusyDisposing;
- DisposeDC();
- _busy = BufferBusyPainting;
- _compatDC = Interop.Gdi32.CreateCompatibleDC(src);
-
- // Recreate the bitmap if necessary.
- if (width > _bufferSize.Width || height > _bufferSize.Height)
- {
- int optWidth = Math.Max(width, _bufferSize.Width);
- int optHeight = Math.Max(height, _bufferSize.Height);
-
- _busy = BufferBusyDisposing;
- DisposeBitmap();
- _busy = BufferBusyPainting;
-
- IntPtr pvbits = IntPtr.Zero;
- _dib = CreateCompatibleDIB(src, IntPtr.Zero, optWidth, optHeight, ref pvbits);
- _bufferSize = new Size(optWidth, optHeight);
- }
-
- // Select the bitmap.
- _oldBitmap = Interop.Kernel32.SelectObject(new HandleRef(this, _compatDC), new HandleRef(this, _dib));
-
- // Create compat graphics.
- _compatGraphics = Graphics.FromHdcInternal(_compatDC);
- _compatGraphics.TranslateTransform(-_targetLoc.X, -_targetLoc.Y);
- _virtualSize = new Size(width, height);
-
- return _compatGraphics;
- }
-
- ///
- /// Create a DIB section with an optimal format w.r.t. the specified hdc.
- ///
- /// If DIB <= 8bpp, then the DIB color table is initialized based on the
- /// specified palette. If the palette handle is NULL, then the system
- /// palette is used.
- ///
- /// Note: The hdc must be a direct DC (not an info or memory DC).
- ///
- /// Note: On palettized displays, if the system palette changes the
- /// UpdateDIBColorTable function should be called to maintain
- /// the identity palette mapping between the DIB and the display.
- ///
- /// A valid bitmap handle if successful, IntPtr.Zero otherwise.
- private IntPtr CreateCompatibleDIB(IntPtr hdc, IntPtr hpal, int ulWidth, int ulHeight, ref IntPtr ppvBits)
- {
- if (hdc == IntPtr.Zero)
- {
- throw new ArgumentNullException(nameof(hdc));
- }
-
- IntPtr hbmRet = IntPtr.Zero;
- Interop.Gdi32.BITMAPINFO_FLAT pbmi = default;
-
- // Validate hdc.
- Interop.Gdi32.ObjectType objType = Interop.Gdi32.GetObjectType(hdc);
- switch (objType)
- {
- case Interop.Gdi32.ObjectType.OBJ_DC:
- case Interop.Gdi32.ObjectType.OBJ_METADC:
- case Interop.Gdi32.ObjectType.OBJ_MEMDC:
- case Interop.Gdi32.ObjectType.OBJ_ENHMETADC:
- break;
- default:
- throw new ArgumentException(SR.DCTypeInvalid);
- }
-
- if (FillBitmapInfo(hdc, hpal, ref pbmi))
- {
- // Change bitmap size to match specified dimensions.
- pbmi.bmiHeader_biWidth = ulWidth;
- pbmi.bmiHeader_biHeight = ulHeight;
- if (pbmi.bmiHeader_biCompression == NativeMethods.BI_RGB)
- {
- pbmi.bmiHeader_biSizeImage = 0;
- }
- else
- {
- if (pbmi.bmiHeader_biBitCount == 16)
- {
- pbmi.bmiHeader_biSizeImage = ulWidth * ulHeight * 2;
- }
- else if (pbmi.bmiHeader_biBitCount == 32)
- {
- pbmi.bmiHeader_biSizeImage = ulWidth * ulHeight * 4;
- }
- else
- {
- pbmi.bmiHeader_biSizeImage = 0;
- }
- }
- pbmi.bmiHeader_biClrUsed = 0;
- pbmi.bmiHeader_biClrImportant = 0;
-
- // Create the DIB section. Let Win32 allocate the memory and return
- // a pointer to the bitmap surface.
- hbmRet = Interop.Gdi32.CreateDIBSection(new HandleRef(null, hdc), ref pbmi, NativeMethods.DIB_RGB_COLORS, ref ppvBits, IntPtr.Zero, 0);
- Win32Exception? ex = null;
- if (hbmRet == IntPtr.Zero)
- {
- ex = new Win32Exception(Marshal.GetLastWin32Error());
- }
-
- if (ex != null)
- {
- throw ex;
- }
- }
-
- return hbmRet;
- }
-
- ///
- /// Disposes the DC, but leaves the bitmap alone.
- ///
- private void DisposeDC()
- {
- if (_oldBitmap != IntPtr.Zero && _compatDC != IntPtr.Zero)
- {
- Interop.Kernel32.SelectObject(new HandleRef(this, _compatDC), new HandleRef(this, _oldBitmap));
- _oldBitmap = IntPtr.Zero;
- }
-
- if (_compatDC != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteDC(new HandleRef(this, _compatDC));
- _compatDC = IntPtr.Zero;
- }
- }
-
- ///
- /// Disposes the bitmap, will ASSERT if bitmap is being used (checks oldbitmap). if ASSERTed, call DisposeDC() first.
- ///
- private void DisposeBitmap()
- {
- if (_dib != IntPtr.Zero)
- {
- Debug.Assert(_oldBitmap == IntPtr.Zero);
-
- Interop.Gdi32.DeleteObject(new HandleRef(this, _dib));
- _dib = IntPtr.Zero;
- }
- }
-
- ///
- /// Disposes of the Graphics buffer.
- ///
- private void Dispose(bool disposing)
- {
- int oldBusy = Interlocked.CompareExchange(ref _busy, BufferBusyDisposing, BufferFree);
-
- if (disposing)
- {
- if (oldBusy == BufferBusyPainting)
- {
- throw new InvalidOperationException(SR.GraphicsBufferCurrentlyBusy);
- }
-
- if (_compatGraphics != null)
- {
- _compatGraphics.Dispose();
- _compatGraphics = null;
- }
- }
-
- DisposeDC();
- DisposeBitmap();
-
- if (_buffer != null)
- {
- _buffer.Dispose();
- _buffer = null;
- }
-
- _bufferSize = Size.Empty;
- _virtualSize = Size.Empty;
-
- _busy = BufferFree;
- }
-
- ///
- /// Invalidates the cached graphics buffer.
- ///
- public void Invalidate()
- {
- int oldBusy = Interlocked.CompareExchange(ref _busy, BufferBusyDisposing, BufferFree);
-
- // If we're not busy with our buffer, lets clean it up now
- if (oldBusy == BufferFree)
- {
- Dispose();
- _busy = BufferFree;
- }
- else
- {
- // This will indicate to free the buffer as soon as it becomes non-busy.
- _invalidateWhenFree = true;
- }
- }
-
- ///
- /// Returns a Graphics object representing a buffer.
- ///
- internal void ReleaseBuffer()
- {
- _buffer = null;
- if (_invalidateWhenFree)
- {
- // Clears everything including the bitmap.
- _busy = BufferBusyDisposing;
- Dispose();
- }
- else
- {
- // Otherwise, just dispose the DC. A new one will be created next time.
- _busy = BufferBusyDisposing;
-
- // Only clears out the DC.
- DisposeDC();
- }
-
- _busy = BufferFree;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsManager.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsManager.cs
deleted file mode 100644
index 5612b92e732b2..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/BufferedGraphicsManager.cs
+++ /dev/null
@@ -1,33 +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.Runtime.ConstrainedExecution;
-
-namespace System.Drawing
-{
- ///
- /// The BufferedGraphicsManager is used for accessing a BufferedGraphicsContext.
- ///
- public static class BufferedGraphicsManager
- {
- ///
- /// Static constructor. Here, we hook the exit & unload events so we can clean up our context buffer.
- ///
- static BufferedGraphicsManager()
- {
- AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnShutdown);
- AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnShutdown);
- Current = new BufferedGraphicsContext();
- }
-
- ///
- /// Retrieves the context associated with the app domain.
- ///
- public static BufferedGraphicsContext Current { get; }
-
- ///
- /// Called on process exit
- ///
- private static void OnShutdown(object? sender, EventArgs e) => Current.Invalidate();
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/CharacterRange.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/CharacterRange.cs
deleted file mode 100644
index a0dccdc4b2876..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/CharacterRange.cs
+++ /dev/null
@@ -1,50 +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.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- [StructLayout(LayoutKind.Sequential)]
- public struct CharacterRange : IEquatable
- {
- private int _first;
- private int _length;
-
- /// Initializes a new instance of the class with the specified coordinates.
- public CharacterRange(int First, int Length)
- {
- _first = First;
- _length = Length;
- }
-
- /// Gets the First character position of this .
- public int First
- {
- get => _first;
- set => _first = value;
- }
-
- /// Gets the Length of this .
- public int Length
- {
- get => _length;
- set => _length = value;
- }
-
- public override bool Equals([NotNullWhen(true)] object? obj) =>
- obj is CharacterRange other && Equals(other);
-
- /// Indicates whether the current instance is equal to another instance of the same type.
- /// An instance to compare with this instance.
- /// true if the current instance is equal to the other instance; otherwise, false.
- public bool Equals(CharacterRange other) => First == other.First && Length == other.Length;
-
- public static bool operator ==(CharacterRange cr1, CharacterRange cr2) => cr1.Equals(cr2);
-
- public static bool operator !=(CharacterRange cr1, CharacterRange cr2) => !cr1.Equals(cr2);
-
- public override int GetHashCode() => HashCode.Combine(First, Length);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs
deleted file mode 100644
index ddaab963c7823..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ClientUtils.cs
+++ /dev/null
@@ -1,275 +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.Collections;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Security;
-
-namespace System.Drawing
-{
- internal static class ClientUtils
- {
- // ExecutionEngineException is obsolete and shouldn't be used (to catch, throw or reference) anymore.
- // Pragma added to prevent converting the "type is obsolete" warning into build error.
-#pragma warning disable 618
- public static bool IsCriticalException(Exception ex)
- {
- return ex is NullReferenceException
- || ex is StackOverflowException
- || ex is OutOfMemoryException
- || ex is System.Threading.ThreadAbortException
- || ex is ExecutionEngineException
- || ex is IndexOutOfRangeException
- || ex is AccessViolationException;
- }
-#pragma warning restore 618
-
- public static bool IsSecurityOrCriticalException(Exception ex)
- {
- return (ex is SecurityException) || IsCriticalException(ex);
- }
-
- ///
- /// WeakRefCollection - a collection that holds onto weak references.
- ///
- /// Essentially you pass in the object as it is, and under the covers
- /// we only hold a weak reference to the object.
- ///
- /// -----------------------------------------------------------------
- /// !!!IMPORTANT USAGE NOTE!!!
- /// Users of this class should set the RefCheckThreshold property
- /// explicitly or call ScavengeReferences every once in a while to
- /// remove dead references.
- /// Also avoid calling Remove(item). Instead call RemoveByHashCode(item)
- /// to make sure dead refs are removed.
- ///
- internal sealed class WeakRefCollection : IList
- {
- internal WeakRefCollection() : this(4) { }
-
- internal WeakRefCollection(int size) => InnerList = new ArrayList(size);
-
- internal ArrayList InnerList { get; }
-
- ///
- /// Indicates the value where the collection should check its items to remove dead weakref left over.
- /// Note: When GC collects weak refs from this collection the WeakRefObject identity changes since its
- /// Target becomes null. This makes the item unrecognizable by the collection and cannot be
- /// removed - Remove(item) and Contains(item) will not find it anymore.
- /// A value of int.MaxValue means disabled by default.
- ///
- public int RefCheckThreshold { get; set; } = int.MaxValue;
-
- public object? this[int index]
- {
- get
- {
- if (InnerList[index] is WeakRefObject weakRef && weakRef.IsAlive)
- {
- return weakRef.Target;
- }
-
- return null;
- }
- set => InnerList[index] = CreateWeakRefObject(value);
- }
-
- public void ScavengeReferences()
- {
- int currentIndex = 0;
- int currentCount = Count;
- for (int i = 0; i < currentCount; i++)
- {
- object? item = this[currentIndex];
-
- if (item == null)
- {
- InnerList.RemoveAt(currentIndex);
- }
- else
- {
- // Only incriment if we have not removed the item.
- currentIndex++;
- }
- }
- }
-
- public override bool Equals(object? obj)
- {
- if (!(obj is WeakRefCollection other))
- {
- return false;
- }
-
- if (other == null || Count != other.Count)
- {
- return false;
- }
-
- for (int i = 0; i < Count; i++)
- {
- object? thisObj = InnerList[i];
- object? otherObj = other.InnerList[i];
- if (thisObj != otherObj)
- {
- if (thisObj is null || !thisObj.Equals(otherObj))
- {
- return false;
- }
- }
- }
-
- return true;
- }
-
- public override int GetHashCode() => base.GetHashCode();
-
- [return: NotNullIfNotNull(nameof(value))]
- private static WeakRefObject? CreateWeakRefObject(object? value)
- {
- if (value == null)
- {
- return null;
- }
-
- return new WeakRefObject(value);
- }
-
- private static void Copy(WeakRefCollection sourceList, int sourceIndex, WeakRefCollection destinationList, int destinationIndex, int length)
- {
- if (sourceIndex < destinationIndex)
- {
- // We need to copy from the back forward to prevent overwrite if source and
- // destination lists are the same, so we need to flip the source/dest indices
- // to point at the end of the spans to be copied.
- sourceIndex += length;
- destinationIndex += length;
- for (; length > 0; length--)
- {
- destinationList.InnerList[--destinationIndex] = sourceList.InnerList[--sourceIndex];
- }
- }
- else
- {
- for (; length > 0; length--)
- {
- destinationList.InnerList[destinationIndex++] = sourceList.InnerList[sourceIndex++];
- }
- }
- }
-
- ///
- /// Removes the value using its hash code as its identity.
- /// This is needed because the underlying item in the collection may have already been collected changing
- /// the identity of the WeakRefObject making it impossible for the collection to identify it.
- /// See WeakRefObject for more info.
- ///
- public void RemoveByHashCode(object value)
- {
- if (value == null)
- {
- return;
- }
-
- int hash = value.GetHashCode();
-
- for (int idx = 0; idx < InnerList.Count; idx++)
- {
- if (InnerList[idx] != null && InnerList[idx]!.GetHashCode() == hash)
- {
- RemoveAt(idx);
- return;
- }
- }
- }
-
- public void Clear() => InnerList.Clear();
-
- public bool IsFixedSize => InnerList.IsFixedSize;
-
- public bool Contains(object? value) => InnerList.Contains(CreateWeakRefObject(value));
-
- public void RemoveAt(int index) => InnerList.RemoveAt(index);
-
- public void Remove(object? value) => InnerList.Remove(CreateWeakRefObject(value));
-
- public int IndexOf(object? value) => InnerList.IndexOf(CreateWeakRefObject(value));
-
- public void Insert(int index, object? value) => InnerList.Insert(index, CreateWeakRefObject(value));
-
- public int Add(object? value)
- {
- if (Count > RefCheckThreshold)
- {
- ScavengeReferences();
- }
-
- return InnerList.Add(CreateWeakRefObject(value));
- }
-
- public int Count => InnerList.Count;
-
- object ICollection.SyncRoot => InnerList.SyncRoot;
-
- public bool IsReadOnly => InnerList.IsReadOnly;
-
- public void CopyTo(Array array, int index) => InnerList.CopyTo(array, index);
-
- bool ICollection.IsSynchronized => InnerList.IsSynchronized;
-
- public IEnumerator GetEnumerator() => InnerList.GetEnumerator();
-
- ///
- /// Wraps a weak ref object.
- /// WARNING: Use this class carefully!
- /// When the weak ref is collected, this object looses its identity. This is bad when the object has been
- /// added to a collection since Contains(WeakRef(item)) and Remove(WeakRef(item)) would not be able to
- /// identify the item.
- ///
- internal sealed class WeakRefObject
- {
- private readonly int _hash;
- private readonly WeakReference _weakHolder;
-
- internal WeakRefObject(object obj)
- {
- Debug.Assert(obj != null, "Unexpected null object!");
- _weakHolder = new WeakReference(obj);
- _hash = obj.GetHashCode();
- }
-
- internal bool IsAlive => _weakHolder.IsAlive;
-
- internal object? Target => _weakHolder.Target;
-
- public override int GetHashCode() => _hash;
-
- public override bool Equals(object? obj)
- {
- WeakRefObject? other = obj as WeakRefObject;
-
- if (other == this)
- {
- return true;
- }
-
- if (other == null)
- {
- return false;
- }
-
- if (other.Target != Target)
- {
- if (Target == null || !Target.Equals(other.Target))
- {
- return false;
- }
- }
-
- return true;
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ColorConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ColorConverter.cs
deleted file mode 100644
index eadb0ea57ead2..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ColorConverter.cs
+++ /dev/null
@@ -1,410 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing {
- using System.Runtime.Serialization.Formatters;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
- using Microsoft.Win32;
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design.Serialization;
- using System.Globalization;
- using System.Reflection;
- using System.Threading;
-
- ///
- ///
- /// ColorConverter is a class that can be used to convert
- /// colors from one data type to another. Access this
- /// class through the TypeDescriptor.
- ///
- public class ColorConverter : TypeConverter {
- private static string ColorConstantsLock = "colorConstants";
- private static Hashtable colorConstants;
- private static string SystemColorConstantsLock = "systemColorConstants";
- private static Hashtable systemColorConstants;
- private static string ValuesLock = "values";
- private static StandardValuesCollection values;
-
- ///
- ///
- /// [To be supplied.]
- ///
- public ColorConverter() {
- }
-
- ///
- ///
- /// Hashtable of color / value pairs (color name is key)
- /// for standard colors.
- ///
- private static Hashtable Colors {
- get {
- if (colorConstants == null) {
- lock(ColorConstantsLock) {
- if (colorConstants == null) {
- Hashtable tempHash = new Hashtable(StringComparer.OrdinalIgnoreCase);
- FillConstants(tempHash, typeof(Color));
- colorConstants = tempHash;
- }
- }
- }
-
- return colorConstants;
- }
- }
-
- ///
- ///
- /// Hashtable of color / value pairs (color name is key)
- /// for system colors.
- ///
- private static Hashtable SystemColors {
- get {
- if (systemColorConstants == null) {
- lock (SystemColorConstantsLock) {
- if (systemColorConstants == null) {
- Hashtable tempHash = new Hashtable(StringComparer.OrdinalIgnoreCase);
- FillConstants(tempHash, typeof(System.Drawing.SystemColors));
- systemColorConstants = tempHash;
- }
- }
- }
-
- return systemColorConstants;
- }
- }
-
- ///
- ///
- /// Determines if this converter can convert an object in the given source
- /// type to the native type of the converter.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
- if (sourceType == typeof(string)) {
- return true;
- }
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- ///
- /// Gets a value indicating whether this converter can
- /// convert an object to the given destination type using the context.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type? destinationType) {
- if (destinationType == typeof(InstanceDescriptor)) {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- internal static object GetNamedColor(string name) {
- object color = null;
- // First, check to see if this is a standard name.
- //
- color = Colors[name];
- if (color != null) {
- return color;
- }
- // Ok, how about a system color?
- //
- color = SystemColors[name];
- return color;
- }
-
- ///
- ///
- /// Converts the given object to the converter's native type.
- ///
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
- string strValue = value as string;
- if (strValue != null) {
- object obj = null;
- string text = strValue.Trim();
-
- if (text.Length == 0) {
- obj = Color.Empty;
- }
- else {
- // First, check to see if this is a standard name.
- //
- obj = GetNamedColor(text);
-
- if (obj == null) {
- culture ??= CultureInfo.CurrentCulture;
-
- char sep = culture.TextInfo.ListSeparator[0];
- bool tryMappingToKnownColor = true;
-
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
-
- // If the value is a 6 digit hex number only, then
- // we want to treat the Alpha as 255, not 0
- //
- if (text.IndexOf(sep) == -1) {
-
- // text can be '' (empty quoted string)
- if (text.Length >= 2 && (text[0] == '\'' || text[0] == '"') && text[0] == text[text.Length -1]) {
- // In quotes means a named value
- string colorName = text.Substring(1, text.Length - 2);
- obj = Color.FromName(colorName);
- tryMappingToKnownColor = false;
- }
- else if ((text.Length == 7 && text[0] == '#') ||
- (text.Length == 8 && (text.StartsWith("0x") || text.StartsWith("0X"))) ||
- (text.Length == 8 && (text.StartsWith("&h") || text.StartsWith("&H")))) {
- // Note: ConvertFromString will raise exception if value cannot be converted.
- obj = Color.FromArgb(unchecked((int)(0xFF000000 | (uint)(int)intConverter.ConvertFromString(context, culture, text))));
- }
- }
-
- // Nope. Parse the RGBA from the text.
- //
- if (obj == null) {
- string[] tokens = text.Split(sep);
- int[] values = new int[tokens.Length];
- for (int i = 0; i < values.Length; i++) {
- values[i] = unchecked((int)intConverter.ConvertFromString(context, culture, tokens[i]));
- }
-
- // We should now have a number of parsed integer values.
- // We support 1, 3, or 4 arguments:
- //
- // 1 -- full ARGB encoded
- // 3 -- RGB
- // 4 -- ARGB
- //
- switch (values.Length) {
- case 1:
- obj = Color.FromArgb(values[0]);
- break;
-
- case 3:
- obj = Color.FromArgb(values[0], values[1], values[2]);
- break;
-
- case 4:
- obj = Color.FromArgb(values[0], values[1], values[2], values[3]);
- break;
- }
- tryMappingToKnownColor = true;
- }
-
- if ((obj != null) && tryMappingToKnownColor) {
-
- // Now check to see if this color matches one of our known colors.
- // If it does, then substitute it. We can only do this for "Colors"
- // because system colors morph with user settings.
- //
- int targetARGB = ((Color)obj).ToArgb();
-
- foreach (Color c in Colors.Values) {
- if (c.ToArgb() == targetARGB) {
- obj = c;
- break;
- }
- }
- }
- }
-
- if (obj == null) {
- throw new ArgumentException(SR.Format(SR.InvalidColor, text));
- }
- }
- return obj;
- }
- return base.ConvertFrom(context, culture, value);
- }
-
- ///
- ///
- /// Converts the given object to another type. The most common types to convert
- /// are to and from a string object. The default implementation will make a call
- /// to ToString on the object if the object is valid and if the destination
- /// type is string. If this cannot convert to the destination type, this will
- /// throw a NotSupportedException.
- ///
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
- if (destinationType == null) {
- throw new ArgumentNullException(nameof(destinationType));
- }
-
- if ( value is Color ){
- if (destinationType == typeof(string)) {
- Color c = (Color)value;
-
- if (c == Color.Empty) {
- return string.Empty;
- }
- else {
- // If this is a known color, then Color can provide its own
- // name. Otherwise, we fabricate an ARGB value for it.
- //
- if (c.IsKnownColor) {
- return c.Name;
- }
- else if (c.IsNamedColor) {
- return "'" + c.Name + "'";
- }
- else {
- culture ??= CultureInfo.CurrentCulture;
- string sep = culture.TextInfo.ListSeparator + " ";
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- string[] args;
- int nArg = 0;
-
- if (c.A < 255) {
- args = new string[4];
- args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.A);
- }
- else {
- args = new string[3];
- }
-
- // Note: ConvertToString will raise exception if value cannot be converted.
- args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.R);
- args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.G);
- args[nArg++] = intConverter.ConvertToString(context, culture, (object)c.B);
-
- // Now slam all of these together with the fantastic Join
- // method.
- //
- return string.Join(sep, args);
- }
- }
- }
- if (destinationType == typeof(InstanceDescriptor)) {
- MemberInfo member = null;
- object[] args = null;
-
- Color c = (Color)value;
-
- if (c.IsEmpty) {
- member = typeof(Color).GetField("Empty");
- }
- else if (c.IsSystemColor) {
- member = typeof(SystemColors).GetProperty(c.Name);
- }
- else if (c.IsKnownColor) {
- member = typeof(Color).GetProperty(c.Name);
- }
- else if (c.A != 255) {
- member = typeof(Color).GetMethod("FromArgb", new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)});
- args = new object[] {c.A, c.R, c.G, c.B};
- }
- else if (c.IsNamedColor) {
- member = typeof(Color).GetMethod("FromName", new Type[] {typeof(string)});
- args = new object[] {c.Name};
- }
- else {
- member = typeof(Color).GetMethod("FromArgb", new Type[] {typeof(int), typeof(int), typeof(int)});
- args = new object[] {c.R, c.G, c.B};
- }
-
- Debug.Assert(member != null, "Could not convert color to member. Did someone change method name / signature and not update Colorconverter?");
- if (member != null) {
- return new InstanceDescriptor(member, args);
- }
- else {
- return null;
- }
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- ///
- ///
- /// Fills the given hashtable with field name / value pairs. It walks all public static
- /// properties of enumType that have a property type of Color.
- ///
- private static void FillConstants(Hashtable hash, Type enumType) {
- MethodAttributes attrs = MethodAttributes.Public | MethodAttributes.Static;
- PropertyInfo[] props = enumType.GetProperties();
-
- for (int i = 0; i < props.Length; i++) {
- PropertyInfo prop = props[i];
- if (prop.PropertyType == typeof(Color)) {
- MethodInfo method = prop.GetGetMethod();
- if (method != null && (method.Attributes & attrs) == attrs) {
- object[] tempIndex = null;
- hash[prop.Name] = prop.GetValue(null, tempIndex);
- }
- }
- }
- }
-
- ///
- ///
- /// Retrieves a collection containing a set of standard values
- /// for the data type this validator is designed for. This
- /// will return null if the data type does not support a
- /// standard set of values.
- ///
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
- if (values == null) {
- lock (ValuesLock) {
- if (values == null) {
-
- // We must take the value from each hashtable and combine them.
- //
- ArrayList arrayValues = new ArrayList();
- arrayValues.AddRange(Colors.Values);
- arrayValues.AddRange(SystemColors.Values);
-
- // Now, we have a couple of colors that have the same names but
- // are identical values. Look for these and remove them. Too
- // bad this is n^2.
- //
- int count = arrayValues.Count;
- for (int i = 0; i < count - 1; i++) {
- for (int j = i + 1; j < count; j++) {
- if (arrayValues[i].Equals(arrayValues[j])) {
- // Remove this item!
- //
- arrayValues.RemoveAt(j);
- count--;
- j--;
- }
- }
- }
-
- // Sort the array.
- //
- arrayValues.Sort(0, arrayValues.Count, new ColorComparer());
- values = new StandardValuesCollection(arrayValues.ToArray());
- }
- }
- }
-
- return values;
- }
-
- ///
- ///
- /// Determines if this object supports a standard set of values
- /// that can be picked from a list.
- ///
- public override bool GetStandardValuesSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- ///
- ///
- /// IComparer for color values. This takes color values but compares their
- /// names.
- ///
- private sealed class ColorComparer : IComparer {
-
- public int Compare(object left, object right) {
- Color cLeft = (Color)left;
- Color cRight = (Color)right;
- return string.Compare(cLeft.Name, cRight.Name, false, CultureInfo.InvariantCulture);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ContentAlignment.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ContentAlignment.cs
deleted file mode 100644
index 12a1932e19c82..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ContentAlignment.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies alignment of content on the drawing surface.
- ///
- [System.ComponentModel.Editor("System.Drawing.Design.ContentAlignmentEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public enum ContentAlignment
- {
- ///
- /// Content is vertically aligned at the top, and horizontally aligned on the left.
- ///
- TopLeft = 0x001,
- ///
- /// Content is vertically aligned at the top, and horizontally aligned at the center.
- ///
- TopCenter = 0x002,
- ///
- /// Content is vertically aligned at the top, and horizontally aligned on the right.
- ///
- TopRight = 0x004,
- ///
- /// Content is vertically aligned in the middle, and horizontally aligned on the left.
- ///
- MiddleLeft = 0x010,
- ///
- /// Content is vertically aligned in the middle, and horizontally aligned at the center.
- ///
- MiddleCenter = 0x020,
- ///
- /// Content is vertically aligned in the middle, and horizontally aligned on the right.
- ///
- MiddleRight = 0x040,
- ///
- /// Content is vertically aligned at the bottom, and horizontally aligned on the left.
- ///
- BottomLeft = 0x100,
- ///
- /// Content is vertically aligned at the bottom, and horizontally aligned at the center.
- ///
- BottomCenter = 0x200,
- ///
- /// Content is vertically aligned at the bottom, and horizontally aligned on the right.
- ///
- BottomRight = 0x400,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/CopyPixelOperation.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/CopyPixelOperation.cs
deleted file mode 100644
index ae66effca9ef4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/CopyPixelOperation.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the Copy Pixel (ROP) operation.
- ///
- public enum CopyPixelOperation
- {
- ///
- /// Fills the Destination Rectangle using the color associated with the index 0 in the physical palette.
- ///
- Blackness = Interop.Gdi32.RasterOp.BLACKNESS,
- ///
- /// Includes any windows that are Layered on Top.
- ///
- CaptureBlt = Interop.Gdi32.RasterOp.CAPTUREBLT,
- DestinationInvert = Interop.Gdi32.RasterOp.DSTINVERT,
- MergeCopy = Interop.Gdi32.RasterOp.MERGECOPY,
- MergePaint = Interop.Gdi32.RasterOp.MERGEPAINT,
- NoMirrorBitmap = Interop.Gdi32.RasterOp.NOMIRRORBITMAP,
- NotSourceCopy = Interop.Gdi32.RasterOp.NOTSRCCOPY,
- NotSourceErase = Interop.Gdi32.RasterOp.NOTSRCERASE,
- PatCopy = Interop.Gdi32.RasterOp.PATCOPY,
- PatInvert = Interop.Gdi32.RasterOp.PATINVERT,
- PatPaint = Interop.Gdi32.RasterOp.PATPAINT,
- SourceAnd = Interop.Gdi32.RasterOp.SRCAND,
- SourceCopy = Interop.Gdi32.RasterOp.SRCCOPY,
- SourceErase = Interop.Gdi32.RasterOp.SRCERASE,
- SourceInvert = Interop.Gdi32.RasterOp.SRCINVERT,
- SourcePaint = Interop.Gdi32.RasterOp.SRCPAINT,
- Whiteness = Interop.Gdi32.RasterOp.WHITENESS,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/DashCap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/DashCap.cs
deleted file mode 100644
index d387fa3a669a2..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/DashCap.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- ///
- /// Specifies the available dash cap styles with which a can end a line.
- ///
- public enum DashCap
- {
- Flat = 0,
- Round = 2,
- Triangle = 3
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Design/CategoryNameCollection.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Design/CategoryNameCollection.cs
deleted file mode 100644
index bf7662bef81d8..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Design/CategoryNameCollection.cs
+++ /dev/null
@@ -1,47 +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.Collections;
-
-namespace System.Drawing.Design
-{
- ///
- /// A collection that stores objects.
- ///
- public sealed class CategoryNameCollection : ReadOnlyCollectionBase
- {
- ///
- /// Initializes a new instance of based on another
- /// .
- ///
- public CategoryNameCollection(CategoryNameCollection value) => InnerList.AddRange(value);
-
- ///
- /// Initializes a new instance of containing any array of
- /// objects.
- ///
- public CategoryNameCollection(string[] value) => InnerList.AddRange(value);
-
- ///
- /// Represents the entry at the specified index of the .
- ///
- public string this[int index] => ((string)(InnerList[index])!);
-
- ///
- /// Gets a value indicating whether the contains the specified
- /// .
- ///
- public bool Contains(string value) => InnerList.Contains(value);
-
- ///
- /// Copies the values to a one-dimensional instance
- /// at the specified index.
- ///
- public void CopyTo(string[] array, int index) => InnerList.CopyTo(array, index);
-
- ///
- /// Returns the index of a in the .
- ///
- public int IndexOf(string value) => InnerList.IndexOf(value);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/AdjustableArrowCap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/AdjustableArrowCap.cs
deleted file mode 100644
index a74e9debc0391..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/AdjustableArrowCap.cs
+++ /dev/null
@@ -1,83 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed partial class AdjustableArrowCap : CustomLineCap
- {
- internal AdjustableArrowCap(IntPtr nativeCap) : base(nativeCap) { }
-
- public AdjustableArrowCap(float width, float height) : this(width, height, true) { }
-
- public AdjustableArrowCap(float width, float height, bool isFilled)
- {
- IntPtr nativeCap;
- int status = Gdip.GdipCreateAdjustableArrowCap(height, width, isFilled, out nativeCap);
- Gdip.CheckStatus(status);
- SetNativeLineCap(nativeCap);
- }
-
- public float Height
- {
- get
- {
- int status = Gdip.GdipGetAdjustableArrowCapHeight(new HandleRef(this, nativeCap), out float height);
- Gdip.CheckStatus(status);
- return height;
- }
- set
- {
- int status = Gdip.GdipSetAdjustableArrowCapHeight(new HandleRef(this, nativeCap), value);
- Gdip.CheckStatus(status);
- }
- }
-
- public float Width
- {
- get
- {
- int status = Gdip.GdipGetAdjustableArrowCapWidth(new HandleRef(this, nativeCap), out float width);
- Gdip.CheckStatus(status);
- return width;
- }
- set
- {
- int status = Gdip.GdipSetAdjustableArrowCapWidth(new HandleRef(this, nativeCap), value);
- Gdip.CheckStatus(status);
- }
- }
-
- public float MiddleInset
- {
- get
- {
- int status = Gdip.GdipGetAdjustableArrowCapMiddleInset(new HandleRef(this, nativeCap), out float middleInset);
- Gdip.CheckStatus(status);
- return middleInset;
- }
- set
- {
- int status = Gdip.GdipSetAdjustableArrowCapMiddleInset(new HandleRef(this, nativeCap), value);
- Gdip.CheckStatus(status);
- }
- }
-
- public bool Filled
- {
- get
- {
- int status = Gdip.GdipGetAdjustableArrowCapFillState(new HandleRef(this, nativeCap), out bool isFilled);
- Gdip.CheckStatus(status);
- return isFilled;
- }
- set
- {
- int status = Gdip.GdipSetAdjustableArrowCapFillState(new HandleRef(this, nativeCap), value);
- Gdip.CheckStatus(status);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Blend.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Blend.cs
deleted file mode 100644
index a15571d499b7c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Blend.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class Blend
- {
- public Blend()
- {
- Factors = new float[1];
- Positions = new float[1];
- }
-
- public Blend(int count)
- {
- Factors = new float[count];
- Positions = new float[count];
- }
-
- public float[] Factors { get; set; }
-
- public float[] Positions { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/BrushType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/BrushType.cs
deleted file mode 100644
index 2cfd7cff07632..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/BrushType.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- internal enum BrushType
- {
- SolidColor = 0,
- HatchFill = 1,
- TextureFill = 2,
- PathGradient = 3,
- LinearGradient = 4
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/ColorBlend.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/ColorBlend.cs
deleted file mode 100644
index 1b72c2edabdad..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/ColorBlend.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class ColorBlend
- {
- public ColorBlend()
- {
- Colors = new Color[1];
- Positions = new float[1];
- }
-
- public ColorBlend(int count)
- {
- Colors = new Color[count];
- Positions = new float[count];
- }
-
- public Color[] Colors { get; set; }
-
- public float[] Positions { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CombineMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CombineMode.cs
deleted file mode 100644
index f7e3cc7246ffd..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CombineMode.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum CombineMode
- {
- Replace = 0,
- Intersect = 1,
- Union = 2,
- Xor = 3,
- Exclude = 4,
- Complement = 5
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingMode.cs
deleted file mode 100644
index 0406af0ea46d9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingMode.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum CompositingMode
- {
- SourceOver = 0,
- SourceCopy = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingQuality.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingQuality.cs
deleted file mode 100644
index 6e9818fcc165b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CompositingQuality.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum CompositingQuality
- {
- Invalid = QualityMode.Invalid,
- Default = QualityMode.Default,
- HighSpeed = QualityMode.Low,
- HighQuality = QualityMode.High,
- GammaCorrected,
- AssumeLinear
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CoordinateSpace.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CoordinateSpace.cs
deleted file mode 100644
index 24ff09c086c01..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CoordinateSpace.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum CoordinateSpace
- {
- World = 0,
- Page = 1,
- Device = 2
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs
deleted file mode 100644
index 481fdce78c88f..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCap.cs
+++ /dev/null
@@ -1,211 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- // Handle to native line cap object
- internal SafeCustomLineCapHandle nativeCap = null!;
-
- private bool _disposed;
-
- // For subclass creation
- internal CustomLineCap() { }
-
- public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath) : this(fillPath, strokePath, LineCap.Flat) { }
-
- public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath, LineCap baseCap) : this(fillPath, strokePath, baseCap, 0) { }
-
- public CustomLineCap(GraphicsPath? fillPath, GraphicsPath? strokePath, LineCap baseCap, float baseInset)
- {
- IntPtr nativeLineCap;
- int status = Gdip.GdipCreateCustomLineCap(
- new HandleRef(fillPath, (fillPath == null) ? IntPtr.Zero : fillPath._nativePath),
- new HandleRef(strokePath, (strokePath == null) ? IntPtr.Zero : strokePath._nativePath),
- baseCap, baseInset, out nativeLineCap);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- SetNativeLineCap(nativeLineCap);
- }
-
- internal CustomLineCap(IntPtr nativeLineCap) => SetNativeLineCap(nativeLineCap);
-
- internal static CustomLineCap CreateCustomLineCapObject(IntPtr cap)
- {
- int status = Gdip.GdipGetCustomLineCapType(cap, out CustomLineCapType capType);
- if (status != Gdip.Ok)
- {
- Gdip.GdipDeleteCustomLineCap(cap);
- throw Gdip.StatusException(status);
- }
-
- switch (capType)
- {
- case CustomLineCapType.Default:
- return new CustomLineCap(cap);
-
- case CustomLineCapType.AdjustableArrowCap:
- return new AdjustableArrowCap(cap);
- }
-
- Gdip.GdipDeleteCustomLineCap(cap);
- throw Gdip.StatusException(Gdip.NotImplemented);
- }
-
- internal void SetNativeLineCap(IntPtr handle)
- {
- if (handle == IntPtr.Zero)
- throw new ArgumentNullException(nameof(handle));
-
- nativeCap = new SafeCustomLineCapHandle(handle);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
-#if FINALIZATION_WATCH
- if (!disposing && nativeCap != null)
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
-#endif
- // propagate the explicit dispose call to the child
- if (disposing && nativeCap != null)
- {
- nativeCap.Dispose();
- }
-
- _disposed = true;
- }
-
- ~CustomLineCap() => Dispose(false);
-
- public object Clone()
- {
- return CoreClone();
- }
-
- internal virtual object CoreClone()
- {
- IntPtr clonedCap;
- int status = Gdip.GdipCloneCustomLineCap(new HandleRef(this, nativeCap), out clonedCap);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return CreateCustomLineCapObject(clonedCap);
- }
-
- public void SetStrokeCaps(LineCap startCap, LineCap endCap)
- {
- int status = Gdip.GdipSetCustomLineCapStrokeCaps(new HandleRef(this, nativeCap), startCap, endCap);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void GetStrokeCaps(out LineCap startCap, out LineCap endCap)
- {
- int status = Gdip.GdipGetCustomLineCapStrokeCaps(new HandleRef(this, nativeCap), out startCap, out endCap);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public LineJoin StrokeJoin
- {
- get
- {
- int status = Gdip.GdipGetCustomLineCapStrokeJoin(new HandleRef(this, nativeCap), out LineJoin lineJoin);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return lineJoin;
- }
- set
- {
- int status = Gdip.GdipSetCustomLineCapStrokeJoin(new HandleRef(this, nativeCap), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- public LineCap BaseCap
- {
- get
- {
- int status = Gdip.GdipGetCustomLineCapBaseCap(new HandleRef(this, nativeCap), out LineCap baseCap);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return baseCap;
- }
- set
- {
- int status = Gdip.GdipSetCustomLineCapBaseCap(new HandleRef(this, nativeCap), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- public float BaseInset
- {
- get
- {
- int status = Gdip.GdipGetCustomLineCapBaseInset(new HandleRef(this, nativeCap), out float inset);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return inset;
- }
- set
- {
- int status = Gdip.GdipSetCustomLineCapBaseInset(new HandleRef(this, nativeCap), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- public float WidthScale
- {
- get
- {
- int status = Gdip.GdipGetCustomLineCapWidthScale(new HandleRef(this, nativeCap), out float widthScale);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return widthScale;
- }
- set
- {
- int status = Gdip.GdipSetCustomLineCapWidthScale(new HandleRef(this, nativeCap), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCapType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCapType.cs
deleted file mode 100644
index a5422e172daad..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/CustomLineCapType.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- internal enum CustomLineCapType
- {
- Default = 0,
- AdjustableArrowCap = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/DashStyle.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/DashStyle.cs
deleted file mode 100644
index 42c3fa3fc6a73..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/DashStyle.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum DashStyle
- {
- Solid = 0,
- Dash = 1,
- Dot = 2,
- DashDot = 3,
- DashDotDot = 4,
- Custom = 5
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FillMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FillMode.cs
deleted file mode 100644
index 4b86ef500b862..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FillMode.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum FillMode
- {
- Alternate = 0,
- Winding = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FlushIntention.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FlushIntention.cs
deleted file mode 100644
index 551f96cf0b96b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/FlushIntention.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- // FlushIntentionFlush merely means that all the pending commands have been passed to
- // the hardware, and that the final results will be shown as soon as the hardware finishes
- // its rendering. FlushIntentionSync means to wait for the hardware to actually finish its
- // rendering before returning - this is important for animation and timing loops.
- public enum FlushIntention
- {
- // Flush all batched rendering operations
- Flush = 0,
-
- // Flush all batched rendering operations and wait for them to complete
- Sync = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsContainer.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsContainer.cs
deleted file mode 100644
index f501b3c8b856c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsContainer.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class GraphicsContainer : MarshalByRefObject
- {
- internal GraphicsContainer(int graphicsContainer) => nativeGraphicsContainer = graphicsContainer;
-
- internal int nativeGraphicsContainer;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.cs
deleted file mode 100644
index c0918a7b84991..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPath.cs
+++ /dev/null
@@ -1,778 +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.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Internal;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable
- {
- internal IntPtr _nativePath;
-
- private const float Flatness = (float)2.0 / (float)3.0;
-
- public GraphicsPath() : this(FillMode.Alternate) { }
-
- public GraphicsPath(FillMode fillMode)
- {
- Gdip.CheckStatus(Gdip.GdipCreatePath(unchecked((int)fillMode), out IntPtr nativePath));
- _nativePath = nativePath;
- }
-
- public GraphicsPath(PointF[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { }
-
- public unsafe GraphicsPath(PointF[] pts, byte[] types, FillMode fillMode)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- if (pts.Length != types.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- fixed (PointF* p = pts)
- fixed (byte* t = types)
- {
- Gdip.CheckStatus(Gdip.GdipCreatePath2(
- p, t, types.Length, (int)fillMode, out IntPtr nativePath));
-
- _nativePath = nativePath;
- }
- }
-
- public GraphicsPath(Point[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { }
-
- public unsafe GraphicsPath(Point[] pts, byte[] types, FillMode fillMode)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- if (pts.Length != types.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- fixed (byte* t = types)
- fixed (Point* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipCreatePath2I(
- p, t, types.Length, unchecked((int)fillMode), out IntPtr nativePath));
-
- _nativePath = nativePath;
- }
- }
-
- public object Clone()
- {
- Gdip.CheckStatus(Gdip.GdipClonePath(new HandleRef(this, _nativePath), out IntPtr clonedPath));
-
- return new GraphicsPath(clonedPath);
- }
-
- private GraphicsPath(IntPtr nativePath)
- {
- if (nativePath == IntPtr.Zero)
- throw new ArgumentNullException(nameof(nativePath));
-
- _nativePath = nativePath;
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (_nativePath != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeletePath(new HandleRef(this, _nativePath));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsSecurityOrCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during Dispose: " + ex.ToString());
- }
- finally
- {
- _nativePath = IntPtr.Zero;
- }
- }
- }
-
- ~GraphicsPath() => Dispose(false);
-
- public void Reset()
- {
- Gdip.CheckStatus(Gdip.GdipResetPath(new HandleRef(this, _nativePath)));
- }
-
- public FillMode FillMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathFillMode(new HandleRef(this, _nativePath), out FillMode fillmode));
- return fillmode;
- }
- set
- {
- if (value < FillMode.Alternate || value > FillMode.Winding)
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(FillMode));
-
- Gdip.CheckStatus(Gdip.GdipSetPathFillMode(new HandleRef(this, _nativePath), value));
- }
- }
-
- private unsafe PathData _GetPathData()
- {
- int count = PointCount;
-
- PathData pathData = new PathData()
- {
- Types = new byte[count],
- Points = new PointF[count]
- };
-
- if (count == 0)
- return pathData;
-
- fixed (byte* t = pathData.Types)
- fixed (PointF* p = pathData.Points)
- {
- GpPathData data = new GpPathData
- {
- Count = count,
- Points = p,
- Types = t
- };
-
- Gdip.CheckStatus(Gdip.GdipGetPathData(new HandleRef(this, _nativePath), &data));
- }
-
- return pathData;
- }
-
- public PathData PathData => _GetPathData();
-
- public void StartFigure()
- {
- Gdip.CheckStatus(Gdip.GdipStartPathFigure(new HandleRef(this, _nativePath)));
- }
-
- public void CloseFigure()
- {
- Gdip.CheckStatus(Gdip.GdipClosePathFigure(new HandleRef(this, _nativePath)));
- }
-
- public void CloseAllFigures()
- {
- Gdip.CheckStatus(Gdip.GdipClosePathFigures(new HandleRef(this, _nativePath)));
- }
-
- public void SetMarkers()
- {
- Gdip.CheckStatus(Gdip.GdipSetPathMarker(new HandleRef(this, _nativePath)));
- }
-
- public void ClearMarkers()
- {
- Gdip.CheckStatus(Gdip.GdipClearPathMarkers(new HandleRef(this, _nativePath)));
- }
-
- public void Reverse()
- {
- Gdip.CheckStatus(Gdip.GdipReversePath(new HandleRef(this, _nativePath)));
- }
-
- public PointF GetLastPoint()
- {
- Gdip.CheckStatus(Gdip.GdipGetPathLastPoint(new HandleRef(this, _nativePath), out PointF point));
- return point;
- }
-
- public bool IsVisible(float x, float y) => IsVisible(new PointF(x, y), null);
-
- public bool IsVisible(PointF point) => IsVisible(point, null);
-
- public bool IsVisible(float x, float y, Graphics? graphics) => IsVisible(new PointF(x, y), graphics);
-
- public bool IsVisible(PointF pt, Graphics? graphics)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisiblePathPoint(
- new HandleRef(this, _nativePath),
- pt.X, pt.Y,
- new HandleRef(graphics, graphics?.NativeGraphics ?? IntPtr.Zero),
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsVisible(int x, int y) => IsVisible(new Point(x, y), null);
-
- public bool IsVisible(Point point) => IsVisible(point, null);
-
- public bool IsVisible(int x, int y, Graphics? graphics) => IsVisible(new Point(x, y), graphics);
-
- public bool IsVisible(Point pt, Graphics? graphics)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisiblePathPointI(
- new HandleRef(this, _nativePath),
- pt.X, pt.Y,
- new HandleRef(graphics, graphics?.NativeGraphics ?? IntPtr.Zero),
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsOutlineVisible(float x, float y, Pen pen) => IsOutlineVisible(new PointF(x, y), pen, null);
-
- public bool IsOutlineVisible(PointF point, Pen pen) => IsOutlineVisible(point, pen, null);
-
- public bool IsOutlineVisible(float x, float y, Pen pen, Graphics? graphics)
- {
- return IsOutlineVisible(new PointF(x, y), pen, graphics);
- }
-
- public bool IsOutlineVisible(PointF pt, Pen pen, Graphics? graphics)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- Gdip.CheckStatus(Gdip.GdipIsOutlineVisiblePathPoint(
- new HandleRef(this, _nativePath),
- pt.X, pt.Y,
- new HandleRef(pen, pen.NativePen),
- new HandleRef(graphics, graphics?.NativeGraphics ?? IntPtr.Zero),
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsOutlineVisible(int x, int y, Pen pen) => IsOutlineVisible(new Point(x, y), pen, null);
-
- public bool IsOutlineVisible(Point point, Pen pen) => IsOutlineVisible(point, pen, null);
-
- public bool IsOutlineVisible(int x, int y, Pen pen, Graphics? graphics) => IsOutlineVisible(new Point(x, y), pen, graphics);
-
- public bool IsOutlineVisible(Point pt, Pen pen, Graphics? graphics)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- Gdip.CheckStatus(Gdip.GdipIsOutlineVisiblePathPointI(
- new HandleRef(this, _nativePath),
- pt.X, pt.Y,
- new HandleRef(pen, pen.NativePen),
- new HandleRef(graphics, graphics?.NativeGraphics ?? IntPtr.Zero),
- out bool isVisible));
-
- return isVisible;
- }
-
- public void AddLine(PointF pt1, PointF pt2) => AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
-
- public void AddLine(float x1, float y1, float x2, float y2)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathLine(new HandleRef(this, _nativePath), x1, y1, x2, y2));
- }
-
- public unsafe void AddLines(PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (points.Length == 0)
- throw new ArgumentException(null, nameof(points));
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathLine2(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public void AddLine(Point pt1, Point pt2) => AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
-
- public void AddLine(int x1, int y1, int x2, int y2)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathLineI(new HandleRef(this, _nativePath), x1, y1, x2, y2));
- }
-
- public unsafe void AddLines(Point[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (points.Length == 0)
- throw new ArgumentException(null, nameof(points));
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathLine2I(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public void AddArc(RectangleF rect, float startAngle, float sweepAngle)
- {
- AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- public void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathArc(
- new HandleRef(this, _nativePath),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- public void AddArc(Rectangle rect, float startAngle, float sweepAngle)
- {
- AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- public void AddArc(int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathArcI(
- new HandleRef(this, _nativePath),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- public void AddBezier(PointF pt1, PointF pt2, PointF pt3, PointF pt4)
- {
- AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
-
- public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathBezier(
- new HandleRef(this, _nativePath),
- x1, y1, x2, y2, x3, y3, x4, y4));
- }
-
- public unsafe void AddBeziers(PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathBeziers(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public void AddBezier(Point pt1, Point pt2, Point pt3, Point pt4)
- {
- AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
-
- public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathBezierI(
- new HandleRef(this, _nativePath),
- x1, y1, x2, y2, x3, y3, x4, y4));
- }
-
- public unsafe void AddBeziers(params Point[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (points.Length == 0)
- return;
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathBeziersI(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- ///
- /// Add cardinal splines to the path object
- ///
- public unsafe void AddCurve(PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurve(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public unsafe void AddCurve(PointF[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (points.Length == 0)
- return;
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurve2(new HandleRef(this, _nativePath), p, points.Length, tension));
- }
- }
-
- public unsafe void AddCurve(PointF[] points, int offset, int numberOfSegments, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurve3(
- new HandleRef(this, _nativePath), p, points.Length, offset, numberOfSegments, tension));
- }
- }
-
- public unsafe void AddCurve(Point[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurveI(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public unsafe void AddCurve(Point[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurve2I(
- new HandleRef(this, _nativePath), p, points.Length, tension));
- }
- }
-
- public unsafe void AddCurve(Point[] points, int offset, int numberOfSegments, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathCurve3I(
- new HandleRef(this, _nativePath), p, points.Length, offset, numberOfSegments, tension));
- }
- }
-
- public unsafe void AddClosedCurve(PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve(
- new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public unsafe void AddClosedCurve(PointF[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve2(new HandleRef(this, _nativePath), p, points.Length, tension));
- }
- }
-
- public unsafe void AddClosedCurve(Point[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathClosedCurveI(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public unsafe void AddClosedCurve(Point[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve2I(new HandleRef(this, _nativePath), p, points.Length, tension));
- }
- }
-
- public void AddRectangle(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathRectangle(
- new HandleRef(this, _nativePath),
- rect.X, rect.Y, rect.Width, rect.Height));
- }
-
- public unsafe void AddRectangles(RectangleF[] rects)
- {
- ArgumentNullException.ThrowIfNull(rects);
-
- if (rects.Length == 0)
- throw new ArgumentException(null, nameof(rects));
-
- fixed (RectangleF* r = rects)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathRectangles(
- new HandleRef(this, _nativePath), r, rects.Length));
- }
- }
-
- public void AddRectangle(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathRectangleI(
- new HandleRef(this, _nativePath),
- rect.X, rect.Y, rect.Width, rect.Height));
- }
-
- public unsafe void AddRectangles(Rectangle[] rects)
- {
- ArgumentNullException.ThrowIfNull(rects);
-
- if (rects.Length == 0)
- throw new ArgumentException(null, nameof(rects));
-
- fixed (Rectangle* r = rects)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathRectanglesI(
- new HandleRef(this, _nativePath), r, rects.Length));
- }
- }
-
- public void AddEllipse(RectangleF rect)
- {
- AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- public void AddEllipse(float x, float y, float width, float height)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathEllipse(new HandleRef(this, _nativePath), x, y, width, height));
- }
-
- public void AddEllipse(Rectangle rect) => AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
-
- public void AddEllipse(int x, int y, int width, int height)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathEllipseI(new HandleRef(this, _nativePath), x, y, width, height));
- }
-
- public void AddPie(Rectangle rect, float startAngle, float sweepAngle)
- {
- AddPie(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathPie(
- new HandleRef(this, _nativePath),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- public void AddPie(int x, int y, int width, int height, float startAngle, float sweepAngle)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathPieI(
- new HandleRef(this, _nativePath),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- public unsafe void AddPolygon(PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathPolygon(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- ///
- /// Adds a polygon to the current figure.
- ///
- public unsafe void AddPolygon(Point[] points)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipAddPathPolygonI(new HandleRef(this, _nativePath), p, points.Length));
- }
- }
-
- public void AddPath(GraphicsPath addingPath, bool connect)
- {
- ArgumentNullException.ThrowIfNull(addingPath);
-
- Gdip.CheckStatus(Gdip.GdipAddPathPath(
- new HandleRef(this, _nativePath), new HandleRef(addingPath, addingPath._nativePath), connect));
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, PointF origin, StringFormat? format)
- {
- AddString(s, family, style, emSize, new RectangleF(origin.X, origin.Y, 0, 0), format);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, Point origin, StringFormat? format)
- {
- AddString(s, family, style, emSize, new Rectangle(origin.X, origin.Y, 0, 0), format);
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat? format)
- {
- ArgumentNullException.ThrowIfNull(family);
-
- Gdip.CheckStatus(Gdip.GdipAddPathString(
- new HandleRef(this, _nativePath),
- s,
- s.Length,
- new HandleRef(family, family?.NativeFamily ?? IntPtr.Zero),
- style,
- emSize,
- ref layoutRect,
- new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero)));
- }
-
- public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat? format)
- {
- ArgumentNullException.ThrowIfNull(family);
-
- Gdip.CheckStatus(Gdip.GdipAddPathStringI(
- new HandleRef(this, _nativePath),
- s,
- s.Length,
- new HandleRef(family, family?.NativeFamily ?? IntPtr.Zero),
- style,
- emSize,
- ref layoutRect,
- new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero)));
- }
-
- public void Transform(Matrix matrix)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- if (matrix.NativeMatrix == IntPtr.Zero)
- return;
-
- Gdip.CheckStatus(Gdip.GdipTransformPath(
- new HandleRef(this, _nativePath),
- new HandleRef(matrix, matrix.NativeMatrix)));
- }
-
- public RectangleF GetBounds() => GetBounds(null);
-
- public RectangleF GetBounds(Matrix? matrix) => GetBounds(matrix, null);
-
- public RectangleF GetBounds(Matrix? matrix, Pen? pen)
- {
- Gdip.CheckStatus(Gdip.GdipGetPathWorldBounds(
- new HandleRef(this, _nativePath),
- out RectangleF bounds,
- new HandleRef(matrix, matrix?.NativeMatrix ?? IntPtr.Zero),
- new HandleRef(pen, pen?.NativePen ?? IntPtr.Zero)));
-
- return bounds;
- }
-
- public void Flatten() => Flatten(null);
-
- public void Flatten(Matrix? matrix) => Flatten(matrix, 0.25f);
-
- public void Flatten(Matrix? matrix, float flatness)
- {
- Gdip.CheckStatus(Gdip.GdipFlattenPath(
- new HandleRef(this, _nativePath),
- new HandleRef(matrix, matrix?.NativeMatrix ?? IntPtr.Zero),
- flatness));
- }
-
- public void Widen(Pen pen) => Widen(pen, null, Flatness);
-
- public void Widen(Pen pen, Matrix? matrix) => Widen(pen, matrix, Flatness);
-
- public void Widen(Pen pen, Matrix? matrix, float flatness)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- // GDI+ wrongly returns an out of memory status when there is nothing in the path, so we have to check
- // before calling the widen method and do nothing if we dont have anything in the path.
- if (PointCount == 0)
- return;
-
- Gdip.CheckStatus(Gdip.GdipWidenPath(
- new HandleRef(this, _nativePath),
- new HandleRef(pen, pen.NativePen),
- new HandleRef(matrix, matrix?.NativeMatrix ?? IntPtr.Zero),
- flatness));
- }
-
- public void Warp(PointF[] destPoints, RectangleF srcRect) => Warp(destPoints, srcRect, null);
-
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix) => Warp(destPoints, srcRect, matrix, WarpMode.Perspective);
-
- public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode)
- {
- Warp(destPoints, srcRect, matrix, warpMode, 0.25f);
- }
-
- public unsafe void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode, float flatness)
- {
- ArgumentNullException.ThrowIfNull(destPoints);
-
- fixed (PointF* p = destPoints)
- {
- Gdip.CheckStatus(Gdip.GdipWarpPath(
- new HandleRef(this, _nativePath),
- new HandleRef(matrix, matrix?.NativeMatrix ?? IntPtr.Zero),
- p,
- destPoints.Length,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- warpMode,
- flatness));
- }
- }
-
- public int PointCount
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPointCount(new HandleRef(this, _nativePath), out int count));
- return count;
- }
- }
-
- public byte[] PathTypes
- {
- get
- {
- byte[] types = new byte[PointCount];
- Gdip.CheckStatus(Gdip.GdipGetPathTypes(new HandleRef(this, _nativePath), types, types.Length));
- return types;
- }
- }
-
- public unsafe PointF[] PathPoints
- {
- get
- {
- PointF[] points = new PointF[PointCount];
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipGetPathPoints(new HandleRef(this, _nativePath), p, points.Length));
- }
- return points;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPathIterator.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPathIterator.cs
deleted file mode 100644
index 8e83841c4f6c5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsPathIterator.cs
+++ /dev/null
@@ -1,221 +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.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class GraphicsPathIterator : MarshalByRefObject, IDisposable
- {
- public GraphicsPathIterator(GraphicsPath? path)
- {
- IntPtr nativeIter = IntPtr.Zero;
- int status = Gdip.GdipCreatePathIter(out nativeIter, new HandleRef(path, (path == null) ? IntPtr.Zero : path._nativePath));
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- this.nativeIter = nativeIter;
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (nativeIter != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeletePathIter(new HandleRef(this, nativeIter));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsSecurityOrCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during Dispose: " + ex.ToString());
- }
- finally
- {
- nativeIter = IntPtr.Zero;
- }
- }
- }
-
- ~GraphicsPathIterator() => Dispose(false);
-
- public int NextSubpath(out int startIndex, out int endIndex, out bool isClosed)
- {
- int status = Gdip.GdipPathIterNextSubpath(new HandleRef(this, nativeIter), out int resultCount,
- out int tempStart, out int tempEnd, out isClosed);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- else
- {
- startIndex = tempStart;
- endIndex = tempEnd;
- }
-
- return resultCount;
- }
-
- public int NextSubpath(GraphicsPath path, out bool isClosed)
- {
- int status = Gdip.GdipPathIterNextSubpathPath(new HandleRef(this, nativeIter), out int resultCount,
- new HandleRef(path, (path == null) ? IntPtr.Zero : path._nativePath), out isClosed);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
-
- public int NextPathType(out byte pathType, out int startIndex, out int endIndex)
- {
- int status = Gdip.GdipPathIterNextPathType(new HandleRef(this, nativeIter), out int resultCount,
- out pathType, out startIndex, out endIndex);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
-
- public int NextMarker(out int startIndex, out int endIndex)
- {
- int status = Gdip.GdipPathIterNextMarker(new HandleRef(this, nativeIter), out int resultCount,
- out startIndex, out endIndex);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
-
- public int NextMarker(GraphicsPath path)
- {
- int status = Gdip.GdipPathIterNextMarkerPath(new HandleRef(this, nativeIter), out int resultCount,
- new HandleRef(path, (path == null) ? IntPtr.Zero : path._nativePath));
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
-
- public int Count
- {
- get
- {
- int status = Gdip.GdipPathIterGetCount(new HandleRef(this, nativeIter), out int resultCount);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
- }
-
- public int SubpathCount
- {
- get
- {
- int status = Gdip.GdipPathIterGetSubpathCount(new HandleRef(this, nativeIter), out int resultCount);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return resultCount;
- }
- }
-
- public bool HasCurve()
- {
- int status = Gdip.GdipPathIterHasCurve(new HandleRef(this, nativeIter), out bool hasCurve);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return hasCurve;
- }
-
- public void Rewind()
- {
- int status = Gdip.GdipPathIterRewind(new HandleRef(this, nativeIter));
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public unsafe int Enumerate(ref PointF[] points, ref byte[] types)
- {
- if (points.Length != types.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- if (points.Length == 0)
- return 0;
-
- fixed (PointF* p = points)
- fixed (byte* t = types)
- {
- int status = Gdip.GdipPathIterEnumerate(
- new HandleRef(this, nativeIter),
- out int resultCount,
- p,
- t,
- points.Length);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- return resultCount;
- }
- }
-
- public unsafe int CopyData(ref PointF[] points, ref byte[] types, int startIndex, int endIndex)
- {
- if ((points.Length != types.Length) || (endIndex - startIndex + 1 > points.Length))
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- fixed (PointF* p = points)
- fixed (byte* t = types)
- {
- int status = Gdip.GdipPathIterCopyData(
- new HandleRef(this, nativeIter),
- out int resultCount,
- p,
- t,
- startIndex,
- endIndex);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- return resultCount;
- }
- }
-
- // handle to native path iterator object
- internal IntPtr nativeIter;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsState.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsState.cs
deleted file mode 100644
index 2830c42f9eb9c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/GraphicsState.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class GraphicsState : MarshalByRefObject
- {
- internal int nativeState;
-
- internal GraphicsState(int nativeState) => this.nativeState = nativeState;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchBrush.cs
deleted file mode 100644
index c34fe129b8a3c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchBrush.cs
+++ /dev/null
@@ -1,81 +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.Runtime.InteropServices;
-using System.Diagnostics;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class HatchBrush : Brush
- {
- public HatchBrush(HatchStyle hatchstyle, Color foreColor) : this(hatchstyle, foreColor, Color.FromArgb(unchecked((int)0xff000000)))
- {
- }
-
- public HatchBrush(HatchStyle hatchstyle, Color foreColor, Color backColor)
- {
- if (hatchstyle < HatchStyle.Min || hatchstyle > HatchStyle.SolidDiamond)
- {
- throw new ArgumentException(SR.Format(SR.InvalidEnumArgument, nameof(hatchstyle), hatchstyle, nameof(HatchStyle)), nameof(hatchstyle));
- }
-
- IntPtr nativeBrush;
- int status = Gdip.GdipCreateHatchBrush(unchecked((int)hatchstyle), foreColor.ToArgb(), backColor.ToArgb(), out nativeBrush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- internal HatchBrush(IntPtr nativeBrush)
- {
- Debug.Assert(nativeBrush != IntPtr.Zero, "Initializing native brush with null.");
- SetNativeBrushInternal(nativeBrush);
- }
-
- public override object Clone()
- {
- IntPtr clonedBrush;
- int status = Gdip.GdipCloneBrush(new HandleRef(this, NativeBrush), out clonedBrush);
- Gdip.CheckStatus(status);
-
- return new HatchBrush(clonedBrush);
- }
-
- public HatchStyle HatchStyle
- {
- get
- {
- int hatchStyle;
- int status = Gdip.GdipGetHatchStyle(new HandleRef(this, NativeBrush), out hatchStyle);
- Gdip.CheckStatus(status);
-
- return (HatchStyle)hatchStyle;
- }
- }
-
- public Color ForegroundColor
- {
- get
- {
- int foregroundArgb;
- int status = Gdip.GdipGetHatchForegroundColor(new HandleRef(this, NativeBrush), out foregroundArgb);
- Gdip.CheckStatus(status);
-
- return Color.FromArgb(foregroundArgb);
- }
- }
-
- public Color BackgroundColor
- {
- get
- {
- int backgroundArgb;
- int status = Gdip.GdipGetHatchBackgroundColor(new HandleRef(this, NativeBrush), out backgroundArgb);
- Gdip.CheckStatus(status);
-
- return Color.FromArgb(backgroundArgb);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchStyle.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchStyle.cs
deleted file mode 100644
index a5fde08bbc02e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/HatchStyle.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum HatchStyle
- {
- Horizontal = 0,
- Vertical = 1,
- ForwardDiagonal = 2,
- BackwardDiagonal = 3,
- Cross = 4,
- DiagonalCross = 5,
- Percent05 = 6,
- Percent10 = 7,
- Percent20 = 8,
- Percent25 = 9,
- Percent30 = 10,
- Percent40 = 11,
- Percent50 = 12,
- Percent60 = 13,
- Percent70 = 14,
- Percent75 = 15,
- Percent80 = 16,
- Percent90 = 17,
- LightDownwardDiagonal = 18,
- LightUpwardDiagonal = 19,
- DarkDownwardDiagonal = 20,
- DarkUpwardDiagonal = 21,
- WideDownwardDiagonal = 22,
- WideUpwardDiagonal = 23,
- LightVertical = 24,
- LightHorizontal = 25,
- NarrowVertical = 26,
- NarrowHorizontal = 27,
- DarkVertical = 28,
- DarkHorizontal = 29,
- DashedDownwardDiagonal = 30,
- DashedUpwardDiagonal = 31,
- DashedHorizontal = 32,
- DashedVertical = 33,
- SmallConfetti = 34,
- LargeConfetti = 35,
- ZigZag = 36,
- Wave = 37,
- DiagonalBrick = 38,
- HorizontalBrick = 39,
- Weave = 40,
- Plaid = 41,
- Divot = 42,
- DottedGrid = 43,
- DottedDiamond = 44,
- Shingle = 45,
- Trellis = 46,
- Sphere = 47,
- SmallGrid = 48,
- SmallCheckerBoard = 49,
- LargeCheckerBoard = 50,
- OutlinedDiamond = 51,
- SolidDiamond = 52,
-
- LargeGrid = Cross,
- Min = Horizontal,
- Max = LargeGrid
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/InterpolationMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/InterpolationMode.cs
deleted file mode 100644
index 1bc25cfda148b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/InterpolationMode.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum InterpolationMode
- {
- Invalid = QualityMode.Invalid,
- Default = QualityMode.Default,
- Low = QualityMode.Low,
- High = QualityMode.High,
- Bilinear,
- Bicubic,
- NearestNeighbor,
- HighQualityBilinear,
- HighQualityBicubic
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineCap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineCap.cs
deleted file mode 100644
index 9d9a0cec19247..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineCap.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum LineCap
- {
- Flat = 0,
- Square = 1,
- Round = 2,
- Triangle = 3,
- NoAnchor = 0x10, // corresponds to flat cap
- SquareAnchor = 0x11, // corresponds to square cap
- RoundAnchor = 0x12, // corresponds to round cap
- DiamondAnchor = 0x13, // corresponds to triangle cap
- ArrowAnchor = 0x14, // no correspondence
-
- Custom = 0xff, // custom cap
- AnchorMask = 0xf0 // mask to check for anchor or not.
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineJoin.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineJoin.cs
deleted file mode 100644
index 3a5953a640351..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LineJoin.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.
-
-namespace System.Drawing.Drawing2D
-{
- public enum LineJoin
- {
- Miter = 0,
- Bevel = 1,
- Round = 2,
- MiterClipped = 3
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs
deleted file mode 100644
index 68b674586aa81..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientBrush.cs
+++ /dev/null
@@ -1,518 +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.ComponentModel;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class LinearGradientBrush : Brush
- {
- private bool _interpolationColorsWasSet;
-
- public LinearGradientBrush(PointF point1, PointF point2, Color color1, Color color2)
- {
- Gdip.CheckStatus(Gdip.GdipCreateLineBrush(
- ref point1, ref point2,
- color1.ToArgb(), color2.ToArgb(),
- WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- public LinearGradientBrush(Point point1, Point point2, Color color1, Color color2)
- {
- Gdip.CheckStatus(Gdip.GdipCreateLineBrushI(
- ref point1, ref point2,
- color1.ToArgb(), color2.ToArgb(),
- WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- public LinearGradientBrush(RectangleF rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
- {
- if (linearGradientMode < LinearGradientMode.Horizontal || linearGradientMode > LinearGradientMode.BackwardDiagonal)
- throw new InvalidEnumArgumentException(nameof(linearGradientMode), unchecked((int)linearGradientMode), typeof(LinearGradientMode));
-
- if (rect.Width == 0.0 || rect.Height == 0.0)
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
-
- Gdip.CheckStatus(Gdip.GdipCreateLineBrushFromRect(
- ref rect,
- color1.ToArgb(),
- color2.ToArgb(),
- linearGradientMode,
- WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- public LinearGradientBrush(Rectangle rect, Color color1, Color color2, LinearGradientMode linearGradientMode)
- {
- if (linearGradientMode < LinearGradientMode.Horizontal || linearGradientMode > LinearGradientMode.BackwardDiagonal)
- throw new InvalidEnumArgumentException(nameof(linearGradientMode), unchecked((int)linearGradientMode), typeof(LinearGradientMode));
- if (rect.Width == 0 || rect.Height == 0)
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
-
- Gdip.CheckStatus(Gdip.GdipCreateLineBrushFromRectI(
- ref rect,
- color1.ToArgb(),
- color2.ToArgb(),
- linearGradientMode,
- WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- public LinearGradientBrush(RectangleF rect, Color color1, Color color2, float angle) : this(rect, color1, color2, angle, false)
- {
- }
-
- public LinearGradientBrush(RectangleF rect, Color color1, Color color2, float angle, bool isAngleScaleable)
- {
- if (rect.Width == 0.0 || rect.Height == 0.0)
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
-
- Gdip.CheckStatus(Gdip.GdipCreateLineBrushFromRectWithAngle(
- ref rect,
- color1.ToArgb(),
- color2.ToArgb(),
- angle,
- isAngleScaleable,
- (int)WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- public LinearGradientBrush(Rectangle rect, Color color1, Color color2, float angle) : this(rect, color1, color2, angle, false)
- {
- }
-
- public LinearGradientBrush(Rectangle rect, Color color1, Color color2, float angle, bool isAngleScaleable)
- {
- if (rect.Width == 0 || rect.Height == 0)
- throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
-
- Gdip.CheckStatus(Gdip.GdipCreateLineBrushFromRectWithAngleI(
- ref rect,
- color1.ToArgb(),
- color2.ToArgb(),
- angle,
- isAngleScaleable,
- WrapMode.Tile,
- out IntPtr nativeBrush));
-
- SetNativeBrushInternal(nativeBrush);
- }
-
- internal LinearGradientBrush(IntPtr nativeBrush)
- {
- Debug.Assert(nativeBrush != IntPtr.Zero, "Initializing native brush with null.");
- SetNativeBrushInternal(nativeBrush);
- }
-
- public override object Clone()
- {
- Gdip.CheckStatus(Gdip.GdipCloneBrush(new HandleRef(this, NativeBrush), out IntPtr clonedBrush));
- return new LinearGradientBrush(clonedBrush);
- }
-
- public Color[] LinearColors
- {
- get
- {
- int[] colors = new int[] { 0, 0 };
- Gdip.CheckStatus(Gdip.GdipGetLineColors(new HandleRef(this, NativeBrush), colors));
-
- return new Color[]
- {
- Color.FromArgb(colors[0]),
- Color.FromArgb(colors[1])
- };
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetLineColors(
- new HandleRef(this, NativeBrush),
- value[0].ToArgb(),
- value[1].ToArgb()));
- }
- }
-
- public RectangleF Rectangle
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetLineRect(new HandleRef(this, NativeBrush), out RectangleF rect));
- return rect;
- }
- }
-
- public bool GammaCorrection
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetLineGammaCorrection(
- new HandleRef(this, NativeBrush),
- out bool useGammaCorrection));
-
- return useGammaCorrection;
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetLineGammaCorrection(new HandleRef(this, NativeBrush), value));
- }
- }
-
- public Blend? Blend
- {
- get
- {
- // Interpolation colors and blends don't work together very well. Getting the Blend when InterpolationColors
- // is set puts the Brush into an unusable state afterwards.
- // Bail out here to avoid that.
- if (_interpolationColorsWasSet)
- return null;
-
- // Figure out the size of blend factor array.
- Gdip.CheckStatus(Gdip.GdipGetLineBlendCount(new HandleRef(this, NativeBrush), out int retval));
-
- if (retval <= 0)
- return null;
-
- // Allocate a temporary native memory buffer.
- int count = retval;
- IntPtr factors = IntPtr.Zero;
- IntPtr positions = IntPtr.Zero;
-
- try
- {
- int size = checked(4 * count);
- factors = Marshal.AllocHGlobal(size);
- positions = Marshal.AllocHGlobal(size);
-
- // Retrieve horizontal blend factors.
- Gdip.CheckStatus(Gdip.GdipGetLineBlend(new HandleRef(this, NativeBrush), factors, positions, count));
-
- // Return the result in a managed array.
- var blend = new Blend(count);
-
- Marshal.Copy(factors, blend.Factors, 0, count);
- Marshal.Copy(positions, blend.Positions, 0, count);
-
- return blend;
- }
- finally
- {
- if (factors != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(factors);
- }
- if (positions != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(positions);
- }
- }
- }
- set
- {
- // Do explicit parameter validation here; libgdiplus does not correctly validate the arguments
-
- // This is the original behavior on Desktop .NET
- if (value == null || value.Factors == null)
- throw new NullReferenceException();
-
- if (value.Positions == null)
- throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, "value.Positions", value.Positions), nameof(value));
-
- int count = value.Factors.Length;
-
- if (count == 0 || value.Positions.Length == 0)
- throw new ArgumentException(SR.BlendObjectMustHaveTwoElements);
- if (count >= 2 && count != value.Positions.Length)
- throw new ArgumentOutOfRangeException(nameof(value));
- if (count >= 2 && value.Positions[0] != 0.0F)
- throw new ArgumentException(SR.BlendObjectFirstElementInvalid);
- if (count >= 2 && value.Positions[count - 1] != 1.0F)
- throw new ArgumentException(SR.BlendObjectLastElementInvalid);
-
- // Allocate temporary native memory buffer and copy input blend factors into it.
- IntPtr factors = IntPtr.Zero;
- IntPtr positions = IntPtr.Zero;
-
- try
- {
- int size = checked(4 * count);
- factors = Marshal.AllocHGlobal(size);
- positions = Marshal.AllocHGlobal(size);
-
- Marshal.Copy(value.Factors, 0, factors, count);
- Marshal.Copy(value.Positions, 0, positions, count);
-
- // Set blend factors.
- Gdip.CheckStatus(Gdip.GdipSetLineBlend(
- new HandleRef(this, NativeBrush),
- factors,
- positions,
- count));
- }
- finally
- {
- if (factors != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(factors);
- }
- if (positions != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(positions);
- }
- }
- }
- }
-
- public void SetSigmaBellShape(float focus) => SetSigmaBellShape(focus, (float)1.0);
-
- public void SetSigmaBellShape(float focus, float scale)
- {
- if (focus < 0 || focus > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
- if (scale < 0 || scale > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
-
- Gdip.CheckStatus(Gdip.GdipSetLineSigmaBlend(new HandleRef(this, NativeBrush), focus, scale));
- }
-
- public void SetBlendTriangularShape(float focus) => SetBlendTriangularShape(focus, (float)1.0);
-
- public void SetBlendTriangularShape(float focus, float scale)
- {
- if (focus < 0 || focus > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
- if (scale < 0 || scale > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
-
- Gdip.CheckStatus(Gdip.GdipSetLineLinearBlend(new HandleRef(this, NativeBrush), focus, scale));
-
- // Setting a triangular shape overrides the explicitly set interpolation colors. libgdiplus correctly clears
- // the interpolation colors (https://github.com/mono/libgdiplus/blob/master/src/lineargradientbrush.c#L959) but
- // returns WrongState instead of ArgumentException (https://github.com/mono/libgdiplus/blob/master/src/lineargradientbrush.c#L814)
- // when calling GdipGetLinePresetBlend, so it is important we set this to false. This way, we are sure get_InterpolationColors
- // will return an ArgumentException.
- _interpolationColorsWasSet = false;
- }
-
- public ColorBlend InterpolationColors
- {
- get
- {
- if (!_interpolationColorsWasSet)
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsColorBlendNotSet, string.Empty));
-
- // Figure out the size of blend factor array.
- Gdip.CheckStatus(Gdip.GdipGetLinePresetBlendCount(new HandleRef(this, NativeBrush), out int retval));
-
- // Allocate temporary native memory buffer.
- int count = retval;
-
- IntPtr colors = IntPtr.Zero;
- IntPtr positions = IntPtr.Zero;
-
- try
- {
- int size = checked(4 * count);
- colors = Marshal.AllocHGlobal(size);
- positions = Marshal.AllocHGlobal(size);
-
- // Retrieve horizontal blend factors.
- Gdip.CheckStatus(Gdip.GdipGetLinePresetBlend(new HandleRef(this, NativeBrush), colors, positions, count));
-
- // Return the result in a managed array.
- var blend = new ColorBlend(count);
-
- int[] argb = new int[count];
- Marshal.Copy(colors, argb, 0, count);
- Marshal.Copy(positions, blend.Positions, 0, count);
-
- // Copy ARGB values into Color array of ColorBlend.
- blend.Colors = new Color[argb.Length];
-
- for (int i = 0; i < argb.Length; i++)
- {
- blend.Colors[i] = Color.FromArgb(argb[i]);
- }
-
- return blend;
- }
- finally
- {
- if (colors != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(colors);
- }
- if (positions != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(positions);
- }
- }
- }
- set
- {
- _interpolationColorsWasSet = true;
-
- if (value == null)
- {
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsInvalidColorBlendObject, string.Empty));
- }
- else if (value.Colors.Length < 2)
- {
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsInvalidColorBlendObject,
- SR.InterpolationColorsLength));
- }
- else if (value.Colors.Length != value.Positions.Length)
- {
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsInvalidColorBlendObject,
- SR.InterpolationColorsLengthsDiffer));
- }
- else if (value.Positions[0] != 0.0f)
- {
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsInvalidColorBlendObject,
- SR.InterpolationColorsInvalidStartPosition));
- }
- else if (value.Positions[value.Positions.Length - 1] != 1.0f)
- {
- throw new ArgumentException(SR.Format(SR.InterpolationColorsCommon,
- SR.InterpolationColorsInvalidColorBlendObject,
- SR.InterpolationColorsInvalidEndPosition));
- }
-
-
- // Allocate a temporary native memory buffer and copy input blend factors into it.
- int count = value.Colors.Length;
- IntPtr colors = IntPtr.Zero;
- IntPtr positions = IntPtr.Zero;
-
- try
- {
- int size = checked(4 * count);
- colors = Marshal.AllocHGlobal(size);
- positions = Marshal.AllocHGlobal(size);
-
- int[] argbs = new int[count];
- for (int i = 0; i < count; i++)
- {
- argbs[i] = value.Colors[i].ToArgb();
- }
-
- Marshal.Copy(argbs, 0, colors, count);
- Marshal.Copy(value.Positions, 0, positions, count);
-
- // Set blend factors.
- Gdip.CheckStatus(Gdip.GdipSetLinePresetBlend(new HandleRef(this, NativeBrush), colors, positions, count));
- }
- finally
- {
- if (colors != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(colors);
- }
- if (positions != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(positions);
- }
- }
- }
- }
-
- public WrapMode WrapMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetLineWrapMode(new HandleRef(this, NativeBrush), out int mode));
- return (WrapMode)mode;
- }
- set
- {
- if (value < WrapMode.Tile || value > WrapMode.Clamp)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(WrapMode));
-
- Gdip.CheckStatus(Gdip.GdipSetLineWrapMode(new HandleRef(this, NativeBrush), unchecked((int)value)));
- }
- }
-
- public Matrix Transform
- {
- get
- {
- var matrix = new Matrix();
- Gdip.CheckStatus(Gdip.GdipGetLineTransform(new HandleRef(this, NativeBrush), new HandleRef(matrix, matrix.NativeMatrix)));
- return matrix;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException(nameof(value));
-
- Gdip.CheckStatus(Gdip.GdipSetLineTransform(new HandleRef(this, NativeBrush), new HandleRef(value, value.NativeMatrix)));
- }
- }
-
- public void ResetTransform()
- {
- Gdip.CheckStatus(Gdip.GdipResetLineTransform(new HandleRef(this, NativeBrush)));
- }
-
- public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);
-
- public void MultiplyTransform(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- // Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
- // with the libgdiplus backend. Simulate a nop for compatibility with GDI+.
- if (matrix.NativeMatrix == IntPtr.Zero)
- return;
-
- Gdip.CheckStatus(Gdip.GdipMultiplyLineTransform(
- new HandleRef(this, NativeBrush),
- new HandleRef(matrix, matrix.NativeMatrix),
- order));
- }
-
- public void TranslateTransform(float dx, float dy) => TranslateTransform(dx, dy, MatrixOrder.Prepend);
-
- public void TranslateTransform(float dx, float dy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateLineTransform(
- new HandleRef(this, NativeBrush), dx, dy, order));
- }
-
- public void ScaleTransform(float sx, float sy) => ScaleTransform(sx, sy, MatrixOrder.Prepend);
-
- public void ScaleTransform(float sx, float sy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipScaleLineTransform(
- new HandleRef(this, NativeBrush), sx, sy, order));
- }
-
- public void RotateTransform(float angle) => RotateTransform(angle, MatrixOrder.Prepend);
-
- public void RotateTransform(float angle, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipRotateLineTransform(
- new HandleRef(this, NativeBrush), angle, order));
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientMode.cs
deleted file mode 100644
index d51c5c8a69091..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/LinearGradientMode.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public enum LinearGradientMode
- {
- Horizontal = 0,
- Vertical = 1,
- ForwardDiagonal = 2,
- BackwardDiagonal = 3
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Matrix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Matrix.cs
deleted file mode 100644
index 0a90b2da9ea8b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/Matrix.cs
+++ /dev/null
@@ -1,336 +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.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Numerics;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class Matrix : MarshalByRefObject, IDisposable
- {
- internal IntPtr NativeMatrix { get; private set; }
-
- public Matrix()
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix(out IntPtr nativeMatrix));
- NativeMatrix = nativeMatrix;
- }
-
- public Matrix(float m11, float m12, float m21, float m22, float dx, float dy)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, out IntPtr nativeMatrix));
- NativeMatrix = nativeMatrix;
- }
-
- ///
- /// Construct a utilizing the given .
- ///
- /// Matrix data to construct from.
- public Matrix(Matrix3x2 matrix) : this(CreateNativeHandle(matrix))
- {
- }
-
- private Matrix(IntPtr nativeMatrix)
- {
- NativeMatrix = nativeMatrix;
- }
-
- internal static IntPtr CreateNativeHandle(Matrix3x2 matrix)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix2(
- matrix.M11,
- matrix.M12,
- matrix.M21,
- matrix.M22,
- matrix.M31,
- matrix.M32,
- out IntPtr nativeMatrix));
-
- return nativeMatrix;
- }
-
- public unsafe Matrix(RectangleF rect, PointF[] plgpts)
- {
- ArgumentNullException.ThrowIfNull(plgpts);
-
- if (plgpts.Length != 3)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- fixed (PointF* p = plgpts)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix3(ref rect, p, out IntPtr nativeMatrix));
- NativeMatrix = nativeMatrix;
- }
- }
-
- public unsafe Matrix(Rectangle rect, Point[] plgpts)
- {
- ArgumentNullException.ThrowIfNull(plgpts);
-
- if (plgpts.Length != 3)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- fixed (Point* p = plgpts)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix3I(ref rect, p, out IntPtr nativeMatrix));
- NativeMatrix = nativeMatrix;
- }
- }
-
- public void Dispose()
- {
- DisposeInternal();
- GC.SuppressFinalize(this);
- }
-
- private void DisposeInternal()
- {
- if (NativeMatrix != IntPtr.Zero)
- {
- if (Gdip.Initialized)
- {
- Gdip.GdipDeleteMatrix(new HandleRef(this, NativeMatrix));
- }
- NativeMatrix = IntPtr.Zero;
- }
- }
-
- ~Matrix() => DisposeInternal();
-
- public Matrix Clone()
- {
- Gdip.CheckStatus(Gdip.GdipCloneMatrix(new HandleRef(this, NativeMatrix), out IntPtr clonedMatrix));
- return new Matrix(clonedMatrix);
- }
-
- public float[] Elements
- {
- get
- {
- float[] elements = new float[6];
- GetElements(elements);
- return elements;
- }
- }
-
- ///
- /// Gets/sets the elements for the matrix.
- ///
- public unsafe Matrix3x2 MatrixElements
- {
- get
- {
- Matrix3x2 matrix = default;
- Gdip.CheckStatus(Gdip.GdipGetMatrixElements(new HandleRef(this, NativeMatrix), (float*)&matrix));
- return matrix;
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetMatrixElements(
- new HandleRef(this, NativeMatrix),
- value.M11,
- value.M12,
- value.M21,
- value.M22,
- value.M31,
- value.M32));
- }
- }
-
- internal unsafe void GetElements(Span elements)
- {
- Debug.Assert(elements.Length >= 6);
-
- fixed (float* m = elements)
- {
- Gdip.CheckStatus(Gdip.GdipGetMatrixElements(new HandleRef(this, NativeMatrix), m));
- }
- }
-
- public unsafe float OffsetX => Offset.X;
-
- public unsafe float OffsetY => Offset.Y;
-
- internal unsafe PointF Offset
- {
- get
- {
- Span elements = stackalloc float[6];
- GetElements(elements);
- return new PointF(elements[4], elements[5]);
- }
- }
-
- public void Reset()
- {
- Gdip.CheckStatus(Gdip.GdipSetMatrixElements(
- new HandleRef(this, NativeMatrix),
- 1.0f, 0.0f, 0.0f,
- 1.0f, 0.0f, 0.0f));
- }
-
- public void Multiply(Matrix matrix) => Multiply(matrix, MatrixOrder.Prepend);
-
- public void Multiply(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- if (matrix.NativeMatrix == NativeMatrix)
- throw new InvalidOperationException(SR.GdiplusObjectBusy);
-
- Gdip.CheckStatus(Gdip.GdipMultiplyMatrix(
- new HandleRef(this, NativeMatrix),
- new HandleRef(matrix, matrix.NativeMatrix),
- order));
- }
-
- public void Translate(float offsetX, float offsetY) => Translate(offsetX, offsetY, MatrixOrder.Prepend);
-
- public void Translate(float offsetX, float offsetY, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateMatrix(
- new HandleRef(this, NativeMatrix),
- offsetX, offsetY, order));
- }
-
- public void Scale(float scaleX, float scaleY) => Scale(scaleX, scaleY, MatrixOrder.Prepend);
-
- public void Scale(float scaleX, float scaleY, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipScaleMatrix(new HandleRef(this, NativeMatrix), scaleX, scaleY, order));
- }
-
- public void Rotate(float angle) => Rotate(angle, MatrixOrder.Prepend);
-
- public void Rotate(float angle, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipRotateMatrix(new HandleRef(this, NativeMatrix), angle, order));
- }
-
- public void RotateAt(float angle, PointF point) => RotateAt(angle, point, MatrixOrder.Prepend);
- public void RotateAt(float angle, PointF point, MatrixOrder order)
- {
- int status;
- if (order == MatrixOrder.Prepend)
- {
- status = Gdip.GdipTranslateMatrix(new HandleRef(this, NativeMatrix), point.X, point.Y, order);
- status |= Gdip.GdipRotateMatrix(new HandleRef(this, NativeMatrix), angle, order);
- status |= Gdip.GdipTranslateMatrix(new HandleRef(this, NativeMatrix), -point.X, -point.Y, order);
- }
- else
- {
- status = Gdip.GdipTranslateMatrix(new HandleRef(this, NativeMatrix), -point.X, -point.Y, order);
- status |= Gdip.GdipRotateMatrix(new HandleRef(this, NativeMatrix), angle, order);
- status |= Gdip.GdipTranslateMatrix(new HandleRef(this, NativeMatrix), point.X, point.Y, order);
- }
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void Shear(float shearX, float shearY)
- {
- Gdip.CheckStatus(Gdip.GdipShearMatrix(new HandleRef(this, NativeMatrix), shearX, shearY, MatrixOrder.Prepend));
- }
-
- public void Shear(float shearX, float shearY, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipShearMatrix(new HandleRef(this, NativeMatrix), shearX, shearY, order));
- }
-
- public void Invert()
- {
- Gdip.CheckStatus(Gdip.GdipInvertMatrix(new HandleRef(this, NativeMatrix)));
- }
-
- public unsafe void TransformPoints(PointF[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (PointF* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipTransformMatrixPoints(
- new HandleRef(this, NativeMatrix),
- p,
- pts.Length));
- }
- }
-
- public unsafe void TransformPoints(Point[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (Point* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipTransformMatrixPointsI(
- new HandleRef(this, NativeMatrix),
- p,
- pts.Length));
- }
- }
-
- public unsafe void TransformVectors(PointF[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (PointF* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipVectorTransformMatrixPoints(
- new HandleRef(this, NativeMatrix),
- p,
- pts.Length));
- }
- }
-
- public void VectorTransformPoints(Point[] pts) => TransformVectors(pts);
-
- public unsafe void TransformVectors(Point[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (Point* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipVectorTransformMatrixPointsI(
- new HandleRef(this, NativeMatrix),
- p,
- pts.Length));
- }
- }
-
- public bool IsInvertible
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipIsMatrixInvertible(new HandleRef(this, NativeMatrix), out int isInvertible));
- return isInvertible != 0;
- }
- }
-
- public bool IsIdentity
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipIsMatrixIdentity(new HandleRef(this, NativeMatrix), out int isIdentity));
- return isIdentity != 0;
- }
- }
-
- public override bool Equals([NotNullWhen(true)] object? obj)
- {
- if (!(obj is Matrix matrix2))
- return false;
-
- Gdip.CheckStatus(Gdip.GdipIsMatrixEqual(
- new HandleRef(this, NativeMatrix),
- new HandleRef(matrix2, matrix2.NativeMatrix),
- out int isEqual));
-
- return isEqual != 0;
- }
-
- public override int GetHashCode() => base.GetHashCode();
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/MatrixOrder.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/MatrixOrder.cs
deleted file mode 100644
index 8910e0e88c334..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/MatrixOrder.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum MatrixOrder
- {
- Prepend = 0,
- Append = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathData.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathData.cs
deleted file mode 100644
index 0fbe7ed638c6d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathData.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class PathData
- {
- public PathData() { }
-
- public PointF[]? Points { get; set; }
-
- public byte[]? Types { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathGradientBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathGradientBrush.cs
deleted file mode 100644
index 8b548b1ae431c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathGradientBrush.cs
+++ /dev/null
@@ -1,408 +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.Runtime.InteropServices;
-using System.Diagnostics;
-using System.ComponentModel;
-using System.Drawing.Internal;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class PathGradientBrush : Brush
- {
- public PathGradientBrush(PointF[] points) : this(points, WrapMode.Clamp) { }
-
- public unsafe PathGradientBrush(PointF[] points, WrapMode wrapMode)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (wrapMode < WrapMode.Tile || wrapMode > WrapMode.Clamp)
- throw new InvalidEnumArgumentException(nameof(wrapMode), unchecked((int)wrapMode), typeof(WrapMode));
-
- // GdipCreatePathGradient returns InsufficientBuffer for less than 3 points, which we turn into
- // OutOfMemoryException(). We used to copy nothing into an empty native buffer for zero points,
- // which gives a valid pointer. Fixing an empty array gives a null pointer, which causes an
- // InvalidParameter result, which we turn into an ArgumentException. Matching the old throw.
- if (points.Length == 0)
- throw new OutOfMemoryException();
-
- fixed (PointF* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipCreatePathGradient(
- p, points.Length, wrapMode, out IntPtr nativeBrush));
- SetNativeBrushInternal(nativeBrush);
- }
- }
-
- public PathGradientBrush(Point[] points) : this(points, WrapMode.Clamp) { }
-
- public unsafe PathGradientBrush(Point[] points, WrapMode wrapMode)
- {
- ArgumentNullException.ThrowIfNull(points);
-
- if (wrapMode < WrapMode.Tile || wrapMode > WrapMode.Clamp)
- throw new InvalidEnumArgumentException(nameof(wrapMode), unchecked((int)wrapMode), typeof(WrapMode));
-
- // GdipCreatePathGradient returns InsufficientBuffer for less than 3 points, which we turn into
- // OutOfMemoryException(). We used to copy nothing into an empty native buffer for zero points,
- // which gives a valid pointer. Fixing an empty array gives a null pointer, which causes an
- // InvalidParameter result, which we turn into an ArgumentException. Matching the old throw.
- if (points.Length == 0)
- throw new OutOfMemoryException();
-
- fixed (Point* p = points)
- {
- Gdip.CheckStatus(Gdip.GdipCreatePathGradientI(
- p, points.Length, wrapMode, out IntPtr nativeBrush));
- SetNativeBrushInternal(nativeBrush);
- }
- }
-
- public PathGradientBrush(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCreatePathGradientFromPath(new HandleRef(path, path._nativePath), out IntPtr nativeBrush));
- SetNativeBrushInternal(nativeBrush);
- }
-
- internal PathGradientBrush(IntPtr nativeBrush)
- {
- Debug.Assert(nativeBrush != IntPtr.Zero, "Initializing native brush with null.");
- SetNativeBrushInternal(nativeBrush);
- }
-
- public override object Clone()
- {
- Gdip.CheckStatus(Gdip.GdipCloneBrush(new HandleRef(this, NativeBrush), out IntPtr clonedBrush));
- return new PathGradientBrush(clonedBrush);
- }
-
- public Color CenterColor
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathGradientCenterColor(new HandleRef(this, NativeBrush), out int argb));
- return Color.FromArgb(argb);
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetPathGradientCenterColor(new HandleRef(this, NativeBrush), value.ToArgb()));
- }
- }
-
- public Color[] SurroundColors
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathGradientSurroundColorCount(
- new HandleRef(this, NativeBrush),
- out int count));
-
- int[] argbs = new int[count];
-
- Gdip.CheckStatus(Gdip.GdipGetPathGradientSurroundColorsWithCount(
- new HandleRef(this, NativeBrush),
- argbs,
- ref count));
-
- Color[] colors = new Color[count];
- for (int i = 0; i < count; i++)
- colors[i] = Color.FromArgb(argbs[i]);
-
- return colors;
- }
- set
- {
- int count = value.Length;
- int[] argbs = new int[count];
- for (int i = 0; i < value.Length; i++)
- argbs[i] = value[i].ToArgb();
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientSurroundColorsWithCount(
- new HandleRef(this, NativeBrush),
- argbs,
- ref count));
- }
- }
-
- public PointF CenterPoint
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathGradientCenterPoint(new HandleRef(this, NativeBrush), out PointF point));
- return point;
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetPathGradientCenterPoint(new HandleRef(this, NativeBrush), ref value));
- }
- }
-
- public RectangleF Rectangle
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathGradientRect(new HandleRef(this, NativeBrush), out RectangleF rect));
- return rect;
- }
- }
-
- public Blend Blend
- {
- get
- {
- // Figure out the size of blend factor array
- Gdip.CheckStatus(Gdip.GdipGetPathGradientBlendCount(new HandleRef(this, NativeBrush), out int retval));
-
- // Allocate temporary native memory buffer
-
- int count = retval;
-
- var factors = new float[count];
- var positions = new float[count];
-
- // Retrieve horizontal blend factors
-
- Gdip.CheckStatus(Gdip.GdipGetPathGradientBlend(new HandleRef(this, NativeBrush), factors, positions, count));
-
- // Return the result in a managed array
-
- Blend blend = new Blend(count)
- {
- Factors = factors,
- Positions = positions
- };
-
- return blend;
- }
- set
- {
- // This is the behavior on Desktop
- if (value == null || value.Factors == null)
- throw new NullReferenceException();
-
- if (value.Positions == null)
- throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, "value.Positions", value.Positions), nameof(value));
-
- int count = value.Factors.Length;
-
- // Explicit argument validation, because libgdiplus does not correctly validate all parameters.
- if (count == 0 || value.Positions.Length == 0)
- throw new ArgumentException(SR.BlendObjectMustHaveTwoElements);
- if (count >= 2 && count != value.Positions.Length)
- throw new ArgumentOutOfRangeException(nameof(value));
- if (count >= 2 && value.Positions[0] != 0.0F)
- throw new ArgumentException(SR.BlendObjectFirstElementInvalid);
- if (count >= 2 && value.Positions[count - 1] != 1.0F)
- throw new ArgumentException(SR.BlendObjectLastElementInvalid);
-
- // Allocate temporary native memory buffer
- // and copy input blend factors into it.
- IntPtr factors = IntPtr.Zero;
- IntPtr positions = IntPtr.Zero;
-
- try
- {
- int size = checked(4 * count);
- factors = Marshal.AllocHGlobal(size);
- positions = Marshal.AllocHGlobal(size);
-
- Marshal.Copy(value.Factors, 0, factors, count);
- Marshal.Copy(value.Positions, 0, positions, count);
-
- // Set blend factors
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientBlend(new HandleRef(this, NativeBrush), factors, positions, count));
- }
- finally
- {
- if (factors != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(factors);
- }
- if (positions != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(positions);
- }
- }
- }
- }
-
- public void SetSigmaBellShape(float focus) => SetSigmaBellShape(focus, (float)1.0);
-
- public void SetSigmaBellShape(float focus, float scale)
- {
- if (focus < 0 || focus > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
- if (scale < 0 || scale > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientSigmaBlend(new HandleRef(this, NativeBrush), focus, scale));
- }
-
- public void SetBlendTriangularShape(float focus) => SetBlendTriangularShape(focus, (float)1.0);
-
- public void SetBlendTriangularShape(float focus, float scale)
- {
- if (focus < 0 || focus > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(focus));
- if (scale < 0 || scale > 1)
- throw new ArgumentException(SR.GdiplusInvalidParameter, nameof(scale));
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientLinearBlend(new HandleRef(this, NativeBrush), focus, scale));
- }
-
- public ColorBlend InterpolationColors
- {
- get
- {
- // Figure out the size of blend factor array
- Gdip.CheckStatus(Gdip.GdipGetPathGradientPresetBlendCount(new HandleRef(this, NativeBrush), out int count));
-
- // If count is 0, then there is nothing to marshal.
- // In this case, we'll return an empty ColorBlend...
- if (count == 0)
- return new ColorBlend();
-
- int[] colors = new int[count];
- float[] positions = new float[count];
-
- ColorBlend blend = new ColorBlend(count);
-
- // status would fail if we ask points or types with a < 2 count
- if (count < 2)
- return blend;
-
- // Retrieve horizontal blend factors
- Gdip.CheckStatus(Gdip.GdipGetPathGradientPresetBlend(new HandleRef(this, NativeBrush), colors, positions, count));
-
- // Return the result in a managed array
-
- blend.Positions = positions;
-
- // copy ARGB values into Color array of ColorBlend
- blend.Colors = new Color[count];
-
- for (int i = 0; i < count; i++)
- {
- blend.Colors[i] = Color.FromArgb(colors[i]);
- }
-
- return blend;
- }
- set
- {
- int count = value.Colors.Length;
-
- if (value.Positions == null)
- throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, "value.Positions", value.Positions), nameof(value));
- if (value.Colors.Length != value.Positions.Length)
- throw new ArgumentOutOfRangeException(nameof(value));
-
- float[] positions = value.Positions;
- int[] argbs = new int[count];
- for (int i = 0; i < count; i++)
- {
- argbs[i] = value.Colors[i].ToArgb();
- }
-
- // Set blend factors
- Gdip.CheckStatus(Gdip.GdipSetPathGradientPresetBlend(new HandleRef(this, NativeBrush), argbs, positions, count));
- }
- }
-
- public Matrix Transform
- {
- get
- {
- Matrix matrix = new Matrix();
- Gdip.CheckStatus(Gdip.GdipGetPathGradientTransform(new HandleRef(this, NativeBrush), new HandleRef(matrix, matrix.NativeMatrix)));
- return matrix;
- }
- set
- {
- if (value == null)
- throw new ArgumentNullException(nameof(value));
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientTransform(new HandleRef(this, NativeBrush), new HandleRef(value, value.NativeMatrix)));
- }
- }
-
- public void ResetTransform()
- {
- Gdip.CheckStatus(Gdip.GdipResetPathGradientTransform(new HandleRef(this, NativeBrush)));
- }
-
- public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);
-
- public void MultiplyTransform(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- // Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
- // with the libgdiplus backend. Simulate a nop for compatibility with GDI+.
- if (matrix.NativeMatrix == IntPtr.Zero)
- return;
-
- Gdip.CheckStatus(Gdip.GdipMultiplyPathGradientTransform(
- new HandleRef(this, NativeBrush),
- new HandleRef(matrix, matrix.NativeMatrix),
- order));
- }
-
- public void TranslateTransform(float dx, float dy) => TranslateTransform(dx, dy, MatrixOrder.Prepend);
-
- public void TranslateTransform(float dx, float dy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipTranslatePathGradientTransform(new HandleRef(this, NativeBrush), dx, dy, order));
- }
-
- public void ScaleTransform(float sx, float sy) => ScaleTransform(sx, sy, MatrixOrder.Prepend);
-
- public void ScaleTransform(float sx, float sy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipScalePathGradientTransform(new HandleRef(this, NativeBrush), sx, sy, order));
- }
-
- public void RotateTransform(float angle) => RotateTransform(angle, MatrixOrder.Prepend);
-
- public void RotateTransform(float angle, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipRotatePathGradientTransform(new HandleRef(this, NativeBrush), angle, order));
- }
-
- public PointF FocusScales
- {
- get
- {
- float[] scaleX = new float[] { 0.0f };
- float[] scaleY = new float[] { 0.0f };
-
- Gdip.CheckStatus(Gdip.GdipGetPathGradientFocusScales(new HandleRef(this, NativeBrush), scaleX, scaleY));
- return new PointF(scaleX[0], scaleY[0]);
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetPathGradientFocusScales(new HandleRef(this, NativeBrush), value.X, value.Y));
- }
- }
-
- public WrapMode WrapMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPathGradientWrapMode(new HandleRef(this, NativeBrush), out int mode));
- return (WrapMode)mode;
- }
- set
- {
- if (value < WrapMode.Tile || value > WrapMode.Clamp)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(WrapMode));
-
- Gdip.CheckStatus(Gdip.GdipSetPathGradientWrapMode(new HandleRef(this, NativeBrush), unchecked((int)value)));
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathPointType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathPointType.cs
deleted file mode 100644
index a2b0945477c9a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PathPointType.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum PathPointType
- {
- Start = 0, // move
- Line = 1, // line
- Bezier = 3, // default Beizer (= cubic Bezier)
- PathTypeMask = 0x07, // type mask (lowest 3 bits).
- DashMode = 0x10, // currently in dash mode.
- PathMarker = 0x20, // a marker for the path.
- CloseSubpath = 0x80, // closed flag
-
- // Path types used for advanced path.
- Bezier3 = 3, // cubic Bezier
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenAlignment.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenAlignment.cs
deleted file mode 100644
index 85ae097e88ddb..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenAlignment.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum PenAlignment
- {
- Center = 0,
- Inset = 1,
- Outset = 2,
- Left = 3,
- Right = 4
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenType.cs
deleted file mode 100644
index dcc22d87b730a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PenType.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum PenType
- {
- SolidColor = BrushType.SolidColor,
- HatchFill = BrushType.HatchFill,
- TextureFill = BrushType.TextureFill,
- PathGradient = BrushType.PathGradient,
- LinearGradient = BrushType.LinearGradient,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PixelOffsetMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PixelOffsetMode.cs
deleted file mode 100644
index 11dc9c598d465..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/PixelOffsetMode.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum PixelOffsetMode
- {
- Invalid = QualityMode.Invalid,
- Default = QualityMode.Default,
- HighSpeed = QualityMode.Low,
- HighQuality = QualityMode.High,
- None,
- Half // offset by -0.5, -0.5 for fast anti-alias perf
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/QualityMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/QualityMode.cs
deleted file mode 100644
index 565494343e9c9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/QualityMode.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.
-
-namespace System.Drawing.Drawing2D
-{
- public enum QualityMode
- {
- Invalid = -1,
- Default = 0,
- Low = 1,
- High = 2
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/RegionData.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/RegionData.cs
deleted file mode 100644
index ea6eb21b8ae08..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/RegionData.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public sealed class RegionData
- {
- internal RegionData(byte[] data) => Data = data;
-
- public byte[] Data { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs
deleted file mode 100644
index 410f4478913ba..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SafeCustomLineCapHandle.cs
+++ /dev/null
@@ -1,62 +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.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Security;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Drawing2D
-{
- internal sealed class SafeCustomLineCapHandle : SafeHandle
- {
- public SafeCustomLineCapHandle() : base(IntPtr.Zero, true)
- {
- }
-
- // Create a SafeHandle, informing the base class
- // that this SafeHandle instance "owns" the handle,
- // and therefore SafeHandle should call
- // our ReleaseHandle method when the SafeHandle
- // is no longer in use.
- internal SafeCustomLineCapHandle(IntPtr h) : base(IntPtr.Zero, true)
- {
- SetHandle(h);
- }
-
- protected override bool ReleaseHandle()
- {
- int status = Gdip.Ok;
- if (!IsInvalid)
- {
- try
- {
- status = !Gdip.Initialized ? Gdip.Ok :
- Gdip.GdipDeleteCustomLineCap(new HandleRef(this, handle));
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsSecurityOrCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during ReleaseHandle: " + ex.ToString());
- }
- finally
- {
- handle = IntPtr.Zero;
- }
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
- }
- return status == Gdip.Ok;
- }
-
- public override bool IsInvalid => handle == IntPtr.Zero;
-
- public static implicit operator IntPtr(SafeCustomLineCapHandle handle) => handle?.handle ?? IntPtr.Zero;
-
- public static explicit operator SafeCustomLineCapHandle(IntPtr handle) => new SafeCustomLineCapHandle(handle);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SmoothingMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SmoothingMode.cs
deleted file mode 100644
index 64a162fb76045..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/SmoothingMode.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum SmoothingMode
- {
- Invalid = QualityMode.Invalid,
- Default = QualityMode.Default,
- HighSpeed = QualityMode.Low,
- HighQuality = QualityMode.High,
- None,
- AntiAlias
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WarpMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WarpMode.cs
deleted file mode 100644
index 75c4764f6866b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WarpMode.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum WarpMode
- {
- Perspective = 0,
- Bilinear = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WrapMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WrapMode.cs
deleted file mode 100644
index 22799810e6b8c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Drawing2D/WrapMode.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Drawing2D
-{
- public enum WrapMode
- {
- Tile = 0,
- TileFlipX = 1,
- TileFlipY = 2,
- TileFlipXY = 3,
- Clamp = 4
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs
deleted file mode 100644
index 11f84642eb7e1..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.ComWrappers.cs
+++ /dev/null
@@ -1,325 +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.Collections;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- ///
- /// The ComWrappers implementation for System.Drawing.Common's COM interop usages.
- ///
- /// Supports IStream and IPicture COM interfaces.
- ///
- internal unsafe partial class DrawingCom : ComWrappers
- {
- private const int S_OK = (int)Interop.HRESULT.S_OK;
- private static readonly Guid IID_IStream = new Guid(0x0000000C, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
-
- private static readonly ComInterfaceEntry* s_wrapperEntry = InitializeComInterfaceEntry();
-
- internal static DrawingCom Instance { get; } = new DrawingCom();
-
- private DrawingCom() { }
-
- private static ComInterfaceEntry* InitializeComInterfaceEntry()
- {
- GetIUnknownImpl(out IntPtr fpQueryInterface, out IntPtr fpAddRef, out IntPtr fpRelease);
-
- IntPtr iStreamVtbl = IStreamVtbl.Create(fpQueryInterface, fpAddRef, fpRelease);
-
- ComInterfaceEntry* wrapperEntry = (ComInterfaceEntry*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(DrawingCom), sizeof(ComInterfaceEntry));
- wrapperEntry->IID = IID_IStream;
- wrapperEntry->Vtable = iStreamVtbl;
- return wrapperEntry;
- }
-
- protected override unsafe ComInterfaceEntry* ComputeVtables(object obj, CreateComInterfaceFlags flags, out int count)
- {
- Debug.Assert(obj is Interop.Ole32.IStream);
- Debug.Assert(s_wrapperEntry != null);
-
- // Always return the same table mappings.
- count = 1;
- return s_wrapperEntry;
- }
-
- protected override object CreateObject(IntPtr externalComObject, CreateObjectFlags flags)
- {
- Debug.Assert(flags == CreateObjectFlags.UniqueInstance);
-
- Guid pictureIID = IPicture.IID;
- int hr = Marshal.QueryInterface(externalComObject, ref pictureIID, out IntPtr comObject);
- if (hr == S_OK)
- {
- return new PictureWrapper(comObject);
- }
-
- throw new NotImplementedException();
- }
-
- protected override void ReleaseObjects(IEnumerable objects)
- {
- throw new NotImplementedException();
- }
-
- internal static IStreamWrapper GetComWrapper(Interop.Ole32.IStream stream)
- {
- IntPtr streamWrapperPtr = Instance.GetOrCreateComInterfaceForObject(stream, CreateComInterfaceFlags.None);
-
- Guid streamIID = IID_IStream;
- int result = Marshal.QueryInterface(streamWrapperPtr, ref streamIID, out IntPtr streamPtr);
-
- Marshal.Release(streamWrapperPtr);
-
- ThrowExceptionForHR(result);
-
- return new IStreamWrapper(streamPtr);
- }
-
- internal static void ThrowExceptionForHR(int errorCode)
- {
- // Pass -1 for errorInfo to indicate that Windows' GetErrorInfo shouldn't be called, and only
- // throw the Exception corresponding to the specified errorCode.
- Marshal.ThrowExceptionForHR(errorCode, errorInfo: new IntPtr(-1));
- }
-
- internal static class IStreamVtbl
- {
- public static IntPtr Create(IntPtr fpQueryInterface, IntPtr fpAddRef, IntPtr fpRelease)
- {
- IntPtr* vtblRaw = (IntPtr*)RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(IStreamVtbl), IntPtr.Size * 14);
- vtblRaw[0] = fpQueryInterface;
- vtblRaw[1] = fpAddRef;
- vtblRaw[2] = fpRelease;
- vtblRaw[3] = (IntPtr)(delegate* unmanaged)&Read;
- vtblRaw[4] = (IntPtr)(delegate* unmanaged)&Write;
- vtblRaw[5] = (IntPtr)(delegate* unmanaged)&Seek;
- vtblRaw[6] = (IntPtr)(delegate* unmanaged)&SetSize;
- vtblRaw[7] = (IntPtr)(delegate* unmanaged)&CopyTo;
- vtblRaw[8] = (IntPtr)(delegate* unmanaged)&Commit;
- vtblRaw[9] = (IntPtr)(delegate* unmanaged)&Revert;
- vtblRaw[10] = (IntPtr)(delegate* unmanaged)&LockRegion;
- vtblRaw[11] = (IntPtr)(delegate* unmanaged)&UnlockRegion;
- vtblRaw[12] = (IntPtr)(delegate* unmanaged)&Stat;
- vtblRaw[13] = (IntPtr)(delegate* unmanaged)&Clone;
-
- return (IntPtr)vtblRaw;
- }
-
- [UnmanagedCallersOnly]
- private static int Read(IntPtr thisPtr, byte* pv, uint cb, uint* pcbRead)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Read(pv, cb, pcbRead);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int Write(IntPtr thisPtr, byte* pv, uint cb, uint* pcbWritten)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Write(pv, cb, pcbWritten);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int Seek(IntPtr thisPtr, long dlibMove, SeekOrigin dwOrigin, ulong* plibNewPosition)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Seek(dlibMove, dwOrigin, plibNewPosition);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int SetSize(IntPtr thisPtr, ulong libNewSize)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.SetSize(libNewSize);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int CopyTo(IntPtr thisPtr, IntPtr pstm, ulong cb, ulong* pcbRead, ulong* pcbWritten)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
-
- return (int)inst.CopyTo(pstm, cb, pcbRead, pcbWritten);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
- }
-
- [UnmanagedCallersOnly]
- private static int Commit(IntPtr thisPtr, uint grfCommitFlags)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Commit(grfCommitFlags);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int Revert(IntPtr thisPtr)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Revert();
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int LockRegion(IntPtr thisPtr, ulong libOffset, ulong cb, uint dwLockType)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- return (int)inst.LockRegion(libOffset, cb, dwLockType);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
- }
-
- [UnmanagedCallersOnly]
- private static int UnlockRegion(IntPtr thisPtr, ulong libOffset, ulong cb, uint dwLockType)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- return (int)inst.UnlockRegion(libOffset, cb, dwLockType);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
- }
-
- [UnmanagedCallersOnly]
- private static int Stat(IntPtr thisPtr, Interop.Ole32.STATSTG* pstatstg, Interop.Ole32.STATFLAG grfStatFlag)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
- inst.Stat(pstatstg, grfStatFlag);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
-
- return S_OK;
- }
-
- [UnmanagedCallersOnly]
- private static int Clone(IntPtr thisPtr, IntPtr* ppstm)
- {
- try
- {
- Interop.Ole32.IStream inst = ComInterfaceDispatch.GetInstance((ComInterfaceDispatch*)thisPtr);
-
- return (int)inst.Clone(ppstm);
- }
- catch (Exception e)
- {
- return e.HResult;
- }
- }
- }
-
- internal interface IPicture : IDisposable
- {
- static readonly Guid IID = new Guid(0x7BF80980, 0xBF32, 0x101A, 0x8B, 0xBB, 0, 0xAA, 0x00, 0x30, 0x0C, 0xAB);
-
- // NOTE: Only SaveAsFile is invoked. The other methods on IPicture are not necessary
-
- int SaveAsFile(IntPtr pstm, int fSaveMemCopy, int* pcbSize);
- }
-
- private sealed class PictureWrapper : IPicture
- {
- private readonly IntPtr _wrappedInstance;
-
- public PictureWrapper(IntPtr wrappedInstance)
- {
- _wrappedInstance = wrappedInstance;
- }
-
- public void Dispose()
- {
- Marshal.Release(_wrappedInstance);
- }
-
- public unsafe int SaveAsFile(IntPtr pstm, int fSaveMemCopy, int* pcbSize)
- {
- // Get the IStream implementation, since the ComWrappers runtime returns a pointer to the IUnknown interface implementation
- Guid streamIID = IID_IStream;
- ThrowExceptionForHR(Marshal.QueryInterface(pstm, ref streamIID, out IntPtr pstmImpl));
-
- try
- {
- return ((delegate* unmanaged)(*(*(void***)_wrappedInstance + 15 /* IPicture.SaveAsFile slot */)))
- (_wrappedInstance, pstmImpl, fSaveMemCopy, pcbSize);
- }
- finally
- {
- Marshal.Release(pstmImpl);
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.cs
deleted file mode 100644
index 17c3ce69b1a90..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/DrawingCom.cs
+++ /dev/null
@@ -1,25 +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.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- internal sealed partial class DrawingCom
- {
- internal readonly struct IStreamWrapper : IDisposable
- {
- public readonly IntPtr Ptr;
-
- public IStreamWrapper(IntPtr ptr)
- {
- Ptr = ptr;
- }
-
- public void Dispose()
- {
- Marshal.Release(Ptr);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs
deleted file mode 100644
index a008f77a3c5c1..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Font.cs
+++ /dev/null
@@ -1,737 +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.ComponentModel;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// Defines a particular format for text, including font face, size, and style attributes.
- ///
- [Editor("System.Drawing.Design.FontEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [TypeConverter(typeof(FontConverter))]
- [Serializable]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed class Font : MarshalByRefObject, ICloneable, IDisposable, ISerializable
- {
- private IntPtr _nativeFont;
- private float _fontSize;
- private FontStyle _fontStyle;
- private FontFamily _fontFamily = null!;
- private GraphicsUnit _fontUnit;
- private byte _gdiCharSet = SafeNativeMethods.DEFAULT_CHARSET;
- private bool _gdiVerticalFont;
- private string _systemFontName = "";
- private string? _originalFontName;
-
- // Return value is in Unit (the unit the font was created in)
- ///
- /// Gets the size of this .
- ///
- public float Size => _fontSize;
-
- ///
- /// Gets style information for this .
- ///
- [Browsable(false)]
- public FontStyle Style => _fontStyle;
-
- ///
- /// Gets a value indicating whether this is bold.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool Bold => (Style & FontStyle.Bold) != 0;
-
- ///
- /// Gets a value indicating whether this is Italic.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool Italic => (Style & FontStyle.Italic) != 0;
-
- ///
- /// Gets a value indicating whether this is strikeout (has a line through it).
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool Strikeout => (Style & FontStyle.Strikeout) != 0;
-
- ///
- /// Gets a value indicating whether this is underlined.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool Underline => (Style & FontStyle.Underline) != 0;
-
- ///
- /// Gets the of this .
- ///
- [Browsable(false)]
- public FontFamily FontFamily => _fontFamily;
-
- ///
- /// Gets the face name of this .
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- [Editor("System.Drawing.Design.FontNameEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [TypeConverter(typeof(FontConverter.FontNameConverter))]
- public string Name => FontFamily.Name;
-
- ///
- /// Gets the unit of measure for this .
- ///
- [TypeConverter(typeof(FontConverter.FontUnitConverter))]
- public GraphicsUnit Unit => _fontUnit;
-
- ///
- /// Returns the GDI char set for this instance of a font. This will only
- /// be valid if this font was created from a classic GDI font definition,
- /// like a LOGFONT or HFONT, or it was passed into the constructor.
- ///
- /// This is here for compatibility with native Win32 intrinsic controls
- /// on non-Unicode platforms.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public byte GdiCharSet => _gdiCharSet;
-
- ///
- /// Determines if this font was created to represent a GDI vertical font. This will only be valid if this font
- /// was created from a classic GDIfont definition, like a LOGFONT or HFONT, or it was passed into the constructor.
- ///
- /// This is here for compatibility with native Win32 intrinsic controls on non-Unicode platforms.
- ///
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public bool GdiVerticalFont => _gdiVerticalFont;
-
- ///
- /// This property is required by the framework and not intended to be used directly.
- ///
- [Browsable(false)]
- public string? OriginalFontName => _originalFontName;
-
- ///
- /// Gets the name of this .
- ///
- [Browsable(false)]
- public string SystemFontName => _systemFontName;
-
- ///
- /// Returns true if this is a SystemFont.
- ///
- [Browsable(false)]
- public bool IsSystemFont => !string.IsNullOrEmpty(_systemFontName);
-
- ///
- /// Gets the height of this .
- ///
- [Browsable(false)]
- public int Height => (int)Math.Ceiling(GetHeight());
-
- ///
- /// Get native GDI+ object pointer. This property triggers the creation of the GDI+ native object if not initialized yet.
- ///
- internal IntPtr NativeFont => _nativeFont;
-
- ///
- /// Cleans up Windows resources for this .
- ///
- ~Font() => Dispose(false);
-
- private Font(SerializationInfo info, StreamingContext context)
- {
- string name = info.GetString("Name")!; // Do not rename (binary serialization)
- FontStyle style = (FontStyle)info.GetValue("Style", typeof(FontStyle))!; // Do not rename (binary serialization)
- GraphicsUnit unit = (GraphicsUnit)info.GetValue("Unit", typeof(GraphicsUnit))!; // Do not rename (binary serialization)
- float size = info.GetSingle("Size"); // Do not rename (binary serialization)
-
- Initialize(name, size, style, unit, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(name));
- }
-
- void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
- {
- string name = string.IsNullOrEmpty(OriginalFontName) ? Name : OriginalFontName;
- si.AddValue("Name", name); // Do not rename (binary serialization)
- si.AddValue("Size", Size); // Do not rename (binary serialization)
- si.AddValue("Style", Style); // Do not rename (binary serialization)
- si.AddValue("Unit", Unit); // Do not rename (binary serialization)
- }
-
- private static bool IsVerticalName(string familyName) => familyName?.Length > 0 && familyName[0] == '@';
-
- ///
- /// Cleans up Windows resources for this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (_nativeFont != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteFont(new HandleRef(this, _nativeFont));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsCriticalException(ex))
- {
- }
- finally
- {
- _nativeFont = IntPtr.Zero;
- }
- }
- }
-
- ///
- /// Returns the height of this Font in the specified graphics context.
- ///
- public float GetHeight(Graphics graphics)
- {
- ArgumentNullException.ThrowIfNull(graphics);
-
- float height;
- int status = Gdip.GdipGetFontHeight(new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), out height);
- Gdip.CheckStatus(status);
-
- return height;
- }
-
- public float GetHeight(float dpi)
- {
- float size;
- int status = Gdip.GdipGetFontHeightGivenDPI(new HandleRef(this, NativeFont), dpi, out size);
- Gdip.CheckStatus(status);
- return size;
- }
-
- ///
- /// Returns a value indicating whether the specified object is a equivalent to this
- /// .
- ///
- public override bool Equals([NotNullWhen(true)] object? obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (!(obj is Font font))
- {
- return false;
- }
-
- // Note: If this and/or the passed-in font are disposed, this method can still return true since we check for cached properties
- // here.
- // We need to call properties on the passed-in object since it could be a proxy in a remoting scenario and proxies don't
- // have access to private/internal fields.
- return font.FontFamily.Equals(FontFamily) &&
- font.GdiVerticalFont == GdiVerticalFont &&
- font.GdiCharSet == GdiCharSet &&
- font.Style == Style &&
- font.Size == Size &&
- font.Unit == Unit;
- }
-
- ///
- /// Gets the hash code for this .
- ///
- public override int GetHashCode()
- {
- return HashCode.Combine(Name, Style, Size, Unit);
- }
-
- ///
- /// Returns a human-readable string representation of this .
- ///
- public override string ToString() =>
- $"[{GetType().Name}: Name={FontFamily.Name}, Size={_fontSize}, Units={(int)_fontUnit}, GdiCharSet={_gdiCharSet}, GdiVerticalFont={_gdiVerticalFont}]";
-
- // This is used by SystemFonts when constructing a system Font objects.
- internal void SetSystemFontName(string systemFontName) => _systemFontName = systemFontName;
-
- public unsafe void ToLogFont(object logFont, Graphics graphics)
- {
- ArgumentNullException.ThrowIfNull(logFont);
-
- Type type = logFont.GetType();
- int nativeSize = sizeof(Interop.User32.LOGFONT);
- if (Marshal.SizeOf(type) != nativeSize)
- {
- // If we don't actually have an object that is LOGFONT in size, trying to pass
- // it to GDI+ is likely to cause an AV.
- throw new ArgumentException(null, nameof(logFont));
- }
-
- Interop.User32.LOGFONT nativeLogFont = ToLogFontInternal(graphics);
-
- // PtrToStructure requires that the passed in object not be a value type.
- if (!type.IsValueType)
- {
- Marshal.PtrToStructure(new IntPtr(&nativeLogFont), logFont);
- }
- else
- {
- GCHandle handle = GCHandle.Alloc(logFont, GCHandleType.Pinned);
- Buffer.MemoryCopy(&nativeLogFont, (byte*)handle.AddrOfPinnedObject(), nativeSize, nativeSize);
- handle.Free();
- }
- }
-
- private unsafe Interop.User32.LOGFONT ToLogFontInternal(Graphics graphics)
- {
- ArgumentNullException.ThrowIfNull(graphics);
-
- Interop.User32.LOGFONT logFont = default;
- Gdip.CheckStatus(Gdip.GdipGetLogFontW(
- new HandleRef(this, NativeFont), new HandleRef(graphics, graphics.NativeGraphics), ref logFont));
-
- // Prefix the string with '@' if this is a gdiVerticalFont.
- if (_gdiVerticalFont)
- {
- Span faceName = logFont.lfFaceName;
- faceName.Slice(0, faceName.Length - 1).CopyTo(faceName.Slice(1));
- faceName[0] = '@';
-
- // Docs require this to be null terminated
- faceName[faceName.Length - 1] = '\0';
- }
-
- if (logFont.lfCharSet == 0)
- {
- logFont.lfCharSet = _gdiCharSet;
- }
-
- return logFont;
- }
-
- ///
- /// Creates the GDI+ native font object.
- ///
- private void CreateNativeFont()
- {
- Debug.Assert(_nativeFont == IntPtr.Zero, "nativeFont already initialized, this will generate a handle leak.");
- Debug.Assert(_fontFamily != null, "fontFamily not initialized.");
-
- // Note: GDI+ creates singleton font family objects (from the corresponding font file) and reference count them so
- // if creating the font object from an external FontFamily, this object's FontFamily will share the same native object.
- int status = Gdip.GdipCreateFont(
- new HandleRef(this, _fontFamily.NativeFamily),
- _fontSize,
- _fontStyle,
- _fontUnit,
- out _nativeFont);
-
- // Special case this common error message to give more information
- if (status == Gdip.FontStyleNotFound)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusFontStyleNotFound, _fontFamily.Name, _fontStyle.ToString()));
- }
- else if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Initializes a new instance of the class from the specified existing
- /// and .
- ///
- public Font(Font prototype, FontStyle newStyle)
- {
- // Copy over the originalFontName because it won't get initialized
- _originalFontName = prototype.OriginalFontName;
- Initialize(prototype.FontFamily, prototype.Size, newStyle, prototype.Unit, SafeNativeMethods.DEFAULT_CHARSET, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit)
- {
- Initialize(family, emSize, style, unit, SafeNativeMethods.DEFAULT_CHARSET, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet)
- {
- Initialize(family, emSize, style, unit, gdiCharSet, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont)
- {
- Initialize(family, emSize, style, unit, gdiCharSet, gdiVerticalFont);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet)
- {
- Initialize(familyName, emSize, style, unit, gdiCharSet, IsVerticalName(familyName));
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont)
- {
- if (float.IsNaN(emSize) || float.IsInfinity(emSize) || emSize <= 0)
- {
- throw new ArgumentException(SR.Format(SR.InvalidBoundArgument, nameof(emSize), emSize, 0, "System.Single.MaxValue"), nameof(emSize));
- }
-
- Initialize(familyName, emSize, style, unit, gdiCharSet, gdiVerticalFont);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize, FontStyle style)
- {
- Initialize(family, emSize, style, GraphicsUnit.Point, SafeNativeMethods.DEFAULT_CHARSET, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize, GraphicsUnit unit)
- {
- Initialize(family, emSize, FontStyle.Regular, unit, SafeNativeMethods.DEFAULT_CHARSET, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(FontFamily family, float emSize)
- {
- Initialize(family, emSize, FontStyle.Regular, GraphicsUnit.Point, SafeNativeMethods.DEFAULT_CHARSET, false);
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit)
- {
- Initialize(familyName, emSize, style, unit, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(familyName));
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize, FontStyle style)
- {
- Initialize(familyName, emSize, style, GraphicsUnit.Point, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(familyName));
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize, GraphicsUnit unit)
- {
- Initialize(familyName, emSize, FontStyle.Regular, unit, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(familyName));
- }
-
- ///
- /// Initializes a new instance of the class with the specified attributes.
- ///
- public Font(string familyName, float emSize)
- {
- Initialize(familyName, emSize, FontStyle.Regular, GraphicsUnit.Point, SafeNativeMethods.DEFAULT_CHARSET, IsVerticalName(familyName));
- }
-
- ///
- /// Constructor to initialize fields from an existing native GDI+ object reference. Used by ToLogFont.
- ///
- private Font(IntPtr nativeFont, byte gdiCharSet, bool gdiVerticalFont)
- {
- Debug.Assert(_nativeFont == IntPtr.Zero, "GDI+ native font already initialized, this will generate a handle leak");
- Debug.Assert(nativeFont != IntPtr.Zero, "nativeFont is null");
-
- _nativeFont = nativeFont;
-
- Gdip.CheckStatus(Gdip.GdipGetFontUnit(new HandleRef(this, nativeFont), out GraphicsUnit unit));
- Gdip.CheckStatus(Gdip.GdipGetFontSize(new HandleRef(this, nativeFont), out float size));
- Gdip.CheckStatus(Gdip.GdipGetFontStyle(new HandleRef(this, nativeFont), out FontStyle style));
- Gdip.CheckStatus(Gdip.GdipGetFamily(new HandleRef(this, nativeFont), out IntPtr nativeFamily));
-
- SetFontFamily(new FontFamily(nativeFamily));
- Initialize(_fontFamily, size, style, unit, gdiCharSet, gdiVerticalFont);
- }
-
- ///
- /// Initializes this object's fields.
- ///
- private void Initialize(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont)
- {
- _originalFontName = familyName;
-
- SetFontFamily(new FontFamily(StripVerticalName(familyName), createDefaultOnFail: true));
- Initialize(_fontFamily, emSize, style, unit, gdiCharSet, gdiVerticalFont);
- }
-
- ///
- /// Initializes this object's fields.
- ///
- private void Initialize(FontFamily family, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet, bool gdiVerticalFont)
- {
- ArgumentNullException.ThrowIfNull(family);
-
- if (float.IsNaN(emSize) || float.IsInfinity(emSize) || emSize <= 0)
- {
- throw new ArgumentException(SR.Format(SR.InvalidBoundArgument, nameof(emSize), emSize, 0, "System.Single.MaxValue"), nameof(emSize));
- }
-
- int status;
-
- _fontSize = emSize;
- _fontStyle = style;
- _fontUnit = unit;
- _gdiCharSet = gdiCharSet;
- _gdiVerticalFont = gdiVerticalFont;
-
- if (_fontFamily == null)
- {
- // GDI+ FontFamily is a singleton object.
- SetFontFamily(new FontFamily(family.NativeFamily));
- }
-
- if (_nativeFont == IntPtr.Zero)
- {
- CreateNativeFont();
- }
-
- // Get actual size.
- status = Gdip.GdipGetFontSize(new HandleRef(this, _nativeFont), out _fontSize);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Creates a from the specified Windows handle.
- ///
- public static Font FromHfont(IntPtr hfont)
- {
- Interop.User32.LOGFONT logFont = default;
- Interop.Gdi32.GetObject(new HandleRef(null, hfont), ref logFont);
-
- using (ScreenDC dc = ScreenDC.Create())
- {
- return FromLogFontInternal(ref logFont, dc);
- }
- }
-
- ///
- /// Creates a from the given LOGFONT using the screen device context.
- ///
- /// A boxed LOGFONT.
- /// The newly created .
- public static Font FromLogFont(object lf)
- {
- using (ScreenDC dc = ScreenDC.Create())
- {
- return FromLogFont(lf, dc);
- }
- }
-
- internal static Font FromLogFont(ref Interop.User32.LOGFONT logFont)
- {
- using (ScreenDC dc = ScreenDC.Create())
- {
- return FromLogFont(logFont, dc);
- }
- }
-
- internal static Font FromLogFontInternal(ref Interop.User32.LOGFONT logFont, IntPtr hdc)
- {
- int status = Gdip.GdipCreateFontFromLogfontW(hdc, ref logFont, out IntPtr font);
-
- // Special case this incredibly common error message to give more information
- if (status == Gdip.NotTrueTypeFont)
- {
- throw new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName);
- }
- else if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- // GDI+ returns font = 0 even though the status is Ok.
- if (font == IntPtr.Zero)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont, logFont.ToString()));
- }
-
- bool gdiVerticalFont = logFont.lfFaceName[0] == '@';
- return new Font(font, logFont.lfCharSet, gdiVerticalFont);
- }
-
- ///
- /// Creates a from the given LOGFONT using the given device context.
- ///
- /// A boxed LOGFONT.
- /// Handle to a device context (HDC).
- /// The newly created .
- public static unsafe Font FromLogFont(object lf, IntPtr hdc)
- {
- ArgumentNullException.ThrowIfNull(lf);
-
- if (lf is Interop.User32.LOGFONT logFont)
- {
- // A boxed LOGFONT, just use it to create the font
- return FromLogFontInternal(ref logFont, hdc);
- }
-
- Type type = lf.GetType();
- int nativeSize = sizeof(Interop.User32.LOGFONT);
- if (Marshal.SizeOf(type) != nativeSize)
- {
- // If we don't actually have an object that is LOGFONT in size, trying to pass
- // it to GDI+ is likely to cause an AV.
- throw new ArgumentException(null, nameof(lf));
- }
-
- // Now that we know the marshalled size is the same as LOGFONT, copy in the data
- logFont = default;
-
- Marshal.StructureToPtr(lf, new IntPtr(&logFont), fDeleteOld: false);
-
- return FromLogFontInternal(ref logFont, hdc);
- }
-
- ///
- /// Creates a from the specified handle to a device context (HDC).
- ///
- /// The newly created .
- public static Font FromHdc(IntPtr hdc)
- {
- IntPtr font = IntPtr.Zero;
- int status = Gdip.GdipCreateFontFromDC(hdc, ref font);
-
- // Special case this incredibly common error message to give more information
- if (status == Gdip.NotTrueTypeFont)
- {
- throw new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName);
- }
- else if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- return new Font(font, 0, false);
- }
-
- ///
- /// Creates an exact copy of this .
- ///
- public object Clone()
- {
- int status = Gdip.GdipCloneFont(new HandleRef(this, _nativeFont), out IntPtr clonedFont);
- Gdip.CheckStatus(status);
-
- return new Font(clonedFont, _gdiCharSet, _gdiVerticalFont);
- }
-
- private void SetFontFamily(FontFamily family)
- {
- _fontFamily = family;
-
- // GDI+ creates ref-counted singleton FontFamily objects based on the family name so all managed
- // objects with same family name share the underlying GDI+ native pointer. The unmanged object is
- // destroyed when its ref-count gets to zero.
- //
- // Make sure _fontFamily is not finalized so the underlying singleton object is kept alive.
- GC.SuppressFinalize(_fontFamily);
- }
-
- [return: NotNullIfNotNull(nameof(familyName))]
- private static string? StripVerticalName(string? familyName)
- {
- if (familyName?.Length > 1 && familyName[0] == '@')
- {
- return familyName.Substring(1);
- }
-
- return familyName;
- }
-
- public void ToLogFont(object logFont)
- {
- using (ScreenDC dc = ScreenDC.Create())
- using (Graphics graphics = Graphics.FromHdcInternal(dc))
- {
- ToLogFont(logFont, graphics);
- }
- }
-
- ///
- /// Returns a handle to this .
- ///
- public IntPtr ToHfont()
- {
- using (ScreenDC dc = ScreenDC.Create())
- using (Graphics graphics = Graphics.FromHdcInternal(dc))
- {
- Interop.User32.LOGFONT lf = ToLogFontInternal(graphics);
- IntPtr handle = Interop.Gdi32.CreateFontIndirectW(ref lf);
- if (handle == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
-
- return handle;
- }
- }
-
- public float GetHeight()
- {
- using (ScreenDC dc = ScreenDC.Create())
- using (Graphics graphics = Graphics.FromHdcInternal(dc))
- {
- return GetHeight(graphics);
- }
- }
-
- ///
- /// Gets the size, in points, of this .
- ///
- [Browsable(false)]
- public float SizeInPoints
- {
- get
- {
- if (Unit == GraphicsUnit.Point)
- {
- return Size;
- }
-
- using (ScreenDC dc = ScreenDC.Create())
- using (Graphics graphics = Graphics.FromHdcInternal(dc))
- {
- float pixelsPerPoint = (float)(graphics.DpiY / 72.0);
- float lineSpacingInPixels = GetHeight(graphics);
- float emHeightInPixels = lineSpacingInPixels * FontFamily.GetEmHeight(Style) / FontFamily.GetLineSpacing(Style);
-
- return emHeightInPixels / pixelsPerPoint;
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/FontConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/FontConverter.cs
deleted file mode 100644
index 3897358d9e37e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/FontConverter.cs
+++ /dev/null
@@ -1,463 +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.Collections;
-using System.ComponentModel;
-using System.ComponentModel.Design.Serialization;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Text;
-using System.Globalization;
-using System.Reflection;
-using System.Text;
-
-namespace System.Drawing
-{
- public class FontConverter : TypeConverter
- {
- private const string StylePrefix = "style=";
-
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
- {
- return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
- }
-
- public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
- {
- return (destinationType == typeof(string)) || (destinationType == typeof(InstanceDescriptor));
- }
-
- public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
- {
- if (value is Font font)
- {
- if (destinationType == typeof(string))
- {
- culture ??= CultureInfo.CurrentCulture;
-
- ValueStringBuilder sb = default;
- sb.Append(font.Name);
- sb.Append(culture.TextInfo.ListSeparator[0]);
- sb.Append(' ');
- sb.Append(font.Size.ToString(culture.NumberFormat));
-
- switch (font.Unit)
- {
- // MS throws ArgumentException, if unit is set
- // to GraphicsUnit.Display
- // Don't know what to append for GraphicsUnit.Display
- case GraphicsUnit.Display:
- sb.Append("display");
- break;
-
- case GraphicsUnit.Document:
- sb.Append("doc");
- break;
-
- case GraphicsUnit.Point:
- sb.Append("pt");
- break;
-
- case GraphicsUnit.Inch:
- sb.Append("in");
- break;
-
- case GraphicsUnit.Millimeter:
- sb.Append("mm");
- break;
-
- case GraphicsUnit.Pixel:
- sb.Append("px");
- break;
-
- case GraphicsUnit.World:
- sb.Append("world");
- break;
- }
-
- if (font.Style != FontStyle.Regular)
- {
- sb.Append(culture.TextInfo.ListSeparator[0]);
- sb.Append(" style=");
- sb.Append(font.Style.ToString());
- }
-
- return sb.ToString();
- }
-
- if (destinationType == typeof(InstanceDescriptor))
- {
- ConstructorInfo? met = typeof(Font).GetConstructor(new Type[] { typeof(string), typeof(float), typeof(FontStyle), typeof(GraphicsUnit) });
- object[] args = new object[4];
- args[0] = font.Name;
- args[1] = font.Size;
- args[2] = font.Style;
- args[3] = font.Unit;
-
- return new InstanceDescriptor(met, args);
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- if (!(value is string font))
- {
- return base.ConvertFrom(context, culture, value);
- }
-
- font = font.Trim();
-
- // Expected string format: "name[, size[, units[, style=style1[, style2[...]]]]]"
- // Example using 'vi-VN' culture: "Microsoft Sans Serif, 8,25pt, style=Italic, Bold"
- if (font.Length == 0)
- {
- return null;
- }
-
- culture ??= CultureInfo.CurrentCulture;
-
- char separator = culture.TextInfo.ListSeparator[0]; // For vi-VN: ','
- string fontName = font; // start with the assumption that only the font name was provided.
- string? style = null;
- string? sizeStr;
- float fontSize = 8.25f;
- FontStyle fontStyle = FontStyle.Regular;
- GraphicsUnit units = GraphicsUnit.Point;
-
- // Get the index of the first separator (would indicate the end of the name in the string).
- int nameIndex = font.IndexOf(separator);
-
- if (nameIndex < 0)
- {
- return new Font(fontName, fontSize, fontStyle, units);
- }
-
- // Some parameters are provided in addition to name.
- fontName = font.Substring(0, nameIndex);
-
- if (nameIndex < font.Length - 1)
- {
- // Get the style index (if any). The size is a bit problematic because it can be formatted differently
- // depending on the culture, we'll parse it last.
- int styleIndex = culture.CompareInfo.IndexOf(font, StylePrefix, CompareOptions.IgnoreCase);
-
- if (styleIndex != -1)
- {
- // style found.
- style = font.Substring(styleIndex);
-
- // Get the mid-substring containing the size information.
- sizeStr = font.Substring(nameIndex + 1, styleIndex - nameIndex - 1);
- }
- else
- {
- // no style.
- sizeStr = font.Substring(nameIndex + 1);
- }
-
- // Parse size.
- (string? size, string? unit) unitTokens = ParseSizeTokens(sizeStr, separator);
-
- if (unitTokens.size != null)
- {
- try
- {
- fontSize = (float)GetFloatConverter().ConvertFromString(context, culture, unitTokens.size)!;
- }
- catch
- {
- // Exception from converter is too generic.
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, font, $"name{separator} size[units[{separator} style=style1[{separator} style2{separator} ...]]]"), nameof(value));
- }
- }
-
- if (unitTokens.unit != null)
- {
- // ParseGraphicsUnits throws an ArgumentException if format is invalid.
- units = ParseGraphicsUnits(unitTokens.unit);
- }
-
- if (style != null)
- {
- // Parse FontStyle
- style = style.Substring(6); // style string always starts with style=
- string[] styleTokens = style.Split(separator);
-
- for (int tokenCount = 0; tokenCount < styleTokens.Length; tokenCount++)
- {
- string styleText = styleTokens[tokenCount];
- styleText = styleText.Trim();
-
- fontStyle |= Enum.Parse(styleText, true);
-
- // Enum.IsDefined doesn't do what we want on flags enums...
- FontStyle validBits = FontStyle.Regular | FontStyle.Bold | FontStyle.Italic | FontStyle.Underline | FontStyle.Strikeout;
- if ((fontStyle | validBits) != validBits)
- {
- throw new InvalidEnumArgumentException(nameof(style), (int)fontStyle, typeof(FontStyle));
- }
- }
- }
- }
-
- return new Font(fontName, fontSize, fontStyle, units);
-
- [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
- Justification = "TypeDescriptor.GetConverter is safe for primitive types.")]
- static TypeConverter GetFloatConverter() => TypeDescriptor.GetConverter(typeof(float));
- }
-
- private static (string?, string?) ParseSizeTokens(string text, char separator)
- {
- string? size = null;
- string? units = null;
-
- text = text.Trim();
-
- int length = text.Length;
- int splitPoint;
-
- if (length > 0)
- {
- // text is expected to have a format like " 8,25pt, ". Leading and trailing spaces (trimmed above),
- // last comma, unit and decimal value may not appear. We need to make it ####.##CC
- for (splitPoint = 0; splitPoint < length; splitPoint++)
- {
- if (char.IsLetter(text[splitPoint]))
- {
- break;
- }
- }
-
- char[] trimChars = new char[] { separator, ' ' };
-
- if (splitPoint > 0)
- {
- size = text.Substring(0, splitPoint);
- // Trimming spaces between size and units.
- size = size.Trim(trimChars);
- }
-
- if (splitPoint < length)
- {
- units = text.Substring(splitPoint);
- units = units.TrimEnd(trimChars);
- }
- }
-
- return (size, units);
- }
-
- private static GraphicsUnit ParseGraphicsUnits(string units) =>
- units switch
- {
- "display" => GraphicsUnit.Display,
- "doc" => GraphicsUnit.Document,
- "pt" => GraphicsUnit.Point,
- "in" => GraphicsUnit.Inch,
- "mm" => GraphicsUnit.Millimeter,
- "px" => GraphicsUnit.Pixel,
- "world" => GraphicsUnit.World,
- _ => throw new ArgumentException(SR.Format(SR.InvalidArgumentValueFontConverter, units), nameof(units)),
- };
-
- public override object CreateInstance(ITypeDescriptorContext? context, IDictionary propertyValues)
- {
- ArgumentNullException.ThrowIfNull(propertyValues);
-
- object? value;
- byte charSet = 1;
- float size = 8;
- string? name = null;
- bool vertical = false;
- FontStyle style = FontStyle.Regular;
- FontFamily? fontFamily = null;
- GraphicsUnit unit = GraphicsUnit.Point;
-
- if ((value = propertyValues["GdiCharSet"]) != null)
- charSet = (byte)value;
-
- if ((value = propertyValues["Size"]) != null)
- size = (float)value;
-
- if ((value = propertyValues["Unit"]) != null)
- unit = (GraphicsUnit)value;
-
- if ((value = propertyValues["Name"]) != null)
- name = (string)value;
-
- if ((value = propertyValues["GdiVerticalFont"]) != null)
- vertical = (bool)value;
-
- if ((value = propertyValues["Bold"]) != null)
- {
- if ((bool)value)
- style |= FontStyle.Bold;
- }
-
- if ((value = propertyValues["Italic"]) != null)
- {
- if ((bool)value)
- style |= FontStyle.Italic;
- }
-
- if ((value = propertyValues["Strikeout"]) != null)
- {
- if ((bool)value)
- style |= FontStyle.Strikeout;
- }
-
- if ((value = propertyValues["Underline"]) != null)
- {
- if ((bool)value)
- style |= FontStyle.Underline;
- }
-
- if (name == null)
- {
- fontFamily = new FontFamily("Tahoma");
- }
- else
- {
- FontCollection collection = new InstalledFontCollection();
- FontFamily[] installedFontList = collection.Families;
- foreach (FontFamily font in installedFontList)
- {
- if (name.Equals(font.Name, StringComparison.OrdinalIgnoreCase))
- {
- fontFamily = font;
- break;
- }
- }
-
- // font family not found in installed fonts
- if (fontFamily == null)
- {
- collection = new PrivateFontCollection();
- FontFamily[] privateFontList = collection.Families;
- foreach (FontFamily font in privateFontList)
- {
- if (name.Equals(font.Name, StringComparison.OrdinalIgnoreCase))
- {
- fontFamily = font;
- break;
- }
- }
- }
-
- // font family not found in private fonts also
- fontFamily ??= FontFamily.GenericSansSerif;
- }
-
- return new Font(fontFamily, size, style, unit, charSet, vertical);
- }
-
- public override bool GetCreateInstanceSupported(ITypeDescriptorContext? context) => true;
-
- [RequiresUnreferencedCode("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- public override PropertyDescriptorCollection? GetProperties(
- ITypeDescriptorContext? context,
- object value,
- Attribute[]? attributes)
- {
- if (value is not Font)
- return base.GetProperties(context, value, attributes);
-
- PropertyDescriptorCollection props = TypeDescriptor.GetProperties(value, attributes);
- return props.Sort(new string[] { nameof(Font.Name), nameof(Font.Size), nameof(Font.Unit) });
- }
-
- public override bool GetPropertiesSupported(ITypeDescriptorContext? context) => true;
-
- public sealed class FontNameConverter : TypeConverter, IDisposable
- {
- private readonly FontFamily[] _fonts;
-
- public FontNameConverter()
- {
- _fonts = FontFamily.Families;
- }
-
- void IDisposable.Dispose()
- {
- }
-
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
- {
- return sourceType == typeof(string) ? true : base.CanConvertFrom(context, sourceType);
- }
-
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- return value is string strValue ? MatchFontName(strValue, context) : base.ConvertFrom(context, culture, value);
- }
-
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
- {
- string[] values = new string[_fonts.Length];
- for (int i = 0; i < _fonts.Length; i++)
- {
- values[i] = _fonts[i].Name;
- }
- Array.Sort(values, Comparer.Default);
-
- return new TypeConverter.StandardValuesCollection(values);
- }
-
- // We allow other values other than those in the font list.
- public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) => false;
-
- // Yes, we support picking an element from the list.
- public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true;
-
- private string MatchFontName(string name, ITypeDescriptorContext? context)
- {
- // Try a partial match
- string? bestMatch = null;
-
- // setting fontName as nullable since IEnumerable.Current returned nullable in 3.0
- foreach (string? fontName in GetStandardValues(context))
- {
- Debug.Assert(fontName != null);
- if (fontName.Equals(name, StringComparison.InvariantCultureIgnoreCase))
- {
- // For an exact match, return immediately
- return fontName;
- }
- if (fontName.StartsWith(name, StringComparison.InvariantCultureIgnoreCase))
- {
- if (bestMatch == null || fontName.Length <= bestMatch.Length)
- {
- bestMatch = fontName;
- }
- }
- }
-
- // No match... fall back on whatever was provided
- return bestMatch ?? name;
- }
- }
-
- public class FontUnitConverter : EnumConverter
- {
- public FontUnitConverter() : base(typeof(GraphicsUnit)) { }
-
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
- {
- // display graphic unit is not supported.
- if (Values == null)
- {
- base.GetStandardValues(context); // sets "values"
- Debug.Assert(Values != null);
- ArrayList filteredValues = new ArrayList(Values);
- filteredValues.Remove(GraphicsUnit.Display);
- Values = new StandardValuesCollection(filteredValues);
- }
- return Values;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs
deleted file mode 100644
index 7991b1ad6b645..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/FontFamily.cs
+++ /dev/null
@@ -1,315 +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.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Text;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// Abstracts a group of type faces having a similar basic design but having certain variation in styles.
- ///
- public sealed class FontFamily : MarshalByRefObject, IDisposable
- {
- private const int NeutralLanguage = 0;
- private IntPtr _nativeFamily;
- private readonly bool _createDefaultOnFail;
-
-#if DEBUG
- private static readonly object s_lockObj = new object();
- private static int s_idCount;
- private int _id;
-#endif
-
- private void SetNativeFamily(IntPtr family)
- {
- Debug.Assert(_nativeFamily == IntPtr.Zero, "Setting GDI+ native font family when already initialized.");
-
- _nativeFamily = family;
-#if DEBUG
- lock (s_lockObj)
- {
- _id = ++s_idCount;
- }
-#endif
- }
-
- internal FontFamily(IntPtr family) => SetNativeFamily(family);
-
- ///
- /// Initializes a new instance of the class with the specified name.
- ///
- /// The parameter determines how errors are handled when creating a
- /// font based on a font family that does not exist on the end user's system at run time. If this parameter is
- /// true, then a fall-back font will always be used instead. If this parameter is false, an exception will be thrown.
- ///
- internal FontFamily(string name, bool createDefaultOnFail)
- {
- _createDefaultOnFail = createDefaultOnFail;
- CreateFontFamily(name, null);
- }
-
- ///
- /// Initializes a new instance of the class with the specified name.
- ///
- public FontFamily(string name) => CreateFontFamily(name, null);
-
- ///
- /// Initializes a new instance of the class in the specified
- /// and with the specified name.
- ///
- public FontFamily(string name, FontCollection? fontCollection) => CreateFontFamily(name, fontCollection);
-
- // Creates the native font family object.
- // Note: GDI+ creates singleton font family objects (from the corresponding font file) and reference count them.
- private void CreateFontFamily(string name, FontCollection? fontCollection)
- {
- IntPtr fontfamily;
- IntPtr nativeFontCollection = (fontCollection == null) ? IntPtr.Zero : fontCollection._nativeFontCollection;
-
- int status = Gdip.GdipCreateFontFamilyFromName(name, new HandleRef(fontCollection, nativeFontCollection), out fontfamily);
-
- if (status != Gdip.Ok)
- {
- if (_createDefaultOnFail)
- {
- fontfamily = GetGdipGenericSansSerif(); // This throws if failed.
- }
- else
- {
- // Special case this incredibly common error message to give more information.
- if (status == Gdip.FontFamilyNotFound)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusFontFamilyNotFound, name));
- }
- else if (status == Gdip.NotTrueTypeFont)
- {
- throw new ArgumentException(SR.Format(SR.GdiplusNotTrueTypeFont, name));
- }
- else
- {
- throw Gdip.StatusException(status);
- }
- }
- }
-
- SetNativeFamily(fontfamily);
- }
-
- ///
- /// Initializes a new instance of the class from the specified generic font family.
- ///
- public FontFamily(GenericFontFamilies genericFamily)
- {
- IntPtr nativeFamily;
- int status;
-
- switch (genericFamily)
- {
- case GenericFontFamilies.Serif:
- status = Gdip.GdipGetGenericFontFamilySerif(out nativeFamily);
- break;
- case GenericFontFamilies.SansSerif:
- status = Gdip.GdipGetGenericFontFamilySansSerif(out nativeFamily);
- break;
- case GenericFontFamilies.Monospace:
- default:
- status = Gdip.GdipGetGenericFontFamilyMonospace(out nativeFamily);
- break;
- }
- Gdip.CheckStatus(status);
-
- SetNativeFamily(nativeFamily);
- }
-
- ~FontFamily() => Dispose(false);
-
- internal IntPtr NativeFamily => _nativeFamily;
-
- ///
- /// Converts this to a human-readable string.
- ///
- public override string ToString() => $"[{GetType().Name}: Name={Name}]";
-
- public override bool Equals([NotNullWhen(true)] object? obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- // if obj = null then (obj is FontFamily) = false.
- if (!(obj is FontFamily otherFamily))
- {
- return false;
- }
-
- // We can safely use the ptr to the native GDI+ FontFamily because in windows it is common to
- // all objects of the same family (singleton RO object).
- return otherFamily.NativeFamily == NativeFamily;
- }
-
- ///
- /// Gets a hash code for this .
- ///
- public override int GetHashCode() => GetName(NeutralLanguage).GetHashCode();
-
- private static int CurrentLanguage => CultureInfo.CurrentUICulture.LCID;
-
- ///
- /// Disposes of this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (_nativeFamily != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteFontFamily(new HandleRef(this, _nativeFamily));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsCriticalException(ex))
- {
- }
- finally
- {
- _nativeFamily = IntPtr.Zero;
- }
- }
- }
-
- ///
- /// Gets the name of this .
- ///
- public string Name => GetName(CurrentLanguage);
-
- ///
- /// Returns the name of this in the specified language.
- ///
- public unsafe string GetName(int language)
- {
- char* name = stackalloc char[32]; // LF_FACESIZE is 32
- int status = Gdip.GdipGetFamilyName(new HandleRef(this, NativeFamily), name, language);
- Gdip.CheckStatus(status);
- return Marshal.PtrToStringUni((IntPtr)name)!;
- }
-
- ///
- /// Returns an array that contains all of the objects associated with the current
- /// graphics context.
- ///
- public static FontFamily[] Families => new InstalledFontCollection().Families;
-
- ///
- /// Gets a generic SansSerif .
- ///
- public static FontFamily GenericSansSerif => new FontFamily(GetGdipGenericSansSerif());
-
- private static IntPtr GetGdipGenericSansSerif()
- {
- IntPtr nativeFamily;
- int status = Gdip.GdipGetGenericFontFamilySansSerif(out nativeFamily);
- Gdip.CheckStatus(status);
-
- return nativeFamily;
- }
-
- ///
- /// Gets a generic Serif .
- ///
- public static FontFamily GenericSerif => new FontFamily(GenericFontFamilies.Serif);
-
- ///
- /// Gets a generic monospace .
- ///
- public static FontFamily GenericMonospace => new FontFamily(GenericFontFamilies.Monospace);
-
- ///
- /// Returns an array that contains all of the objects associated with the specified
- /// graphics context.
- ///
- [Obsolete("FontFamily.GetFamilies has been deprecated. Use Families instead.")]
- public static FontFamily[] GetFamilies(Graphics graphics)
- {
- ArgumentNullException.ThrowIfNull(graphics);
-
- return new InstalledFontCollection().Families;
- }
-
- ///
- /// Indicates whether the specified is available.
- ///
- public bool IsStyleAvailable(FontStyle style)
- {
- int bresult;
- int status = Gdip.GdipIsStyleAvailable(new HandleRef(this, NativeFamily), style, out bresult);
- Gdip.CheckStatus(status);
-
- return bresult != 0;
- }
-
- ///
- /// Gets the size of the Em square for the specified style in font design units.
- ///
- public int GetEmHeight(FontStyle style)
- {
- int result;
- int status = Gdip.GdipGetEmHeight(new HandleRef(this, NativeFamily), style, out result);
- Gdip.CheckStatus(status);
-
- return result;
- }
-
- ///
- /// Returns the ascender metric for Windows.
- ///
- public int GetCellAscent(FontStyle style)
- {
- int result;
- int status = Gdip.GdipGetCellAscent(new HandleRef(this, NativeFamily), style, out result);
- Gdip.CheckStatus(status);
-
- return result;
- }
-
- ///
- /// Returns the descender metric for Windows.
- ///
- public int GetCellDescent(FontStyle style)
- {
- int result;
- int status = Gdip.GdipGetCellDescent(new HandleRef(this, NativeFamily), style, out result);
- Gdip.CheckStatus(status);
-
- return result;
- }
-
- ///
- /// Returns the distance between two consecutive lines of text for this with the
- /// specified .
- ///
- public int GetLineSpacing(FontStyle style)
- {
- int result;
- int status = Gdip.GdipGetLineSpacing(new HandleRef(this, NativeFamily), style, out result);
- Gdip.CheckStatus(status);
-
- return result;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/FontStyle.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/FontStyle.cs
deleted file mode 100644
index 3d380bdfe5c13..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/FontStyle.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies style information applied to text.
- ///
- [Flags]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public enum FontStyle
- {
- ///
- /// Normal text.
- ///
- Regular = 0,
- ///
- /// Bold text.
- ///
- Bold = 1,
- ///
- /// Italic text.
- ///
- Italic = 2,
- ///
- /// Underlined text.
- ///
- Underline = 4,
- ///
- /// Text with a line through the middle.
- ///
- Strikeout = 8,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Gdiplus.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Gdiplus.cs
deleted file mode 100644
index 723e2804a880e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Gdiplus.cs
+++ /dev/null
@@ -1,426 +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.Collections;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- internal static partial class SafeNativeMethods
- {
- // We make this a nested class so that we don't have to initialize GDI+ to access SafeNativeMethods (mostly gdi/user32).
- internal static partial class Gdip
- {
- private static readonly IntPtr s_initToken;
-
- [ThreadStatic]
- private static IDictionary? t_threadData;
-
- static Gdip()
- {
- if (!OperatingSystem.IsWindows())
- {
- NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), static (_, _, _) =>
- throw new PlatformNotSupportedException(SR.PlatformNotSupported_Unix));
- }
-
- Debug.Assert(s_initToken == IntPtr.Zero, "GdiplusInitialization: Initialize should not be called more than once in the same domain!");
-
- // GDI+ ref counts multiple calls to Startup in the same process, so calls from multiple
- // domains are ok, just make sure to pair each w/GdiplusShutdown
- int status = GdiplusStartup(out s_initToken, StartupInputEx.GetDefault(), out _);
- CheckStatus(status);
- }
-
- ///
- /// Returns true if GDI+ has been started, but not shut down
- ///
- internal static bool Initialized => s_initToken != IntPtr.Zero;
-
- ///
- /// This property will give us back a hashtable we can use to store all of our static brushes and pens on
- /// a per-thread basis. This way we can avoid 'object in use' crashes when different threads are
- /// referencing the same drawing object.
- ///
- internal static IDictionary ThreadData => t_threadData ??= new Hashtable();
-
- // Used to ensure static constructor has run.
- internal static void DummyFunction()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // Status codes
- //----------------------------------------------------------------------------------------
- internal const int Ok = 0;
- internal const int GenericError = 1;
- internal const int InvalidParameter = 2;
- internal const int OutOfMemory = 3;
- internal const int ObjectBusy = 4;
- internal const int InsufficientBuffer = 5;
- internal const int NotImplemented = 6;
- internal const int Win32Error = 7;
- internal const int WrongState = 8;
- internal const int Aborted = 9;
- internal const int FileNotFound = 10;
- internal const int ValueOverflow = 11;
- internal const int AccessDenied = 12;
- internal const int UnknownImageFormat = 13;
- internal const int FontFamilyNotFound = 14;
- internal const int FontStyleNotFound = 15;
- internal const int NotTrueTypeFont = 16;
- internal const int UnsupportedGdiplusVersion = 17;
- internal const int GdiplusNotInitialized = 18;
- internal const int PropertyNotFound = 19;
- internal const int PropertyNotSupported = 20;
-
- internal static void CheckStatus(int status)
- {
- if (status != Ok)
- throw StatusException(status);
- }
-
- internal static Exception StatusException(int status)
- {
- Debug.Assert(status != Ok, "Throwing an exception for an 'Ok' return code");
-
- switch (status)
- {
- case GenericError:
- return new ExternalException(SR.GdiplusGenericError, E_FAIL);
- case InvalidParameter:
- return new ArgumentException(SR.GdiplusInvalidParameter);
- case OutOfMemory:
- return new OutOfMemoryException(SR.GdiplusOutOfMemory);
- case ObjectBusy:
- return new InvalidOperationException(SR.GdiplusObjectBusy);
- case InsufficientBuffer:
- return new OutOfMemoryException(SR.GdiplusInsufficientBuffer);
- case NotImplemented:
- return new NotImplementedException(SR.GdiplusNotImplemented);
- case Win32Error:
- return new ExternalException(SR.GdiplusGenericError, E_FAIL);
- case WrongState:
- return new InvalidOperationException(SR.GdiplusWrongState);
- case Aborted:
- return new ExternalException(SR.GdiplusAborted, E_ABORT);
- case FileNotFound:
- return new FileNotFoundException(SR.GdiplusFileNotFound);
- case ValueOverflow:
- return new OverflowException(SR.GdiplusOverflow);
- case AccessDenied:
- return new ExternalException(SR.GdiplusAccessDenied, E_ACCESSDENIED);
- case UnknownImageFormat:
- return new ArgumentException(SR.GdiplusUnknownImageFormat);
- case PropertyNotFound:
- return new ArgumentException(SR.GdiplusPropertyNotFoundError);
- case PropertyNotSupported:
- return new ArgumentException(SR.GdiplusPropertyNotSupportedError);
-
- case FontFamilyNotFound:
- Debug.Fail("We should be special casing FontFamilyNotFound so we can provide the font name");
- return new ArgumentException(SR.Format(SR.GdiplusFontFamilyNotFound, "?"));
-
- case FontStyleNotFound:
- Debug.Fail("We should be special casing FontStyleNotFound so we can provide the font name");
- return new ArgumentException(SR.Format(SR.GdiplusFontStyleNotFound, "?", "?"));
-
- case NotTrueTypeFont:
- Debug.Fail("We should be special casing NotTrueTypeFont so we can provide the font name");
- return new ArgumentException(SR.GdiplusNotTrueTypeFont_NoName);
-
- case UnsupportedGdiplusVersion:
- return new ExternalException(SR.GdiplusUnsupportedGdiplusVersion, E_FAIL);
-
- case GdiplusNotInitialized:
- return new ExternalException(SR.GdiplusNotInitialized, E_FAIL);
- }
-
- return new ExternalException($"{SR.GdiplusUnknown} [{status}]", E_UNEXPECTED);
- }
- }
-
- public const int
- E_UNEXPECTED = unchecked((int)0x8000FFFF),
- E_NOTIMPL = unchecked((int)0x80004001),
- E_ABORT = unchecked((int)0x80004004),
- E_FAIL = unchecked((int)0x80004005),
- E_ACCESSDENIED = unchecked((int)0x80070005),
- GMEM_MOVEABLE = 0x0002,
- GMEM_ZEROINIT = 0x0040,
- DM_IN_BUFFER = 8,
- DM_OUT_BUFFER = 2,
- DC_PAPERS = 2,
- DC_PAPERSIZE = 3,
- DC_BINS = 6,
- DC_DUPLEX = 7,
- DC_BINNAMES = 12,
- DC_ENUMRESOLUTIONS = 13,
- DC_PAPERNAMES = 16,
- DC_ORIENTATION = 17,
- DC_COPIES = 18,
- DC_COLORDEVICE = 32,
- PD_ALLPAGES = 0x00000000,
- PD_SELECTION = 0x00000001,
- PD_PAGENUMS = 0x00000002,
- PD_CURRENTPAGE = 0x00400000,
- PD_RETURNDEFAULT = 0x00000400,
- DI_NORMAL = 0x0003,
- IMAGE_ICON = 1,
- IDI_APPLICATION = 32512,
- IDI_HAND = 32513,
- IDI_QUESTION = 32514,
- IDI_EXCLAMATION = 32515,
- IDI_ASTERISK = 32516,
- IDI_WINLOGO = 32517,
- IDI_WARNING = 32515,
- IDI_ERROR = 32513,
- IDI_INFORMATION = 32516,
- DM_ORIENTATION = 0x00000001,
- DM_PAPERSIZE = 0x00000002,
- DM_PAPERLENGTH = 0x00000004,
- DM_PAPERWIDTH = 0x00000008,
- DM_COPIES = 0x00000100,
- DM_DEFAULTSOURCE = 0x00000200,
- DM_PRINTQUALITY = 0x00000400,
- DM_COLOR = 0x00000800,
- DM_DUPLEX = 0x00001000,
- DM_YRESOLUTION = 0x00002000,
- DM_COLLATE = 0x00008000,
- DMORIENT_PORTRAIT = 1,
- DMORIENT_LANDSCAPE = 2,
- DMPAPER_LETTER = 1,
- DMPAPER_LETTERSMALL = 2,
- DMPAPER_TABLOID = 3,
- DMPAPER_LEDGER = 4,
- DMPAPER_LEGAL = 5,
- DMPAPER_STATEMENT = 6,
- DMPAPER_EXECUTIVE = 7,
- DMPAPER_A3 = 8,
- DMPAPER_A4 = 9,
- DMPAPER_A4SMALL = 10,
- DMPAPER_A5 = 11,
- DMPAPER_B4 = 12,
- DMPAPER_B5 = 13,
- DMPAPER_FOLIO = 14,
- DMPAPER_QUARTO = 15,
- DMPAPER_10X14 = 16,
- DMPAPER_11X17 = 17,
- DMPAPER_NOTE = 18,
- DMPAPER_ENV_9 = 19,
- DMPAPER_ENV_10 = 20,
- DMPAPER_ENV_11 = 21,
- DMPAPER_ENV_12 = 22,
- DMPAPER_ENV_14 = 23,
- DMPAPER_CSHEET = 24,
- DMPAPER_DSHEET = 25,
- DMPAPER_ESHEET = 26,
- DMPAPER_ENV_DL = 27,
- DMPAPER_ENV_C5 = 28,
- DMPAPER_ENV_C3 = 29,
- DMPAPER_ENV_C4 = 30,
- DMPAPER_ENV_C6 = 31,
- DMPAPER_ENV_C65 = 32,
- DMPAPER_ENV_B4 = 33,
- DMPAPER_ENV_B5 = 34,
- DMPAPER_ENV_B6 = 35,
- DMPAPER_ENV_ITALY = 36,
- DMPAPER_ENV_MONARCH = 37,
- DMPAPER_ENV_PERSONAL = 38,
- DMPAPER_FANFOLD_US = 39,
- DMPAPER_FANFOLD_STD_GERMAN = 40,
- DMPAPER_FANFOLD_LGL_GERMAN = 41,
- DMPAPER_ISO_B4 = 42,
- DMPAPER_JAPANESE_POSTCARD = 43,
- DMPAPER_9X11 = 44,
- DMPAPER_10X11 = 45,
- DMPAPER_15X11 = 46,
- DMPAPER_ENV_INVITE = 47,
- DMPAPER_RESERVED_48 = 48,
- DMPAPER_RESERVED_49 = 49,
- DMPAPER_LETTER_EXTRA = 50,
- DMPAPER_LEGAL_EXTRA = 51,
- DMPAPER_TABLOID_EXTRA = 52,
- DMPAPER_A4_EXTRA = 53,
- DMPAPER_LETTER_TRANSVERSE = 54,
- DMPAPER_A4_TRANSVERSE = 55,
- DMPAPER_LETTER_EXTRA_TRANSVERSE = 56,
- DMPAPER_A_PLUS = 57,
- DMPAPER_B_PLUS = 58,
- DMPAPER_LETTER_PLUS = 59,
- DMPAPER_A4_PLUS = 60,
- DMPAPER_A5_TRANSVERSE = 61,
- DMPAPER_B5_TRANSVERSE = 62,
- DMPAPER_A3_EXTRA = 63,
- DMPAPER_A5_EXTRA = 64,
- DMPAPER_B5_EXTRA = 65,
- DMPAPER_A2 = 66,
- DMPAPER_A3_TRANSVERSE = 67,
- DMPAPER_A3_EXTRA_TRANSVERSE = 68,
-
- // WINVER >= 0x0500
- DMPAPER_DBL_JAPANESE_POSTCARD = 69, /* Japanese Double Postcard 200 x 148 mm */
- DMPAPER_A6 = 70, /* A6 105 x 148 mm */
- DMPAPER_JENV_KAKU2 = 71, /* Japanese Envelope Kaku #2 */
- DMPAPER_JENV_KAKU3 = 72, /* Japanese Envelope Kaku #3 */
- DMPAPER_JENV_CHOU3 = 73, /* Japanese Envelope Chou #3 */
- DMPAPER_JENV_CHOU4 = 74, /* Japanese Envelope Chou #4 */
- DMPAPER_LETTER_ROTATED = 75, /* Letter Rotated 11 x 8 1/2 11 in */
- DMPAPER_A3_ROTATED = 76, /* A3 Rotated 420 x 297 mm */
- DMPAPER_A4_ROTATED = 77, /* A4 Rotated 297 x 210 mm */
- DMPAPER_A5_ROTATED = 78, /* A5 Rotated 210 x 148 mm */
- DMPAPER_B4_JIS_ROTATED = 79, /* B4 (JIS) Rotated 364 x 257 mm */
- DMPAPER_B5_JIS_ROTATED = 80, /* B5 (JIS) Rotated 257 x 182 mm */
- DMPAPER_JAPANESE_POSTCARD_ROTATED = 81, /* Japanese Postcard Rotated 148 x 100 mm */
- DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82, /* Double Japanese Postcard Rotated 148 x 200 mm */
- DMPAPER_A6_ROTATED = 83, /* A6 Rotated 148 x 105 mm */
- DMPAPER_JENV_KAKU2_ROTATED = 84, /* Japanese Envelope Kaku #2 Rotated */
- DMPAPER_JENV_KAKU3_ROTATED = 85, /* Japanese Envelope Kaku #3 Rotated */
- DMPAPER_JENV_CHOU3_ROTATED = 86, /* Japanese Envelope Chou #3 Rotated */
- DMPAPER_JENV_CHOU4_ROTATED = 87, /* Japanese Envelope Chou #4 Rotated */
- DMPAPER_B6_JIS = 88, /* B6 (JIS) 128 x 182 mm */
- DMPAPER_B6_JIS_ROTATED = 89, /* B6 (JIS) Rotated 182 x 128 mm */
- DMPAPER_12X11 = 90, /* 12 x 11 in */
- DMPAPER_JENV_YOU4 = 91, /* Japanese Envelope You #4 */
- DMPAPER_JENV_YOU4_ROTATED = 92, /* Japanese Envelope You #4 Rotated*/
- DMPAPER_P16K = 93, /* PRC 16K 146 x 215 mm */
- DMPAPER_P32K = 94, /* PRC 32K 97 x 151 mm */
- DMPAPER_P32KBIG = 95, /* PRC 32K(Big) 97 x 151 mm */
- DMPAPER_PENV_1 = 96, /* PRC Envelope #1 102 x 165 mm */
- DMPAPER_PENV_2 = 97, /* PRC Envelope #2 102 x 176 mm */
- DMPAPER_PENV_3 = 98, /* PRC Envelope #3 125 x 176 mm */
- DMPAPER_PENV_4 = 99, /* PRC Envelope #4 110 x 208 mm */
- DMPAPER_PENV_5 = 100, /* PRC Envelope #5 110 x 220 mm */
- DMPAPER_PENV_6 = 101, /* PRC Envelope #6 120 x 230 mm */
- DMPAPER_PENV_7 = 102, /* PRC Envelope #7 160 x 230 mm */
- DMPAPER_PENV_8 = 103, /* PRC Envelope #8 120 x 309 mm */
- DMPAPER_PENV_9 = 104, /* PRC Envelope #9 229 x 324 mm */
- DMPAPER_PENV_10 = 105, /* PRC Envelope #10 324 x 458 mm */
- DMPAPER_P16K_ROTATED = 106, /* PRC 16K Rotated */
- DMPAPER_P32K_ROTATED = 107, /* PRC 32K Rotated */
- DMPAPER_P32KBIG_ROTATED = 108, /* PRC 32K(Big) Rotated */
- DMPAPER_PENV_1_ROTATED = 109, /* PRC Envelope #1 Rotated 165 x 102 mm */
- DMPAPER_PENV_2_ROTATED = 110, /* PRC Envelope #2 Rotated 176 x 102 mm */
- DMPAPER_PENV_3_ROTATED = 111, /* PRC Envelope #3 Rotated 176 x 125 mm */
- DMPAPER_PENV_4_ROTATED = 112, /* PRC Envelope #4 Rotated 208 x 110 mm */
- DMPAPER_PENV_5_ROTATED = 113, /* PRC Envelope #5 Rotated 220 x 110 mm */
- DMPAPER_PENV_6_ROTATED = 114, /* PRC Envelope #6 Rotated 230 x 120 mm */
- DMPAPER_PENV_7_ROTATED = 115, /* PRC Envelope #7 Rotated 230 x 160 mm */
- DMPAPER_PENV_8_ROTATED = 116, /* PRC Envelope #8 Rotated 309 x 120 mm */
- DMPAPER_PENV_9_ROTATED = 117, /* PRC Envelope #9 Rotated 324 x 229 mm */
- DMPAPER_PENV_10_ROTATED = 118, /* PRC Envelope #10 Rotated 458 x 324 mm */
-
- DMPAPER_LAST = DMPAPER_PENV_10_ROTATED,
-
- DMBIN_UPPER = 1,
- DMBIN_LOWER = 2,
- DMBIN_MIDDLE = 3,
- DMBIN_MANUAL = 4,
- DMBIN_ENVELOPE = 5,
- DMBIN_ENVMANUAL = 6,
- DMBIN_AUTO = 7,
- DMBIN_TRACTOR = 8,
- DMBIN_SMALLFMT = 9,
- DMBIN_LARGEFMT = 10,
- DMBIN_LARGECAPACITY = 11,
- DMBIN_CASSETTE = 14,
- DMBIN_FORMSOURCE = 15,
- DMBIN_LAST = 15,
- DMBIN_USER = 256,
- DMRES_DRAFT = -1,
- DMRES_LOW = -2,
- DMRES_MEDIUM = -3,
- DMRES_HIGH = -4,
- DMCOLOR_MONOCHROME = 1,
- DMCOLOR_COLOR = 2,
- DMDUP_SIMPLEX = 1,
- DMDUP_VERTICAL = 2,
- DMDUP_HORIZONTAL = 3,
-
- DMCOLLATE_FALSE = 0,
- DMCOLLATE_TRUE = 1,
- PRINTER_ENUM_LOCAL = 0x00000002,
- PRINTER_ENUM_CONNECTIONS = 0x00000004,
- SM_CXICON = 11,
- SM_CYICON = 12,
- DEFAULT_CHARSET = 1;
-
- public const int ERROR_ACCESS_DENIED = 5;
- public const int ERROR_INVALID_PARAMETER = 87;
- public const int ERROR_PROC_NOT_FOUND = 127;
- public const int ERROR_CANCELLED = 1223;
-
- [StructLayout(LayoutKind.Sequential)]
- public struct ENHMETAHEADER
- {
- /// The ENHMETAHEADER structure is defined natively as a union with WmfHeader.
- /// Extreme care should be taken if changing the layout of the corresponding managed
- /// structures to minimize the risk of buffer overruns. The affected managed classes
- /// are the following: ENHMETAHEADER, MetaHeader, MetafileHeaderWmf, MetafileHeaderEmf.
- public int iType;
- public int nSize;
- // rclBounds was a by-value RECTL structure
- public int rclBounds_left;
- public int rclBounds_top;
- public int rclBounds_right;
- public int rclBounds_bottom;
- // rclFrame was a by-value RECTL structure
- public int rclFrame_left;
- public int rclFrame_top;
- public int rclFrame_right;
- public int rclFrame_bottom;
- public int dSignature;
- public int nVersion;
- public int nBytes;
- public int nRecords;
- public short nHandles;
- public short sReserved;
- public int nDescription;
- public int offDescription;
- public int nPalEntries;
- // szlDevice was a by-value SIZE structure
- public int szlDevice_cx;
- public int szlDevice_cy;
- // szlMillimeters was a by-value SIZE structure
- public int szlMillimeters_cx;
- public int szlMillimeters_cy;
- public int cbPixelFormat;
- public int offPixelFormat;
- public int bOpenGL;
- }
-
- // https://devblogs.microsoft.com/oldnewthing/20101018-00/?p=12513
- // https://devblogs.microsoft.com/oldnewthing/20120720-00/?p=7083
-
- // Needs to be packed to 2 to get ICONDIRENTRY to follow immediately after idCount.
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public struct ICONDIR
- {
- // Must be 0
- public ushort idReserved;
- // Must be 1
- public ushort idType;
- // Count of entries
- public ushort idCount;
- // First entry (anysize array)
- public ICONDIRENTRY idEntries;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct ICONDIRENTRY
- {
- // Width and height are 1 - 255 or 0 for 256
- public byte bWidth;
- public byte bHeight;
- public byte bColorCount;
- public byte bReserved;
- public ushort wPlanes;
- public ushort wBitCount;
- public uint dwBytesInRes;
- public uint dwImageOffset;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
deleted file mode 100644
index 709c63d2d7ec7..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GdiplusNative.cs
+++ /dev/null
@@ -1,4502 +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.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.Drawing.Text;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing
-{
- // Raw function imports for gdiplus
- internal static partial class SafeNativeMethods
- {
- internal static unsafe partial class Gdip
- {
- private const string LibraryName = "gdiplus.dll";
-
- // Imported functions
- [LibraryImport(LibraryName)]
- private static partial int GdiplusStartup(out IntPtr token, in StartupInputEx input, out StartupOutput output);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBeginContainer(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, ref RectangleF dstRect, ref RectangleF srcRect, GraphicsUnit unit, out int state);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBeginContainer2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int state);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBeginContainerI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, ref Rectangle dstRect, ref Rectangle srcRect, GraphicsUnit unit, out int state);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEndContainer(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int state);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateAdjustableArrowCap(float height, float width, [MarshalAs(UnmanagedType.Bool)] bool isFilled, out IntPtr adjustableArrowCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetAdjustableArrowCapHeight(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, out float height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetAdjustableArrowCapHeight(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, float height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetAdjustableArrowCapWidth(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, float width);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetAdjustableArrowCapWidth(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, out float width);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetAdjustableArrowCapMiddleInset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, float middleInset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetAdjustableArrowCapMiddleInset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, out float middleInset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetAdjustableArrowCapFillState(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, [MarshalAs(UnmanagedType.Bool)] bool fillState);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetAdjustableArrowCapFillState(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef adjustableArrowCap, [MarshalAs(UnmanagedType.Bool)] out bool fillState);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapType(IntPtr customCap, out CustomLineCapType capType);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateCustomLineCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fillpath,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef strokepath, LineCap baseCap, float baseInset, out IntPtr customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteCustomLineCap(IntPtr customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteCustomLineCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneCustomLineCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out IntPtr clonedCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCustomLineCapStrokeCaps(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, LineCap startCap, LineCap endCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapStrokeCaps(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out LineCap startCap, out LineCap endCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCustomLineCapStrokeJoin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, LineJoin lineJoin);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapStrokeJoin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out LineJoin lineJoin);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCustomLineCapBaseCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, LineCap baseCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapBaseCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out LineCap baseCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCustomLineCapBaseInset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, float inset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapBaseInset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out float inset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCustomLineCapWidthScale(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, float widthScale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCustomLineCapWidthScale(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap, out float widthScale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePathIter(out IntPtr pathIter,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeletePathIter(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterNextSubpath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex, [MarshalAs(UnmanagedType.Bool)] out bool isClosed);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterNextSubpathPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, [MarshalAs(UnmanagedType.Bool)] out bool isClosed);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterNextPathType(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount, out byte pathType, out int startIndex, out int endIndex);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterNextMarker(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount, out int startIndex, out int endIndex);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterNextMarkerPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterGetCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterGetSubpathCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterHasCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, [MarshalAs(UnmanagedType.Bool)] out bool hasCurve);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterRewind(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterEnumerate(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount, PointF* points, byte* types, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPathIterCopyData(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pathIter, out int resultCount, PointF* points, byte* types, int startIndex, int endIndex);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateHatchBrush(int hatchstyle, int forecol, int backcol, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetHatchStyle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int hatchstyle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetHatchForegroundColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int forecol);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetHatchBackgroundColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int backcol);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneBrush(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out IntPtr clonebrush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrush(ref PointF point1, ref PointF point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrushI(ref Point point1, ref Point point2, int color1, int color2, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrushFromRect(ref RectangleF rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrushFromRectI(ref Rectangle rect, int color1, int color2, LinearGradientMode lineGradientMode, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrushFromRectWithAngle(ref RectangleF rect, int color1, int color2, float angle, [MarshalAs(UnmanagedType.Bool)] bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateLineBrushFromRectWithAngleI(ref Rectangle rect, int color1, int color2, float angle, [MarshalAs(UnmanagedType.Bool)] bool isAngleScaleable, WrapMode wrapMode, out IntPtr lineGradient);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineColors(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int color1, int color2);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineColors(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int[] colors);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out RectangleF gprectf);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineGammaCorrection(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, [MarshalAs(UnmanagedType.Bool)] out bool useGammaCorrection);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineGammaCorrection(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, [MarshalAs(UnmanagedType.Bool)] bool useGammaCorrection);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineSigmaBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float focus, float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineLinearBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float focus, float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineBlendCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, IntPtr blend, IntPtr positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, IntPtr blend, IntPtr positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLinePresetBlendCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLinePresetBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, IntPtr blend, IntPtr positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLinePresetBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, IntPtr blend, IntPtr positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int wrapMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int wrapMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float dx, float dy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScaleLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float sx, float sy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotateLineTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePathGradient(PointF* points, int count, WrapMode wrapMode, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePathGradientI(Point* points, int count, WrapMode wrapMode, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePathGradientFromPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientCenterColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int color);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientCenterColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int color);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientSurroundColorsWithCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int[] color, ref int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientSurroundColorsWithCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int[] argb, ref int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientCenterPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out PointF point);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientCenterPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, ref PointF point);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out RectangleF gprectf);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientPointCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientSurroundColorCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientBlendCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float[] blend, float[] positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, IntPtr blend, IntPtr positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientPresetBlendCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientPresetBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int[] blend, float[] positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientPresetBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int[] blend, float[] positions, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientSigmaBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float focus, float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientLinearBlend(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float focus, float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int wrapmode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int wrapmode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetPathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyPathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslatePathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float dx, float dy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScalePathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float sx, float sy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotatePathGradientTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathGradientFocusScales(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float[] xScale, float[] yScale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathGradientFocusScales(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float xScale, float yScale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateImageAttributes(out IntPtr imageattr);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneImageAttributes(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, out IntPtr cloneImageattr);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDisposeImageAttributes(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesColorMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(ColorMatrix.PinningMarshaller))]
-#endif
- ColorMatrix? colorMatrix,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(ColorMatrix.PinningMarshaller))]
-#endif
- ColorMatrix? grayMatrix, ColorMatrixFlag flags);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesThreshold(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, float threshold);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesGamma(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, float gamma);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesNoOp(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesColorKeys(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, int colorLow, int colorHigh);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesOutputChannel(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, ColorChannelFlag flags);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipSetImageAttributesOutputChannelColorProfile(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, string colorProfileFilename);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesRemapTable(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, ColorAdjustType type, [MarshalAs(UnmanagedType.Bool)] bool enableFlag, int mapSize, IntPtr map);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImageAttributesWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, int wrapmode, int argb, [MarshalAs(UnmanagedType.Bool)] bool clamp);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageAttributesAdjustedPalette(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattr, IntPtr palette, ColorAdjustType type);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageDecodersSize(out int numDecoders, out int size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageEncodersSize(out int numEncoders, out int size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateSolidFill(int color, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetSolidFillColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int color);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetSolidFillColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int color);
-
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateTexture(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, int wrapmode, out IntPtr texture);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateTexture2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, int wrapmode, float x, float y, float width, float height, out IntPtr texture);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateTextureIA(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttrib, float x, float y, float width, float height, out IntPtr texture);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateTexture2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, int wrapmode, int x, int y, int width, int height, out IntPtr texture);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateTextureIAI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttrib, int x, int y, int width, int height, out IntPtr texture);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float dx, float dy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScaleTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float sx, float sy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotateTextureTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetTextureWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int wrapMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetTextureWrapMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out int wrapMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetTextureImage(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, out IntPtr image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontCollectionFamilyCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontCollection, out int numFound);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontCollectionFamilyList(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontCollection, int numSought, IntPtr[] gpfamilies, out int numFound);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneFontFamily(IntPtr fontfamily, out IntPtr clonefontfamily);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipCreateFontFamilyFromName(string name,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontCollection, out IntPtr FontFamily);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetGenericFontFamilySansSerif(out IntPtr fontfamily);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetGenericFontFamilySerif(out IntPtr fontfamily);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetGenericFontFamilyMonospace(out IntPtr fontfamily);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteFontFamily(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontFamily);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipGetFamilyName(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, char* name, int language);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsStyleAvailable(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, FontStyle style, out int isStyleAvailable);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetEmHeight(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, FontStyle style, out int EmHeight);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCellAscent(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, FontStyle style, out int CellAscent);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCellDescent(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, FontStyle style, out int CellDescent);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLineSpacing(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef family, FontStyle style, out int LineSpaceing);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipNewInstalledFontCollection(out IntPtr fontCollection);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipNewPrivateFontCollection(out IntPtr fontCollection);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeletePrivateFontCollection(ref IntPtr fontCollection);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipPrivateAddFontFile(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontCollection, string filename);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPrivateAddMemoryFont(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontCollection, IntPtr memory, int length);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateFont(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateFontFromDC(IntPtr hdc, ref IntPtr font);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneFont(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, out IntPtr cloneFont);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteFont(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFamily(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, out IntPtr family);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontStyle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, out FontStyle style);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontSize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, out float size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontHeight(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out float size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontHeightGivenDPI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, float dpi, out float size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetFontUnit(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, out GraphicsUnit unit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetLogFontW(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, ref Interop.User32.LOGFONT lf);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePen1(int argb, float width, int unit, out IntPtr pen);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePen2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float width, int unit, out IntPtr pen);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipClonePen(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out IntPtr clonepen);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeletePen(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef Pen);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PenAlignment penAlign);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out PenAlignment penAlign);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenWidth(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float width);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenWidth(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] width);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenLineCap197819(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int startCap, int endCap, int dashCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenStartCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int startCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenEndCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int endCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenStartCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int startCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenEndCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int endCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenDashCap197819(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int dashCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenDashCap197819(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int dashCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenLineJoin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int lineJoin);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenLineJoin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int lineJoin);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenCustomStartCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenCustomStartCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out IntPtr customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenCustomEndCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenCustomEndCap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out IntPtr customCap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenMiterLimit(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float miterLimit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenMiterLimit(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] miterLimit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetPenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyPenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslatePenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float dx, float dy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScalePenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float sx, float sy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotatePenTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int argb);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int argb);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenBrushFill(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenBrushFill(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out IntPtr brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenFillType(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int pentype);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenDashStyle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int dashstyle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenDashStyle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int dashstyle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenDashArray(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef memorydash, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenDashOffset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] dashoffset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenDashOffset(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float dashoffset);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenDashCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int dashcount);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenDashArray(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] memorydash, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenCompoundCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPenCompoundArray(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] array, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPenCompoundArray(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float[] array, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float dx, float dy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScaleWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float sx, float sy, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotateWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetWorldTransform(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCompositingMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, CompositingMode compositingMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetTextRenderingHint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, TextRenderingHint textRenderingHint);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetTextContrast(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int textContrast);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetInterpolationMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, InterpolationMode interpolationMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCompositingMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out CompositingMode compositingMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetRenderingOrigin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int x, int y);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRenderingOrigin(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int x, out int y);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetCompositingQuality(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, CompositingQuality quality);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetCompositingQuality(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out CompositingQuality quality);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetSmoothingMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, SmoothingMode smoothingMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetSmoothingMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out SmoothingMode smoothingMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPixelOffsetMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, PixelOffsetMode pixelOffsetMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPixelOffsetMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out PixelOffsetMode pixelOffsetMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetTextRenderingHint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out TextRenderingHint textRenderingHint);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetTextContrast(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int textContrast);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetInterpolationMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out InterpolationMode interpolationMode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPageUnit(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out GraphicsUnit unit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPageScale(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPageUnit(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, GraphicsUnit unit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPageScale(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float scale);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetDpiX(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out float dpi);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetDpiY(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out float dpi);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMatrix(out IntPtr matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMatrix2(float m11, float m12, float m21, float m22, float dx, float dy, out IntPtr matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMatrix3(ref RectangleF rect, PointF* dstplg, out IntPtr matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMatrix3I(ref Rectangle rect, Point* dstplg, out IntPtr matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, out IntPtr cloneMatrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetMatrixElements(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float m11, float m12, float m21, float m22, float dx, float dy);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipMultiplyMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix2, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float offsetX, float offsetY, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipScaleMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float scaleX, float scaleY, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRotateMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float angle, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipShearMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float shearX, float shearY, MatrixOrder order);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipInvertMatrix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformMatrixPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, PointF* pts, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformMatrixPointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, Point* pts, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipVectorTransformMatrixPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, PointF* pts, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipVectorTransformMatrixPointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, Point* pts, int count);
-
- [LibraryImport(LibraryName)]
- internal static unsafe partial int GdipGetMatrixElements(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float* m);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsMatrixInvertible(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsMatrixIdentity(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsMatrixEqual(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix2, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegion(out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegionRect(ref RectangleF gprectf, out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegionRectI(ref Rectangle gprect, out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegionPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegionRgnData(byte[] rgndata, int size, out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateRegionHrgn(IntPtr hRgn, out IntPtr region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, out IntPtr cloneregion);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetInfinite(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetEmpty(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCombineRegionRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, ref RectangleF gprectf, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCombineRegionRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, ref Rectangle gprect, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCombineRegionPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCombineRegionRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region2, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, float dx, float dy);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateRegionI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, int dx, int dy);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionBounds(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out RectangleF gprectf);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionHRgn(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out IntPtr hrgn);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsEmptyRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsInfiniteRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsEqualRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region2,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionDataSize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, out int bufferSize);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionData(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, byte[] regionData, int bufferSize, out int sizeFilled);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRegionPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, float X, float Y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRegionPointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, int X, int Y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRegionRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, float X, float Y, float width, float height,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRegionRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, int X, int Y, int width, int height,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int boolean);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionScansCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, out int count,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetRegionScans(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, RectangleF* rects, out int count,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateFromHDC(IntPtr hdc, out IntPtr graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetClipGraphics(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef srcgraphics, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetClipRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float x, float y, float width, float height, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetClipRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int x, int y, int width, int height, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetClipPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetClipRegion(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region, CombineMode mode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetClip(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTranslateClip(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float dx, float dy);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetClip(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef region);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetClipBounds(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out RectangleF rect);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsClipEmpty(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetVisibleClipBounds(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out RectangleF rect);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleClipEmpty(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisiblePoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float x, float y, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisiblePointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int x, int y, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, float x, float y, float width, float height, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisibleRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int x, int y, int width, int height, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipFlush(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, FlushIntention intention);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetDC(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out IntPtr hdc);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatMeasurableCharacterRanges(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, int rangeCount, CharacterRange[] range);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateStringFormat(StringFormatFlags options, int language, out IntPtr format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipStringFormatGetGenericDefault(out IntPtr format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipStringFormatGetGenericTypographic(out IntPtr format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteStringFormat(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneStringFormat(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out IntPtr newFormat);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatFlags(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, StringFormatFlags options);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatFlags(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out StringFormatFlags result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatAlign(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, StringAlignment align);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatAlign(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out StringAlignment align);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatLineAlign(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, StringAlignment align);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatLineAlign(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out StringAlignment align);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatHotkeyPrefix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, HotkeyPrefix hotkeyPrefix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatHotkeyPrefix(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out HotkeyPrefix hotkeyPrefix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatTabStops(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, float firstTabOffset, int count, float[] tabStops);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatTabStops(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, int count, out float firstTabOffset, float[] tabStops);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatTabStopCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatMeasurableCharacterRangeCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatTrimming(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, StringTrimming trimming);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatTrimming(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out StringTrimming trimming);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetStringFormatDigitSubstitution(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, int langID, StringDigitSubstitute sds);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetStringFormatDigitSubstitution(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format, out int langID, out StringDigitSubstitute sds);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageDimension(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out float width, out float height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageWidth(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int width);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageHeight(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageHorizontalResolution(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out float horzRes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageVerticalResolution(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out float vertRes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageFlags(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int flags);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageRawFormat(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, ref Guid format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImagePixelFormat(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out PixelFormat format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageGetFrameCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, ref Guid dimensionID, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageSelectActiveFrame(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, ref Guid dimensionID, int frameIndex);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageRotateFlip(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int rotateFlipType);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetAllPropertyItems(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, uint totalBufferSize, uint numProperties, PropertyItemInternal* allItems);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPropertyCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out uint numOfProperty);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPropertyIdList(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, uint numOfProperty, int* list);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPropertyItem(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int propid, uint propSize, PropertyItemInternal* buffer);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPropertyItemSize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int propid, out uint size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPropertySize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out uint totalBufferSize, out uint numProperties);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRemovePropertyItem(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int propid);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPropertyItem(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, PropertyItemInternal* item);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageType(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int type);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageType(IntPtr image, out int type);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDisposeImage(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDisposeImage(IntPtr image);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipCreateBitmapFromFileICM(string filename, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromScan0(int width, int height, int stride, int format, IntPtr scan0, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromGraphics(int width, int height,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromHBITMAP(IntPtr hbitmap, IntPtr hpalette, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromHICON(IntPtr hicon, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromResource(IntPtr hresource, IntPtr name, out IntPtr bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateHBITMAPFromBitmap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateHICONFromBitmap(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef nativeBitmap, out IntPtr hicon);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneBitmapArea(float x, float y, float width, float height, int format,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef srcbitmap, out IntPtr dstbitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneBitmapAreaI(int x, int y, int width, int height, int format,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef srcbitmap, out IntPtr dstbitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBitmapLockBits(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, ref Rectangle rect, ImageLockMode flags, PixelFormat format,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(BitmapData.PinningMarshaller))]
-#endif
- BitmapData lockedBitmapData);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBitmapUnlockBits(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(BitmapData.PinningMarshaller))]
-#endif
- BitmapData lockedBitmapData);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBitmapGetPixel(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, int x, int y, out int argb);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBitmapSetPixel(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, int x, int y, int argb);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipBitmapSetResolution(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef bitmap, float dpix, float dpiy);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageGetFrameDimensionsCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageGetFrameDimensionsList(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, Guid* dimensionIDs, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMetafileFromEmf(IntPtr hEnhMetafile, [MarshalAs(UnmanagedType.Bool)] bool deleteEmf, out IntPtr metafile);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMetafileFromWmf(IntPtr hMetafile, [MarshalAs(UnmanagedType.Bool)] bool deleteWmf,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(WmfPlaceableFileHeader.PinningMarshaller))]
-#endif
- WmfPlaceableFileHeader wmfplacealbeHeader, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipCreateMetafileFromFile(string file, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafile(IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileI(IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, ref RectangleF frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileFileName(string fileName, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileFileNameI(string fileName, IntPtr referenceHdc, EmfType emfType, ref Rectangle frameRect, MetafileFrameUnit frameUnit, string? description, out IntPtr metafile);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipPlayMetafileRecord(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, EmfPlusRecordType recordType, int flags, int dataSize, byte[] data);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSaveGraphics(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, out int state);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawArc(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawArcI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawLinesI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawBezier(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawEllipse(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawEllipseI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawLine(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x1, float y1, float x2, float y2);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawLineI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int x1, int y1, int x2, int y2);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawLines(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawPie(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawPieI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawPolygon(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawPolygonI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillEllipse(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillEllipseI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillPolygon(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, PointF* points, int count, FillMode brushMode);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillPolygonI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, Point* points, int count, FillMode brushMode);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillRectangle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillRectangleI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillRectangles(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, RectangleF* rects, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillRectanglesI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, Rectangle* rects, int count);
-
- [LibraryImport(LibraryName, SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipDrawString(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, string textString, int length,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, ref RectangleF layoutRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef stringFormat,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImageRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGraphicsClear(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int argb);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawClosedCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawClosedCurveI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawClosedCurve2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawClosedCurve2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurveI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurve2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurve2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurve3(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count, int offset, int numberOfSegments, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawCurve3I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count, int offset, int numberOfSegments, float tension);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillClosedCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillClosedCurveI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillClosedCurve2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, PointF* points, int count, float tension, FillMode mode);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillClosedCurve2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, Point* points, int count, float tension, FillMode mode);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillPie(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillPieI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipMeasureString(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, string textString, int length,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, ref RectangleF layoutRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef stringFormat, ref RectangleF boundingBox, out int codepointsFitted, out int linesFilled);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipMeasureCharacterRanges(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, string textString, int length,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef font, ref RectangleF layoutRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef stringFormat, int characterCount, IntPtr[] region);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImageI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int x, int y);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImage(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, float x, float y);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImageRectRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttributes,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.DrawImageAbortMarshaller))]
-#endif
- Graphics.DrawImageAbort? callback,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef callbackdata);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePointsRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, PointF* points, int count, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttributes,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.DrawImageAbortMarshaller))]
-#endif
- Graphics.DrawImageAbort? callback,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef callbackdata);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImageRectRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GraphicsUnit srcunit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttributes,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.DrawImageAbortMarshaller))]
-#endif
- Graphics.DrawImageAbort? callback,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef callbackdata);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePointsRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, Point* points, int count, int srcx, int srcy, int srcwidth, int srcheight, GraphicsUnit srcunit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageAttributes,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.DrawImageAbortMarshaller))]
-#endif
- Graphics.DrawImageAbort? callback,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef callbackdata);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImageRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePointRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, int srcunit);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawImagePointRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, int srcunit);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawRectangle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawRectangleI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawRectangles(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, RectangleF* rects, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawRectanglesI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Rectangle* rects, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int destSpace, int srcSpace, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformPointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int destSpace, int srcSpace, Point* points, int count);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipLoadImageFromFileICM(string filename, out IntPtr image);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipLoadImageFromFile(string filename, out IntPtr image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetEncoderParameterListSize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, ref Guid encoder, out int size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetEncoderParameterList(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, ref Guid encoder, int size, IntPtr buffer);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePath(int brushMode, out IntPtr path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePath2(PointF* points, byte* types, int count, int brushMode, out IntPtr path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreatePath2I(Point* points, byte* types, int count, int brushMode, out IntPtr path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipClonePath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out IntPtr clonepath);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeletePath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipResetPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPointCount(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathTypes(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, byte[] types, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathFillMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out FillMode fillmode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathFillMode(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, FillMode fillmode);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathData(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, GpPathData* pathData);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipStartPathFigure(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipClosePathFigure(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipClosePathFigures(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetPathMarker(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipClearPathMarkers(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipReversePath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathLastPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out PointF lastPoint);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathLine(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x1, float y1, float x2, float y2);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathLine2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathArc(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathBezier(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathBeziers(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurve2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurve3(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count, int offset, int numberOfSegments, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathClosedCurve(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathClosedCurve2(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathRectangle(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathRectangles(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, RectangleF* rects, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathEllipse(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y, float width, float height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathPie(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y, float width, float height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathPolygon(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, PointF* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef addingPath, [MarshalAs(UnmanagedType.Bool)] bool connect);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipAddPathString(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, string s, int length,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontFamily, int style, float emSize, ref RectangleF layoutRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipAddPathStringI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, string s, int length,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef fontFamily, int style, float emSize, ref Rectangle layoutRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef format);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathLineI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x1, int y1, int x2, int y2);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathLine2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathArcI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathBezierI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathBeziersI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurveI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurve2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathCurve3I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count, int offset, int numberOfSegments, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathClosedCurveI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathClosedCurve2I(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count, float tension);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathRectangleI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathRectanglesI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Rectangle* rects, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathEllipseI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y, int width, int height);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathPieI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y, int width, int height, float startAngle, float sweepAngle);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipAddPathPolygonI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, Point* points, int count);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipFlattenPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrixfloat, float flatness);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipWidenPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, float flatness);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipWarpPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix, PointF* points, int count, float srcX, float srcY, float srcWidth, float srcHeight, WarpMode warpMode, float flatness);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipTransformPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetPathWorldBounds(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, out RectangleF gprectf,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef matrix,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisiblePathPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsVisiblePathPointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsOutlineVisiblePathPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, float x, float y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipIsOutlineVisiblePathPointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path, int x, int y,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, [MarshalAs(UnmanagedType.Bool)] out bool result);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteBrush(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipLoadImageFromStream(IntPtr stream, IntPtr* image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipLoadImageFromStreamICM(IntPtr stream, IntPtr* image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCloneImage(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out IntPtr cloneimage);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipSaveImageToFile(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, string filename, ref Guid classId,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef encoderParams);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSaveImageToStream(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, IntPtr stream, Guid* classId,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef encoderParams);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSaveAdd(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef encoderParams);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSaveAddImage(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef newImage,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef encoderParams);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageGraphicsContext(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out IntPtr graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageBounds(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out RectangleF gprectf, out GraphicsUnit unit);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImageThumbnail(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, int thumbWidth, int thumbHeight, out IntPtr thumbImage,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Image.GetThumbnailImageAbortMarshaller))]
-#endif
- Image.GetThumbnailImageAbort? callback, IntPtr callbackdata);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImagePalette(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, IntPtr palette, int size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipSetImagePalette(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, IntPtr palette);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetImagePaletteSize(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef image, out int size);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipImageForceValidation(IntPtr image);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateFromHDC2(IntPtr hdc, IntPtr hdevice, out IntPtr graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateFromHWND(IntPtr hwnd, out IntPtr graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipDeleteGraphics(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipReleaseDC(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, IntPtr hdc);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetNearestColor(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, ref int color);
-
- [LibraryImport(LibraryName)]
- internal static partial IntPtr GdipCreateHalftonePalette();
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawBeziers(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, PointF* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipDrawBeziersI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef pen, Point* points, int count);
-
- [LibraryImport(LibraryName, SetLastError = true)]
- internal static partial int GdipFillPath(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef brush,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef path);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref PointF destPoint,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestPointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref Point destPoint,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref RectangleF destRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref Rectangle destRect,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, PointF* destPoints, int count,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileDestPointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, Point* destPoints, int count,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestPoint(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref PointF destPoint, ref RectangleF srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestPointI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref Point destPoint, ref Rectangle srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestRect(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref RectangleF destRect, ref RectangleF srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestRectI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, ref Rectangle destRect, ref Rectangle srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestPoints(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, PointF* destPoints, int count, ref RectangleF srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipEnumerateMetafileSrcRectDestPointsI(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, Point* destPoints, int count, ref Rectangle srcRect, GraphicsUnit pageUnit,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(Graphics.EnumerateMetafileProcMarshaller))]
-#endif
- Graphics.EnumerateMetafileProc callback, IntPtr callbackdata,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef imageattributes);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipRestoreGraphics(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int state);
-
- [LibraryImport(LibraryName, EntryPoint = "GdipGetMetafileHeaderFromWmf")]
- private static partial int GdipGetMetafileHeaderFromWmf_Internal(IntPtr hMetafile,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(WmfPlaceableFileHeader.PinningMarshaller))]
-#endif
- WmfPlaceableFileHeader wmfplaceable,
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(MetafileHeaderWmf.Marshaller))]
- ref MetafileHeaderWmf metafileHeaderWmf
-#else
- MetafileHeaderWmf metafileHeaderWmf
-#endif
- );
-
- internal static int GdipGetMetafileHeaderFromWmf(IntPtr hMetafile,
- WmfPlaceableFileHeader wmfplaceable,
- MetafileHeaderWmf metafileHeaderWmf
- )
- {
- return GdipGetMetafileHeaderFromWmf_Internal(hMetafile,
- wmfplaceable,
-#if NET7_0_OR_GREATER
- ref
-#endif
- metafileHeaderWmf
- );
- }
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetMetafileHeaderFromEmf(IntPtr hEnhMetafile, MetafileHeaderEmf metafileHeaderEmf);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipGetMetafileHeaderFromFile(string filename, IntPtr header);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetMetafileHeaderFromStream(IntPtr stream, IntPtr header);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetMetafileHeaderFromMetafile(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, IntPtr header);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipGetHemfFromMetafile(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef metafile, out IntPtr hEnhMetafile);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateMetafileFromStream(IntPtr stream, IntPtr* metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileStream(IntPtr stream, IntPtr referenceHdc, EmfType emfType, RectangleF* frameRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileStream(IntPtr stream, IntPtr referenceHdc, EmfType emfType, IntPtr pframeRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipRecordMetafileStreamI(IntPtr stream, IntPtr referenceHdc, EmfType emfType, Rectangle* frameRect, MetafileFrameUnit frameUnit, string? description, IntPtr* metafile);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipComment(
-#if NET7_0_OR_GREATER
- [MarshalUsing(typeof(HandleRefMarshaller))]
-#endif
- HandleRef graphics, int sizeData, byte[] data);
-
- [LibraryImport(LibraryName, StringMarshalling = StringMarshalling.Utf16)]
- internal static partial int GdipCreateFontFromLogfontW(IntPtr hdc, ref Interop.User32.LOGFONT lf, out IntPtr font);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromStream(IntPtr stream, IntPtr* bitmap);
-
- [LibraryImport(LibraryName)]
- internal static partial int GdipCreateBitmapFromStreamICM(IntPtr stream, IntPtr* bitmap);
-
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct StartupInputEx
- {
- public int GdiplusVersion; // Must be 1 or 2
-
- public IntPtr DebugEventCallback;
-
- public Interop.BOOL SuppressBackgroundThread; // FALSE unless you're prepared to call
- // the hook/unhook functions properly
-
- public Interop.BOOL SuppressExternalCodecs; // FALSE unless you want GDI+ only to use
- // its internal image codecs.
- public int StartupParameters;
-
- public static StartupInputEx GetDefault()
- {
- OperatingSystem os = Environment.OSVersion;
- StartupInputEx result = default;
-
- // In Windows 7 GDI+1.1 story is different as there are different binaries per GDI+ version.
- bool isWindows7 = os.Platform == PlatformID.Win32NT && os.Version.Major == 6 && os.Version.Minor == 1;
- result.GdiplusVersion = isWindows7 ? 1 : 2;
- result.SuppressBackgroundThread = Interop.BOOL.FALSE;
- result.SuppressExternalCodecs = Interop.BOOL.FALSE;
- result.StartupParameters = 0;
- return result;
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct StartupOutput
- {
- // The following 2 fields won't be used. They were originally intended
- // for getting GDI+ to run on our thread - however there are marshalling
- // dealing with function *'s and what not - so we make explicit calls
- // to gdi+ after the fact, via the GdiplusNotificationHook and
- // GdiplusNotificationUnhook methods.
- public IntPtr hook; //not used
- public IntPtr unhook; //not used.
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.cs
deleted file mode 100644
index 1cdbf8cd5ac3b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Graphics.cs
+++ /dev/null
@@ -1,3465 +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.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.Drawing.Text;
-using System.Globalization;
-using System.Numerics;
-using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
-using System.Diagnostics.CodeAnalysis;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// Encapsulates a GDI+ drawing surface.
- ///
- public sealed class Graphics : MarshalByRefObject, IDisposable, IDeviceContext
- {
-#if FINALIZATION_WATCH
- static readonly TraceSwitch GraphicsFinalization = new TraceSwitch("GraphicsFinalization", "Tracks the creation and destruction of finalization");
- internal static string GetAllocationStack() {
- if (GraphicsFinalization.TraceVerbose) {
- return Environment.StackTrace;
- }
- else {
- return "Enabled 'GraphicsFinalization' switch to see stack of allocation";
- }
- }
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- ///
- /// The context state previous to the current Graphics context (the head of the stack).
- /// We don't keep a GraphicsContext for the current context since it is available at any time from GDI+ and
- /// we don't want to keep track of changes in it.
- ///
- private GraphicsContext? _previousContext;
-
- private static readonly object s_syncObject = new object();
-
- // Object reference used for printing; it could point to a PrintPreviewGraphics to obtain the VisibleClipBounds, or
- // a DeviceContext holding a printer DC.
- private object? _printingHelper;
-
- // GDI+'s preferred HPALETTE.
- private static IntPtr s_halftonePalette;
-
- // pointer back to the Image backing a specific graphic object
- private Image? _backingImage;
-
- ///
- /// Handle to native DC - obtained from the GDI+ graphics object. We need to cache it to implement
- /// IDeviceContext interface.
- ///
- private IntPtr _nativeHdc;
-
- public delegate bool DrawImageAbort(IntPtr callbackdata);
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(DrawImageAbort), MarshalMode.ManagedToUnmanagedIn, typeof(KeepAliveMarshaller))]
- internal static class DrawImageAbortMarshaller
- {
- internal unsafe struct KeepAliveMarshaller
- {
- private delegate Interop.BOOL DrawImageAbortNative(IntPtr callbackdata);
- private DrawImageAbortNative? _managed;
- private delegate* unmanaged _nativeFunction;
- public void FromManaged(DrawImageAbort? managed)
- {
- _managed = managed is null ? null : data => managed(data) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
- _nativeFunction = _managed is null ? null : (delegate* unmanaged)Marshal.GetFunctionPointerForDelegate(_managed);
- }
-
- public delegate* unmanaged ToUnmanaged()
- {
- return _nativeFunction;
- }
-
- public void OnInvoked()
- {
- GC.KeepAlive(_managed);
- }
-
- public void Free() { }
- }
- }
-#endif
-
- ///
- /// Callback for EnumerateMetafile methods.
- /// This method can then call Metafile.PlayRecord to play the record that was just enumerated.
- ///
- /// if >= MinRecordType, it's an EMF+ record
- /// always 0 for EMF records
- /// size of the data, or 0 if no data
- /// pointer to the data, or NULL if no data (UINT32 aligned)
- /// pointer to callbackData, if any
- /// False to abort enumerating, true to continue.
- public delegate bool EnumerateMetafileProc(
- EmfPlusRecordType recordType,
- int flags,
- int dataSize,
- IntPtr data,
- PlayRecordCallback? callbackData);
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(EnumerateMetafileProc), MarshalMode.ManagedToUnmanagedIn, typeof(KeepAliveMarshaller))]
- internal static class EnumerateMetafileProcMarshaller
- {
- internal unsafe struct KeepAliveMarshaller
- {
- private delegate Interop.BOOL EnumerateMetafileProcNative(
- EmfPlusRecordType recordType,
- int flags,
- int dataSize,
- IntPtr data,
- IntPtr callbackData);
- private EnumerateMetafileProcNative? _managed;
- private delegate* unmanaged _nativeFunction;
- public void FromManaged(EnumerateMetafileProc? managed)
- {
- _managed = managed is null ? null : (recordType, flags, dataSize, data, callbackData) =>
- managed(recordType, flags, dataSize, data, callbackData == IntPtr.Zero ? null : Marshal.GetDelegateForFunctionPointer(callbackData)) ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
- _nativeFunction = _managed is null ? null : (delegate* unmanaged)Marshal.GetFunctionPointerForDelegate(_managed);
- }
-
- public delegate* unmanaged ToUnmanaged()
- {
- return _nativeFunction;
- }
-
- public void OnInvoked()
- {
- GC.KeepAlive(_managed);
- }
-
- public void Free() {}
- }
- }
-#endif
-
- ///
- /// Constructor to initialize this object from a native GDI+ Graphics pointer.
- ///
- private Graphics(IntPtr gdipNativeGraphics)
- {
- if (gdipNativeGraphics == IntPtr.Zero)
- throw new ArgumentNullException(nameof(gdipNativeGraphics));
-
- NativeGraphics = gdipNativeGraphics;
- }
-
- ///
- /// Creates a new instance of the class from the specified handle to a device context.
- ///
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHdc(IntPtr hdc)
- {
- if (hdc == IntPtr.Zero)
- throw new ArgumentNullException(nameof(hdc));
-
- return FromHdcInternal(hdc);
- }
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHdcInternal(IntPtr hdc)
- {
- Gdip.CheckStatus(Gdip.GdipCreateFromHDC(hdc, out IntPtr nativeGraphics));
- return new Graphics(nativeGraphics);
- }
-
- ///
- /// Creates a new instance of the Graphics class from the specified handle to a device context and handle to a device.
- ///
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHdc(IntPtr hdc, IntPtr hdevice)
- {
- Gdip.CheckStatus(Gdip.GdipCreateFromHDC2(hdc, hdevice, out IntPtr nativeGraphics));
- return new Graphics(nativeGraphics);
- }
-
- ///
- /// Creates a new instance of the class from a window handle.
- ///
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHwnd(IntPtr hwnd) => FromHwndInternal(hwnd);
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public static Graphics FromHwndInternal(IntPtr hwnd)
- {
- Gdip.CheckStatus(Gdip.GdipCreateFromHWND(hwnd, out IntPtr nativeGraphics));
- return new Graphics(nativeGraphics);
- }
-
- ///
- /// Creates an instance of the class from an existing .
- ///
- public static Graphics FromImage(Image image)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- if ((image.PixelFormat & PixelFormat.Indexed) != 0)
- throw new ArgumentException(SR.GdiplusCannotCreateGraphicsFromIndexedPixelFormat, nameof(image));
-
- Gdip.CheckStatus(Gdip.GdipGetImageGraphicsContext(
- new HandleRef(image, image.nativeImage),
- out IntPtr nativeGraphics));
-
- return new Graphics(nativeGraphics) { _backingImage = image };
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void ReleaseHdcInternal(IntPtr hdc)
- {
- Gdip.CheckStatus(!Gdip.Initialized ? Gdip.Ok :
- Gdip.GdipReleaseDC(new HandleRef(this, NativeGraphics), hdc));
- _nativeHdc = IntPtr.Zero;
- }
-
- ///
- /// Deletes this , and frees the memory allocated for it.
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
-#if DEBUG && FINALIZATION_WATCH
- if (!disposing && _nativeGraphics != IntPtr.Zero)
- {
- Debug.WriteLine("System.Drawing.Graphics: ***************************************************");
- Debug.WriteLine("System.Drawing.Graphics: Object Disposed through finalization:\n" + allocationSite);
- }
-#endif
- while (_previousContext != null)
- {
- // Dispose entire stack.
- GraphicsContext? context = _previousContext.Previous;
- _previousContext.Dispose();
- _previousContext = context;
- }
-
- if (NativeGraphics != IntPtr.Zero)
- {
- try
- {
- if (_nativeHdc != IntPtr.Zero) // avoid a handle leak.
- {
- ReleaseHdc();
- }
-
- if (PrintingHelper is DeviceContext printerDC)
- {
- printerDC.Dispose();
- _printingHelper = null;
- }
-
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteGraphics(new HandleRef(this, NativeGraphics));
-
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- }
- finally
- {
- NativeGraphics = IntPtr.Zero;
- }
- }
- }
-
- ~Graphics() => Dispose(false);
-
- ///
- /// Handle to native GDI+ graphics object. This object is created on demand.
- ///
- internal IntPtr NativeGraphics { get; private set; }
-
- public Region Clip
- {
- get
- {
- var region = new Region();
- int status = Gdip.GdipGetClip(new HandleRef(this, NativeGraphics), new HandleRef(region, region.NativeRegion));
- Gdip.CheckStatus(status);
-
- return region;
- }
- set => SetClip(value, CombineMode.Replace);
- }
-
- public RectangleF ClipBounds
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetClipBounds(new HandleRef(this, NativeGraphics), out RectangleF rect));
- return rect;
- }
- }
-
- ///
- /// Gets or sets the associated with this .
- ///
- public CompositingMode CompositingMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetCompositingMode(new HandleRef(this, NativeGraphics), out CompositingMode mode));
- return mode;
- }
- set
- {
- if (value < CompositingMode.SourceOver || value > CompositingMode.SourceCopy)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(CompositingMode));
-
- Gdip.CheckStatus(Gdip.GdipSetCompositingMode(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public CompositingQuality CompositingQuality
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetCompositingQuality(new HandleRef(this, NativeGraphics), out CompositingQuality cq));
- return cq;
- }
- set
- {
- if (value < CompositingQuality.Invalid || value > CompositingQuality.AssumeLinear)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(CompositingQuality));
-
- Gdip.CheckStatus(Gdip.GdipSetCompositingQuality(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public float DpiX
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetDpiX(new HandleRef(this, NativeGraphics), out float dpi));
- return dpi;
- }
- }
-
- public float DpiY
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetDpiY(new HandleRef(this, NativeGraphics), out float dpi));
- return dpi;
- }
- }
-
- ///
- /// Gets or sets the interpolation mode associated with this Graphics.
- ///
- public InterpolationMode InterpolationMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetInterpolationMode(new HandleRef(this, NativeGraphics), out InterpolationMode mode));
- return mode;
- }
- set
- {
- if (value < InterpolationMode.Invalid || value > InterpolationMode.HighQualityBicubic)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(InterpolationMode));
-
- // GDI+ interprets the value of InterpolationMode and sets a value accordingly.
- // Libgdiplus does not, so do this manually here.
- switch (value)
- {
- case InterpolationMode.Default:
- case InterpolationMode.Low:
- value = InterpolationMode.Bilinear;
- break;
- case InterpolationMode.High:
- value = InterpolationMode.HighQualityBicubic;
- break;
- case InterpolationMode.Invalid:
- throw new ArgumentException(SR.GdiplusInvalidParameter);
- default:
- break;
- }
-
- Gdip.CheckStatus(Gdip.GdipSetInterpolationMode(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public bool IsClipEmpty
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipIsClipEmpty(new HandleRef(this, NativeGraphics), out bool isEmpty));
- return isEmpty;
- }
- }
-
- public bool IsVisibleClipEmpty
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleClipEmpty(new HandleRef(this, NativeGraphics), out bool isEmpty));
- return isEmpty;
- }
- }
-
- public float PageScale
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPageScale(new HandleRef(this, NativeGraphics), out float scale));
- return scale;
- }
- set
- {
- // Libgdiplus doesn't perform argument validation, so do this here for compatibility.
- if (value <= 0 || value > 1000000032)
- throw new ArgumentException(SR.GdiplusInvalidParameter);
-
- Gdip.CheckStatus(Gdip.GdipSetPageScale(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public GraphicsUnit PageUnit
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPageUnit(new HandleRef(this, NativeGraphics), out GraphicsUnit unit));
- return unit;
- }
- set
- {
- if (value < GraphicsUnit.World || value > GraphicsUnit.Millimeter)
- throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(GraphicsUnit));
-
- // GDI+ doesn't allow GraphicsUnit.World as a valid value for PageUnit.
- // Libgdiplus doesn't perform argument validation, so do this here.
- if (value == GraphicsUnit.World)
- throw new ArgumentException(SR.GdiplusInvalidParameter);
-
- Gdip.CheckStatus(Gdip.GdipSetPageUnit(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public PixelOffsetMode PixelOffsetMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPixelOffsetMode(new HandleRef(this, NativeGraphics), out PixelOffsetMode mode));
- return mode;
- }
- set
- {
- if (value < PixelOffsetMode.Invalid || value > PixelOffsetMode.Half)
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(PixelOffsetMode));
-
- // GDI+ doesn't allow PixelOffsetMode.Invalid as a valid value for PixelOffsetMode.
- // Libgdiplus doesn't perform argument validation, so do this here.
- if (value == PixelOffsetMode.Invalid)
- throw new ArgumentException(SR.GdiplusInvalidParameter);
-
- Gdip.CheckStatus(Gdip.GdipSetPixelOffsetMode(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public Point RenderingOrigin
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetRenderingOrigin(new HandleRef(this, NativeGraphics), out int x, out int y));
- return new Point(x, y);
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetRenderingOrigin(new HandleRef(this, NativeGraphics), value.X, value.Y));
- }
- }
-
- public SmoothingMode SmoothingMode
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetSmoothingMode(new HandleRef(this, NativeGraphics), out SmoothingMode mode));
- return mode;
- }
- set
- {
- if (value < SmoothingMode.Invalid || value > SmoothingMode.AntiAlias)
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(SmoothingMode));
-
- // GDI+ interprets the value of SmoothingMode and sets a value accordingly.
- // Libgdiplus does not, so do this manually here.
- switch (value)
- {
- case SmoothingMode.Default:
- case SmoothingMode.HighSpeed:
- value = SmoothingMode.None;
- break;
- case SmoothingMode.HighQuality:
- value = SmoothingMode.AntiAlias;
- break;
- case SmoothingMode.Invalid:
- throw new ArgumentException(SR.GdiplusInvalidParameter);
- default:
- break;
- }
-
- Gdip.CheckStatus(Gdip.GdipSetSmoothingMode(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- public int TextContrast
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetTextContrast(new HandleRef(this, NativeGraphics), out int textContrast));
- return textContrast;
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetTextContrast(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- ///
- /// Gets or sets the rendering mode for text associated with this .
- ///
- public TextRenderingHint TextRenderingHint
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetTextRenderingHint(new HandleRef(this, NativeGraphics), out TextRenderingHint hint));
- return hint;
- }
- set
- {
- if (value < TextRenderingHint.SystemDefault || value > TextRenderingHint.ClearTypeGridFit)
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(TextRenderingHint));
-
- Gdip.CheckStatus(Gdip.GdipSetTextRenderingHint(new HandleRef(this, NativeGraphics), value));
- }
- }
-
- ///
- /// Gets or sets the world transform for this .
- ///
- public Matrix Transform
- {
- get
- {
- var matrix = new Matrix();
- Gdip.CheckStatus(Gdip.GdipGetWorldTransform(
- new HandleRef(this, NativeGraphics), new HandleRef(matrix, matrix.NativeMatrix)));
-
- return matrix;
- }
- set
- {
- Gdip.CheckStatus(Gdip.GdipSetWorldTransform(
- new HandleRef(this, NativeGraphics), new HandleRef(value, value.NativeMatrix)));
- }
- }
-
- ///
- /// Gets or sets the world transform elements for this .
- ///
- ///
- /// This is a more performant alternative to that does not need disposal.
- ///
- public unsafe Matrix3x2 TransformElements
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipCreateMatrix(out IntPtr nativeMatrix));
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetWorldTransform(
- new HandleRef(this, NativeGraphics), new HandleRef(null, nativeMatrix)));
-
- Matrix3x2 matrix = default;
- Gdip.CheckStatus(Gdip.GdipGetMatrixElements(new HandleRef(null, nativeMatrix), (float*)&matrix));
- return matrix;
- }
- finally
- {
- if (nativeMatrix != IntPtr.Zero)
- {
- Gdip.GdipDeleteMatrix(new HandleRef(null, nativeMatrix));
- }
- }
- }
- set
- {
- IntPtr nativeMatrix = Matrix.CreateNativeHandle(value);
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipSetWorldTransform(
- new HandleRef(this, NativeGraphics), new HandleRef(null, nativeMatrix)));
- }
- finally
- {
- if (nativeMatrix != IntPtr.Zero)
- {
- Gdip.GdipDeleteMatrix(new HandleRef(null, nativeMatrix));
- }
- }
- }
- }
-
- public IntPtr GetHdc()
- {
- IntPtr hdc;
- Gdip.CheckStatus(Gdip.GdipGetDC(new HandleRef(this, NativeGraphics), out hdc));
-
- _nativeHdc = hdc; // need to cache the hdc to be able to release with a call to IDeviceContext.ReleaseHdc().
- return _nativeHdc;
- }
-
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- public void ReleaseHdc(IntPtr hdc) => ReleaseHdcInternal(hdc);
-
- public void ReleaseHdc() => ReleaseHdcInternal(_nativeHdc);
-
- ///
- /// Forces immediate execution of all operations currently on the stack.
- ///
- public void Flush() => Flush(FlushIntention.Flush);
-
- ///
- /// Forces execution of all operations currently on the stack.
- ///
- public void Flush(FlushIntention intention)
- {
- Gdip.CheckStatus(Gdip.GdipFlush(new HandleRef(this, NativeGraphics), intention));
- }
-
- public void SetClip(Graphics g) => SetClip(g, CombineMode.Replace);
-
- public void SetClip(Graphics g, CombineMode combineMode)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipSetClipGraphics(
- new HandleRef(this, NativeGraphics),
- new HandleRef(g, g.NativeGraphics),
- combineMode));
- }
-
- public void SetClip(Rectangle rect) => SetClip(rect, CombineMode.Replace);
-
- public void SetClip(Rectangle rect, CombineMode combineMode)
- {
- Gdip.CheckStatus(Gdip.GdipSetClipRectI(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- combineMode));
- }
-
- public void SetClip(RectangleF rect) => SetClip(rect, CombineMode.Replace);
-
- public void SetClip(RectangleF rect, CombineMode combineMode)
- {
- Gdip.CheckStatus(Gdip.GdipSetClipRect(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- combineMode));
- }
-
- public void SetClip(GraphicsPath path) => SetClip(path, CombineMode.Replace);
-
- public void SetClip(GraphicsPath path, CombineMode combineMode)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipSetClipPath(
- new HandleRef(this, NativeGraphics),
- new HandleRef(path, path._nativePath),
- combineMode));
- }
-
- public void SetClip(Region region, CombineMode combineMode)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipSetClipRegion(
- new HandleRef(this, NativeGraphics),
- new HandleRef(region, region.NativeRegion),
- combineMode));
- }
-
- public void IntersectClip(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipSetClipRectI(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- CombineMode.Intersect));
- }
-
- public void IntersectClip(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipSetClipRect(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- CombineMode.Intersect));
- }
-
- public void IntersectClip(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipSetClipRegion(
- new HandleRef(this, NativeGraphics),
- new HandleRef(region, region.NativeRegion),
- CombineMode.Intersect));
- }
-
- public void ExcludeClip(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipSetClipRectI(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- CombineMode.Exclude));
- }
-
- public void ExcludeClip(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipSetClipRegion(
- new HandleRef(this, NativeGraphics),
- new HandleRef(region, region.NativeRegion),
- CombineMode.Exclude));
- }
-
- public void ResetClip()
- {
- Gdip.CheckStatus(Gdip.GdipResetClip(new HandleRef(this, NativeGraphics)));
- }
-
- public void TranslateClip(float dx, float dy)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateClip(new HandleRef(this, NativeGraphics), dx, dy));
- }
-
- public void TranslateClip(int dx, int dy)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateClip(new HandleRef(this, NativeGraphics), dx, dy));
- }
-
- public bool IsVisible(int x, int y) => IsVisible(new Point(x, y));
-
- public bool IsVisible(Point point)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisiblePointI(
- new HandleRef(this, NativeGraphics),
- point.X, point.Y,
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsVisible(float x, float y) => IsVisible(new PointF(x, y));
-
- public bool IsVisible(PointF point)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisiblePoint(
- new HandleRef(this, NativeGraphics),
- point.X, point.Y,
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsVisible(int x, int y, int width, int height)
- {
- return IsVisible(new Rectangle(x, y, width, height));
- }
-
- public bool IsVisible(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRectI(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- out bool isVisible));
-
- return isVisible;
- }
-
- public bool IsVisible(float x, float y, float width, float height)
- {
- return IsVisible(new RectangleF(x, y, width, height));
- }
-
- public bool IsVisible(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRect(
- new HandleRef(this, NativeGraphics),
- rect.X, rect.Y, rect.Width, rect.Height,
- out bool isVisible));
-
- return isVisible;
- }
-
- ///
- /// Resets the world transform to identity.
- ///
- public void ResetTransform()
- {
- Gdip.CheckStatus(Gdip.GdipResetWorldTransform(new HandleRef(this, NativeGraphics)));
- }
-
- ///
- /// Multiplies the that represents the world transform and .
- ///
- public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);
-
- ///
- /// Multiplies the that represents the world transform and .
- ///
- public void MultiplyTransform(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- // Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
- // with the libgdiplus backend. Simulate a nop for compatibility with GDI+.
- if (matrix.NativeMatrix == IntPtr.Zero)
- return;
-
- Gdip.CheckStatus(Gdip.GdipMultiplyWorldTransform(
- new HandleRef(this, NativeGraphics), new HandleRef(matrix, matrix.NativeMatrix), order));
- }
-
- public void TranslateTransform(float dx, float dy) => TranslateTransform(dx, dy, MatrixOrder.Prepend);
-
- public void TranslateTransform(float dx, float dy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateWorldTransform(new HandleRef(this, NativeGraphics), dx, dy, order));
- }
-
- public void ScaleTransform(float sx, float sy) => ScaleTransform(sx, sy, MatrixOrder.Prepend);
-
- public void ScaleTransform(float sx, float sy, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipScaleWorldTransform(new HandleRef(this, NativeGraphics), sx, sy, order));
- }
-
- public void RotateTransform(float angle) => RotateTransform(angle, MatrixOrder.Prepend);
-
- public void RotateTransform(float angle, MatrixOrder order)
- {
- Gdip.CheckStatus(Gdip.GdipRotateWorldTransform(new HandleRef(this, NativeGraphics), angle, order));
- }
-
- ///
- /// Draws an arc from the specified ellipse.
- ///
- public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawArc(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Draws an arc from the specified ellipse.
- ///
- public void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
- {
- DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Draws an arc from the specified ellipse.
- ///
- public void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawArcI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Draws an arc from the specified ellipse.
- ///
- public void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
- {
- DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Draws a cubic bezier curve defined by four ordered pairs that represent points.
- ///
- public void DrawBezier(Pen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawBezier(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- x1, y1, x2, y2, x3, y3, x4, y4));
- }
-
- ///
- /// Draws a cubic bezier curve defined by four points.
- ///
- public void DrawBezier(Pen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
- {
- DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
-
- ///
- /// Draws a cubic bezier curve defined by four points.
- ///
- public void DrawBezier(Pen pen, Point pt1, Point pt2, Point pt3, Point pt4)
- {
- DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
- }
-
- ///
- /// Draws the outline of a rectangle specified by .
- ///
- /// A Pen that determines the color, width, and style of the rectangle.
- /// A Rectangle structure that represents the rectangle to draw.
- public void DrawRectangle(Pen pen, RectangleF rect)
- {
- DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Draws the outline of a rectangle specified by .
- ///
- public void DrawRectangle(Pen pen, Rectangle rect)
- {
- DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Draws the outline of the specified rectangle.
- ///
- public void DrawRectangle(Pen pen, float x, float y, float width, float height)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawRectangle(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- x, y, width, height));
- }
-
- ///
- /// Draws the outline of the specified rectangle.
- ///
- public void DrawRectangle(Pen pen, int x, int y, int width, int height)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawRectangleI(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- x, y, width, height));
- }
-
- ///
- /// Draws the outlines of a series of rectangles.
- ///
- public unsafe void DrawRectangles(Pen pen, RectangleF[] rects)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(rects);
-
- fixed (RectangleF* r = rects)
- {
- CheckErrorStatus(Gdip.GdipDrawRectangles(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- r, rects.Length));
- }
- }
-
- ///
- /// Draws the outlines of a series of rectangles.
- ///
- public unsafe void DrawRectangles(Pen pen, Rectangle[] rects)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(rects);
-
- fixed (Rectangle* r = rects)
- {
- CheckErrorStatus(Gdip.GdipDrawRectanglesI(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- r, rects.Length));
- }
- }
-
- ///
- /// Draws the outline of an ellipse defined by a bounding rectangle.
- ///
- public void DrawEllipse(Pen pen, RectangleF rect)
- {
- DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Draws the outline of an ellipse defined by a bounding rectangle.
- ///
- public void DrawEllipse(Pen pen, float x, float y, float width, float height)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawEllipse(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height));
- }
-
- ///
- /// Draws the outline of an ellipse specified by a bounding rectangle.
- ///
- public void DrawEllipse(Pen pen, Rectangle rect)
- {
- DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Draws the outline of an ellipse defined by a bounding rectangle.
- ///
- public void DrawEllipse(Pen pen, int x, int y, int width, int height)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawEllipseI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height));
- }
-
- ///
- /// Draws the outline of a pie section defined by an ellipse and two radial lines.
- ///
- public void DrawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle)
- {
- DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Draws the outline of a pie section defined by an ellipse and two radial lines.
- ///
- public void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawPie(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Draws the outline of a pie section defined by an ellipse and two radial lines.
- ///
- public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle)
- {
- DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Draws the outline of a pie section defined by an ellipse and two radial lines.
- ///
- public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawPieI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Draws the outline of a polygon defined by an array of points.
- ///
- public unsafe void DrawPolygon(Pen pen, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawPolygon(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws the outline of a polygon defined by an array of points.
- ///
- public unsafe void DrawPolygon(Pen pen, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawPolygonI(
- new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws the lines and curves defined by a .
- ///
- public void DrawPath(Pen pen, GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(path);
-
- CheckErrorStatus(Gdip.GdipDrawPath(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- new HandleRef(path, path._nativePath)));
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurve(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, PointF[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurve2(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- tension));
- }
- }
-
- public void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments)
- {
- DrawCurve(pen, points, offset, numberOfSegments, 0.5f);
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurve3(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- offset,
- numberOfSegments,
- tension));
- }
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurveI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, Point[] points, float tension)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurve2I(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- tension));
- }
- }
-
- ///
- /// Draws a curve defined by an array of points.
- ///
- public unsafe void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawCurve3I(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- offset,
- numberOfSegments,
- tension));
- }
- }
-
- ///
- /// Draws a closed curve defined by an array of points.
- ///
- public unsafe void DrawClosedCurve(Pen pen, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawClosedCurve(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws a closed curve defined by an array of points.
- ///
- public unsafe void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawClosedCurve2(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- tension));
- }
- }
-
- ///
- /// Draws a closed curve defined by an array of points.
- ///
- public unsafe void DrawClosedCurve(Pen pen, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawClosedCurveI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws a closed curve defined by an array of points.
- ///
- public unsafe void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawClosedCurve2I(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length,
- tension));
- }
- }
-
- ///
- /// Fills the entire drawing surface with the specified color.
- ///
- public void Clear(Color color)
- {
- Gdip.CheckStatus(Gdip.GdipGraphicsClear(new HandleRef(this, NativeGraphics), color.ToArgb()));
- }
-
- ///
- /// Fills the interior of a rectangle with a .
- ///
- public void FillRectangle(Brush brush, RectangleF rect)
- {
- FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Fills the interior of a rectangle with a .
- ///
- public void FillRectangle(Brush brush, float x, float y, float width, float height)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillRectangle(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height));
- }
-
- ///
- /// Fills the interior of a rectangle with a .
- ///
- public void FillRectangle(Brush brush, Rectangle rect)
- {
- FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Fills the interior of a rectangle with a .
- ///
- public void FillRectangle(Brush brush, int x, int y, int width, int height)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillRectangleI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height));
- }
-
- ///
- /// Fills the interiors of a series of rectangles with a .
- ///
- public unsafe void FillRectangles(Brush brush, RectangleF[] rects)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(rects);
-
- fixed (RectangleF* r = rects)
- {
- CheckErrorStatus(Gdip.GdipFillRectangles(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- r, rects.Length));
- }
- }
-
- ///
- /// Fills the interiors of a series of rectangles with a .
- ///
- public unsafe void FillRectangles(Brush brush, Rectangle[] rects)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(rects);
-
- fixed (Rectangle* r = rects)
- {
- CheckErrorStatus(Gdip.GdipFillRectanglesI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- r, rects.Length));
- }
- }
-
- ///
- /// Fills the interior of a polygon defined by an array of points.
- ///
- public void FillPolygon(Brush brush, PointF[] points)
- {
- FillPolygon(brush, points, FillMode.Alternate);
- }
-
- ///
- /// Fills the interior of a polygon defined by an array of points.
- ///
- public unsafe void FillPolygon(Brush brush, PointF[] points, FillMode fillMode)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillPolygon(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length,
- fillMode));
- }
- }
-
- ///
- /// Fills the interior of a polygon defined by an array of points.
- ///
- public void FillPolygon(Brush brush, Point[] points)
- {
- FillPolygon(brush, points, FillMode.Alternate);
- }
-
- ///
- /// Fills the interior of a polygon defined by an array of points.
- ///
- public unsafe void FillPolygon(Brush brush, Point[] points, FillMode fillMode)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillPolygonI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length,
- fillMode));
- }
- }
-
- ///
- /// Fills the interior of an ellipse defined by a bounding rectangle.
- ///
- public void FillEllipse(Brush brush, RectangleF rect)
- {
- FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Fills the interior of an ellipse defined by a bounding rectangle.
- ///
- public void FillEllipse(Brush brush, float x, float y, float width, float height)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillEllipse(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height));
- }
-
- ///
- /// Fills the interior of an ellipse defined by a bounding rectangle.
- ///
- public void FillEllipse(Brush brush, Rectangle rect)
- {
- FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- ///
- /// Fills the interior of an ellipse defined by a bounding rectangle.
- ///
- public void FillEllipse(Brush brush, int x, int y, int width, int height)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillEllipseI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height));
- }
-
- ///
- /// Fills the interior of a pie section defined by an ellipse and two radial lines.
- ///
- public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle)
- {
- FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Fills the interior of a pie section defined by an ellipse and two radial lines.
- ///
- /// A Brush that determines the characteristics of the fill.
- /// A Rectangle structure that represents the bounding rectangle that defines the ellipse from which the pie section comes.
- /// Angle in degrees measured clockwise from the x-axis to the first side of the pie section.
- /// Angle in degrees measured clockwise from the parameter to the second side of the pie section.
- public void FillPie(Brush brush, RectangleF rect, float startAngle, float sweepAngle)
- {
- FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
- }
-
- ///
- /// Fills the interior of a pie section defined by an ellipse and two radial lines.
- ///
- public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillPie(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Fills the interior of a pie section defined by an ellipse and two radial lines.
- ///
- public void FillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- CheckErrorStatus(Gdip.GdipFillPieI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- x, y, width, height,
- startAngle,
- sweepAngle));
- }
-
- ///
- /// Fills the interior a closed curve defined by an array of points.
- ///
- public unsafe void FillClosedCurve(Brush brush, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillClosedCurve(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length));
- }
- }
-
- ///
- /// Fills the interior of a closed curve defined by an array of points.
- ///
- public void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode)
- {
- FillClosedCurve(brush, points, fillmode, 0.5f);
- }
-
- public unsafe void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillClosedCurve2(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length,
- tension,
- fillmode));
- }
- }
-
- ///
- /// Fills the interior a closed curve defined by an array of points.
- ///
- public unsafe void FillClosedCurve(Brush brush, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillClosedCurveI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length));
- }
- }
-
- public void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode)
- {
- FillClosedCurve(brush, points, fillmode, 0.5f);
- }
-
- public unsafe void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipFillClosedCurve2I(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- p, points.Length,
- tension,
- fillmode));
- }
- }
-
- ///
- /// Draws a string with the specified font.
- ///
- public void DrawString(string? s, Font font, Brush brush, float x, float y)
- {
- DrawString(s, font, brush, new RectangleF(x, y, 0, 0), null);
- }
-
- public void DrawString(string? s, Font font, Brush brush, PointF point)
- {
- DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), null);
- }
-
- public void DrawString(string? s, Font font, Brush brush, float x, float y, StringFormat? format)
- {
- DrawString(s, font, brush, new RectangleF(x, y, 0, 0), format);
- }
-
- public void DrawString(string? s, Font font, Brush brush, PointF point, StringFormat? format)
- {
- DrawString(s, font, brush, new RectangleF(point.X, point.Y, 0, 0), format);
- }
-
- public void DrawString(string? s, Font font, Brush brush, RectangleF layoutRectangle)
- {
- DrawString(s, font, brush, layoutRectangle, null);
- }
-
- public void DrawString(string? s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat? format)
- {
- ArgumentNullException.ThrowIfNull(brush);
- if (string.IsNullOrEmpty(s))
- return;
- ArgumentNullException.ThrowIfNull(font);
-
- CheckErrorStatus(Gdip.GdipDrawString(
- new HandleRef(this, NativeGraphics),
- s,
- s.Length,
- new HandleRef(font, font.NativeFont),
- ref layoutRectangle,
- new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero),
- new HandleRef(brush, brush.NativeBrush)));
- }
-
- public SizeF MeasureString(
- string? text,
- Font font,
- SizeF layoutArea,
- StringFormat? stringFormat,
- out int charactersFitted,
- out int linesFilled)
- {
- if (string.IsNullOrEmpty(text))
- {
- charactersFitted = 0;
- linesFilled = 0;
- return SizeF.Empty;
- }
-
- if (font == null)
- throw new ArgumentNullException(nameof(font));
-
- RectangleF layout = new RectangleF(0, 0, layoutArea.Width, layoutArea.Height);
- RectangleF boundingBox = default;
-
- Gdip.CheckStatus(Gdip.GdipMeasureString(
- new HandleRef(this, NativeGraphics),
- text,
- text.Length,
- new HandleRef(font, font.NativeFont),
- ref layout,
- new HandleRef(stringFormat, stringFormat?.nativeFormat ?? IntPtr.Zero),
- ref boundingBox,
- out charactersFitted,
- out linesFilled));
-
- return boundingBox.Size;
- }
-
- public SizeF MeasureString(string? text, Font font, PointF origin, StringFormat? stringFormat)
- {
- if (string.IsNullOrEmpty(text))
- return SizeF.Empty;
- if (font == null)
- throw new ArgumentNullException(nameof(font));
-
- RectangleF layout = new RectangleF(origin.X, origin.Y, 0, 0);
- RectangleF boundingBox = default;
-
- Gdip.CheckStatus(Gdip.GdipMeasureString(
- new HandleRef(this, NativeGraphics),
- text,
- text.Length,
- new HandleRef(font, font.NativeFont),
- ref layout,
- new HandleRef(stringFormat, stringFormat?.nativeFormat ?? IntPtr.Zero),
- ref boundingBox,
- out _,
- out _));
-
- return boundingBox.Size;
- }
-
- public SizeF MeasureString(string? text, Font font, SizeF layoutArea) => MeasureString(text, font, layoutArea, null);
-
- public SizeF MeasureString(string? text, Font font, SizeF layoutArea, StringFormat? stringFormat)
- {
- if (string.IsNullOrEmpty(text))
- return SizeF.Empty;
- if (font == null)
- throw new ArgumentNullException(nameof(font));
-
- RectangleF layout = new RectangleF(0, 0, layoutArea.Width, layoutArea.Height);
- RectangleF boundingBox = default;
-
- Gdip.CheckStatus(Gdip.GdipMeasureString(
- new HandleRef(this, NativeGraphics),
- text,
- text.Length,
- new HandleRef(font, font.NativeFont),
- ref layout,
- new HandleRef(stringFormat, stringFormat?.nativeFormat ?? IntPtr.Zero),
- ref boundingBox,
- out _,
- out _));
-
- return boundingBox.Size;
- }
-
- public SizeF MeasureString(string? text, Font font)
- {
- return MeasureString(text, font, new SizeF(0, 0));
- }
-
- public SizeF MeasureString(string? text, Font font, int width)
- {
- return MeasureString(text, font, new SizeF(width, 999999));
- }
-
- public SizeF MeasureString(string? text, Font font, int width, StringFormat? format)
- {
- return MeasureString(text, font, new SizeF(width, 999999), format);
- }
-
- public Region[] MeasureCharacterRanges(string? text, Font font, RectangleF layoutRect, StringFormat? stringFormat)
- {
- if (string.IsNullOrEmpty(text))
- return Array.Empty();
- if (font == null)
- throw new ArgumentNullException(nameof(font));
-
- Gdip.CheckStatus(Gdip.GdipGetStringFormatMeasurableCharacterRangeCount(
- new HandleRef(stringFormat, stringFormat?.nativeFormat ?? IntPtr.Zero),
- out int count));
-
- IntPtr[] gpRegions = new IntPtr[count];
- Region[] regions = new Region[count];
-
- for (int f = 0; f < count; f++)
- {
- regions[f] = new Region();
- gpRegions[f] = regions[f].NativeRegion;
- }
-
- Gdip.CheckStatus(Gdip.GdipMeasureCharacterRanges(
- new HandleRef(this, NativeGraphics),
- text,
- text.Length,
- new HandleRef(font, font.NativeFont),
- ref layoutRect,
- new HandleRef(stringFormat, stringFormat?.nativeFormat ?? IntPtr.Zero),
- count,
- gpRegions));
-
- return regions;
- }
-
- ///
- /// Draws the specified image at the specified location.
- ///
- public void DrawImage(Image image, PointF point)
- {
- DrawImage(image, point.X, point.Y);
- }
-
- public void DrawImage(Image image, float x, float y)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImage(
- new HandleRef(this, NativeGraphics), new HandleRef(image, image.nativeImage),
- x, y);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, RectangleF rect)
- {
- DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- public void DrawImage(Image image, float x, float y, float width, float height)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- x, y,
- width, height);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, Point point)
- {
- DrawImage(image, point.X, point.Y);
- }
-
- public void DrawImage(Image image, int x, int y)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- x, y);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, Rectangle rect)
- {
- DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
- }
-
- public void DrawImage(Image image, int x, int y, int width, int height)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- x, y,
- width, height);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImageUnscaled(Image image, Point point)
- {
- DrawImage(image, point.X, point.Y);
- }
-
- public void DrawImageUnscaled(Image image, int x, int y)
- {
- DrawImage(image, x, y);
- }
-
- public void DrawImageUnscaled(Image image, Rectangle rect)
- {
- DrawImage(image, rect.X, rect.Y);
- }
-
- public void DrawImageUnscaled(Image image, int x, int y, int width, int height)
- {
- DrawImage(image, x, y);
- }
-
- public void DrawImageUnscaledAndClipped(Image image, Rectangle rect)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int width = Math.Min(rect.Width, image.Width);
- int height = Math.Min(rect.Height, image.Height);
-
- // We could put centering logic here too for the case when the image
- // is smaller than the rect.
- DrawImage(image, rect, 0, 0, width, height, GraphicsUnit.Pixel);
- }
-
- // Affine or perspective blt
- // destPoints.Length = 3: rect => parallelogram
- // destPoints[0] <=> top-left corner of the source rectangle
- // destPoints[1] <=> top-right corner
- // destPoints[2] <=> bottom-left corner
- // destPoints.Length = 4: rect => quad
- // destPoints[3] <=> bottom-right corner
- //
- // @notes Perspective blt only works for bitmap images.
-
- public unsafe void DrawImage(Image image, PointF[] destPoints)
- {
- ArgumentNullException.ThrowIfNull(image);
- ArgumentNullException.ThrowIfNull(destPoints);
-
- int count = destPoints.Length;
- if (count != 3 && count != 4)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
-
- fixed (PointF* p = destPoints)
- {
- int status = Gdip.GdipDrawImagePoints(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- p, count);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
- }
-
- public unsafe void DrawImage(Image image, Point[] destPoints)
- {
- ArgumentNullException.ThrowIfNull(image);
- ArgumentNullException.ThrowIfNull(destPoints);
-
- int count = destPoints.Length;
- if (count != 3 && count != 4)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
-
- fixed (Point* p = destPoints)
- {
- int status = Gdip.GdipDrawImagePointsI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- p, count);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
- }
-
- public void DrawImage(Image image, float x, float y, RectangleF srcRect, GraphicsUnit srcUnit)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImagePointRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- x, y,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- (int)srcUnit);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, int x, int y, Rectangle srcRect, GraphicsUnit srcUnit)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImagePointRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- x, y,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- (int)srcUnit);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRectRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- destRect.X, destRect.Y, destRect.Width, destRect.Height,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- srcUnit,
- NativeMethods.NullHandleRef,
- null,
- NativeMethods.NullHandleRef);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(Image image, Rectangle destRect, Rectangle srcRect, GraphicsUnit srcUnit)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRectRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- destRect.X, destRect.Y, destRect.Width, destRect.Height,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- srcUnit,
- NativeMethods.NullHandleRef,
- null,
- NativeMethods.NullHandleRef);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public unsafe void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
- {
- ArgumentNullException.ThrowIfNull(image);
- ArgumentNullException.ThrowIfNull(destPoints);
-
- int count = destPoints.Length;
- if (count != 3 && count != 4)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
-
- fixed (PointF* p = destPoints)
- {
- int status = Gdip.GdipDrawImagePointsRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- p, destPoints.Length,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- srcUnit,
- NativeMethods.NullHandleRef,
- null,
- NativeMethods.NullHandleRef);
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
- }
-
- public void DrawImage(Image image, PointF[] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes? imageAttr)
- {
- DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, null, 0);
- }
-
- public void DrawImage(
- Image image,
- PointF[] destPoints,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr,
- DrawImageAbort? callback)
- {
- DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, callback, 0);
- }
-
- public unsafe void DrawImage(
- Image image,
- PointF[] destPoints,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr,
- DrawImageAbort? callback,
- int callbackData)
- {
- ArgumentNullException.ThrowIfNull(image);
- ArgumentNullException.ThrowIfNull(destPoints);
-
- int count = destPoints.Length;
- if (count != 3 && count != 4)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
-
- fixed (PointF* p = destPoints)
- {
- int status = Gdip.GdipDrawImagePointsRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- p, destPoints.Length,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- srcUnit,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero),
- callback,
- new HandleRef(null, (IntPtr)callbackData));
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
- }
-
- public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit)
- {
- DrawImage(image, destPoints, srcRect, srcUnit, null, null, 0);
- }
-
- public void DrawImage(
- Image image,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr)
- {
- DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, null, 0);
- }
-
- public void DrawImage(
- Image image,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr,
- DrawImageAbort? callback)
- {
- DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, callback, 0);
- }
-
- public unsafe void DrawImage(
- Image image,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr,
- DrawImageAbort? callback,
- int callbackData)
- {
- ArgumentNullException.ThrowIfNull(image);
- ArgumentNullException.ThrowIfNull(destPoints);
-
- int count = destPoints.Length;
- if (count != 3 && count != 4)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidLength);
-
- fixed (Point* p = destPoints)
- {
- int status = Gdip.GdipDrawImagePointsRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- p, destPoints.Length,
- srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
- srcUnit,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero),
- callback,
- new HandleRef(null, (IntPtr)callbackData));
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- float srcX,
- float srcY,
- float srcWidth,
- float srcHeight,
- GraphicsUnit srcUnit)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- float srcX,
- float srcY,
- float srcWidth,
- float srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttrs)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs, null);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- float srcX,
- float srcY,
- float srcWidth,
- float srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttrs,
- DrawImageAbort? callback)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttrs, callback, IntPtr.Zero);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- float srcX,
- float srcY,
- float srcWidth,
- float srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttrs,
- DrawImageAbort? callback,
- IntPtr callbackData)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRectRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- destRect.X, destRect.Y, destRect.Width, destRect.Height,
- srcX, srcY, srcWidth, srcHeight,
- srcUnit,
- new HandleRef(imageAttrs, imageAttrs?.nativeImageAttributes ?? IntPtr.Zero),
- callback,
- new HandleRef(null, callbackData));
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- int srcX,
- int srcY,
- int srcWidth,
- int srcHeight,
- GraphicsUnit srcUnit)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, null);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- int srcX,
- int srcY,
- int srcWidth,
- int srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, null);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- int srcX,
- int srcY,
- int srcWidth,
- int srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttr,
- DrawImageAbort? callback)
- {
- DrawImage(image, destRect, srcX, srcY, srcWidth, srcHeight, srcUnit, imageAttr, callback, IntPtr.Zero);
- }
-
- public void DrawImage(
- Image image,
- Rectangle destRect,
- int srcX,
- int srcY,
- int srcWidth,
- int srcHeight,
- GraphicsUnit srcUnit,
- ImageAttributes? imageAttrs,
- DrawImageAbort? callback,
- IntPtr callbackData)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- int status = Gdip.GdipDrawImageRectRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(image, image.nativeImage),
- destRect.X, destRect.Y, destRect.Width, destRect.Height,
- srcX, srcY, srcWidth, srcHeight,
- srcUnit,
- new HandleRef(imageAttrs, imageAttrs?.nativeImageAttributes ?? IntPtr.Zero),
- callback,
- new HandleRef(null, callbackData));
-
- IgnoreMetafileErrors(image, ref status);
- CheckErrorStatus(status);
- }
-
- ///
- /// Draws a line connecting the two specified points.
- ///
- public void DrawLine(Pen pen, PointF pt1, PointF pt2)
- {
- DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
- }
-
- ///
- /// Draws a series of line segments that connect an array of points.
- ///
- public unsafe void DrawLines(Pen pen, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawLines(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
-
- ///
- /// Draws a line connecting the two specified points.
- ///
- public void DrawLine(Pen pen, int x1, int y1, int x2, int y2)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawLineI(new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen), x1, y1, x2, y2));
- }
-
- ///
- /// Draws a line connecting the two specified points.
- ///
- public void DrawLine(Pen pen, Point pt1, Point pt2)
- {
- DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
- }
-
- ///
- /// Draws a series of line segments that connect an array of points.
- ///
- public unsafe void DrawLines(Pen pen, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawLinesI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p,
- points.Length));
- }
- }
-
- ///
- /// CopyPixels will perform a gdi "bitblt" operation to the source from the destination with the given size.
- ///
- public void CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize)
- {
- CopyFromScreen(upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y, blockRegionSize);
- }
-
- ///
- /// CopyPixels will perform a gdi "bitblt" operation to the source from the destination with the given size.
- ///
- public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize)
- {
- CopyFromScreen(sourceX, sourceY, destinationX, destinationY, blockRegionSize, CopyPixelOperation.SourceCopy);
- }
-
- ///
- /// CopyPixels will perform a gdi "bitblt" operation to the source from the destination with the given size
- /// and specified raster operation.
- ///
- public void CopyFromScreen(Point upperLeftSource, Point upperLeftDestination, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
- {
- CopyFromScreen(upperLeftSource.X, upperLeftSource.Y, upperLeftDestination.X, upperLeftDestination.Y, blockRegionSize, copyPixelOperation);
- }
-
- public void EnumerateMetafile(Metafile metafile, PointF destPoint, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoint, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(Metafile metafile, PointF destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoint, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(Metafile metafile, Point destPoint, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoint, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoint, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destRect, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destRect, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destRect, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(Metafile metafile, Rectangle destRect, EnumerateMetafileProc callback, IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destRect, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(Metafile metafile, PointF[] destPoints, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoints, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF[] destPoints,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoints, callback, IntPtr.Zero, null);
- }
-
- public void EnumerateMetafile(Metafile metafile, Point[] destPoints, EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoints, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(Metafile metafile, Point[] destPoints, EnumerateMetafileProc callback, IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoints, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF destPoint,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF destPoint,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Point destPoint,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Point destPoint,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- RectangleF destRect,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- RectangleF destRect,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Rectangle destRect,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Rectangle destRect,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF[] destPoints,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoints, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF[] destPoints,
- RectangleF srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoints, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback)
- {
- EnumerateMetafile(metafile, destPoints, srcRect, srcUnit, callback, IntPtr.Zero);
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit srcUnit,
- EnumerateMetafileProc callback,
- IntPtr callbackData)
- {
- EnumerateMetafile(metafile, destPoints, srcRect, srcUnit, callback, callbackData, null);
- }
-
- public unsafe void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (PointF* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipTransformPoints(
- new HandleRef(this, NativeGraphics),
- (int)destSpace,
- (int)srcSpace,
- p,
- pts.Length));
- }
- }
-
- public unsafe void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts)
- {
- ArgumentNullException.ThrowIfNull(pts);
-
- fixed (Point* p = pts)
- {
- Gdip.CheckStatus(Gdip.GdipTransformPointsI(
- new HandleRef(this, NativeGraphics),
- (int)destSpace,
- (int)srcSpace,
- p,
- pts.Length));
- }
- }
-
- ///
- /// GDI+ will return a 'generic error' when we attempt to draw an Emf
- /// image with width/height == 1. Here, we will hack around this by
- /// resetting the errorstatus. Note that we don't do simple arg checking
- /// for height || width == 1 here because transforms can be applied to
- /// the Graphics object making it difficult to identify this scenario.
- ///
- private static void IgnoreMetafileErrors(Image image, ref int errorStatus)
- {
- if (errorStatus != Gdip.Ok && image.RawFormat.Equals(ImageFormat.Emf))
- errorStatus = Gdip.Ok;
- }
-
- ///
- /// Creates a Region class only if the native region is not infinite.
- ///
- internal Region? GetRegionIfNotInfinite()
- {
- Gdip.CheckStatus(Gdip.GdipCreateRegion(out IntPtr regionHandle));
- try
- {
- Gdip.GdipGetClip(new HandleRef(this, NativeGraphics), new HandleRef(null, regionHandle));
- Gdip.CheckStatus(Gdip.GdipIsInfiniteRegion(
- new HandleRef(null, regionHandle),
- new HandleRef(this, NativeGraphics),
- out int isInfinite));
-
- if (isInfinite != 0)
- {
- // Infinite
- return null;
- }
-
- Region region = new Region(regionHandle);
- regionHandle = IntPtr.Zero;
- return region;
- }
- finally
- {
- if (regionHandle != IntPtr.Zero)
- {
- Gdip.GdipDeleteRegion(new HandleRef(null, regionHandle));
- }
- }
- }
-
- ///
- /// Represents an object used in connection with the printing API, it is used to hold a reference to a
- /// PrintPreviewGraphics (fake graphics) or a printer DeviceContext (and maybe more in the future).
- ///
- internal object? PrintingHelper
- {
- get => _printingHelper;
- set
- {
- Debug.Assert(_printingHelper == null, "WARNING: Overwritting the printing helper reference!");
- _printingHelper = value;
- }
- }
-
- ///
- /// CopyPixels will perform a gdi "bitblt" operation to the source from the destination with the given size
- /// and specified raster operation.
- ///
- public void CopyFromScreen(int sourceX, int sourceY, int destinationX, int destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
- {
- switch (copyPixelOperation)
- {
- case CopyPixelOperation.Blackness:
- case CopyPixelOperation.NotSourceErase:
- case CopyPixelOperation.NotSourceCopy:
- case CopyPixelOperation.SourceErase:
- case CopyPixelOperation.DestinationInvert:
- case CopyPixelOperation.PatInvert:
- case CopyPixelOperation.SourceInvert:
- case CopyPixelOperation.SourceAnd:
- case CopyPixelOperation.MergePaint:
- case CopyPixelOperation.MergeCopy:
- case CopyPixelOperation.SourceCopy:
- case CopyPixelOperation.SourcePaint:
- case CopyPixelOperation.PatCopy:
- case CopyPixelOperation.PatPaint:
- case CopyPixelOperation.Whiteness:
- case CopyPixelOperation.CaptureBlt:
- case CopyPixelOperation.NoMirrorBitmap:
- break;
- default:
- throw new InvalidEnumArgumentException(nameof(copyPixelOperation), (int)copyPixelOperation, typeof(CopyPixelOperation));
- }
-
- int destWidth = blockRegionSize.Width;
- int destHeight = blockRegionSize.Height;
-
- IntPtr screenDC = Interop.User32.GetDC(IntPtr.Zero);
- try
- {
- IntPtr targetDC = GetHdc();
- int result = Interop.Gdi32.BitBlt(
- targetDC,
- destinationX,
- destinationY,
- destWidth,
- destHeight,
- screenDC,
- sourceX,
- sourceY,
- (Interop.Gdi32.RasterOp)copyPixelOperation);
-
- //a zero result indicates a win32 exception has been thrown
- if (result == 0)
- {
- throw new Win32Exception();
- }
- }
- finally
- {
- Interop.User32.ReleaseDC(IntPtr.Zero, screenDC);
- ReleaseHdc();
- }
- }
-
- public Color GetNearestColor(Color color)
- {
- int nearest = color.ToArgb();
- Gdip.CheckStatus(Gdip.GdipGetNearestColor(new HandleRef(this, NativeGraphics), ref nearest));
- return Color.FromArgb(nearest);
- }
-
- ///
- /// Draws a line connecting the two specified points.
- ///
- public void DrawLine(Pen pen, float x1, float y1, float x2, float y2)
- {
- ArgumentNullException.ThrowIfNull(pen);
-
- CheckErrorStatus(Gdip.GdipDrawLine(new HandleRef(this, NativeGraphics), new HandleRef(pen, pen.NativePen), x1, y1, x2, y2));
- }
-
- ///
- /// Draws a series of cubic Bezier curves from an array of points.
- ///
- public unsafe void DrawBeziers(Pen pen, PointF[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (PointF* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawBeziers(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p, points.Length));
- }
- }
-
- ///
- /// Draws a series of cubic Bezier curves from an array of points.
- ///
- public unsafe void DrawBeziers(Pen pen, Point[] points)
- {
- ArgumentNullException.ThrowIfNull(pen);
- ArgumentNullException.ThrowIfNull(points);
-
- fixed (Point* p = points)
- {
- CheckErrorStatus(Gdip.GdipDrawBeziersI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(pen, pen.NativePen),
- p,
- points.Length));
- }
- }
-
- ///
- /// Fills the interior of a path.
- ///
- public void FillPath(Brush brush, GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(path);
-
- CheckErrorStatus(Gdip.GdipFillPath(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- new HandleRef(path, path._nativePath)));
- }
-
- ///
- /// Fills the interior of a .
- ///
- public void FillRegion(Brush brush, Region region)
- {
- ArgumentNullException.ThrowIfNull(brush);
- ArgumentNullException.ThrowIfNull(region);
-
- CheckErrorStatus(Gdip.GdipFillRegion(
- new HandleRef(this, NativeGraphics),
- new HandleRef(brush, brush.NativeBrush),
- new HandleRef(region, region.NativeRegion)));
- }
-
- public void DrawIcon(Icon icon, int x, int y)
- {
- ArgumentNullException.ThrowIfNull(icon);
-
- if (_backingImage != null)
- {
- // We don't call the icon directly because we want to stay in GDI+ all the time
- // to avoid alpha channel interop issues between gdi and gdi+
- // so we do icon.ToBitmap() and then we call DrawImage. This is probably slower.
- DrawImage(icon.ToBitmap(), x, y);
- }
- else
- {
- icon.Draw(this, x, y);
- }
- }
-
- ///
- /// Draws this image to a graphics object. The drawing command originates on the graphics
- /// object, but a graphics object generally has no idea how to render a given image. So,
- /// it passes the call to the actual image. This version crops the image to the given
- /// dimensions and allows the user to specify a rectangle within the image to draw.
- ///
- public void DrawIcon(Icon icon, Rectangle targetRect)
- {
- ArgumentNullException.ThrowIfNull(icon);
-
- if (_backingImage != null)
- {
- // We don't call the icon directly because we want to stay in GDI+ all the time
- // to avoid alpha channel interop issues between gdi and gdi+
- // so we do icon.ToBitmap() and then we call DrawImage. This is probably slower.
- DrawImage(icon.ToBitmap(), targetRect);
- }
- else
- {
- icon.Draw(this, targetRect);
- }
- }
-
- ///
- /// Draws this image to a graphics object. The drawing command originates on the graphics
- /// object, but a graphics object generally has no idea how to render a given image. So,
- /// it passes the call to the actual image. This version stretches the image to the given
- /// dimensions and allows the user to specify a rectangle within the image to draw.
- ///
- public void DrawIconUnstretched(Icon icon, Rectangle targetRect)
- {
- ArgumentNullException.ThrowIfNull(icon);
-
- if (_backingImage != null)
- {
- DrawImageUnscaled(icon.ToBitmap(), targetRect);
- }
- else
- {
- icon.DrawUnstretched(this, targetRect);
- }
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF destPoint,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPoint(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destPoint,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
- public void EnumerateMetafile(
- Metafile metafile,
- Point destPoint,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPointI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destPoint,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- RectangleF destRect,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destRect,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Rectangle destRect,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destRect,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public unsafe void EnumerateMetafile(
- Metafile metafile,
- PointF[] destPoints,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(destPoints);
-
- if (destPoints.Length != 3)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
-
- fixed (PointF* p = destPoints)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPoints(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- p, destPoints.Length,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
- }
-
- public unsafe void EnumerateMetafile(
- Metafile metafile,
- Point[] destPoints,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(destPoints);
-
- if (destPoints.Length != 3)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
-
- fixed (Point* p = destPoints)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileDestPointsI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- p, destPoints.Length,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- PointF destPoint,
- RectangleF srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPoint(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destPoint,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Point destPoint,
- Rectangle srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPointI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destPoint,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- RectangleF destRect,
- RectangleF srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestRect(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destRect,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public void EnumerateMetafile(
- Metafile metafile,
- Rectangle destRect,
- Rectangle srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestRectI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- ref destRect,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
-
- public unsafe void EnumerateMetafile(
- Metafile metafile,
- PointF[] destPoints,
- RectangleF srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(destPoints);
-
- if (destPoints.Length != 3)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
-
- fixed (PointF* p = destPoints)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPoints(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- p, destPoints.Length,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
- }
-
- public unsafe void EnumerateMetafile(
- Metafile metafile,
- Point[] destPoints,
- Rectangle srcRect,
- GraphicsUnit unit,
- EnumerateMetafileProc callback,
- IntPtr callbackData,
- ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(destPoints);
-
- if (destPoints.Length != 3)
- throw new ArgumentException(SR.GdiplusDestPointsInvalidParallelogram);
-
- fixed (Point* p = destPoints)
- {
- Gdip.CheckStatus(Gdip.GdipEnumerateMetafileSrcRectDestPointsI(
- new HandleRef(this, NativeGraphics),
- new HandleRef(metafile, metafile?.nativeImage ?? IntPtr.Zero),
- p, destPoints.Length,
- ref srcRect,
- unit,
- callback,
- callbackData,
- new HandleRef(imageAttr, imageAttr?.nativeImageAttributes ?? IntPtr.Zero)));
- }
- }
-
- ///
- /// Combines current Graphics context with all previous contexts.
- /// When BeginContainer() is called, a copy of the current context is pushed into the GDI+ context stack, it keeps track of the
- /// absolute clipping and transform but reset the public properties so it looks like a brand new context.
- /// When Save() is called, a copy of the current context is also pushed in the GDI+ stack but the public clipping and transform
- /// properties are not reset (cumulative). Consecutive Save context are ignored with the exception of the top one which contains
- /// all previous information.
- /// The return value is an object array where the first element contains the cumulative clip region and the second the cumulative
- /// translate transform matrix.
- /// WARNING: This method is for internal FX support only.
- ///
- [EditorBrowsable(EditorBrowsableState.Never)]
-#if NETCOREAPP3_1_OR_GREATER
- [Obsolete(Obsoletions.GetContextInfoMessage, DiagnosticId = Obsoletions.GetContextInfoDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
-#endif
- [SupportedOSPlatform("windows")]
- public object GetContextInfo()
- {
- GetContextInfo(out Matrix3x2 cumulativeTransform, calculateClip: true, out Region? cumulativeClip);
- return new object[] { cumulativeClip ?? new Region(), new Matrix(cumulativeTransform) };
- }
-
- private void GetContextInfo(out Matrix3x2 cumulativeTransform, bool calculateClip, out Region? cumulativeClip)
- {
- cumulativeClip = calculateClip ? GetRegionIfNotInfinite() : null; // Current context clip.
- cumulativeTransform = TransformElements; // Current context transform.
- Vector2 currentOffset = default; // Offset of current context.
- Vector2 totalOffset = default; // Absolute coordinate offset of top context.
-
- GraphicsContext? context = _previousContext;
-
- if (!cumulativeTransform.IsIdentity)
- {
- currentOffset = cumulativeTransform.Translation;
- }
-
- while (context is not null)
- {
- if (!context.TransformOffset.IsEmpty())
- {
- cumulativeTransform.Translate(context.TransformOffset);
- }
-
- if (!currentOffset.IsEmpty())
- {
- // The location of the GDI+ clip region is relative to the coordinate origin after any translate transform
- // has been applied. We need to intersect regions using the same coordinate origin relative to the previous
- // context.
-
- // If we don't have a cumulative clip, we're infinite, and translation on infinite regions is a no-op.
- cumulativeClip?.Translate(currentOffset.X, currentOffset.Y);
- totalOffset.X += currentOffset.X;
- totalOffset.Y += currentOffset.Y;
- }
-
- // Context only stores clips if they are not infinite. Intersecting a clip with an infinite clip is a no-op.
- if (calculateClip && context.Clip is not null)
- {
- // Intersecting an infinite clip with another is just a copy of the second clip.
- if (cumulativeClip is null)
- {
- cumulativeClip = context.Clip;
- }
- else
- {
- cumulativeClip.Intersect(context.Clip);
- }
- }
-
- currentOffset = context.TransformOffset;
-
- // Ignore subsequent cumulative contexts.
- do
- {
- context = context.Previous;
-
- if (context == null || !context.Next!.IsCumulative)
- {
- break;
- }
- } while (context.IsCumulative);
- }
-
- if (!totalOffset.IsEmpty())
- {
- // We need now to reset the total transform in the region so when calling Region.GetHRgn(Graphics)
- // the HRegion is properly offset by GDI+ based on the total offset of the graphics object.
-
- // If we don't have a cumulative clip, we're infinite, and translation on infinite regions is a no-op.
- cumulativeClip?.Translate(-totalOffset.X, -totalOffset.Y);
- }
- }
-
-#if NETCOREAPP3_1_OR_GREATER
- ///
- /// Gets the cumulative offset.
- ///
- /// The cumulative offset.
- [EditorBrowsable(EditorBrowsableState.Never)]
- [SupportedOSPlatform("windows")]
- public void GetContextInfo(out PointF offset)
- {
- GetContextInfo(out Matrix3x2 cumulativeTransform, calculateClip: false, out _);
- Vector2 translation = cumulativeTransform.Translation;
- offset = new PointF(translation.X, translation.Y);
- }
-
- ///
- /// Gets the cumulative offset and clip region.
- ///
- /// The cumulative offset.
- /// The cumulative clip region or null if the clip region is infinite.
- [EditorBrowsable(EditorBrowsableState.Never)]
- [SupportedOSPlatform("windows")]
- public void GetContextInfo(out PointF offset, out Region? clip)
- {
- GetContextInfo(out Matrix3x2 cumulativeTransform, calculateClip: true, out clip);
- Vector2 translation = cumulativeTransform.Translation;
- offset = new PointF(translation.X, translation.Y);
- }
-#endif
-
- public RectangleF VisibleClipBounds
- {
- get
- {
- if (PrintingHelper is PrintPreviewGraphics ppGraphics)
- return ppGraphics.VisibleClipBounds;
-
- Gdip.CheckStatus(Gdip.GdipGetVisibleClipBounds(new HandleRef(this, NativeGraphics), out RectangleF rect));
-
- return rect;
- }
- }
-
- ///
- /// Saves the current context into the context stack.
- ///
- private void PushContext(GraphicsContext context)
- {
- Debug.Assert(context != null && context.State != 0, "GraphicsContext object is null or not valid.");
-
- if (_previousContext != null)
- {
- // Push context.
- context.Previous = _previousContext;
- _previousContext.Next = context;
- }
- _previousContext = context;
- }
-
- ///
- /// Pops all contexts from the specified one included. The specified context is becoming the current context.
- ///
- private void PopContext(int currentContextState)
- {
- Debug.Assert(_previousContext != null, "Trying to restore a context when the stack is empty");
- GraphicsContext? context = _previousContext;
-
- // Pop all contexts up the stack.
- while (context != null)
- {
- if (context.State == currentContextState)
- {
- _previousContext = context.Previous;
-
- // This will dispose all context object up the stack.
- context.Dispose();
- return;
- }
- context = context.Previous;
- }
- Debug.Fail("Warning: context state not found!");
- }
-
- public GraphicsState Save()
- {
- GraphicsContext context = new GraphicsContext(this);
- int status = Gdip.GdipSaveGraphics(new HandleRef(this, NativeGraphics), out int state);
-
- if (status != Gdip.Ok)
- {
- context.Dispose();
- throw Gdip.StatusException(status);
- }
-
- context.State = state;
- context.IsCumulative = true;
- PushContext(context);
-
- return new GraphicsState(state);
- }
-
- public void Restore(GraphicsState gstate)
- {
- Gdip.CheckStatus(Gdip.GdipRestoreGraphics(new HandleRef(this, NativeGraphics), gstate.nativeState));
- PopContext(gstate.nativeState);
- }
-
- public GraphicsContainer BeginContainer(RectangleF dstrect, RectangleF srcrect, GraphicsUnit unit)
- {
- GraphicsContext context = new GraphicsContext(this);
-
- int status = Gdip.GdipBeginContainer(
- new HandleRef(this, NativeGraphics), ref dstrect, ref srcrect, unit, out int state);
-
- if (status != Gdip.Ok)
- {
- context.Dispose();
- throw Gdip.StatusException(status);
- }
-
- context.State = state;
- PushContext(context);
-
- return new GraphicsContainer(state);
- }
-
- public GraphicsContainer BeginContainer()
- {
- GraphicsContext context = new GraphicsContext(this);
- int status = Gdip.GdipBeginContainer2(new HandleRef(this, NativeGraphics), out int state);
-
- if (status != Gdip.Ok)
- {
- context.Dispose();
- throw Gdip.StatusException(status);
- }
-
- context.State = state;
- PushContext(context);
-
- return new GraphicsContainer(state);
- }
-
- public void EndContainer(GraphicsContainer container)
- {
- ArgumentNullException.ThrowIfNull(container);
-
- Gdip.CheckStatus(Gdip.GdipEndContainer(new HandleRef(this, NativeGraphics), container.nativeGraphicsContainer));
- PopContext(container.nativeGraphicsContainer);
- }
-
- public GraphicsContainer BeginContainer(Rectangle dstrect, Rectangle srcrect, GraphicsUnit unit)
- {
- GraphicsContext context = new GraphicsContext(this);
-
- int status = Gdip.GdipBeginContainerI(
- new HandleRef(this, NativeGraphics), ref dstrect, ref srcrect, unit, out int state);
-
- if (status != Gdip.Ok)
- {
- context.Dispose();
- throw Gdip.StatusException(status);
- }
-
- context.State = state;
- PushContext(context);
-
- return new GraphicsContainer(state);
- }
-
- public void AddMetafileComment(byte[] data)
- {
- ArgumentNullException.ThrowIfNull(data);
-
- Gdip.CheckStatus(Gdip.GdipComment(new HandleRef(this, NativeGraphics), data.Length, data));
- }
-
- public static IntPtr GetHalftonePalette()
- {
- if (s_halftonePalette == IntPtr.Zero)
- {
- lock (s_syncObject)
- {
- if (s_halftonePalette == IntPtr.Zero)
- {
- AppDomain.CurrentDomain.DomainUnload += OnDomainUnload;
- AppDomain.CurrentDomain.ProcessExit += OnDomainUnload;
-
- s_halftonePalette = Gdip.GdipCreateHalftonePalette();
- }
- }
- }
- return s_halftonePalette;
- }
-
- // This is called from AppDomain.ProcessExit and AppDomain.DomainUnload.
- private static void OnDomainUnload(object? sender, EventArgs e)
- {
- if (s_halftonePalette != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteObject(s_halftonePalette);
- s_halftonePalette = IntPtr.Zero;
- }
- }
-
- ///
- /// GDI+ will return a 'generic error' with specific win32 last error codes when
- /// a terminal server session has been closed, minimized, etc... We don't want
- /// to throw when this happens, so we'll guard against this by looking at the
- /// 'last win32 error code' and checking to see if it is either 1) access denied
- /// or 2) proc not found and then ignore it.
- ///
- /// The problem is that when you lock the machine, the secure desktop is enabled and
- /// rendering fails which is expected (since the app doesn't have permission to draw
- /// on the secure desktop). Not sure if there's anything you can do, short of catching
- /// the desktop switch message and absorbing all the exceptions that get thrown while
- /// it's the secure desktop.
- ///
- private static void CheckErrorStatus(int status)
- {
- if (status == Gdip.Ok)
- return;
-
- // Generic error from GDI+ can be GenericError or Win32Error.
- if (status == Gdip.GenericError || status == Gdip.Win32Error)
- {
- int error = Marshal.GetLastWin32Error();
- if (error == SafeNativeMethods.ERROR_ACCESS_DENIED || error == SafeNativeMethods.ERROR_PROC_NOT_FOUND ||
- // Here, we'll check to see if we are in a terminal services session...
- (((Interop.User32.GetSystemMetrics(NativeMethods.SM_REMOTESESSION) & 0x00000001) != 0) && (error == 0)))
- {
- return;
- }
- }
-
- // Legitimate error, throw our status exception.
- throw Gdip.StatusException(status);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsContext.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsContext.cs
deleted file mode 100644
index bc37013170fbe..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsContext.cs
+++ /dev/null
@@ -1,68 +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.Numerics;
-
-namespace System.Drawing
-{
- ///
- /// Contains information about the context of a Graphics object.
- ///
- internal sealed class GraphicsContext : IDisposable
- {
- public GraphicsContext(Graphics g)
- {
- TransformOffset = g.TransformElements.Translation;
- Clip = g.GetRegionIfNotInfinite();
- }
-
- ///
- /// Disposes this and all contexts up the stack.
- ///
- public void Dispose()
- {
- // Dispose all contexts up the stack since they are relative to this one and its state will be invalid.
- Next?.Dispose();
- Next = null;
-
- Clip?.Dispose();
- Clip = null;
-
- GC.SuppressFinalize(this);
- }
-
- ///
- /// The state id representing the GraphicsContext.
- ///
- public int State { get; set; }
-
- ///
- /// The translate transform in the GraphicsContext.
- ///
- public Vector2 TransformOffset { get; private set; }
-
- ///
- /// The clipping region the GraphicsContext.
- ///
- public Region? Clip { get; private set; }
-
- ///
- /// The next GraphicsContext object in the stack.
- ///
- public GraphicsContext? Next { get; set; }
-
- ///
- /// The previous GraphicsContext object in the stack.
- ///
- public GraphicsContext? Previous { get; set; }
-
- ///
- /// Flag that determines whether the context was created for a Graphics.Save() operation.
- /// This kind of contexts are cumulative across subsequent Save() calls so the top context
- /// info is cumulative. This is not the same for contexts created for a Graphics.BeginContainer()
- /// operation, in this case the new context information is reset. See Graphics.BeginContainer()
- /// and Graphics.Save() for more information.
- ///
- public bool IsCumulative { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsUnit.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsUnit.cs
deleted file mode 100644
index 8c2fc0e715048..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/GraphicsUnit.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the unit of measure for the given data.
- ///
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public enum GraphicsUnit
- {
- ///
- /// Specifies the world unit as the unit of measure.
- ///
- World = 0,
- ///
- /// Specifies 1/75 inch as the unit of measure.
- ///
- Display = 1,
- ///
- /// Specifies a device pixel as the unit of measure.
- ///
- Pixel = 2,
- ///
- /// Specifies a printer's point (1/72 inch) as the unit of measure.
- ///
- Point = 3,
- ///
- /// Specifies the inch as the unit of measure.
- ///
- Inch = 4,
- ///
- /// Specifies the document unit (1/300 inch) as the unit of measure.
- ///
- Document = 5,
- ///
- /// Specifies the millimeter as the unit of measure.
- ///
- Millimeter = 6
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/IDeviceContext.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/IDeviceContext.cs
deleted file mode 100644
index 349770b8ccf1c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/IDeviceContext.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// This interface defines methods for obtaining a display/window device context handle (Win32 hdc).
- /// Note: Display and window dc handles are obtained and released using BeginPaint/EndPaint and
- /// GetDC/ReleaseDC; this interface is intended to be used with the last method only.
- ///
- /// Warning to implementors: Creating and releasing non-display dc handles using this interface needs
- /// special care, for instance using other Win32 functions like CreateDC or CreateCompatibleDC require
- /// DeleteDC instead of ReleaseDC to properly free the dc handle.
- ///
- /// See the DeviceContext class for an implementation of this interface, it uses the Dispose method
- /// for freeing non-display dc handles.
- ///
- /// This is a low-level API that is expected to be used with TextRenderer or PInvoke calls.
- ///
- public interface IDeviceContext : IDisposable
- {
- IntPtr GetHdc();
-
- void ReleaseHdc();
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs
deleted file mode 100644
index caf7f181c5889..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.ComWrappers.cs
+++ /dev/null
@@ -1,85 +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.Diagnostics;
-using System.Drawing.Internal;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-
-namespace System.Drawing
-{
- public sealed partial class Icon : MarshalByRefObject, ICloneable, IDisposable, ISerializable
- {
- public unsafe void Save(Stream outputStream)
- {
- if (_iconData != null)
- {
- outputStream.Write(_iconData, 0, _iconData.Length);
- }
- else
- {
- if (outputStream == null)
- throw new ArgumentNullException(nameof(outputStream));
-
- // Ideally, we would pick apart the icon using
- // GetIconInfo, and then pull the individual bitmaps out,
- // converting them to DIBS and saving them into the file.
- // But, in the interest of simplicity, we just call to
- // OLE to do it for us.
- PICTDESC pictdesc = PICTDESC.CreateIconPICTDESC(Handle);
- Guid iid = DrawingCom.IPicture.IID;
- IntPtr lpPicture;
- Marshal.ThrowExceptionForHR(OleCreatePictureIndirect(&pictdesc, &iid, fOwn: 0, &lpPicture));
-
- IntPtr streamPtr = IntPtr.Zero;
- try
- {
- // Use UniqueInstance here because we never want to cache the wrapper. It only gets used once and then disposed.
- using DrawingCom.IPicture picture = (DrawingCom.IPicture)DrawingCom.Instance
- .GetOrCreateObjectForComInstance(lpPicture, CreateObjectFlags.UniqueInstance);
-
- var gpStream = new GPStream(outputStream, makeSeekable: false);
- streamPtr = DrawingCom.Instance.GetOrCreateComInterfaceForObject(gpStream, CreateComInterfaceFlags.None);
-
- DrawingCom.ThrowExceptionForHR(picture.SaveAsFile(streamPtr, -1, null));
- }
- finally
- {
- if (streamPtr != IntPtr.Zero)
- {
- int count = Marshal.Release(streamPtr);
- Debug.Assert(count == 0);
- }
-
- if (lpPicture != IntPtr.Zero)
- {
- int count = Marshal.Release(lpPicture);
- Debug.Assert(count == 0);
- }
- }
- }
- }
-
- [LibraryImport(Interop.Libraries.Oleaut32)]
- private static unsafe partial int OleCreatePictureIndirect(PICTDESC* pictdesc, Guid* refiid, int fOwn, IntPtr* lplpvObj);
-
- [StructLayout(LayoutKind.Sequential)]
- private readonly struct PICTDESC
- {
- public readonly int SizeOfStruct;
- public readonly int PicType;
- public readonly IntPtr Icon;
-
- private unsafe PICTDESC(int picType, IntPtr hicon)
- {
- SizeOfStruct = sizeof(PICTDESC);
- PicType = picType;
- Icon = hicon;
- }
-
- public static PICTDESC CreateIconPICTDESC(IntPtr hicon) =>
- new PICTDESC(Ole.PICTYPE_ICON, hicon);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs
deleted file mode 100644
index a3d7c5cce0665..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Icon.cs
+++ /dev/null
@@ -1,882 +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.Buffers;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-
-namespace System.Drawing
-{
- [Editor("System.Drawing.Design.IconEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [TypeConverter(typeof(IconConverter))]
- [Serializable]
- [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed partial class Icon : MarshalByRefObject, ICloneable, IDisposable, ISerializable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- private static int s_bitDepth;
-
- // The PNG signature is specified at http://www.w3.org/TR/PNG/#5PNG-file-signature
- private const int PNGSignature1 = 137 + ('P' << 8) + ('N' << 16) + ('G' << 24);
- private const int PNGSignature2 = 13 + (10 << 8) + (26 << 16) + (10 << 24);
-
- // Icon data
- private readonly byte[]? _iconData;
- private uint _bestImageOffset;
- private uint _bestBitDepth;
- private uint _bestBytesInRes;
- private bool? _isBestImagePng;
- private Size _iconSize = Size.Empty;
- private IntPtr _handle = IntPtr.Zero;
- private readonly bool _ownHandle = true;
-
- private Icon() { }
-
- internal Icon(IntPtr handle) : this(handle, false)
- {
- }
-
- internal Icon(IntPtr handle, bool takeOwnership)
- {
- if (handle == IntPtr.Zero)
- {
- throw new ArgumentException(SR.Format(SR.InvalidGDIHandle, nameof(Icon)));
- }
-
- _handle = handle;
- _ownHandle = takeOwnership;
- }
-
- public Icon(string fileName) : this(fileName, 0, 0)
- {
- }
-
- public Icon(string fileName, Size size) : this(fileName, size.Width, size.Height)
- {
- }
-
- public Icon(string fileName, int width, int height) : this()
- {
- using (FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
- {
- Debug.Assert(f != null, "File.OpenRead returned null instead of throwing an exception");
- _iconData = new byte[(int)f.Length];
- f.Read(_iconData, 0, _iconData.Length);
- }
-
- Initialize(width, height);
- }
-
- public Icon(Icon original, Size size) : this(original, size.Width, size.Height)
- {
- }
-
- public Icon(Icon original, int width, int height) : this()
- {
- ArgumentNullException.ThrowIfNull(original);
-
- _iconData = original._iconData;
-
- if (_iconData == null)
- {
- _iconSize = original.Size;
- _handle = Interop.User32.CopyImage(new HandleRef(original, original.Handle), SafeNativeMethods.IMAGE_ICON, _iconSize.Width, _iconSize.Height, 0);
- }
- else
- {
- Initialize(width, height);
- }
- }
-
- public Icon(Type type, string resource) : this()
- {
- ArgumentNullException.ThrowIfNull(resource);
-
- Stream? stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
- if (stream == null)
- {
- throw new ArgumentException(SR.Format(SR.ResourceNotFound, type, resource));
- }
-
- _iconData = new byte[(int)stream.Length];
- stream.Read(_iconData, 0, _iconData.Length);
- Initialize(0, 0);
- }
-
- public Icon(Stream stream) : this(stream, 0, 0)
- {
- }
-
- public Icon(Stream stream, Size size) : this(stream, size.Width, size.Height)
- {
- }
-
- public Icon(Stream stream, int width, int height) : this()
- {
- ArgumentNullException.ThrowIfNull(stream);
-
- _iconData = new byte[(int)stream.Length];
-#if NET7_0_OR_GREATER
- stream.ReadExactly(_iconData);
-#else
- int totalRead = 0;
- while (totalRead < _iconData.Length)
- {
- int bytesRead = stream.Read(_iconData, totalRead, _iconData.Length - totalRead);
- if (bytesRead <= 0)
- {
- throw new EndOfStreamException();
- }
- totalRead += bytesRead;
- }
-#endif
- Initialize(width, height);
- }
-
- private Icon(SerializationInfo info, StreamingContext context)
- {
- _iconData = (byte[])info.GetValue("IconData", typeof(byte[]))!; // Do not rename (binary serialization)
- _iconSize = (Size)info.GetValue("IconSize", typeof(Size))!; // Do not rename (binary serialization)
- Initialize(_iconSize.Width, _iconSize.Height);
- }
-
- void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
- {
- if (_iconData != null)
- {
- si.AddValue("IconData", _iconData, typeof(byte[])); // Do not rename (binary serialization)
- }
- else
- {
- MemoryStream stream = new MemoryStream();
- Save(stream);
- si.AddValue("IconData", stream.ToArray(), typeof(byte[])); // Do not rename (binary serialization)
- }
-
- si.AddValue("IconSize", _iconSize, typeof(Size)); // Do not rename (binary serialization)
- }
-
- public static Icon? ExtractAssociatedIcon(string filePath) => ExtractAssociatedIcon(filePath, 0);
-
- private static unsafe Icon? ExtractAssociatedIcon(string filePath, int index)
- {
- ArgumentNullException.ThrowIfNull(filePath);
- if (string.IsNullOrEmpty(filePath))
- throw new ArgumentException(SR.NullOrEmptyPath, nameof(filePath));
-
- filePath = Path.GetFullPath(filePath);
- if (!File.Exists(filePath))
- {
- throw new FileNotFoundException(message: null, fileName: filePath);
- }
-
- // ExtractAssociatedIcon copies the loaded path into the buffer that it is passed.
- // It isn't clear what the exact semantics are for copying back the path, a quick
- // look at the code it might be hard coded to 128 chars for some cases. Leaving the
- // historical MAX_PATH as a minimum to be safe.
-
- char[] buffer = ArrayPool.Shared.Rent(Math.Max(NativeMethods.MAX_PATH, filePath.Length));
- filePath.CopyTo(0, buffer, 0, filePath.Length);
- buffer[filePath.Length] = '\0';
-
- IntPtr hIcon;
- fixed (char* b = buffer)
- {
- hIcon = Interop.Shell32.ExtractAssociatedIcon(NativeMethods.NullHandleRef, b, ref index);
- }
-
- ArrayPool.Shared.Return(buffer);
-
- if (hIcon != IntPtr.Zero)
- {
- return new Icon(hIcon, true);
- }
-
- return null;
- }
-
- [Browsable(false)]
- public IntPtr Handle
- {
- get
- {
- if (_handle == IntPtr.Zero)
- {
- throw new ObjectDisposedException(GetType().Name);
- }
- return _handle;
- }
- }
-
- [Browsable(false)]
- public int Height => Size.Height;
-
- public unsafe Size Size
- {
- get
- {
- if (_iconSize.IsEmpty)
- {
- Interop.User32.ICONINFO info = default;
- Interop.User32.GetIconInfo(new HandleRef(this, Handle), ref info);
- Interop.Gdi32.BITMAP bitmap = default;
-
- if (info.hbmColor != IntPtr.Zero)
- {
- Interop.Gdi32.GetObject(
- new HandleRef(null, info.hbmColor),
- sizeof(Interop.Gdi32.BITMAP),
- ref bitmap);
- Interop.Gdi32.DeleteObject(info.hbmColor);
- _iconSize = new Size((int)bitmap.bmWidth, (int)bitmap.bmHeight);
- }
- else if (info.hbmMask != IntPtr.Zero)
- {
- Interop.Gdi32.GetObject(
- new HandleRef(null, info.hbmMask),
- sizeof(Interop.Gdi32.BITMAP),
- ref bitmap);
- _iconSize = new Size((int)bitmap.bmWidth, (int)(bitmap.bmHeight / 2));
- }
-
- if (info.hbmMask != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteObject(info.hbmMask);
- }
- }
-
- return _iconSize;
- }
- }
-
- [Browsable(false)]
- public int Width => Size.Width;
-
- public object Clone() => new Icon(this, Size.Width, Size.Height);
-
- // Called when this object is going to destroy it's Win32 handle. You
- // may override this if there is something special you need to do to
- // destroy the handle. This will be called even if the handle is not
- // owned by this object, which is handy if you want to create a
- // derived class that has it's own create/destroy semantics.
- //
- // The default implementation will call the appropriate Win32
- // call to destroy the handle if this object currently owns the
- // handle. It will do nothing if the object does not currently
- // own the handle.
- internal void DestroyHandle()
- {
- if (_ownHandle)
- {
- Interop.User32.DestroyIcon(new HandleRef(this, _handle));
- _handle = IntPtr.Zero;
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (_handle != IntPtr.Zero)
- {
-#if FINALIZATION_WATCH
- if (!disposing)
- {
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
- }
-#endif
- DestroyHandle();
- }
- }
-
- // Draws this image to a graphics object. The drawing command originates on the graphics
- // object, but a graphics object generally has no idea how to render a given image. So,
- // it passes the call to the actual image. This version crops the image to the given
- // dimensions and allows the user to specify a rectangle within the image to draw.
- private void DrawIcon(IntPtr dc, Rectangle imageRect, Rectangle targetRect, bool stretch)
- {
- int imageX = 0;
- int imageY = 0;
- int imageWidth;
- int imageHeight;
- int targetX = 0;
- int targetY = 0;
- int targetWidth;
- int targetHeight;
-
- Size cursorSize = Size;
-
- // Compute the dimensions of the icon if needed.
- if (!imageRect.IsEmpty)
- {
- imageX = imageRect.X;
- imageY = imageRect.Y;
- imageWidth = imageRect.Width;
- imageHeight = imageRect.Height;
- }
- else
- {
- imageWidth = cursorSize.Width;
- imageHeight = cursorSize.Height;
- }
-
- if (!targetRect.IsEmpty)
- {
- targetX = targetRect.X;
- targetY = targetRect.Y;
- targetWidth = targetRect.Width;
- targetHeight = targetRect.Height;
- }
- else
- {
- targetWidth = cursorSize.Width;
- targetHeight = cursorSize.Height;
- }
-
- int drawWidth, drawHeight;
- int clipWidth, clipHeight;
-
- if (stretch)
- {
- drawWidth = cursorSize.Width * targetWidth / imageWidth;
- drawHeight = cursorSize.Height * targetHeight / imageHeight;
- clipWidth = targetWidth;
- clipHeight = targetHeight;
- }
- else
- {
- drawWidth = cursorSize.Width;
- drawHeight = cursorSize.Height;
- clipWidth = targetWidth < imageWidth ? targetWidth : imageWidth;
- clipHeight = targetHeight < imageHeight ? targetHeight : imageHeight;
- }
-
- // The ROP is SRCCOPY, so we can be simple here and take
- // advantage of clipping regions. Drawing the cursor
- // is merely a matter of offsetting and clipping.
- IntPtr hSaveRgn = SaveClipRgn(dc);
- try
- {
- Interop.Gdi32.IntersectClipRect(new HandleRef(this, dc), targetX, targetY, targetX + clipWidth, targetY + clipHeight);
- Interop.User32.DrawIconEx(new HandleRef(null, dc),
- targetX - imageX,
- targetY - imageY,
- new HandleRef(this, _handle),
- drawWidth,
- drawHeight,
- 0,
- NativeMethods.NullHandleRef,
- SafeNativeMethods.DI_NORMAL);
- }
- finally
- {
- Interop.Gdi32.SelectClipRgn(dc, hSaveRgn);
- // We need to delete the region handle after restoring the region as GDI+ uses a copy of the handle.
- Interop.Gdi32.DeleteObject(hSaveRgn);
- }
- }
-
- private static IntPtr SaveClipRgn(IntPtr hDC)
- {
- IntPtr hTempRgn = Interop.Gdi32.CreateRectRgn(0, 0, 0, 0);
- IntPtr hSaveRgn = IntPtr.Zero;
-
- int result = Interop.Gdi32.GetClipRgn(hDC, hTempRgn);
- if (result > 0)
- {
- hSaveRgn = hTempRgn;
- }
- else
- {
- // if we fail to get the clip region delete the handle.
- Interop.Gdi32.DeleteObject(hTempRgn);
- }
-
- return hSaveRgn;
- }
-
- internal void Draw(Graphics graphics, int x, int y)
- {
- Size size = Size;
- Draw(graphics, new Rectangle(x, y, size.Width, size.Height));
- }
-
- // Draws this image to a graphics object. The drawing command originates on the graphics
- // object, but a graphics object generally has no idea how to render a given image. So,
- // it passes the call to the actual image. This version stretches the image to the given
- // dimensions and allows the user to specify a rectangle within the image to draw.
- internal void Draw(Graphics graphics, Rectangle targetRect)
- {
- Rectangle copy = targetRect;
-
- using Matrix transform = graphics.Transform;
- PointF offset = transform.Offset;
- copy.X += (int)offset.X;
- copy.Y += (int)offset.Y;
-
- using (WindowsGraphics wg = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping))
- {
- IntPtr dc = wg.GetHdc();
- DrawIcon(dc, Rectangle.Empty, copy, true);
- }
- }
-
- // Draws this image to a graphics object. The drawing command originates on the graphics
- // object, but a graphics object generally has no idea how to render a given image. So,
- // it passes the call to the actual image. This version crops the image to the given
- // dimensions and allows the user to specify a rectangle within the image to draw.
- internal void DrawUnstretched(Graphics graphics, Rectangle targetRect)
- {
- Rectangle copy = targetRect;
- using Matrix transform = graphics.Transform;
- PointF offset = transform.Offset;
- copy.X += (int)offset.X;
- copy.Y += (int)offset.Y;
-
- using (WindowsGraphics wg = WindowsGraphics.FromGraphics(graphics, ApplyGraphicsProperties.Clipping))
- {
- IntPtr dc = wg.GetHdc();
- DrawIcon(dc, Rectangle.Empty, copy, false);
- }
- }
-
- ~Icon() => Dispose(false);
-
- public static Icon FromHandle(IntPtr handle)
- {
- if (handle == IntPtr.Zero)
- throw new ArgumentException(null, nameof(handle));
-
- return new Icon(handle);
- }
-
- // Initializes this Image object. This is identical to calling the image's
- // constructor with picture, but this allows non-constructor initialization,
- // which may be necessary in some instances.
- private unsafe void Initialize(int width, int height)
- {
- if (_iconData == null || _handle != IntPtr.Zero)
- {
- throw new InvalidOperationException(SR.Format(SR.IllegalState, GetType().Name));
- }
-
- if (_iconData.Length < sizeof(SafeNativeMethods.ICONDIR))
- {
- throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
- }
-
- // Get the correct width and height.
- if (width == 0)
- {
- width = Interop.User32.GetSystemMetrics(SafeNativeMethods.SM_CXICON);
- }
-
- if (height == 0)
- {
- height = Interop.User32.GetSystemMetrics(SafeNativeMethods.SM_CYICON);
- }
-
- if (s_bitDepth == 0)
- {
- IntPtr dc = Interop.User32.GetDC(IntPtr.Zero);
- s_bitDepth = Interop.Gdi32.GetDeviceCaps(dc, Interop.Gdi32.DeviceCapability.BITSPIXEL);
- s_bitDepth *= Interop.Gdi32.GetDeviceCaps(dc, Interop.Gdi32.DeviceCapability.PLANES);
- Interop.User32.ReleaseDC(IntPtr.Zero, dc);
-
- // If the bitdepth is 8, make it 4 because windows does not
- // choose a 256 color icon if the display is running in 256 color mode
- // due to palette flicker.
- if (s_bitDepth == 8)
- {
- s_bitDepth = 4;
- }
- }
-
- fixed (byte* b = _iconData)
- {
- SafeNativeMethods.ICONDIR* dir = (SafeNativeMethods.ICONDIR*)b;
-
- if (dir->idReserved != 0 || dir->idType != 1 || dir->idCount == 0)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
- }
-
- byte bestWidth = 0;
- byte bestHeight = 0;
-
- if (sizeof(SafeNativeMethods.ICONDIRENTRY) * (dir->idCount - 1) + sizeof(SafeNativeMethods.ICONDIR)
- > _iconData.Length)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
- }
-
- var entries = new ReadOnlySpan(&dir->idEntries, dir->idCount);
- foreach (SafeNativeMethods.ICONDIRENTRY entry in entries)
- {
- bool fUpdateBestFit = false;
- uint iconBitDepth;
- if (entry.bColorCount != 0)
- {
- iconBitDepth = 4;
- if (entry.bColorCount < 0x10)
- {
- iconBitDepth = 1;
- }
- }
- else
- {
- iconBitDepth = entry.wBitCount;
- }
-
- // If it looks like if nothing is specified at this point then set the bits per pixel to 8.
- if (iconBitDepth == 0)
- {
- iconBitDepth = 8;
- }
-
- // Windows rules for specifing an icon:
- //
- // 1. The icon with the closest size match.
- // 2. For matching sizes, the image with the closest bit depth.
- // 3. If there is no color depth match, the icon with the closest color depth that does not exceed the display.
- // 4. If all icon color depth > display, lowest color depth is chosen.
- // 5. color depth of > 8bpp are all equal.
- // 6. Never choose an 8bpp icon on an 8bpp system.
-
- if (_bestBytesInRes == 0)
- {
- fUpdateBestFit = true;
- }
- else
- {
- int bestDelta = Math.Abs(bestWidth - width) + Math.Abs(bestHeight - height);
- int thisDelta = Math.Abs(entry.bWidth - width) + Math.Abs(entry.bHeight - height);
-
- if ((thisDelta < bestDelta) ||
- (thisDelta == bestDelta && (iconBitDepth <= s_bitDepth && iconBitDepth > _bestBitDepth || _bestBitDepth > s_bitDepth && iconBitDepth < _bestBitDepth)))
- {
- fUpdateBestFit = true;
- }
- }
-
- if (fUpdateBestFit)
- {
- bestWidth = entry.bWidth;
- bestHeight = entry.bHeight;
- _bestImageOffset = entry.dwImageOffset;
- _bestBytesInRes = entry.dwBytesInRes;
- _bestBitDepth = iconBitDepth;
- }
- }
-
- if (_bestImageOffset > int.MaxValue)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
- }
-
- if (_bestBytesInRes > int.MaxValue)
- {
- throw new Win32Exception(SafeNativeMethods.ERROR_INVALID_PARAMETER);
- }
-
- uint endOffset;
- try
- {
- endOffset = checked(_bestImageOffset + _bestBytesInRes);
- }
- catch (OverflowException)
- {
- throw new Win32Exception(SafeNativeMethods.ERROR_INVALID_PARAMETER);
- }
-
- if (endOffset > _iconData.Length)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPictureType, "picture", nameof(Icon)));
- }
-
- // Copy the bytes into an aligned buffer if needed.
- if ((_bestImageOffset % IntPtr.Size) != 0)
- {
- // Beginning of icon's content is misaligned.
- byte[] alignedBuffer = ArrayPool.Shared.Rent((int)_bestBytesInRes);
- Array.Copy(_iconData, _bestImageOffset, alignedBuffer, 0, _bestBytesInRes);
-
- fixed (byte* pbAlignedBuffer = alignedBuffer)
- {
- _handle = Interop.User32.CreateIconFromResourceEx(pbAlignedBuffer, _bestBytesInRes, true, 0x00030000, 0, 0, 0);
- }
- ArrayPool.Shared.Return(alignedBuffer);
- }
- else
- {
- try
- {
- _handle = Interop.User32.CreateIconFromResourceEx(checked(b + _bestImageOffset), _bestBytesInRes, true, 0x00030000, 0, 0, 0);
- }
- catch (OverflowException)
- {
- throw new Win32Exception(SafeNativeMethods.ERROR_INVALID_PARAMETER);
- }
- }
-
- if (_handle == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
- }
- }
-
- private unsafe void CopyBitmapData(BitmapData sourceData, BitmapData targetData)
- {
- byte* srcPtr = (byte*)sourceData.Scan0;
- byte* destPtr = (byte*)targetData.Scan0;
-
- Debug.Assert(sourceData.Height == targetData.Height, "Unexpected height. How did this happen?");
- int height = Math.Min(sourceData.Height, targetData.Height);
- long bytesToCopyEachIter = Math.Abs(targetData.Stride);
-
- for (int i = 0; i < height; i++)
- {
- Buffer.MemoryCopy(srcPtr, destPtr, bytesToCopyEachIter, bytesToCopyEachIter);
- srcPtr += sourceData.Stride;
- destPtr += targetData.Stride;
- }
-
- GC.KeepAlive(this); // finalizer mustn't deallocate data blobs while this method is running
- }
-
- private static bool BitmapHasAlpha(BitmapData bmpData)
- {
- bool hasAlpha = false;
- for (int i = 0; i < bmpData.Height; i++)
- {
- for (int j = 3; j < Math.Abs(bmpData.Stride); j += 4)
- {
- // Stride here is fine since we know we're doing this on the whole image.
- unsafe
- {
- byte* candidate = unchecked(((byte*)bmpData.Scan0.ToPointer()) + (i * bmpData.Stride) + j);
- if (*candidate != 0)
- {
- hasAlpha = true;
- return hasAlpha;
- }
- }
- }
- }
-
- return false;
- }
-
- public Bitmap ToBitmap()
- {
- // DontSupportPngFramesInIcons is true when the application is targeting framework version below 4.6
- // and false when the application is targeting 4.6 and above. Downlevel application can also set the following switch
- // to false in the .config file's runtime section in order to opt-in into the new behavior:
- //
- if (HasPngSignature() && !LocalAppContextSwitches.DontSupportPngFramesInIcons)
- {
- return PngFrame();
- }
-
- return BmpFrame();
- }
-
- private unsafe Bitmap BmpFrame()
- {
- Bitmap? bitmap = null;
- if (_iconData != null && _bestBitDepth == 32)
- {
- // GDI+ doesnt handle 32 bpp icons with alpha properly
- // we load the icon ourself from the byte table
- bitmap = new Bitmap(Size.Width, Size.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
- Debug.Assert(_bestImageOffset >= 0 && (_bestImageOffset + _bestBytesInRes) <= _iconData.Length, "Illegal offset/length for the Icon data");
-
- unsafe
- {
- BitmapData bmpdata = bitmap.LockBits(new Rectangle(0, 0, Size.Width, Size.Height),
- ImageLockMode.WriteOnly,
- PixelFormat.Format32bppArgb);
- try
- {
- uint* pixelPtr = (uint*)bmpdata.Scan0.ToPointer();
-
- // jumping the image header
- int newOffset = (int)(_bestImageOffset + sizeof(NativeMethods.BITMAPINFOHEADER));
- // there is no color table that we need to skip since we're 32bpp
-
- int lineLength = Size.Width * 4;
- int width = Size.Width;
- for (int j = (Size.Height - 1) * 4; j >= 0; j -= 4)
- {
- Marshal.Copy(_iconData, newOffset + j * width, (IntPtr)pixelPtr, lineLength);
- pixelPtr += width;
- }
-
- // note: we ignore the mask that's available after the pixel table
- }
- finally
- {
- bitmap.UnlockBits(bmpdata);
- }
- }
- }
- else if (_bestBitDepth == 0 || _bestBitDepth == 32)
- {
- // This may be a 32bpp icon or an icon without any data.
- Interop.User32.ICONINFO info = default;
- Interop.User32.GetIconInfo(new HandleRef(this, _handle), ref info);
- Interop.Gdi32.BITMAP bmp = default;
- try
- {
- if (info.hbmColor != IntPtr.Zero)
- {
- Interop.Gdi32.GetObject(new HandleRef(null, info.hbmColor), sizeof(Interop.Gdi32.BITMAP), ref bmp);
- if (bmp.bmBitsPixel == 32)
- {
- Bitmap? tmpBitmap = null;
- BitmapData? bmpData = null;
- BitmapData? targetData = null;
- try
- {
- tmpBitmap = Image.FromHbitmap(info.hbmColor);
-
- // In GDI+ the bits are there but the bitmap was created with no alpha channel
- // so copy the bits by hand to a new bitmap
- // we also need to go around a limitation in the way the ICON is stored (ie if it's another bpp
- // but stored in 32bpp all pixels are transparent and not opaque)
- // (Here you mostly need to remain calm....)
- bmpData = tmpBitmap.LockBits(new Rectangle(0, 0, tmpBitmap.Width, tmpBitmap.Height), ImageLockMode.ReadOnly, tmpBitmap.PixelFormat);
-
- // we need do the following if the image has alpha because otherwise the image is fully transparent even though it has data
- if (BitmapHasAlpha(bmpData))
- {
- bitmap = new Bitmap(bmpData.Width, bmpData.Height, PixelFormat.Format32bppArgb);
- targetData = bitmap.LockBits(new Rectangle(0, 0, bmpData.Width, bmpData.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
-
- CopyBitmapData(bmpData, targetData);
- }
- }
- finally
- {
- if (tmpBitmap != null && bmpData != null)
- {
- tmpBitmap.UnlockBits(bmpData);
- }
- if (bitmap != null && targetData != null)
- {
- bitmap.UnlockBits(targetData);
- }
- }
- tmpBitmap.Dispose();
- }
- }
- }
- finally
- {
- if (info.hbmColor != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteObject(info.hbmColor);
- }
- if (info.hbmMask != IntPtr.Zero)
- {
- Interop.Gdi32.DeleteObject(info.hbmMask);
- }
- }
- }
-
-
- if (bitmap == null)
- {
- // last chance... all the other cases (ie non 32 bpp icons coming from a handle or from the bitmapData)
-
- // we have to do this rather than just return Bitmap.FromHIcon because
- // the bitmap returned from that, even though it's 32bpp, just paints where the mask allows it
- // seems like another GDI+ weirdness. might be interesting to investigate further. In the meantime
- // this looks like the right thing to do and is not more expansive that what was present before.
-
- Size size = Size;
- bitmap = new Bitmap(size.Width, size.Height); // initialized to transparent
- Graphics? graphics;
- using (graphics = Graphics.FromImage(bitmap))
- {
- try
- {
- using (Bitmap tmpBitmap = Bitmap.FromHicon(Handle))
- {
- graphics.DrawImage(tmpBitmap, new Rectangle(0, 0, size.Width, size.Height));
- }
- }
- catch (ArgumentException)
- {
- // Sometimes FromHicon will crash with no real reason.
- // The backup plan is to just draw the image like we used to.
- // NOTE: FromHIcon is also where we have the buffer overrun
- // if width and height are mismatched.
- Draw(graphics, new Rectangle(0, 0, size.Width, size.Height));
- }
- }
-
-
- // GDI+ fills the surface with a sentinel color for GetDC, but does
- // not correctly clean it up again, so we have to do it.
- Color fakeTransparencyColor = Color.FromArgb(0x0d, 0x0b, 0x0c);
- bitmap.MakeTransparent(fakeTransparencyColor);
- }
-
- Debug.Assert(bitmap != null, "Bitmap cannot be null");
- return bitmap;
- }
-
- private Bitmap PngFrame()
- {
- Debug.Assert(_iconData != null);
- using (var stream = new MemoryStream())
- {
- stream.Write(_iconData, (int)_bestImageOffset, (int)_bestBytesInRes);
- return new Bitmap(stream);
- }
- }
-
- private bool HasPngSignature()
- {
- if (!_isBestImagePng.HasValue)
- {
- if (_iconData != null && _iconData.Length >= _bestImageOffset + 8)
- {
- int iconSignature1 = BitConverter.ToInt32(_iconData, (int)_bestImageOffset);
- int iconSignature2 = BitConverter.ToInt32(_iconData, (int)_bestImageOffset + 4);
- _isBestImagePng = (iconSignature1 == PNGSignature1) && (iconSignature2 == PNGSignature2);
- }
- else
- {
- _isBestImagePng = false;
- }
- }
-
- return _isBestImagePng.Value;
- }
-
- public override string ToString() => SR.toStringIcon;
-
- internal static class Ole
- {
- public const int PICTYPE_ICON = 3;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/IconConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/IconConverter.cs
deleted file mode 100644
index f60174f9e46a9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/IconConverter.cs
+++ /dev/null
@@ -1,64 +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.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.IO;
-
-namespace System.Drawing
-{
- public class IconConverter : ExpandableObjectConverter
- {
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
- {
- return (sourceType == typeof(byte[]));
- }
-
- public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
- {
- return destinationType == typeof(byte[]) || destinationType == typeof(string)
- || destinationType == typeof(Image) || destinationType == typeof(Bitmap);
- }
-
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- return value is byte[] bytes ? new Icon(new MemoryStream(bytes)) : base.ConvertFrom(context, culture, value);
- }
-
- public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
- {
- if (destinationType == typeof(string))
- {
- if (value == null)
- {
- return SR.none;
- }
- else if (value is Icon)
- {
- return value.ToString()!;
- }
- }
- else if (destinationType == typeof(byte[]))
- {
- if (value is Icon icon)
- {
- using (MemoryStream ms = new MemoryStream())
- {
- icon.Save(ms);
- return ms.ToArray();
- }
- }
- }
- else if (destinationType == typeof(Image) || destinationType == typeof(Bitmap))
- {
- if (value is Icon icon)
- {
- return icon.ToBitmap();
- }
- }
-
- throw GetConvertFromException(value);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs
deleted file mode 100644
index 078eb6d5352d9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Image.cs
+++ /dev/null
@@ -1,1096 +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.Buffers;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-using System.Diagnostics.CodeAnalysis;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// An abstract base class that provides functionality for 'Bitmap', 'Icon', 'Cursor', and 'Metafile' descended classes.
- ///
- [Editor("System.Drawing.Design.ImageEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [ImmutableObject(true)]
- [Serializable]
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [TypeConverter(typeof(ImageConverter))]
- public abstract class Image : MarshalByRefObject, IDisposable, ICloneable, ISerializable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- // The signature of this delegate is incorrect. The signature of the corresponding
- // native callback function is:
- // extern "C" {
- // typedef BOOL (CALLBACK * ImageAbort)(VOID *);
- // typedef ImageAbort DrawImageAbort;
- // typedef ImageAbort GetThumbnailImageAbort;
- // }
- // However, as this delegate is not used in both GDI 1.0 and 1.1, we choose not
- // to modify it, in order to preserve compatibility.
- public delegate bool GetThumbnailImageAbort();
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(GetThumbnailImageAbort), MarshalMode.ManagedToUnmanagedIn, typeof(KeepAliveMarshaller))]
- internal static class GetThumbnailImageAbortMarshaller
- {
- internal unsafe struct KeepAliveMarshaller
- {
- private delegate Interop.BOOL GetThumbnailImageAbortNative(IntPtr callbackdata);
- private GetThumbnailImageAbortNative? _managed;
- private delegate* unmanaged _nativeFunction;
- public void FromManaged(GetThumbnailImageAbort managed)
- {
- if (managed is null)
- {
- _managed = null;
- _nativeFunction = null;
- }
- else
- {
- _managed = data => managed() ? Interop.BOOL.TRUE : Interop.BOOL.FALSE;
- _nativeFunction = (delegate* unmanaged)Marshal.GetFunctionPointerForDelegate(_managed);
- }
- }
-
- public delegate* unmanaged ToUnmanaged()
- {
- return _nativeFunction;
- }
-
- public void OnInvoked()
- {
- GC.KeepAlive(_managed);
- }
-
- public void Free() { }
- }
- }
-#endif
-
- internal IntPtr nativeImage;
-
- private object? _userData;
-
- // used to work around lack of animated gif encoder... rarely set...
- private byte[]? _rawData;
-
- [Localizable(false)]
- [DefaultValue(null)]
- public object? Tag
- {
- get => _userData;
- set => _userData = value;
- }
-
- private protected Image() { }
-
- private protected Image(SerializationInfo info, StreamingContext context)
- {
- byte[] dat = (byte[])info.GetValue("Data", typeof(byte[]))!; // Do not rename (binary serialization)
-
- try
- {
- SetNativeImage(InitializeFromStream(new MemoryStream(dat)));
- }
- catch (ExternalException)
- {
- }
- catch (ArgumentException)
- {
- }
- catch (OutOfMemoryException)
- {
- }
- catch (InvalidOperationException)
- {
- }
- catch (NotImplementedException)
- {
- }
- catch (FileNotFoundException)
- {
- }
- }
-
- void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
- {
- using (MemoryStream stream = new MemoryStream())
- {
- Save(stream);
- si.AddValue("Data", stream.ToArray(), typeof(byte[])); // Do not rename (binary serialization)
- }
- }
-
- ///
- /// Creates an from the specified file.
- ///
- public static Image FromFile(string filename) => FromFile(filename, false);
-
- public static Image FromFile(string filename, bool useEmbeddedColorManagement)
- {
- if (!File.Exists(filename))
- {
- // Throw a more specific exception for invalid paths that are null or empty,
- // contain invalid characters or are too long.
- filename = Path.GetFullPath(filename);
- throw new FileNotFoundException(filename);
- }
-
- // GDI+ will read this file multiple times. Get the fully qualified path
- // so if our app changes default directory we won't get an error
- filename = Path.GetFullPath(filename);
-
- IntPtr image;
-
- if (useEmbeddedColorManagement)
- {
- Gdip.CheckStatus(Gdip.GdipLoadImageFromFileICM(filename, out image));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipLoadImageFromFile(filename, out image));
- }
-
- ValidateImage(image);
-
- Image img = CreateImageObject(image);
- EnsureSave(img, filename, null);
- return img;
- }
-
- ///
- /// Creates an from the specified data stream.
- ///
- public static Image FromStream(Stream stream) => Image.FromStream(stream, false);
-
- public static Image FromStream(Stream stream, bool useEmbeddedColorManagement) => FromStream(stream, useEmbeddedColorManagement, true);
-
- public static Image FromStream(Stream stream, bool useEmbeddedColorManagement, bool validateImageData)
- {
- ArgumentNullException.ThrowIfNull(stream);
-
- IntPtr image = LoadGdipImageFromStream(new GPStream(stream), useEmbeddedColorManagement);
-
- if (validateImageData)
- ValidateImage(image);
-
- Image img = CreateImageObject(image);
- EnsureSave(img, null, stream);
- return img;
- }
-
- // Used for serialization
- private IntPtr InitializeFromStream(Stream stream)
- {
- IntPtr image = LoadGdipImageFromStream(new GPStream(stream), useEmbeddedColorManagement: false);
- ValidateImage(image);
-
- nativeImage = image;
-
- Gdip.CheckStatus(Gdip.GdipGetImageType(new HandleRef(this, nativeImage), out _));
- EnsureSave(this, null, stream);
- return image;
- }
-
- private static unsafe IntPtr LoadGdipImageFromStream(GPStream stream, bool useEmbeddedColorManagement)
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(stream);
-
- IntPtr image = IntPtr.Zero;
- if (useEmbeddedColorManagement)
- {
- Gdip.CheckStatus(Gdip.GdipLoadImageFromStreamICM(streamWrapper.Ptr, &image));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipLoadImageFromStream(streamWrapper.Ptr, &image));
- }
- return image;
- }
-
- internal Image(IntPtr nativeImage) => SetNativeImage(nativeImage);
-
- ///
- /// Cleans up Windows resources for this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- ~Image() => Dispose(false);
-
- ///
- /// Creates an exact copy of this .
- ///
- public object Clone()
- {
- IntPtr cloneImage;
-
- Gdip.CheckStatus(Gdip.GdipCloneImage(new HandleRef(this, nativeImage), out cloneImage));
- ValidateImage(cloneImage);
-
- return CreateImageObject(cloneImage);
- }
-
- protected virtual void Dispose(bool disposing)
- {
-#if FINALIZATION_WATCH
- if (!disposing && nativeImage != IntPtr.Zero)
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
-#endif
- if (nativeImage == IntPtr.Zero)
- return;
-
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDisposeImage(new HandleRef(this, nativeImage));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsSecurityOrCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during Dispose: " + ex.ToString());
- }
- finally
- {
- nativeImage = IntPtr.Zero;
- }
- }
-
- ///
- /// Saves this to the specified file.
- ///
- public void Save(string filename) => Save(filename, RawFormat);
-
- ///
- /// Saves this to the specified file in the specified format.
- ///
- public void Save(string filename, ImageFormat format)
- {
- ArgumentNullException.ThrowIfNull(format);
-
- ImageCodecInfo codec = format.FindEncoder() ?? ImageFormat.Png.FindEncoder()!;
-
- Save(filename, codec, null);
- }
-
- ///
- /// Saves this to the specified file in the specified format and with the specified encoder parameters.
- ///
- public void Save(string filename, ImageCodecInfo encoder, EncoderParameters? encoderParams)
- {
- ArgumentNullException.ThrowIfNull(filename);
- ArgumentNullException.ThrowIfNull(encoder);
- ThrowIfDirectoryDoesntExist(filename);
-
- IntPtr encoderParamsMemory = IntPtr.Zero;
-
- if (encoderParams != null)
- {
- _rawData = null;
- encoderParamsMemory = encoderParams.ConvertToMemory();
- }
-
- try
- {
- Guid g = encoder.Clsid;
- bool saved = false;
-
- if (_rawData != null)
- {
- ImageCodecInfo? rawEncoder = RawFormat.FindEncoder();
- if (rawEncoder != null && rawEncoder.Clsid == g)
- {
- using (FileStream fs = File.OpenWrite(filename))
- {
- fs.Write(_rawData, 0, _rawData.Length);
- saved = true;
- }
- }
- }
-
- if (!saved)
- {
- Gdip.CheckStatus(Gdip.GdipSaveImageToFile(
- new HandleRef(this, nativeImage),
- filename,
- ref g,
- new HandleRef(encoderParams, encoderParamsMemory)));
- }
- }
- finally
- {
- if (encoderParamsMemory != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(encoderParamsMemory);
- }
- }
- }
-
- private void Save(MemoryStream stream)
- {
- // Jpeg loses data, so we don't want to use it to serialize...
- ImageFormat dest = RawFormat;
- if (dest.Guid == ImageFormat.Jpeg.Guid)
- dest = ImageFormat.Png;
-
- // If we don't find an Encoder (for things like Icon), we just switch back to PNG...
- ImageCodecInfo codec = dest.FindEncoder() ?? ImageFormat.Png.FindEncoder()!;
-
- Save(stream, codec, null);
- }
-
- ///
- /// Saves this to the specified stream in the specified format.
- ///
- public void Save(Stream stream, ImageFormat format)
- {
- ArgumentNullException.ThrowIfNull(format);
-
- ImageCodecInfo codec = format.FindEncoder()!;
- Save(stream, codec, null);
- }
-
- ///
- /// Saves this to the specified stream in the specified format.
- ///
- public void Save(Stream stream, ImageCodecInfo encoder, EncoderParameters? encoderParams)
- {
- ArgumentNullException.ThrowIfNull(stream);
- ArgumentNullException.ThrowIfNull(encoder);
-
- IntPtr encoderParamsMemory = IntPtr.Zero;
-
- if (encoderParams != null)
- {
- _rawData = null;
- encoderParamsMemory = encoderParams.ConvertToMemory();
- }
-
- try
- {
- Guid g = encoder.Clsid;
- bool saved = false;
-
- if (_rawData != null)
- {
- ImageCodecInfo? rawEncoder = RawFormat.FindEncoder();
- if (rawEncoder != null && rawEncoder.Clsid == g)
- {
- stream.Write(_rawData, 0, _rawData.Length);
- saved = true;
- }
- }
-
- if (!saved)
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream, makeSeekable: false));
- unsafe
- {
- Gdip.CheckStatus(Gdip.GdipSaveImageToStream(
- new HandleRef(this, nativeImage),
- streamWrapper.Ptr,
- &g,
- new HandleRef(encoderParams, encoderParamsMemory)));
- }
- }
- }
- finally
- {
- if (encoderParamsMemory != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(encoderParamsMemory);
- }
- }
- }
-
- ///
- /// Adds an to this .
- ///
- public void SaveAdd(EncoderParameters? encoderParams)
- {
- IntPtr encoder = IntPtr.Zero;
- if (encoderParams != null)
- encoder = encoderParams.ConvertToMemory();
-
- _rawData = null;
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipSaveAdd(new HandleRef(this, nativeImage), new HandleRef(encoderParams, encoder)));
- }
- finally
- {
- if (encoder != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(encoder);
- }
- }
- }
-
- ///
- /// Adds an to the specified .
- ///
- public void SaveAdd(Image image, EncoderParameters? encoderParams)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- IntPtr encoder = IntPtr.Zero;
-
- if (encoderParams != null)
- encoder = encoderParams.ConvertToMemory();
-
- _rawData = null;
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipSaveAddImage(
- new HandleRef(this, nativeImage),
- new HandleRef(image, image.nativeImage),
- new HandleRef(encoderParams, encoder)));
- }
- finally
- {
- if (encoder != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(encoder);
- }
- }
- }
-
- private static void ThrowIfDirectoryDoesntExist(string filename)
- {
- var directoryPart = System.IO.Path.GetDirectoryName(filename);
- if (!string.IsNullOrEmpty(directoryPart) && !System.IO.Directory.Exists(directoryPart))
- {
- throw new DirectoryNotFoundException(SR.Format(SR.TargetDirectoryDoesNotExist, directoryPart, filename));
- }
- }
-
- ///
- /// Gets the width and height of this .
- ///
- public SizeF PhysicalDimension
- {
- get
- {
- float width;
- float height;
-
- int status = Gdip.GdipGetImageDimension(new HandleRef(this, nativeImage), out width, out height);
- Gdip.CheckStatus(status);
-
- return new SizeF(width, height);
- }
- }
-
- ///
- /// Gets the width and height of this .
- ///
- public Size Size => new Size(Width, Height);
-
- ///
- /// Gets the width of this .
- ///
- [DefaultValue(false)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public int Width
- {
- get
- {
- int width;
-
- int status = Gdip.GdipGetImageWidth(new HandleRef(this, nativeImage), out width);
- Gdip.CheckStatus(status);
-
- return width;
- }
- }
-
- ///
- /// Gets the height of this .
- ///
- [DefaultValue(false)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public int Height
- {
- get
- {
- int height;
-
- int status = Gdip.GdipGetImageHeight(new HandleRef(this, nativeImage), out height);
- Gdip.CheckStatus(status);
-
- return height;
- }
- }
-
- ///
- /// Gets the horizontal resolution, in pixels-per-inch, of this .
- ///
- public float HorizontalResolution
- {
- get
- {
- float horzRes;
-
- int status = Gdip.GdipGetImageHorizontalResolution(new HandleRef(this, nativeImage), out horzRes);
- Gdip.CheckStatus(status);
-
- return horzRes;
- }
- }
-
- ///
- /// Gets the vertical resolution, in pixels-per-inch, of this .
- ///
- public float VerticalResolution
- {
- get
- {
- float vertRes;
-
- int status = Gdip.GdipGetImageVerticalResolution(new HandleRef(this, nativeImage), out vertRes);
- Gdip.CheckStatus(status);
-
- return vertRes;
- }
- }
-
- ///
- /// Gets attribute flags for this .
- ///
- [Browsable(false)]
- public int Flags
- {
- get
- {
- int flags;
-
- int status = Gdip.GdipGetImageFlags(new HandleRef(this, nativeImage), out flags);
- Gdip.CheckStatus(status);
-
- return flags;
- }
- }
-
- ///
- /// Gets the format of this .
- ///
- public ImageFormat RawFormat
- {
- get
- {
- Guid guid = default;
-
- int status = Gdip.GdipGetImageRawFormat(new HandleRef(this, nativeImage), ref guid);
- Gdip.CheckStatus(status);
-
- return new ImageFormat(guid);
- }
- }
-
- ///
- /// Gets the pixel format for this .
- ///
- public PixelFormat PixelFormat
- {
- get
- {
- int status = Gdip.GdipGetImagePixelFormat(new HandleRef(this, nativeImage), out PixelFormat format);
- return (status != Gdip.Ok) ? PixelFormat.Undefined : format;
- }
- }
-
- ///
- /// Gets an array of the property IDs stored in this .
- ///
- [Browsable(false)]
- public unsafe int[] PropertyIdList
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPropertyCount(new HandleRef(this, nativeImage), out uint count));
- if (count == 0)
- return Array.Empty();
-
- var propid = new int[count];
- fixed (int* pPropid = propid)
- {
- Gdip.CheckStatus(Gdip.GdipGetPropertyIdList(new HandleRef(this, nativeImage), count, pPropid));
- }
-
- return propid;
- }
- }
-
- ///
- /// Gets an array of objects that describe this .
- ///
- [Browsable(false)]
- public unsafe PropertyItem[] PropertyItems
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetPropertySize(new HandleRef(this, nativeImage), out uint size, out uint count));
-
- if (size == 0 || count == 0)
- return Array.Empty();
-
- var result = new PropertyItem[(int)count];
- byte[] buffer = ArrayPool.Shared.Rent((int)size);
- fixed (byte *pBuffer = buffer)
- {
- PropertyItemInternal* pPropData = (PropertyItemInternal*)pBuffer;
- Gdip.CheckStatus(Gdip.GdipGetAllPropertyItems(new HandleRef(this, nativeImage), size, count, pPropData));
-
- for (int i = 0; i < count; i++)
- {
- result[i] = new PropertyItem
- {
- Id = pPropData[i].id,
- Len = pPropData[i].len,
- Type = pPropData[i].type,
- Value = pPropData[i].Value.ToArray()
- };
- }
- }
-
- ArrayPool.Shared.Return(buffer);
- return result;
- }
- }
-
- ///
- /// Gets a bounding rectangle in the specified units for this .
- ///
- public RectangleF GetBounds(ref GraphicsUnit pageUnit)
- {
- Gdip.CheckStatus(Gdip.GdipGetImageBounds(new HandleRef(this, nativeImage), out RectangleF bounds, out pageUnit));
- return bounds;
- }
-
- ///
- /// Gets or sets the color palette used for this .
- ///
- [Browsable(false)]
- public ColorPalette Palette
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipGetImagePaletteSize(new HandleRef(this, nativeImage), out int size));
-
- // "size" is total byte size:
- // sizeof(ColorPalette) + (pal->Count-1)*sizeof(ARGB)
-
- ColorPalette palette = new ColorPalette(size);
-
- // Memory layout is:
- // UINT Flags
- // UINT Count
- // ARGB Entries[size]
-
- IntPtr memory = Marshal.AllocHGlobal(size);
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetImagePalette(new HandleRef(this, nativeImage), memory, size));
- palette.ConvertFromMemory(memory);
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return palette;
- }
- set
- {
- IntPtr memory = value.ConvertToMemory();
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipSetImagePalette(new HandleRef(this, nativeImage), memory));
- }
- finally
- {
- if (memory != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(memory);
- }
- }
- }
- }
-
- // Thumbnail support
-
- ///
- /// Returns the thumbnail for this .
- ///
- public Image GetThumbnailImage(int thumbWidth, int thumbHeight, GetThumbnailImageAbort? callback, IntPtr callbackData)
- {
- IntPtr thumbImage;
-
- Gdip.CheckStatus(Gdip.GdipGetImageThumbnail(
- new HandleRef(this, nativeImage),
- thumbWidth,
- thumbHeight,
- out thumbImage,
- callback,
- callbackData));
-
- return CreateImageObject(thumbImage);
- }
-
- internal static void ValidateImage(IntPtr image)
- {
- try
- {
- Gdip.CheckStatus(Gdip.GdipImageForceValidation(image));
- }
- catch
- {
- Gdip.GdipDisposeImage(image);
- throw;
- }
- }
-
- ///
- /// Returns the number of frames of the given dimension.
- ///
- public int GetFrameCount(FrameDimension dimension)
- {
- Guid dimensionID = dimension.Guid;
- Gdip.CheckStatus(Gdip.GdipImageGetFrameCount(new HandleRef(this, nativeImage), ref dimensionID, out int count));
- return count;
- }
-
- ///
- /// Gets the specified property item from this .
- ///
- public unsafe PropertyItem? GetPropertyItem(int propid)
- {
- Gdip.CheckStatus(Gdip.GdipGetPropertyItemSize(new HandleRef(this, nativeImage), propid, out uint size));
-
- if (size == 0)
- return null;
-
- PropertyItem result;
- byte[] buffer = ArrayPool.Shared.Rent((int)size);
- fixed (byte *pBuffer = buffer)
- {
- PropertyItemInternal* pPropData = (PropertyItemInternal*)pBuffer;
- Gdip.CheckStatus(Gdip.GdipGetPropertyItem(new HandleRef(this, nativeImage), propid, size, pPropData));
-
- result = new PropertyItem
- {
- Id = pPropData->id,
- Len = pPropData->len,
- Type = pPropData->type,
- Value = pPropData->Value.ToArray()
- };
- }
-
- ArrayPool.Shared.Return(buffer);
- return result;
- }
-
- ///
- /// Selects the frame specified by the given dimension and index.
- ///
- public int SelectActiveFrame(FrameDimension dimension, int frameIndex)
- {
- Guid dimensionID = dimension.Guid;
- Gdip.CheckStatus(Gdip.GdipImageSelectActiveFrame(new HandleRef(this, nativeImage), ref dimensionID, frameIndex));
- return 0;
- }
-
- ///
- /// Sets the specified property item to the specified value.
- ///
- public unsafe void SetPropertyItem(PropertyItem propitem)
- {
- fixed (byte *propItemValue = propitem.Value)
- {
- var propItemInternal = new PropertyItemInternal
- {
- id = propitem.Id,
- len = propitem.Len,
- type = propitem.Type,
- value = propItemValue
- };
- Gdip.CheckStatus(Gdip.GdipSetPropertyItem(new HandleRef(this, nativeImage), &propItemInternal));
- }
- }
-
- public void RotateFlip(RotateFlipType rotateFlipType)
- {
- int status = Gdip.GdipImageRotateFlip(new HandleRef(this, nativeImage), unchecked((int)rotateFlipType));
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Removes the specified property item from this .
- ///
- public void RemovePropertyItem(int propid)
- {
- int status = Gdip.GdipRemovePropertyItem(new HandleRef(this, nativeImage), propid);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Returns information about the codecs used for this .
- ///
- public EncoderParameters? GetEncoderParameterList(Guid encoder)
- {
- EncoderParameters p;
-
- Gdip.CheckStatus(Gdip.GdipGetEncoderParameterListSize(
- new HandleRef(this, nativeImage),
- ref encoder,
- out int size));
-
- if (size <= 0)
- return null;
-
- IntPtr buffer = Marshal.AllocHGlobal(size);
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetEncoderParameterList(
- new HandleRef(this, nativeImage),
- ref encoder,
- size,
- buffer));
-
- p = EncoderParameters.ConvertFromMemory(buffer);
- }
- finally
- {
- Marshal.FreeHGlobal(buffer);
- }
-
- return p;
- }
-
- ///
- /// Creates a from a Windows handle.
- ///
- public static Bitmap FromHbitmap(IntPtr hbitmap) => FromHbitmap(hbitmap, IntPtr.Zero);
-
- ///
- /// Creates a from the specified Windows handle with the specified color palette.
- ///
- public static Bitmap FromHbitmap(IntPtr hbitmap, IntPtr hpalette)
- {
- Gdip.CheckStatus(Gdip.GdipCreateBitmapFromHBITMAP(hbitmap, hpalette, out IntPtr bitmap));
- return new Bitmap(bitmap);
- }
-
- ///
- /// Returns a value indicating whether the pixel format is extended.
- ///
- public static bool IsExtendedPixelFormat(PixelFormat pixfmt)
- {
- return (pixfmt & PixelFormat.Extended) != 0;
- }
-
- ///
- /// Returns a value indicating whether the pixel format is canonical.
- ///
- public static bool IsCanonicalPixelFormat(PixelFormat pixfmt)
- {
- // Canonical formats:
- //
- // PixelFormat32bppARGB
- // PixelFormat32bppPARGB
- // PixelFormat64bppARGB
- // PixelFormat64bppPARGB
-
- return (pixfmt & PixelFormat.Canonical) != 0;
- }
-
- internal void SetNativeImage(IntPtr handle)
- {
- if (handle == IntPtr.Zero)
- throw new ArgumentException(SR.NativeHandle0, nameof(handle));
-
- nativeImage = handle;
- }
-
- // Multi-frame support
-
- ///
- /// Gets an array of GUIDs that represent the dimensions of frames within this .
- ///
- [Browsable(false)]
- public unsafe Guid[] FrameDimensionsList
- {
- get
- {
- Gdip.CheckStatus(Gdip.GdipImageGetFrameDimensionsCount(new HandleRef(this, nativeImage), out int count));
-
- Debug.Assert(count >= 0, "FrameDimensionsList returns bad count");
- if (count <= 0)
- return Array.Empty();
-
- Guid[] guids = new Guid[count];
- fixed (Guid* g = guids)
- {
- Gdip.CheckStatus(Gdip.GdipImageGetFrameDimensionsList(new HandleRef(this, nativeImage), g, count));
- }
-
- return guids;
- }
- }
-
- ///
- /// Returns the size of the specified pixel format.
- ///
- public static int GetPixelFormatSize(PixelFormat pixfmt)
- {
- return (unchecked((int)pixfmt) >> 8) & 0xFF;
- }
-
- ///
- /// Returns a value indicating whether the pixel format contains alpha information.
- ///
- public static bool IsAlphaPixelFormat(PixelFormat pixfmt)
- {
- return (pixfmt & PixelFormat.Alpha) != 0;
- }
-
- internal static Image CreateImageObject(IntPtr nativeImage)
- {
- Gdip.CheckStatus(Gdip.GdipGetImageType(nativeImage, out int type));
- switch ((ImageType)type)
- {
- case ImageType.Bitmap:
- return new Bitmap(nativeImage);
- case ImageType.Metafile:
- return new Metafile(nativeImage);
- default:
- throw new ArgumentException(SR.InvalidImage);
- }
- }
-
- internal static unsafe void EnsureSave(Image image, string? filename, Stream? dataStream)
- {
- if (image.RawFormat.Equals(ImageFormat.Gif))
- {
- bool animatedGif = false;
-
- Gdip.CheckStatus(Gdip.GdipImageGetFrameDimensionsCount(new HandleRef(image, image.nativeImage), out int dimensions));
- if (dimensions <= 0)
- {
- return;
- }
-
- Span guids = dimensions < 16 ?
- stackalloc Guid[dimensions] :
- new Guid[dimensions];
-
- fixed (Guid* g = &MemoryMarshal.GetReference(guids))
- {
- Gdip.CheckStatus(Gdip.GdipImageGetFrameDimensionsList(new HandleRef(image, image.nativeImage), g, dimensions));
- }
-
- Guid timeGuid = FrameDimension.Time.Guid;
- for (int i = 0; i < dimensions; i++)
- {
- if (timeGuid == guids[i])
- {
- animatedGif = image.GetFrameCount(FrameDimension.Time) > 1;
- break;
- }
- }
-
- if (animatedGif)
- {
- try
- {
- Stream? created = null;
- long lastPos = 0;
- if (dataStream != null)
- {
- lastPos = dataStream.Position;
- dataStream.Position = 0;
- }
-
- try
- {
- if (dataStream == null)
- {
- created = dataStream = File.OpenRead(filename!);
- }
-
- image._rawData = new byte[(int)dataStream.Length];
- dataStream.Read(image._rawData, 0, (int)dataStream.Length);
- }
- finally
- {
- if (created != null)
- {
- created.Close();
- }
- else
- {
- dataStream!.Position = lastPos;
- }
- }
- }
- // possible exceptions for reading the filename
- catch (UnauthorizedAccessException)
- {
- }
- catch (DirectoryNotFoundException)
- {
- }
- catch (IOException)
- {
- }
- // possible exceptions for setting/getting the position inside dataStream
- catch (NotSupportedException)
- {
- }
- catch (ObjectDisposedException)
- {
- }
- // possible exception when reading stuff into dataStream
- catch (ArgumentException)
- {
- }
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs
deleted file mode 100644
index e0b89339d4d73..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.cs
+++ /dev/null
@@ -1,426 +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.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Imaging;
-using System.Threading;
-
-namespace System.Drawing
-{
- ///
- /// Animates one or more images that have time-based frames.
- /// See the ImageInfo.cs file for the helper nested ImageInfo class.
- ///
- /// A common pattern for using this class is as follows (See PictureBox control):
- /// 1. The winform app (user's code) calls ImageAnimator.Animate() from the main thread.
- /// 2. Animate() spawns the animating (worker) thread in the background, which will update the image
- /// frames and raise the OnFrameChanged event, which handler will be executed in the main thread.
- /// 3. The main thread triggers a paint event (Invalidate()) from the OnFrameChanged handler.
- /// 4. From the OnPaint event, the main thread calls ImageAnimator.UpdateFrames() and then paints the
- /// image (updated frame).
- /// 5. The main thread calls ImageAnimator.StopAnimate() when needed. This does not kill the worker thread.
- ///
- /// Comment on locking the image ref:
- /// We need to synchronize access to sections of code that modify the image(s), but we don't want to block
- /// animation of one image when modifying a different one; for this, we use the image ref for locking the
- /// critical section (lock(image)).
- ///
- /// This class is safe for multi-threading but Image is not; multithreaded applications must use a critical
- /// section lock using the image ref the image access is not from the same thread that executes ImageAnimator
- /// code. If the user code locks on the image ref forever a deadlock will happen preventing the animation
- /// from occurring.
- ///
- public sealed partial class ImageAnimator
- {
- // We use a timer to apply an animation tick speeds of something a bit shorter than 50ms
- // such that if the requested frame rate is about 20 frames per second, we will rarely skip
- // a frame entirely. Sometimes we'll show a few more frames if available, but we will never
- // show more than 25 frames a second and that's OK.
- internal const int AnimationDelayMS = 40;
-
- ///
- /// A list of images to be animated.
- ///
- private static List? s_imageInfoList;
-
- ///
- /// A variable to flag when an image or images need to be updated due to the selection of a new frame
- /// in an image. We don't need to synchronize access to this variable, in the case it is true we don't
- /// do anything, otherwise the worse case is where a thread attempts to update the image's frame after
- /// another one did which is harmless.
- ///
- private static bool s_anyFrameDirty;
-
- ///
- /// The thread used for animating the images.
- ///
- private static Thread? s_animationThread;
-
- ///
- /// Lock that allows either concurrent read-access to the images list for multiple threads, or write-
- /// access to it for a single thread. Observe that synchronization access to image objects are done
- /// with critical sections (lock).
- ///
- private static readonly ReaderWriterLock s_rwImgListLock = new ReaderWriterLock();
-
- ///
- /// Flag to avoid a deadlock when waiting on a write-lock and an attempt to acquire a read-lock is
- /// made in the same thread. If RWLock is currently owned by another thread, the current thread is going to wait on an
- /// event using CoWaitForMultipleHandles while pumps message.
- /// The comment above refers to the COM STA message pump, not to be confused with the UI message pump.
- /// However, the effect is the same, the COM message pump will pump messages and dispatch them to the
- /// window while waiting on the writer lock; this has the potential of creating a re-entrancy situation
- /// that if during the message processing a wait on a reader lock is originated the thread will be block
- /// on itself.
- /// While processing STA message, the thread may call back into managed code. We do this because
- /// we can not block finalizer thread. Finalizer thread may need to release STA objects on this thread. If
- /// the current thread does not pump message, finalizer thread is blocked, and AD unload is blocked while
- /// waiting for finalizer thread. RWLock is a fair lock. If a thread waits for a writer lock, then it needs
- /// a reader lock while pumping message, the thread is blocked forever.
- /// This TLS variable is used to flag the above situation and avoid the deadlock, it is ThreadStatic so each
- /// thread calling into ImageAnimator is guarded against this problem.
- ///
-
-
-
-
- [ThreadStatic]
- private static int t_threadWriterLockWaitCount;
-
- ///
- /// Prevent instantiation of this class.
- ///
- private ImageAnimator()
- {
- }
-
- ///
- /// Advances the frame in the specified image. The new frame is drawn the next time the image is rendered.
- ///
- public static void UpdateFrames(Image? image)
- {
- if (image == null || s_imageInfoList == null)
- {
- return;
- }
-
- if (t_threadWriterLockWaitCount > 0)
- {
- // Cannot acquire reader lock - frame update will be missed.
- return;
- }
-
- // If the current thread already has the writer lock, no reader lock is acquired. Instead, the lock count on
- // the writer lock is incremented. It already has a reader lock, the locks ref count will be incremented
- // w/o placing the request at the end of the reader queue.
-
- s_rwImgListLock.AcquireReaderLock(Timeout.Infinite);
-
- try
- {
- bool foundDirty = false;
- bool foundImage = false;
-
- foreach (ImageInfo imageInfo in s_imageInfoList)
- {
- if (imageInfo.Image == image)
- {
- if (imageInfo.FrameDirty)
- {
- // See comment in the class header about locking the image ref.
- lock (imageInfo.Image)
- {
- imageInfo.UpdateFrame();
- }
- }
-
- foundImage = true;
- }
- else if (imageInfo.FrameDirty)
- {
- foundDirty = true;
- }
-
- if (foundDirty && foundImage)
- {
- break;
- }
- }
-
- s_anyFrameDirty = foundDirty;
- }
- finally
- {
- s_rwImgListLock.ReleaseReaderLock();
- }
- }
-
- ///
- /// Advances the frame in all images currently being animated. The new frame is drawn the next time the image is rendered.
- ///
- public static void UpdateFrames()
- {
- if (!s_anyFrameDirty || s_imageInfoList == null)
- {
- return;
- }
-
- if (t_threadWriterLockWaitCount > 0)
- {
- // Cannot acquire reader lock at this time, frames update will be missed.
- return;
- }
-
- s_rwImgListLock.AcquireReaderLock(Timeout.Infinite);
-
- try
- {
- foreach (ImageInfo imageInfo in s_imageInfoList)
- {
- // See comment in the class header about locking the image ref.
- lock (imageInfo.Image)
- {
- imageInfo.UpdateFrame();
- }
- }
-
- s_anyFrameDirty = false;
- }
- finally
- {
- s_rwImgListLock.ReleaseReaderLock();
- }
- }
-
- ///
- /// Adds an image to the image manager. If the image does not support animation this method does nothing.
- /// This method creates the image list and spawns the animation thread the first time it is called.
- ///
- public static void Animate(Image image, EventHandler onFrameChangedHandler)
- {
- if (image == null)
- {
- return;
- }
-
- ImageInfo? imageInfo = null;
-
- // See comment in the class header about locking the image ref.
- lock (image)
- {
- // could we avoid creating an ImageInfo object if FrameCount == 1 ?
- imageInfo = new ImageInfo(image);
- }
-
- // If the image is already animating, stop animating it
- StopAnimate(image, onFrameChangedHandler);
-
- // Acquire a writer lock to modify the image info list. If the thread has a reader lock we need to upgrade
- // it to a writer lock; acquiring a reader lock in this case would block the thread on itself.
- // If the thread already has a writer lock its ref count will be incremented w/o placing the request in the
- // writer queue. See ReaderWriterLock.AcquireWriterLock method in the MSDN.
-
- bool readerLockHeld = s_rwImgListLock.IsReaderLockHeld;
- LockCookie lockDowngradeCookie = default;
-
- t_threadWriterLockWaitCount++;
-
- try
- {
- if (readerLockHeld)
- {
- lockDowngradeCookie = s_rwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
- }
- else
- {
- s_rwImgListLock.AcquireWriterLock(Timeout.Infinite);
- }
- }
- finally
- {
- t_threadWriterLockWaitCount--;
- Debug.Assert(t_threadWriterLockWaitCount >= 0, "threadWriterLockWaitCount less than zero.");
- }
-
- try
- {
- if (imageInfo.Animated)
- {
- // Construct the image array
- //
- s_imageInfoList ??= new List();
-
- // Add the new image
- //
- imageInfo.FrameChangedHandler = onFrameChangedHandler;
- s_imageInfoList.Add(imageInfo);
-
- // Construct a new timer thread if we haven't already
- //
- if (s_animationThread == null)
- {
- s_animationThread = new Thread(new ThreadStart(AnimateImages));
- s_animationThread.Name = nameof(ImageAnimator);
- s_animationThread.IsBackground = true;
- s_animationThread.Start();
- }
- }
- }
- finally
- {
- if (readerLockHeld)
- {
- s_rwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
- }
- else
- {
- s_rwImgListLock.ReleaseWriterLock();
- }
- }
- }
-
- ///
- /// Whether or not the image has multiple time-based frames.
- ///
- public static bool CanAnimate([NotNullWhen(true)] Image? image)
- {
- if (image == null)
- {
- return false;
- }
-
- // See comment in the class header about locking the image ref.
- lock (image)
- {
- Guid[] dimensions = image.FrameDimensionsList;
-
- foreach (Guid guid in dimensions)
- {
- FrameDimension dimension = new FrameDimension(guid);
- if (dimension.Equals(FrameDimension.Time))
- {
- return image.GetFrameCount(FrameDimension.Time) > 1;
- }
- }
- }
-
- return false;
- }
-
- ///
- /// Removes an image from the image manager so it is no longer animated.
- ///
- public static void StopAnimate(Image image, EventHandler onFrameChangedHandler)
- {
- // Make sure we have a list of images
- if (image == null || s_imageInfoList == null)
- {
- return;
- }
-
- // Acquire a writer lock to modify the image info list - See comments on Animate() about this locking.
-
- bool readerLockHeld = s_rwImgListLock.IsReaderLockHeld;
- LockCookie lockDowngradeCookie = default;
-
- t_threadWriterLockWaitCount++;
-
- try
- {
- if (readerLockHeld)
- {
- lockDowngradeCookie = s_rwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
- }
- else
- {
- s_rwImgListLock.AcquireWriterLock(Timeout.Infinite);
- }
- }
- finally
- {
- t_threadWriterLockWaitCount--;
- Debug.Assert(t_threadWriterLockWaitCount >= 0, "threadWriterLockWaitCount less than zero.");
- }
-
- try
- {
- // Find the corresponding reference and remove it
- for (int i = 0; i < s_imageInfoList.Count; i++)
- {
- ImageInfo imageInfo = s_imageInfoList[i];
-
- if (image == imageInfo.Image)
- {
- if ((onFrameChangedHandler == imageInfo.FrameChangedHandler) || (onFrameChangedHandler != null && onFrameChangedHandler.Equals(imageInfo.FrameChangedHandler)))
- {
- s_imageInfoList.Remove(imageInfo);
- }
- break;
- }
- }
- }
- finally
- {
- if (readerLockHeld)
- {
- s_rwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
- }
- else
- {
- s_rwImgListLock.ReleaseWriterLock();
- }
- }
- }
-
- ///
- /// Worker thread procedure which implements the main animation loop.
- /// NOTE: This is the ONLY code the worker thread executes, keeping it in one method helps better understand
- /// any synchronization issues.
- /// WARNING: Also, this is the only place where ImageInfo objects (not the contained image object) are modified,
- /// so no access synchronization is required to modify them.
- ///
- private static void AnimateImages()
- {
- Debug.Assert(s_imageInfoList != null, "Null images list");
-
- Stopwatch stopwatch = Stopwatch.StartNew();
-
- while (true)
- {
- Thread.Sleep(AnimationDelayMS);
-
- // Because Thread.Sleep is not accurate, capture how much time has actually elapsed during the animation
- long timeElapsed = stopwatch.ElapsedMilliseconds;
- stopwatch.Restart();
-
- // Acquire reader-lock to access imageInfoList, elements in the list can be modified w/o needing a writer-lock.
- // Observe that we don't need to check if the thread is waiting or a writer lock here since the thread this
- // method runs in never acquires a writer lock.
- s_rwImgListLock.AcquireReaderLock(Timeout.Infinite);
- try
- {
- for (int i = 0; i < s_imageInfoList.Count; i++)
- {
- ImageInfo imageInfo = s_imageInfoList[i];
-
- if (imageInfo.Animated)
- {
- imageInfo.AdvanceAnimationBy(timeElapsed);
-
- if (imageInfo.FrameDirty)
- {
- s_anyFrameDirty = true;
- }
- }
- }
- }
- finally
- {
- s_rwImgListLock.ReleaseReaderLock();
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageConverter.cs
deleted file mode 100644
index 66a00b47edb30..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageConverter.cs
+++ /dev/null
@@ -1,164 +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.Buffers.Binary;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Imaging;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-
-namespace System.Drawing
-{
- public class ImageConverter : TypeConverter
- {
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type? sourceType)
- {
- return sourceType == typeof(byte[]) || sourceType == typeof(Icon);
- }
-
- public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
- {
- return destinationType == typeof(byte[]) || destinationType == typeof(string);
- }
-
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- if (value is Icon icon)
- {
- return icon.ToBitmap();
- }
-
- if (value is byte[] bytes)
- {
- Debug.Assert(value != null, "value is null.");
- // Try to get memory stream for images with ole header.
- MemoryStream memStream = GetBitmapStream(bytes) ?? new MemoryStream(bytes);
- return Image.FromStream(memStream);
- }
- else
- {
- return base.ConvertFrom(context, culture, value);
- }
- }
-
- public override object ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
- {
- if (destinationType == typeof(string))
- {
- if (value == null)
- {
- return SR.none;
- }
- else if (value is Image)
- {
- return value.ToString()!;
- }
- }
- else if (destinationType == typeof(byte[]))
- {
- if (value == null)
- {
- return Array.Empty();
- }
- else if (value is Image image)
- {
- using (MemoryStream ms = new MemoryStream())
- {
- ImageFormat dest = image.RawFormat;
- // Jpeg loses data, so we don't want to use it to serialize.
- if (dest == ImageFormat.Jpeg)
- {
- dest = ImageFormat.Png;
- }
-
- // If we don't find an Encoder (for things like Icon), we
- // just switch back to PNG.
- ImageCodecInfo codec = FindEncoder(dest) ?? FindEncoder(ImageFormat.Png)!;
- image.Save(ms, codec, null);
- return ms.ToArray();
- }
- }
- }
-
- throw GetConvertFromException(value);
- }
-
- // Find any random encoder which supports this format.
- private static ImageCodecInfo? FindEncoder(ImageFormat imageformat)
- {
- ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
- foreach (ImageCodecInfo codec in codecs)
- {
- if (codec.FormatID.Equals(imageformat.Guid))
- return codec;
- }
- return null;
- }
-
- [RequiresUnreferencedCode("The Type of value cannot be statically discovered. The public parameterless constructor or the 'Default' static field may be trimmed from the Attribute's Type.")]
- public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext? context, object? value, Attribute[]? attributes)
- {
- return TypeDescriptor.GetProperties(typeof(Image), attributes);
- }
-
- public override bool GetPropertiesSupported(ITypeDescriptorContext? context) => true;
-
- private static unsafe MemoryStream? GetBitmapStream(ReadOnlySpan rawData)
- {
- try
- {
- short signature = BinaryPrimitives.ReadInt16LittleEndian(rawData);
-
- if (signature != 0x1c15)
- {
- return null;
- }
-
- // The data is in the form of OBJECTHEADER. It's an encoded format that Access uses to push images into the DB.
- //
- // The layout of OBJECTHEADER is as follows - we only need the signature
- // and headersize fields, which need to be read as little-endian data:
- //
- // [StructLayout(LayoutKind.Sequential)]
- // private struct OBJECTHEADER
- // {
- // public short signature; // it's always 0x1c15
- // public short headersize;
- // public short objectType;
- // public short nameLen;
- // public short classLen;
- // public short nameOffset;
- // public short classOffset;
- // public short width;
- // public short height;
- // public IntPtr pInfo;
- // }
- short headersize = BinaryPrimitives.ReadInt16LittleEndian(rawData.Slice(2, 2));
-
- // pHeader.signature will always be 0x1c15.
- // "PBrush" should be the 6 chars after position 12 as well.
- if (rawData.Length <= headersize + 18 ||
- !rawData.Slice(headersize + 12, 6).SequenceEqual("PBrush"u8))
- {
- return null;
- }
-
- // We can safely trust that we've got a bitmap.
- // The start of our bitmap data in the rawdata is always 78.
- return new MemoryStream(rawData.Slice(78).ToArray());
- }
- catch (OutOfMemoryException) // This exception may be caused by creating a new MemoryStream.
- {
- }
- catch (ArgumentOutOfRangeException) // This exception may get thrown by MemoryMarshal when input array size is less than the size of the output type.
- {
- }
-
- return null;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs
deleted file mode 100644
index 9bbb729a629a8..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageFormatConverter.cs
+++ /dev/null
@@ -1,145 +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.ComponentModel;
-using System.ComponentModel.Design.Serialization;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Imaging;
-using System.Globalization;
-using System.Reflection;
-
-namespace System.Drawing
-{
- [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Heif and Webp are referenced here for " +
- "design-time support, the user is responsible to ensure that they are used on a supported version of Windows.")]
- public class ImageFormatConverter : TypeConverter
- {
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
- {
- return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
- }
-
- public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
- {
- if ((destinationType == typeof(string)) || (destinationType == typeof(InstanceDescriptor)))
- {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- // we must be able to convert from short names and long names
- string? strFormat = value as string;
- if (strFormat == null)
- {
- // case #1, this is not a string
- return base.ConvertFrom(context, culture, value);
- }
-
- if ((strFormat[0] == '[') && (strFormat.Length >= 50) && Guid.TryParse(strFormat.AsSpan(14, 36), out Guid guid))
- {
- // case #2, this is probably a long format (guid)
- return new ImageFormat(guid);
- }
-
- // case #3, this is probably a short format
- if (strFormat.Equals("Bmp", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Bmp;
- else if (strFormat.Equals("Emf", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Emf;
- else if (strFormat.Equals("Exif", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Exif;
- else if (strFormat.Equals("Gif", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Gif;
- else if (strFormat.Equals("Icon", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Icon;
- else if (strFormat.Equals("Jpeg", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Jpeg;
- else if (strFormat.Equals("MemoryBmp", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.MemoryBmp;
- else if (strFormat.Equals("Png", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Png;
- else if (strFormat.Equals("Tiff", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Tiff;
- else if (strFormat.Equals("Wmf", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Wmf;
- else if (strFormat.Equals("Heif", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Heif;
- else if (strFormat.Equals("Webp", StringComparison.OrdinalIgnoreCase))
- return ImageFormat.Webp;
-
- throw new FormatException(SR.Format(SR.ConvertInvalidPrimitive, strFormat, nameof(ImageFormat)));
- }
-
- public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
- {
- if (value is ImageFormat imgFormat)
- {
- if (destinationType == typeof(string))
- {
- return imgFormat.ToString();
- }
-
- if (destinationType == typeof(InstanceDescriptor))
- {
- string? strFormat = null;
- if (imgFormat.Guid.Equals(ImageFormat.Bmp.Guid))
- strFormat = "Bmp";
- else if (imgFormat.Guid.Equals(ImageFormat.Emf.Guid))
- strFormat = "Emf";
- else if (imgFormat.Guid.Equals(ImageFormat.Exif.Guid))
- strFormat = "Exif";
- else if (imgFormat.Guid.Equals(ImageFormat.Gif.Guid))
- strFormat = "Gif";
- else if (imgFormat.Guid.Equals(ImageFormat.Icon.Guid))
- strFormat = "Icon";
- else if (imgFormat.Guid.Equals(ImageFormat.Jpeg.Guid))
- strFormat = "Jpeg";
- else if (imgFormat.Guid.Equals(ImageFormat.MemoryBmp.Guid))
- strFormat = "MemoryBmp";
- else if (imgFormat.Guid.Equals(ImageFormat.Png.Guid))
- strFormat = "Png";
- else if (imgFormat.Guid.Equals(ImageFormat.Tiff.Guid))
- strFormat = "Tiff";
- else if (imgFormat.Guid.Equals(ImageFormat.Wmf.Guid))
- strFormat = "Wmf";
-
- if (strFormat != null)
- {
- return new InstanceDescriptor(typeof(ImageFormat).GetProperty(strFormat), null);
- }
- else
- {
- ConstructorInfo? ctor = typeof(ImageFormat).GetConstructor(new Type[] { typeof(Guid) });
- return new InstanceDescriptor(ctor, new object[] { imgFormat.Guid });
- }
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext? context)
- {
- return new TypeConverter.StandardValuesCollection(new ImageFormat[]
- {
- ImageFormat.MemoryBmp,
- ImageFormat.Bmp,
- ImageFormat.Emf,
- ImageFormat.Wmf,
- ImageFormat.Gif,
- ImageFormat.Jpeg,
- ImageFormat.Png,
- ImageFormat.Tiff,
- ImageFormat.Exif,
- ImageFormat.Icon,
- ImageFormat.Heif,
- ImageFormat.Webp
- });
- }
-
- public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageInfo.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageInfo.cs
deleted file mode 100644
index 9eb32d873008a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageInfo.cs
+++ /dev/null
@@ -1,224 +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.Diagnostics;
-using System.Drawing.Imaging;
-
-namespace System.Drawing
-{
- ///
- /// Animates one or more images that have time-based frames. This file contains the nested ImageInfo class
- /// - See ImageAnimator.cs for the definition of the outer class.
- ///
- public sealed partial class ImageAnimator
- {
- ///
- /// ImageAnimator nested helper class used to store extra image state info.
- ///
- private sealed class ImageInfo
- {
- private const int PropertyTagFrameDelay = 0x5100;
- private const int PropertyTagLoopCount = 0x5101;
-
- private readonly Image _image;
- private int _frame;
- private short _loop;
- private readonly int _frameCount;
- private readonly short _loopCount;
- private bool _frameDirty;
- private readonly bool _animated;
- private EventHandler? _onFrameChangedHandler;
- private readonly long[]? _frameEndTimes;
- private readonly long _totalAnimationTime;
- private long _frameTimer;
-
- public ImageInfo(Image image)
- {
- _image = image;
- _animated = ImageAnimator.CanAnimate(image);
- _frameEndTimes = null;
-
- if (_animated)
- {
- _frameCount = image.GetFrameCount(FrameDimension.Time);
-
- PropertyItem? frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
-
- // If the image does not have a frame delay, we just return 0.
- if (frameDelayItem != null)
- {
- // Convert the frame delay from byte[] to int
- byte[] values = frameDelayItem.Value!;
-
- // On Windows, we get the frame delays for every frame. On Linux, we only get the first frame delay.
- // We handle this by treating the frame delays as a repeating sequence, asserting that the sequence
- // is fully repeatable to match the frame count.
- Debug.Assert(values.Length % 4 == 0, "PropertyItem has an invalid value byte array. It should have a length evenly divisible by 4 to represent ints.");
- Debug.Assert(_frameCount % (values.Length / 4) == 0, "PropertyItem has invalid value byte array. The FrameCount should be evenly divisible by a quarter of the byte array's length.");
-
- _frameEndTimes = new long[_frameCount];
- long lastEndTime = 0;
-
- for (int f = 0, i = 0; f < _frameCount; ++f, i += 4)
- {
- if (i >= values.Length)
- {
- i = 0;
- }
-
- // Frame delays are stored in 1/100ths of a second; convert to milliseconds while accumulating
- // Per spec, a frame delay can be 0 which is treated as a single animation tick
- int delay = BitConverter.ToInt32(values, i) * 10;
- lastEndTime += delay > 0 ? delay : ImageAnimator.AnimationDelayMS;
-
- // Guard against overflows
- if (lastEndTime < _totalAnimationTime)
- {
- lastEndTime = _totalAnimationTime;
- }
- else
- {
- _totalAnimationTime = lastEndTime;
- }
-
- _frameEndTimes[f] = lastEndTime;
- }
- }
-
- PropertyItem? loopCountItem = image.GetPropertyItem(PropertyTagLoopCount);
-
- if (loopCountItem != null)
- {
- // The loop count is a short where 0 = infinite, and a positive value indicates the
- // number of times to loop. The animation will be shown 1 time more than the loop count.
- byte[] values = loopCountItem.Value!;
-
- Debug.Assert(values.Length == sizeof(short), "PropertyItem has an invalid byte array. It should represent a single short value.");
- _loopCount = BitConverter.ToInt16(values);
- }
- else
- {
- _loopCount = 0;
- }
- }
- else
- {
- _frameCount = 1;
- }
- }
-
- ///
- /// Whether the image supports animation.
- ///
- public bool Animated => _animated;
-
- ///
- /// The current frame has changed but the image has not yet been updated.
- ///
- public bool FrameDirty => _frameDirty;
-
- public EventHandler? FrameChangedHandler
- {
- get
- {
- return _onFrameChangedHandler;
- }
- set
- {
- _onFrameChangedHandler = value;
- }
- }
-
- ///
- /// The total animation time of the image in milliseconds, or 0 if not animated.
- ///
- private long TotalAnimationTime => Animated ? _totalAnimationTime : 0;
-
- ///
- /// Whether animation should progress, respecting the image's animation support
- /// and if there are animation frames or loops remaining.
- ///
- private bool ShouldAnimate => TotalAnimationTime > 0 ? (_loopCount == 0 || _loop <= _loopCount) : false;
-
- ///
- /// Advance the animation by the specified number of milliseconds. If the advancement
- /// progresses beyond the end time of the current Frame,
- /// will be called. Subscribed handlers often use that event to call
- /// .
- ///
- /// If the animation progresses beyond the end of the image's total animation time,
- /// the animation will loop.
- ///
- ///
- ///
- /// This animation does not respect a GIF's specified number of animation repeats;
- /// instead, animations loop indefinitely.
- ///
- /// The number of milliseconds to advance the animation by
- public void AdvanceAnimationBy(long milliseconds)
- {
- if (ShouldAnimate)
- {
- int oldFrame = _frame;
- _frameTimer += milliseconds;
-
- if (_frameTimer > TotalAnimationTime)
- {
- _loop += (short)Math.DivRem(_frameTimer, TotalAnimationTime, out long newTimer);
- _frameTimer = newTimer;
-
- if (!ShouldAnimate)
- {
- // If we've finished looping, then freeze onto the last frame
- _frame = _frameCount - 1;
- _frameTimer = TotalAnimationTime;
- }
- else if (_frame > 0 && _frameTimer < _frameEndTimes![_frame - 1])
- {
- // If the loop put us before the current frame (which is common)
- // then reset back to the first frame. We will then progress
- // forward again from there (below).
- _frame = 0;
- }
- }
-
- while (_frameTimer > _frameEndTimes![_frame])
- {
- _frame++;
- }
-
- if (_frame != oldFrame)
- {
- _frameDirty = true;
- OnFrameChanged(EventArgs.Empty);
- }
- }
- }
-
- ///
- /// The image this object wraps.
- ///
- internal Image Image => _image;
-
- ///
- /// Selects the current frame as the active frame in the image.
- ///
- internal void UpdateFrame()
- {
- if (_frameDirty)
- {
- _image.SelectActiveFrame(FrameDimension.Time, _frame);
- _frameDirty = false;
- }
- }
-
- ///
- /// Raises the FrameChanged event.
- ///
- private void OnFrameChanged(EventArgs e)
- {
- _onFrameChangedHandler?.Invoke(_image, e);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageType.cs
deleted file mode 100644
index fa15f3d72bd70..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageType.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- internal enum ImageType
- {
- Unknown = 0,
- Bitmap = 1,
- Metafile = 2,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs
deleted file mode 100644
index f9502ca98e2eb..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/BitmapData.cs
+++ /dev/null
@@ -1,126 +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.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the attributes of a bitmap image.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public sealed class BitmapData
- {
- private int _width;
- private int _height;
- private int _stride;
- private PixelFormat _pixelFormat;
- private IntPtr _scan0;
- private int _reserved;
-
- ///
- /// Specifies the pixel width of the .
- ///
- public int Width
- {
- get { return _width; }
- set { _width = value; }
- }
-
- ///
- /// Specifies the pixel height of the .
- ///
- public int Height
- {
- get { return _height; }
- set { _height = value; }
- }
-
- ///
- /// Specifies the stride width of the .
- ///
- public int Stride
- {
- get { return _stride; }
- set { _stride = value; }
- }
-
- ///
- /// Specifies the format of the pixel information in this .
- ///
- public PixelFormat PixelFormat
- {
- get { return _pixelFormat; }
- set
- {
- switch (value)
- {
- case PixelFormat.DontCare:
- // case PixelFormat.Undefined: same as DontCare
- case PixelFormat.Max:
- case PixelFormat.Indexed:
- case PixelFormat.Gdi:
- case PixelFormat.Format16bppRgb555:
- case PixelFormat.Format16bppRgb565:
- case PixelFormat.Format24bppRgb:
- case PixelFormat.Format32bppRgb:
- case PixelFormat.Format1bppIndexed:
- case PixelFormat.Format4bppIndexed:
- case PixelFormat.Format8bppIndexed:
- case PixelFormat.Alpha:
- case PixelFormat.Format16bppArgb1555:
- case PixelFormat.PAlpha:
- case PixelFormat.Format32bppPArgb:
- case PixelFormat.Extended:
- case PixelFormat.Format16bppGrayScale:
- case PixelFormat.Format48bppRgb:
- case PixelFormat.Format64bppPArgb:
- case PixelFormat.Canonical:
- case PixelFormat.Format32bppArgb:
- case PixelFormat.Format64bppArgb:
- break;
- default:
- throw new System.ComponentModel.InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(PixelFormat));
- }
-
- _pixelFormat = value;
- }
- }
-
- ///
- /// Specifies the address of the pixel data.
- ///
- public IntPtr Scan0
- {
- get { return _scan0; }
- set { _scan0 = value; }
- }
-
- ///
- /// Reserved. Do not use.
- ///
- public int Reserved
- {
- get { return _reserved; }
- set { _reserved = value; }
- }
-
- internal ref int GetPinnableReference() => ref _width;
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(BitmapData), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))]
- internal static unsafe class PinningMarshaller
- {
- public static ref int GetPinnableReference(BitmapData managed) => ref (managed is null ? ref Unsafe.NullRef() : ref managed.GetPinnableReference());
-
- // All usages in our currently supported scenarios will always go through GetPinnableReference
- public static int* ConvertToUnmanaged(BitmapData _) => throw new UnreachableException();
- }
-#endif
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorAdjustType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorAdjustType.cs
deleted file mode 100644
index fdda9a3079616..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorAdjustType.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies which GDI+ objects use color adjustment information.
- ///
- public enum ColorAdjustType
- {
- ///
- /// Defines color adjustment information that is used by all GDI+ objects that do not have their own color
- /// adjustment information.
- ///
- Default = 0,
- ///
- /// Defines color adjustment information for
- /// objects.
- ///
- Bitmap,
- ///
- /// Defines color adjustment information for objects.
- ///
- Brush,
- ///
- /// Defines color adjustment information for objects.
- ///
- Pen,
- ///
- /// Defines color adjustment information for text.
- ///
- Text,
- ///
- /// Specifies the number of types specified.
- ///
- Count,
- ///
- /// Specifies the number of types specified.
- ///
- Any
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorChannelFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorChannelFlags.cs
deleted file mode 100644
index 690112ae464cf..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorChannelFlags.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies a range of CMYK channels.
- ///
- public enum ColorChannelFlag
- {
- ///
- /// Specifies the Cyan color channel.
- ///
- ColorChannelC = 0,
- ///
- /// Specifies the Magenta color channel.
- ///
- ColorChannelM,
- ///
- /// Specifies the Yellow color channel.
- ///
- ColorChannelY,
- ///
- /// Specifies the Black color channel.
- ///
- ColorChannelK,
- ///
- /// This element specifies to leave the color channel unchanged from the last selected channel.
- ///
- ColorChannelLast
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMap.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMap.cs
deleted file mode 100644
index 2e747c756eb46..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMap.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Defines a map for converting colors.
- ///
- public sealed class ColorMap
- {
- private Color _oldColor;
- private Color _newColor;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ColorMap()
- {
- }
-
- ///
- /// Specifies the existing to be converted.
- ///
- public Color OldColor
- {
- get { return _oldColor; }
- set { _oldColor = value; }
- }
- ///
- /// Specifies the new to which to convert.
- ///
- public Color NewColor
- {
- get { return _newColor; }
- set { _newColor = value; }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMapType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMapType.cs
deleted file mode 100644
index 04ceaf39048f3..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMapType.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the types of color maps.
- ///
- public enum ColorMapType
- {
- ///
- /// A default color map.
- ///
- Default = 0,
- ///
- /// Specifies a color map for a .
- ///
- Brush
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
deleted file mode 100644
index 7859deb26cb7d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrix.cs
+++ /dev/null
@@ -1,413 +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.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Defines a 5 x 5 matrix that contains the homogeneous coordinates for the RGBA space.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public sealed class ColorMatrix
- {
- private float _matrix00;
- private float _matrix01;
- private float _matrix02;
- private float _matrix03;
- private float _matrix04;
- private float _matrix10;
- private float _matrix11;
- private float _matrix12;
- private float _matrix13;
- private float _matrix14;
- private float _matrix20;
- private float _matrix21;
- private float _matrix22;
- private float _matrix23;
- private float _matrix24;
- private float _matrix30;
- private float _matrix31;
- private float _matrix32;
- private float _matrix33;
- private float _matrix34;
- private float _matrix40;
- private float _matrix41;
- private float _matrix42;
- private float _matrix43;
- private float _matrix44;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ColorMatrix()
- {
- /*
- * Setup identity matrix by default
- */
-
- _matrix00 = 1.0f;
- //matrix01 = 0.0f;
- //matrix02 = 0.0f;
- //matrix03 = 0.0f;
- //matrix04 = 0.0f;
- //matrix10 = 0.0f;
- _matrix11 = 1.0f;
- //matrix12 = 0.0f;
- //matrix13 = 0.0f;
- //matrix14 = 0.0f;
- //matrix20 = 0.0f;
- //matrix21 = 0.0f;
- _matrix22 = 1.0f;
- // matrix23 = 0.0f;
- // matrix24 = 0.0f;
- // matrix30 = 0.0f;
- //matrix31 = 0.0f;
- // matrix32 = 0.0f;
- _matrix33 = 1.0f;
- // matrix34 = 0.0f;
- // matrix40 = 0.0f;
- // matrix41 = 0.0f;
- // matrix42 = 0.0f;
- // matrix43 = 0.0f;
- _matrix44 = 1.0f;
- }
-
- ///
- /// Represents the element at the 0th row and 0th column of this .
- ///
- public float Matrix00
- {
- get { return _matrix00; }
- set { _matrix00 = value; }
- }
- ///
- /// Represents the element at the 0th row and 1st column of this .
- ///
- public float Matrix01
- {
- get { return _matrix01; }
- set { _matrix01 = value; }
- }
-
- ///
- /// Represents the element at the 0th row and 2nd column of this .
- ///
- public float Matrix02
- {
- get { return _matrix02; }
- set { _matrix02 = value; }
- }
-
- ///
- /// Represents the element at the 0th row and 3rd column of this .
- ///
- public float Matrix03
- {
- get { return _matrix03; }
- set { _matrix03 = value; }
- }
-
- ///
- /// Represents the element at the 0th row and 4th column of this .
- ///
- public float Matrix04
- {
- get { return _matrix04; }
- set { _matrix04 = value; }
- }
-
- ///
- /// Represents the element at the 1st row and 0th column of this .
- ///
- public float Matrix10
- {
- get { return _matrix10; }
- set { _matrix10 = value; }
- }
-
- ///
- /// Represents the element at the 1st row and 1st column of this .
- ///
- public float Matrix11
- {
- get { return _matrix11; }
- set { _matrix11 = value; }
- }
-
- ///
- /// Represents the element at the 1st row and 2nd column of this .
- ///
- public float Matrix12
- {
- get { return _matrix12; }
- set { _matrix12 = value; }
- }
-
- ///
- /// Represents the element at the 1st row and 3rd column of this .
- ///
- public float Matrix13
- {
- get { return _matrix13; }
- set { _matrix13 = value; }
- }
-
- ///
- /// Represents the element at the 1st row and 4th column of this .
- ///
- public float Matrix14
- {
- get { return _matrix14; }
- set { _matrix14 = value; }
- }
-
- ///
- /// Represents the element at the 2nd row and 0th column of this .
- ///
- public float Matrix20
- {
- get { return _matrix20; }
- set { _matrix20 = value; }
- }
-
- ///
- /// Represents the element at the 2nd row and 1st column of this .
- ///
- public float Matrix21
- {
- get { return _matrix21; }
- set { _matrix21 = value; }
- }
-
- ///
- /// Represents the element at the 2nd row and 2nd column of this .
- ///
- public float Matrix22
- {
- get { return _matrix22; }
- set { _matrix22 = value; }
- }
-
- ///
- /// Represents the element at the 2nd row and 3rd column of this .
- ///
- public float Matrix23
- {
- get { return _matrix23; }
- set { _matrix23 = value; }
- }
-
- ///
- /// Represents the element at the 2nd row and 4th column of this .
- ///
- public float Matrix24
- {
- get { return _matrix24; }
- set { _matrix24 = value; }
- }
-
- ///
- /// Represents the element at the 3rd row and 0th column of this .
- ///
- public float Matrix30
- {
- get { return _matrix30; }
- set { _matrix30 = value; }
- }
-
- ///
- /// Represents the element at the 3rd row and 1st column of this .
- ///
- public float Matrix31
- {
- get { return _matrix31; }
- set { _matrix31 = value; }
- }
-
- ///
- /// Represents the element at the 3rd row and 2nd column of this .
- ///
- public float Matrix32
- {
- get { return _matrix32; }
- set { _matrix32 = value; }
- }
-
- ///
- /// Represents the element at the 3rd row and 3rd column of this .
- ///
- public float Matrix33
- {
- get { return _matrix33; }
- set { _matrix33 = value; }
- }
-
- ///
- /// Represents the element at the 3rd row and 4th column of this .
- ///
- public float Matrix34
- {
- get { return _matrix34; }
- set { _matrix34 = value; }
- }
-
- ///
- /// Represents the element at the 4th row and 0th column of this .
- ///
- public float Matrix40
- {
- get { return _matrix40; }
- set { _matrix40 = value; }
- }
-
- ///
- /// Represents the element at the 4th row and 1st column of this .
- ///
- public float Matrix41
- {
- get { return _matrix41; }
- set { _matrix41 = value; }
- }
-
- ///
- /// Represents the element at the 4th row and 2nd column of this .
- ///
- public float Matrix42
- {
- get { return _matrix42; }
- set { _matrix42 = value; }
- }
-
- ///
- /// Represents the element at the 4th row and 3rd column of this .
- ///
- public float Matrix43
- {
- get { return _matrix43; }
- set { _matrix43 = value; }
- }
-
- ///
- /// Represents the element at the 4th row and 4th column of this .
- ///
- public float Matrix44
- {
- get { return _matrix44; }
- set { _matrix44 = value; }
- }
-
-
- ///
- /// Initializes a new instance of the class with the elements in the specified matrix.
- ///
- [CLSCompliant(false)]
- public ColorMatrix(float[][] newColorMatrix)
- {
- SetMatrix(newColorMatrix);
- }
-
- internal void SetMatrix(float[][] newColorMatrix)
- {
- _matrix00 = newColorMatrix[0][0];
- _matrix01 = newColorMatrix[0][1];
- _matrix02 = newColorMatrix[0][2];
- _matrix03 = newColorMatrix[0][3];
- _matrix04 = newColorMatrix[0][4];
- _matrix10 = newColorMatrix[1][0];
- _matrix11 = newColorMatrix[1][1];
- _matrix12 = newColorMatrix[1][2];
- _matrix13 = newColorMatrix[1][3];
- _matrix14 = newColorMatrix[1][4];
- _matrix20 = newColorMatrix[2][0];
- _matrix21 = newColorMatrix[2][1];
- _matrix22 = newColorMatrix[2][2];
- _matrix23 = newColorMatrix[2][3];
- _matrix24 = newColorMatrix[2][4];
- _matrix30 = newColorMatrix[3][0];
- _matrix31 = newColorMatrix[3][1];
- _matrix32 = newColorMatrix[3][2];
- _matrix33 = newColorMatrix[3][3];
- _matrix34 = newColorMatrix[3][4];
- _matrix40 = newColorMatrix[4][0];
- _matrix41 = newColorMatrix[4][1];
- _matrix42 = newColorMatrix[4][2];
- _matrix43 = newColorMatrix[4][3];
- _matrix44 = newColorMatrix[4][4];
- }
-
- internal float[][] GetMatrix()
- {
- float[][] returnMatrix = new float[5][];
-
- for (int i = 0; i < 5; i++)
- returnMatrix[i] = new float[5];
-
- returnMatrix[0][0] = _matrix00;
- returnMatrix[0][1] = _matrix01;
- returnMatrix[0][2] = _matrix02;
- returnMatrix[0][3] = _matrix03;
- returnMatrix[0][4] = _matrix04;
- returnMatrix[1][0] = _matrix10;
- returnMatrix[1][1] = _matrix11;
- returnMatrix[1][2] = _matrix12;
- returnMatrix[1][3] = _matrix13;
- returnMatrix[1][4] = _matrix14;
- returnMatrix[2][0] = _matrix20;
- returnMatrix[2][1] = _matrix21;
- returnMatrix[2][2] = _matrix22;
- returnMatrix[2][3] = _matrix23;
- returnMatrix[2][4] = _matrix24;
- returnMatrix[3][0] = _matrix30;
- returnMatrix[3][1] = _matrix31;
- returnMatrix[3][2] = _matrix32;
- returnMatrix[3][3] = _matrix33;
- returnMatrix[3][4] = _matrix34;
- returnMatrix[4][0] = _matrix40;
- returnMatrix[4][1] = _matrix41;
- returnMatrix[4][2] = _matrix42;
- returnMatrix[4][3] = _matrix43;
- returnMatrix[4][4] = _matrix44;
-
- return returnMatrix;
- }
-
- ///
- /// Gets or sets the value of the specified element of this .
- ///
- public float this[int row, int column]
- {
- get
- {
- return GetMatrix()[row][column];
- }
-
- set
- {
- float[][] tempMatrix = GetMatrix();
-
- tempMatrix[row][column] = value;
-
- SetMatrix(tempMatrix);
- }
- }
-
- internal ref float GetPinnableReference() => ref _matrix00;
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(ColorMatrix), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))]
- internal static unsafe class PinningMarshaller
- {
- public static ref float GetPinnableReference(ColorMatrix managed) => ref (managed is null ? ref Unsafe.NullRef() : ref managed.GetPinnableReference());
-
- // All usages in our currently supported scenarios will always go through GetPinnableReference
- public static float* ConvertToUnmanaged(ColorMatrix _) => throw new UnreachableException();
- }
-#endif
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrixFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrixFlags.cs
deleted file mode 100644
index a0c36410f5dfd..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMatrixFlags.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies available options for color-adjusting. GDI+ can adjust color data only, grayscale data only, or both.
- ///
- public enum ColorMatrixFlag
- {
- ///
- /// Both colors and grayscale are color-adjusted.
- ///
- Default = 0,
- ///
- /// Grascale values are not color-adjusted.
- ///
- SkipGrays = 1,
- ///
- /// Only grascale values are color-adjusted.
- ///
- AltGrays = 2
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMode.cs
deleted file mode 100644
index 57e1dd0d0a0e0..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorMode.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies two modes for color component values.
- ///
- public enum ColorMode
- {
- ///
- /// Specifies that integer values supplied are 32-bit values.
- ///
- Argb32Mode = 0,
- ///
- /// Specifies that integer values supplied are 64-bit values.
- ///
- Argb64Mode = 1
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs
deleted file mode 100644
index e6e9367a1e706..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ColorPalette.cs
+++ /dev/null
@@ -1,97 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Defines an array of colors that make up a color palette.
- ///
- public sealed class ColorPalette
- {
- // We don't provide a public constructor for ColorPalette because if we allow
- // arbitrary creation of color palettes you could in theroy not only change the color entries, but the size
- // of the palette and that is not valid for an image (meaning you cannot change the palette size for an image).
- // ColorPalettes are only valid for "indexed" images like GIFs.
-
- private int _flags;
- private Color[] _entries;
-
- ///
- /// Specifies how to interpret the color information in the array of colors.
- ///
- public int Flags
- {
- get
- {
- return _flags;
- }
- }
-
- ///
- /// Specifies an array of objects.
- ///
- public Color[] Entries
- {
- get
- {
- return _entries;
- }
- }
-
- internal ColorPalette(int count)
- {
- _entries = new Color[count];
- }
-
- internal ColorPalette()
- {
- _entries = new Color[1];
- }
-
- internal unsafe void ConvertFromMemory(IntPtr memory)
- {
- // Memory layout is:
- // UINT Flags
- // UINT Count
- // ARGB Entries[size]
-
- byte* pMemory = (byte*)memory;
-
- _flags = *(int*)pMemory;
-
- int size = *(int*)(pMemory + 4);
-
- _entries = new Color[size];
-
- for (int i = 0; i < size; i++)
- {
- int argb = *(int*)(pMemory + 8 + i * 4);
- _entries[i] = Color.FromArgb(argb);
- }
- }
-
- internal unsafe IntPtr ConvertToMemory()
- {
- // Memory layout is:
- // UINT Flags
- // UINT Count
- // ARGB Entries[size]
-
- int length = _entries.Length;
- IntPtr memory = Marshal.AllocHGlobal(checked(4 * (2 + length)));
- byte* pMemory = (byte*)memory;
-
- *(int*)pMemory = _flags;
- *(int*)(pMemory + 4) = length;
-
- for (int i = 0; i < length; i++)
- {
- *(int*)(pMemory + 4 * (i + 2)) = _entries[i].ToArgb();
- }
-
- return memory;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusFlags.cs
deleted file mode 100644
index e510ae6818451..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusFlags.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- /**
- * EMF+ Flags
- */
- internal enum EmfPlusFlags
- {
- Display = 0x00000001,
- NonDualGdi = 0x00000002
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusRecordType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusRecordType.cs
deleted file mode 100644
index ef4fd40050355..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfPlusRecordType.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the methods available in a metafile to read and write graphic commands.
- ///
- public enum EmfPlusRecordType
- {
- WmfRecordBase = 0x00010000,
- WmfSetBkColor = WmfRecordBase | 0x201,
- WmfSetBkMode = WmfRecordBase | 0x102,
- WmfSetMapMode = WmfRecordBase | 0x103,
- WmfSetROP2 = WmfRecordBase | 0x104,
- WmfSetRelAbs = WmfRecordBase | 0x105,
- WmfSetPolyFillMode = WmfRecordBase | 0x106,
- WmfSetStretchBltMode = WmfRecordBase | 0x107,
- WmfSetTextCharExtra = WmfRecordBase | 0x108,
- WmfSetTextColor = WmfRecordBase | 0x209,
- WmfSetTextJustification = WmfRecordBase | 0x20A,
- WmfSetWindowOrg = WmfRecordBase | 0x20B,
- WmfSetWindowExt = WmfRecordBase | 0x20C,
- WmfSetViewportOrg = WmfRecordBase | 0x20D,
- WmfSetViewportExt = WmfRecordBase | 0x20E,
- WmfOffsetWindowOrg = WmfRecordBase | 0x20F,
- WmfScaleWindowExt = WmfRecordBase | 0x410,
- WmfOffsetViewportOrg = WmfRecordBase | 0x211,
- WmfScaleViewportExt = WmfRecordBase | 0x412,
- WmfLineTo = WmfRecordBase | 0x213,
- WmfMoveTo = WmfRecordBase | 0x214,
- WmfExcludeClipRect = WmfRecordBase | 0x415,
- WmfIntersectClipRect = WmfRecordBase | 0x416,
- WmfArc = WmfRecordBase | 0x817,
- WmfEllipse = WmfRecordBase | 0x418,
- WmfFloodFill = WmfRecordBase | 0x419,
- WmfPie = WmfRecordBase | 0x81A,
- WmfRectangle = WmfRecordBase | 0x41B,
- WmfRoundRect = WmfRecordBase | 0x61C,
- WmfPatBlt = WmfRecordBase | 0x61D,
- WmfSaveDC = WmfRecordBase | 0x01E,
- WmfSetPixel = WmfRecordBase | 0x41F,
- WmfOffsetCilpRgn = WmfRecordBase | 0x220,
- WmfTextOut = WmfRecordBase | 0x521,
- WmfBitBlt = WmfRecordBase | 0x922,
- WmfStretchBlt = WmfRecordBase | 0xB23,
- WmfPolygon = WmfRecordBase | 0x324,
- WmfPolyline = WmfRecordBase | 0x325,
- WmfEscape = WmfRecordBase | 0x626,
- WmfRestoreDC = WmfRecordBase | 0x127,
- WmfFillRegion = WmfRecordBase | 0x228,
- WmfFrameRegion = WmfRecordBase | 0x429,
- WmfInvertRegion = WmfRecordBase | 0x12A,
- WmfPaintRegion = WmfRecordBase | 0x12B,
- WmfSelectClipRegion = WmfRecordBase | 0x12C,
- WmfSelectObject = WmfRecordBase | 0x12D,
- WmfSetTextAlign = WmfRecordBase | 0x12E,
- WmfChord = WmfRecordBase | 0x830,
- WmfSetMapperFlags = WmfRecordBase | 0x231,
- WmfExtTextOut = WmfRecordBase | 0xA32,
- WmfSetDibToDev = WmfRecordBase | 0xD33,
- WmfSelectPalette = WmfRecordBase | 0x234,
- WmfRealizePalette = WmfRecordBase | 0x035,
- WmfAnimatePalette = WmfRecordBase | 0x436,
- WmfSetPalEntries = WmfRecordBase | 0x037,
- WmfPolyPolygon = WmfRecordBase | 0x538,
- WmfResizePalette = WmfRecordBase | 0x139,
- WmfDibBitBlt = WmfRecordBase | 0x940,
- WmfDibStretchBlt = WmfRecordBase | 0xb41,
- WmfDibCreatePatternBrush = WmfRecordBase | 0x142,
- WmfStretchDib = WmfRecordBase | 0xf43,
- WmfExtFloodFill = WmfRecordBase | 0x548,
- WmfSetLayout = WmfRecordBase | 0x149, // META_SETLAYOUT
- WmfDeleteObject = WmfRecordBase | 0x1f0,
- WmfCreatePalette = WmfRecordBase | 0x0f7,
- WmfCreatePatternBrush = WmfRecordBase | 0x1f9,
- WmfCreatePenIndirect = WmfRecordBase | 0x2fa,
- WmfCreateFontIndirect = WmfRecordBase | 0x2fb,
- WmfCreateBrushIndirect = WmfRecordBase | 0x2fc,
- WmfCreateRegion = WmfRecordBase | 0x6ff,
-
- // Since we have to enumerate GDI records right along with GDI+ records,
- // we list all the GDI records here so that they can be part of the
- // same enumeration type which is used in the enumeration callback.
-
- EmfHeader = 1,
- EmfPolyBezier = 2,
- EmfPolygon = 3,
- EmfPolyline = 4,
- EmfPolyBezierTo = 5,
- EmfPolyLineTo = 6,
- EmfPolyPolyline = 7,
- EmfPolyPolygon = 8,
- EmfSetWindowExtEx = 9,
- EmfSetWindowOrgEx = 10,
- EmfSetViewportExtEx = 11,
- EmfSetViewportOrgEx = 12,
- EmfSetBrushOrgEx = 13,
- EmfEof = 14,
- EmfSetPixelV = 15,
- EmfSetMapperFlags = 16,
- EmfSetMapMode = 17,
- EmfSetBkMode = 18,
- EmfSetPolyFillMode = 19,
- EmfSetROP2 = 20,
- EmfSetStretchBltMode = 21,
- EmfSetTextAlign = 22,
- EmfSetColorAdjustment = 23,
- EmfSetTextColor = 24,
- EmfSetBkColor = 25,
- EmfOffsetClipRgn = 26,
- EmfMoveToEx = 27,
- EmfSetMetaRgn = 28,
- EmfExcludeClipRect = 29,
- EmfIntersectClipRect = 30,
- EmfScaleViewportExtEx = 31,
- EmfScaleWindowExtEx = 32,
- EmfSaveDC = 33,
- EmfRestoreDC = 34,
- EmfSetWorldTransform = 35,
- EmfModifyWorldTransform = 36,
- EmfSelectObject = 37,
- EmfCreatePen = 38,
- EmfCreateBrushIndirect = 39,
- EmfDeleteObject = 40,
- EmfAngleArc = 41,
- EmfEllipse = 42,
- EmfRectangle = 43,
- EmfRoundRect = 44,
- EmfRoundArc = 45,
- EmfChord = 46,
- EmfPie = 47,
- EmfSelectPalette = 48,
- EmfCreatePalette = 49,
- EmfSetPaletteEntries = 50,
- EmfResizePalette = 51,
- EmfRealizePalette = 52,
- EmfExtFloodFill = 53,
- EmfLineTo = 54,
- EmfArcTo = 55,
- EmfPolyDraw = 56,
- EmfSetArcDirection = 57,
- EmfSetMiterLimit = 58,
- EmfBeginPath = 59,
- EmfEndPath = 60,
- EmfCloseFigure = 61,
- EmfFillPath = 62,
- EmfStrokeAndFillPath = 63,
- EmfStrokePath = 64,
- EmfFlattenPath = 65,
- EmfWidenPath = 66,
- EmfSelectClipPath = 67,
- EmfAbortPath = 68,
- EmfReserved069 = 69,
- EmfGdiComment = 70,
- EmfFillRgn = 71,
- EmfFrameRgn = 72,
- EmfInvertRgn = 73,
- EmfPaintRgn = 74,
- EmfExtSelectClipRgn = 75,
- EmfBitBlt = 76,
- EmfStretchBlt = 77,
- EmfMaskBlt = 78,
- EmfPlgBlt = 79,
- EmfSetDIBitsToDevice = 80,
- EmfStretchDIBits = 81,
- EmfExtCreateFontIndirect = 82,
- EmfExtTextOutA = 83,
- EmfExtTextOutW = 84,
- EmfPolyBezier16 = 85,
- EmfPolygon16 = 86,
- EmfPolyline16 = 87,
- EmfPolyBezierTo16 = 88,
- EmfPolylineTo16 = 89,
- EmfPolyPolyline16 = 90,
- EmfPolyPolygon16 = 91,
- EmfPolyDraw16 = 92,
- EmfCreateMonoBrush = 93,
- EmfCreateDibPatternBrushPt = 94,
- EmfExtCreatePen = 95,
- EmfPolyTextOutA = 96,
- EmfPolyTextOutW = 97,
- EmfSetIcmMode = 98, // EMR_SETICMMODE,
- EmfCreateColorSpace = 99, // EMR_CREATECOLORSPACE,
- EmfSetColorSpace = 100, // EMR_SETCOLORSPACE,
- EmfDeleteColorSpace = 101, // EMR_DELETECOLORSPACE,
- EmfGlsRecord = 102, // EMR_GLSRECORD,
- EmfGlsBoundedRecord = 103, // EMR_GLSBOUNDEDRECORD,
- EmfPixelFormat = 104, // EMR_PIXELFORMAT,
- EmfDrawEscape = 105, // EMR_RESERVED_105,
- EmfExtEscape = 106, // EMR_RESERVED_106,
- EmfStartDoc = 107, // EMR_RESERVED_107,
- EmfSmallTextOut = 108, // EMR_RESERVED_108,
- EmfForceUfiMapping = 109, // EMR_RESERVED_109,
- EmfNamedEscpae = 110, // EMR_RESERVED_110,
- EmfColorCorrectPalette = 111, // EMR_COLORCORRECTPALETTE,
- EmfSetIcmProfileA = 112, // EMR_SETICMPROFILEA,
- EmfSetIcmProfileW = 113, // EMR_SETICMPROFILEW,
- EmfAlphaBlend = 114, // EMR_ALPHABLEND,
- EmfSetLayout = 115, // EMR_SETLAYOUT,
- EmfTransparentBlt = 116, // EMR_TRANSPARENTBLT,
- EmfReserved117 = 117,
- EmfGradientFill = 118, // EMR_GRADIENTFILL,
- EmfSetLinkedUfis = 119, // EMR_RESERVED_119,
- EmfSetTextJustification = 120, // EMR_RESERVED_120,
- EmfColorMatchToTargetW = 121, // EMR_COLORMATCHTOTARGETW,
- EmfCreateColorSpaceW = 122, // EMR_CREATECOLORSPACEW,
- EmfMax = 122,
- EmfMin = 1,
-
- // That is the END of the GDI EMF records.
-
- // Now we start the list of EMF+ records. We leave quite
- // a bit of room here for the addition of any new GDI
- // records that may be added later.
-
- EmfPlusRecordBase = 0x00004000,
- Invalid = EmfPlusRecordBase,
- Header,
- EndOfFile,
-
- Comment,
-
- GetDC, // the application grabbed the metafile dc
-
- MultiFormatStart,
- MultiFormatSection,
- MultiFormatEnd,
-
- // For all Persistent Objects
- Object,
- // Drawing Records
- Clear,
- FillRects,
- DrawRects,
- FillPolygon,
- DrawLines,
- FillEllipse,
- DrawEllipse,
- FillPie,
- DrawPie,
- DrawArc,
- FillRegion,
- FillPath,
- DrawPath,
- FillClosedCurve,
- DrawClosedCurve,
- DrawCurve,
- DrawBeziers,
- DrawImage,
- DrawImagePoints,
- DrawString,
-
- // Graphics State Records
- SetRenderingOrigin,
- SetAntiAliasMode,
- SetTextRenderingHint,
- SetTextContrast,
- SetInterpolationMode,
- SetPixelOffsetMode,
- SetCompositingMode,
- SetCompositingQuality,
- Save,
- Restore,
- BeginContainer,
- BeginContainerNoParams,
- EndContainer,
- SetWorldTransform,
- ResetWorldTransform,
- MultiplyWorldTransform,
- TranslateWorldTransform,
- ScaleWorldTransform,
- RotateWorldTransform,
- SetPageTransform,
- ResetClip,
- SetClipRect,
- SetClipPath,
- SetClipRegion,
- OffsetClip,
-
- DrawDriverString,
-
- Total,
-
- Max = Total - 1,
- Min = Header
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfType.cs
deleted file mode 100644
index d7583a98a48db..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EmfType.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the metafile type.
- ///
- public enum EmfType
- {
- ///
- /// Windows enhanced metafile. Contains GDI commands. Metafiles of this type are referred to as an EMF file.
- ///
- EmfOnly = MetafileType.Emf,
- ///
- /// Windows enhanced metafile plus. Contains GDI+ commands. Metafiles of this type are referred to as an EMF+ file.
- ///
- EmfPlusOnly = MetafileType.EmfPlusOnly,
- ///
- /// Dual Windows enhanced metafile. Contains equivalent GDI and GDI+ commands. Metafiles of this type are referred to as an EMF+ file.
- ///
- EmfPlusDual = MetafileType.EmfPlusDual
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs
deleted file mode 100644
index b7f92cd55d667..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Encoder.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- public sealed class Encoder
- {
- public static readonly Encoder Compression = new Encoder(new Guid(unchecked((int)0xe09d739d), unchecked((short)0xccd4), unchecked((short)0x44ee), new byte[] { 0x8e, 0xba, 0x3f, 0xbf, 0x8b, 0xe4, 0xfc, 0x58 }));
- public static readonly Encoder ColorDepth = new Encoder(new Guid(0x66087055, unchecked((short)0xad66), unchecked((short)0x4c7c), new byte[] { 0x9a, 0x18, 0x38, 0xa2, 0x31, 0x0b, 0x83, 0x37 }));
- public static readonly Encoder ScanMethod = new Encoder(new Guid(0x3a4e2661, (short)0x3109, (short)0x4e56, new byte[] { 0x85, 0x36, 0x42, 0xc1, 0x56, 0xe7, 0xdc, 0xfa }));
- public static readonly Encoder Version = new Encoder(new Guid(0x24d18c76, unchecked((short)0x814a), unchecked((short)0x41a4), new byte[] { 0xbf, 0x53, 0x1c, 0x21, 0x9c, 0xcc, 0xf7, 0x97 }));
- public static readonly Encoder RenderMethod = new Encoder(new Guid(0x6d42c53a, (short)0x229a, (short)0x4825, new byte[] { 0x8b, 0xb7, 0x5c, 0x99, 0xe2, 0xb9, 0xa8, 0xb8 }));
- public static readonly Encoder Quality = new Encoder(new Guid(0x1d5be4b5, unchecked((short)0xfa4a), unchecked((short)0x452d), new byte[] { 0x9c, 0xdd, 0x5d, 0xb3, 0x51, 0x05, 0xe7, 0xeb }));
- public static readonly Encoder Transformation = new Encoder(new Guid(unchecked((int)0x8d0eb2d1), unchecked((short)0xa58e), unchecked((short)0x4ea8), new byte[] { 0xaa, 0x14, 0x10, 0x80, 0x74, 0xb7, 0xb6, 0xf9 }));
- public static readonly Encoder LuminanceTable = new Encoder(new Guid(unchecked((int)0xedb33bce), unchecked((short)0x0266), unchecked((short)0x4a77), new byte[] { 0xb9, 0x04, 0x27, 0x21, 0x60, 0x99, 0xe7, 0x17 }));
- public static readonly Encoder ChrominanceTable = new Encoder(new Guid(unchecked((int)0xf2e455dc), unchecked((short)0x09b3), unchecked((short)0x4316), new byte[] { 0x82, 0x60, 0x67, 0x6a, 0xda, 0x32, 0x48, 0x1c }));
- public static readonly Encoder SaveFlag = new Encoder(new Guid(unchecked((int)0x292266fc), unchecked((short)0xac40), unchecked((short)0x47bf), new byte[] { 0x8c, 0xfc, 0xa8, 0x5b, 0x89, 0xa6, 0x55, 0xde }));
-
- ///
- /// An object that is initialized with the globally unique identifier for the color space category.
- ///
- public static readonly Encoder ColorSpace = new Encoder(new Guid(unchecked((int)0xae7a62a0), unchecked((short)0xee2c), unchecked((short)0x49d8), new byte[] { 0x9d, 0x07, 0x1b, 0xa8, 0xa9, 0x27, 0x59, 0x6e }));
-
- ///
- /// An object that is initialized with the globally unique identifier for the image items category.
- ///
- public static readonly Encoder ImageItems = new Encoder(new Guid(unchecked((int)0x63875e13), unchecked((short)0x1f1d), unchecked((short)0x45ab), new byte[] { 0x91, 0x95, 0xa2, 0x9b, 0x60, 0x66, 0xa6, 0x50 }));
-
- ///
- /// An object that is initialized with the globally unique identifier for the save as CMYK category.
- ///
- public static readonly Encoder SaveAsCmyk = new Encoder(new Guid(unchecked((int)0xa219bbc9), unchecked((short)0x0a9d), unchecked((short)0x4005), new byte[] { 0xa3, 0xee, 0x3a, 0x42, 0x1b, 0x8b, 0xb0, 0x6c }));
-
- private readonly Guid _guid;
-
- public Encoder(Guid guid) => _guid = guid;
-
- public Guid Guid => _guid;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs
deleted file mode 100644
index 910de3f82e2bf..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameter.cs
+++ /dev/null
@@ -1,393 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- [StructLayout(LayoutKind.Sequential)]
- public sealed unsafe class EncoderParameter : IDisposable
- {
- private Guid _parameterGuid; // GUID of the parameter
- private readonly int _numberOfValues; // Number of the parameter values
- private readonly EncoderParameterValueType _parameterValueType; // Value type, like ValueTypeLONG etc.
- private IntPtr _parameterValue; // A pointer to the parameter values
-
- ~EncoderParameter()
- {
- DisposeInternal();
- }
-
- ///
- /// Gets/Sets the Encoder for the EncoderPameter.
- ///
- public Encoder Encoder
- {
- get
- {
- return new Encoder(_parameterGuid);
- }
- set
- {
- _parameterGuid = value.Guid;
- }
- }
-
- ///
- /// Gets the EncoderParameterValueType object from the EncoderParameter.
- ///
- public EncoderParameterValueType Type
- {
- get
- {
- return _parameterValueType;
- }
- }
-
- ///
- /// Gets the EncoderParameterValueType object from the EncoderParameter.
- ///
- public EncoderParameterValueType ValueType
- {
- get
- {
- return _parameterValueType;
- }
- }
-
- ///
- /// Gets the NumberOfValues from the EncoderParameter.
- ///
- public int NumberOfValues
- {
- get
- {
- return _numberOfValues;
- }
- }
-
- public void Dispose()
- {
- DisposeInternal();
- GC.KeepAlive(this);
- GC.SuppressFinalize(this);
- }
-
- private void DisposeInternal()
- {
- if (_parameterValue != IntPtr.Zero)
- Marshal.FreeHGlobal(_parameterValue);
- _parameterValue = IntPtr.Zero;
- }
-
- public EncoderParameter(Encoder encoder, byte value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeByte;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(sizeof(byte));
-
- *(byte*)_parameterValue = value;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, byte value, bool undefined)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = undefined ? EncoderParameterValueType.ValueTypeUndefined : EncoderParameterValueType.ValueTypeByte;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(sizeof(byte));
-
- *(byte*)_parameterValue = value;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, short value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeShort;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(sizeof(short));
-
- *(short*)_parameterValue = value;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, long value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeLong;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(sizeof(int));
-
- *(int*)_parameterValue = unchecked((int)value);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, int numerator, int denominator)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeRational;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(2 * sizeof(int));
-
- ((int*)_parameterValue)[0] = numerator;
- ((int*)_parameterValue)[1] = denominator;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, long rangebegin, long rangeend)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeLongRange;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(2 * sizeof(int));
-
- ((int*)_parameterValue)[0] = unchecked((int)rangebegin);
- ((int*)_parameterValue)[1] = unchecked((int)rangeend);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder,
- int numerator1, int demoninator1,
- int numerator2, int demoninator2)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeRationalRange;
- _numberOfValues = 1;
- _parameterValue = Marshal.AllocHGlobal(4 * sizeof(int));
-
- ((int*)_parameterValue)[0] = numerator1;
- ((int*)_parameterValue)[1] = demoninator1;
- ((int*)_parameterValue)[2] = numerator2;
- ((int*)_parameterValue)[3] = demoninator2;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, string value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeAscii;
- _numberOfValues = value.Length;
- _parameterValue = Marshal.StringToHGlobalAnsi(value);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, byte[] value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeByte;
- _numberOfValues = value.Length;
-
- _parameterValue = Marshal.AllocHGlobal(_numberOfValues);
-
- Marshal.Copy(value, 0, _parameterValue, _numberOfValues);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, byte[] value, bool undefined)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = undefined ? EncoderParameterValueType.ValueTypeUndefined : EncoderParameterValueType.ValueTypeByte;
-
- _numberOfValues = value.Length;
- _parameterValue = Marshal.AllocHGlobal(_numberOfValues);
-
- Marshal.Copy(value, 0, _parameterValue, _numberOfValues);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, short[] value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeShort;
- _numberOfValues = value.Length;
- _parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * sizeof(short)));
-
- Marshal.Copy(value, 0, _parameterValue, _numberOfValues);
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, long[] value)
- {
- _parameterGuid = encoder.Guid;
-
- _parameterValueType = EncoderParameterValueType.ValueTypeLong;
- _numberOfValues = value.Length;
- _parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * sizeof(int)));
-
- int* dest = (int*)_parameterValue;
- fixed (long* source = value)
- {
- for (int i = 0; i < value.Length; i++)
- {
- dest[i] = unchecked((int)source[i]);
- }
- }
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, int[] numerator, int[] denominator)
- {
- _parameterGuid = encoder.Guid;
-
- if (numerator.Length != denominator.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- _parameterValueType = EncoderParameterValueType.ValueTypeRational;
- _numberOfValues = numerator.Length;
- _parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * 2 * sizeof(int)));
-
- for (int i = 0; i < _numberOfValues; i++)
- {
- ((int*)_parameterValue)[i * 2 + 0] = numerator[i];
- ((int*)_parameterValue)[i * 2 + 1] = denominator[i];
- }
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, long[] rangebegin, long[] rangeend)
- {
- _parameterGuid = encoder.Guid;
-
- if (rangebegin.Length != rangeend.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- _parameterValueType = EncoderParameterValueType.ValueTypeLongRange;
- _numberOfValues = rangebegin.Length;
- _parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * 2 * sizeof(int)));
-
- for (int i = 0; i < _numberOfValues; i++)
- {
- ((int*)_parameterValue)[i * 2 + 0] = unchecked((int)rangebegin[i]);
- ((int*)_parameterValue)[i * 2 + 1] = unchecked((int)rangeend[i]);
- }
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder,
- int[] numerator1, int[] denominator1,
- int[] numerator2, int[] denominator2)
- {
- _parameterGuid = encoder.Guid;
-
- if (numerator1.Length != denominator1.Length ||
- numerator1.Length != denominator2.Length ||
- denominator1.Length != denominator2.Length)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- _parameterValueType = EncoderParameterValueType.ValueTypeRationalRange;
- _numberOfValues = numerator1.Length;
- _parameterValue = Marshal.AllocHGlobal(checked(_numberOfValues * 4 * sizeof(int)));
-
- for (int i = 0; i < _numberOfValues; i++)
- {
- ((int*)_parameterValue)[i * 4 + 0] = numerator1[i];
- ((int*)_parameterValue)[i * 4 + 1] = denominator1[i];
- ((int*)_parameterValue)[i * 4 + 2] = numerator2[i];
- ((int*)_parameterValue)[i * 4 + 3] = denominator2[i];
- }
- GC.KeepAlive(this);
- }
-
- [Obsolete("This constructor has been deprecated. Use EncoderParameter(Encoder encoder, int numberValues, EncoderParameterValueType type, IntPtr value) instead.")]
- public EncoderParameter(Encoder encoder, int NumberOfValues, int Type, int Value)
- {
- int size;
-
- switch ((EncoderParameterValueType)Type)
- {
- case EncoderParameterValueType.ValueTypeByte:
- case EncoderParameterValueType.ValueTypeAscii:
- size = 1;
- break;
- case EncoderParameterValueType.ValueTypeShort:
- size = 2;
- break;
- case EncoderParameterValueType.ValueTypeLong:
- size = 4;
- break;
- case EncoderParameterValueType.ValueTypeRational:
- case EncoderParameterValueType.ValueTypeLongRange:
- size = 2 * 4;
- break;
- case EncoderParameterValueType.ValueTypeUndefined:
- size = 1;
- break;
- case EncoderParameterValueType.ValueTypeRationalRange:
- size = 2 * 2 * 4;
- break;
- default:
- throw Gdip.StatusException(Gdip.WrongState);
- }
-
- int bytes = checked(size * NumberOfValues);
-
- _parameterValue = Marshal.AllocHGlobal(bytes);
-
- new ReadOnlySpan((void*)Value, bytes).CopyTo(new Span((void*)_parameterValue, bytes));
-
- _parameterValueType = (EncoderParameterValueType)Type;
- _numberOfValues = NumberOfValues;
- _parameterGuid = encoder.Guid;
- GC.KeepAlive(this);
- }
-
- public EncoderParameter(Encoder encoder, int numberValues, EncoderParameterValueType type, IntPtr value)
- {
- int size;
-
- switch (type)
- {
- case EncoderParameterValueType.ValueTypeByte:
- case EncoderParameterValueType.ValueTypeAscii:
- size = 1;
- break;
- case EncoderParameterValueType.ValueTypeShort:
- size = 2;
- break;
- case EncoderParameterValueType.ValueTypeLong:
- size = 4;
- break;
- case EncoderParameterValueType.ValueTypeRational:
- case EncoderParameterValueType.ValueTypeLongRange:
- size = 2 * 4;
- break;
- case EncoderParameterValueType.ValueTypeUndefined:
- size = 1;
- break;
- case EncoderParameterValueType.ValueTypeRationalRange:
- size = 2 * 2 * 4;
- break;
- case EncoderParameterValueType.ValueTypePointer:
- size = IntPtr.Size;
- break;
- default:
- throw Gdip.StatusException(Gdip.WrongState);
- }
-
- int bytes = checked(size * numberValues);
-
- _parameterValue = Marshal.AllocHGlobal(bytes);
-
- new ReadOnlySpan((void*)value, bytes).CopyTo(new Span((void*)_parameterValue, bytes));
-
- _parameterValueType = type;
- _numberOfValues = numberValues;
- _parameterGuid = encoder.Guid;
- GC.KeepAlive(this);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterPrivate.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterPrivate.cs
deleted file mode 100644
index 994ac2e1e46b9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterPrivate.cs
+++ /dev/null
@@ -1,16 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
- [StructLayout(LayoutKind.Sequential)]
- internal struct EncoderParameterPrivate
- {
- public Guid ParameterGuid; // GUID of the parameter
- public int NumberOfValues; // Number of the parameter values
- public EncoderParameterValueType ParameterValueType; // Value type, like ValueTypeLONG etc.
- public IntPtr ParameterValue; // A pointer to the parameter values
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterValueType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterValueType.cs
deleted file mode 100644
index 11a19e938163e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameterValueType.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies a EncoderParameter data type.
- ///
- public enum EncoderParameterValueType
- {
- ///
- /// The data is an 8-bit unsigned value.
- ///
- ValueTypeByte = 1,
- ///
- /// The data is an 8-bit ASCII value.
- ///
- ValueTypeAscii = 2, // 8-bit byte containing one 7-bit ASCII code. NULL terminated.
- ///
- /// The data is a 16-bit unsigned value.
- ///
- ValueTypeShort = 3,
- ///
- /// The data is a 32-bit unsigned value.
- ///
- ValueTypeLong = 4,
- ///
- /// The data is two long integers, specifying the numerator and the denominator of a rational number, respectively.
- ///
- ValueTypeRational = 5, // Two Longs. The first Long is the numerator, the second Long expresses the denomintor.
-
- ///
- /// Two longs which specify a range of integer values.
- /// The first Long specifies the lower end and the second one specifies the higher end.
- /// All values are inclusive at both ends.
- ///
- ValueTypeLongRange = 6,
- ///
- /// An 8-bit undefined value that can take any value depending on field definition.
- ///
- ValueTypeUndefined = 7,
- ///
- /// Two Rationals. The first Rational specifies the lower end and the second specifies the higher end.
- /// All values are inclusive at both ends
- ///
- ValueTypeRationalRange = 8,
- ///
- /// The parameter is a pointer to a block of custom metadata.
- ///
- ValueTypePointer = 9,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs
deleted file mode 100644
index 4e5620aad3da9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderParameters.cs
+++ /dev/null
@@ -1,106 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- public sealed class EncoderParameters : IDisposable
- {
- private EncoderParameter[] _param;
-
- public EncoderParameters(int count)
- {
- _param = new EncoderParameter[count];
- }
-
- public EncoderParameters()
- {
- _param = new EncoderParameter[1];
- }
-
- public EncoderParameter[] Param
- {
- get
- {
- return _param;
- }
- set
- {
- _param = value;
- }
- }
-
- ///
- /// Copy the EncoderParameters data into a chunk of memory to be consumed by native GDI+ code.
- ///
- /// We need to marshal the EncoderParameters info from/to native GDI+ ourselves since the definition of the managed/unmanaged classes
- /// are different and the native class is a bit weird. The native EncoderParameters class is defined in GDI+ as follows:
- ///
- /// class EncoderParameters {
- /// UINT Count; // Number of parameters in this structure
- /// EncoderParameter Parameter[1]; // Parameter values
- /// };
- ///
- /// We don't have the 'Count' field since the managed array contains it. In order for this structure to work with more than one
- /// EncoderParameter we need to preallocate memory for the extra n-1 elements, something like this:
- ///
- /// EncoderParameters* pEncoderParameters = (EncoderParameters*) malloc(sizeof(EncoderParameters) + (n-1) * sizeof(EncoderParameter));
- ///
- /// Also, in 64-bit platforms, 'Count' is aligned in 8 bytes (4 extra padding bytes) so we use IntPtr instead of Int32 to account for
- /// that.
- ///
- internal unsafe IntPtr ConvertToMemory()
- {
- int size = sizeof(EncoderParameterPrivate);
-
- int length = _param.Length;
- IntPtr memory = Marshal.AllocHGlobal(length * size + IntPtr.Size);
-
- Marshal.WriteIntPtr(memory, (nint)length);
-
- byte* arrayOffset = (byte*)memory + IntPtr.Size;
-
- for (int i = 0; i < length; i++)
- {
- Marshal.StructureToPtr(_param[i], (nint)(arrayOffset + (nint)i * size), false);
- }
-
- return memory;
- }
-
- ///
- /// Copy the native GDI+ EncoderParameters data from a chunk of memory into a managed EncoderParameters object.
- /// See ConvertToMemory for more info.
- ///
- internal static unsafe EncoderParameters ConvertFromMemory(IntPtr memory)
- {
- if (memory == IntPtr.Zero)
- {
- throw Gdip.StatusException(Gdip.InvalidParameter);
- }
-
- int count = *(int*)memory;
- EncoderParameterPrivate* parameters = (EncoderParameterPrivate*)((byte*)memory + IntPtr.Size);
- EncoderParameters p = new EncoderParameters(count);
- for (int i = 0; i < count; i++)
- {
- ref readonly EncoderParameterPrivate param = ref parameters[i];
-
- p._param[i] = new EncoderParameter(new Encoder(param.ParameterGuid), param.NumberOfValues, param.ParameterValueType, param.ParameterValue);
- }
-
- return p;
- }
-
- public void Dispose()
- {
- foreach (EncoderParameter p in _param)
- {
- p?.Dispose();
- }
- _param = null!;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderValue.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderValue.cs
deleted file mode 100644
index e0a6d14bd34d4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/EncoderValue.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// The EncoderValue enum.
- ///
- public enum EncoderValue
- {
- ///
- /// Specifies the CMYK color space.
- ///
- ColorTypeCMYK,
- ///
- /// Specifies the YCCK color space.
- ///
- ColorTypeYCCK,
- ///
- /// Specifies the LZW compression method.
- ///
- CompressionLZW,
- ///
- /// For a TIFF image, specifies the CCITT3 compression method.
- ///
- CompressionCCITT3,
- ///
- /// For a TIFF image, specifies the CCITT4 compression method.
- ///
- CompressionCCITT4,
- ///
- /// For a TIFF image, specifies the RLE compression method.
- ///
- CompressionRle,
- ///
- /// For a TIFF image, specifies no compression.
- ///
- CompressionNone,
- ///
- /// Specifies interlaced mode.
- ///
- ScanMethodInterlaced,
- ///
- /// Specifies non-interlaced mode.
- ///
- ScanMethodNonInterlaced,
- ///
- /// For a GIF image, specifies version 87.
- ///
- VersionGif87,
- ///
- /// For a GIF images, specifies version 89a.
- ///
- VersionGif89,
- ///
- /// Specifies progressive mode.
- ///
- RenderProgressive,
- ///
- /// Specifies non-progressive mode.
- ///
- RenderNonProgressive,
- ///
- /// For a JPEG image, specifies lossless 90-degree clockwise rotation.
- ///
- TransformRotate90,
- ///
- /// For a JPEG image, specifies lossless 180-degree rotation.
- ///
- TransformRotate180,
- ///
- /// For a JPEG image, specifies lossless 270-degree clockwise rotation.
- ///
- TransformRotate270,
- ///
- /// For a JPEG image, specifies a lossless horizontal flip.
- ///
- TransformFlipHorizontal,
- ///
- /// For a JPEG image, specifies a lossless vertical flip.
- ///
- TransformFlipVertical,
- ///
- /// Specifies multiframe encoding.
- ///
- MultiFrame,
- ///
- /// Specifies the last frame of a multi-frame image.
- ///
- LastFrame,
- ///
- /// Specifies that the encoder object is to be closed.
- ///
- Flush,
- ///
- /// For a GIF image, specifies the time frame dimension.
- ///
- FrameDimensionTime,
- ///
- /// Specifies the resolution frame dimension.
- ///
- FrameDimensionResolution,
- ///
- /// For a TIFF image, specifies the page frame dimension
- ///
- FrameDimensionPage
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs
deleted file mode 100644
index bbfcec12bbfcb..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/FrameDimension.cs
+++ /dev/null
@@ -1,84 +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.Diagnostics.CodeAnalysis;
-
-namespace System.Drawing.Imaging
-{
- public sealed class FrameDimension
- {
- // Frame dimension GUIDs, from sdkinc\imgguids.h
- private static readonly FrameDimension s_time = new FrameDimension(new Guid("{6aedbd6d-3fb5-418a-83a6-7f45229dc872}"));
- private static readonly FrameDimension s_resolution = new FrameDimension(new Guid("{84236f7b-3bd3-428f-8dab-4ea1439ca315}"));
- private static readonly FrameDimension s_page = new FrameDimension(new Guid("{7462dc86-6180-4c7e-8e3f-ee7333a7a483}"));
-
- private readonly Guid _guid;
-
- ///
- /// Initializes a new instance of the class with the specified GUID.
- ///
- public FrameDimension(Guid guid)
- {
- _guid = guid;
- }
-
- ///
- /// Specifies a global unique identifier (GUID) that represents this .
- ///
- public Guid Guid
- {
- get { return _guid; }
- }
-
- ///
- /// The time dimension.
- ///
- public static FrameDimension Time
- {
- get { return s_time; }
- }
-
- ///
- /// The resolution dimension.
- ///
- public static FrameDimension Resolution
- {
- get { return s_resolution; }
- }
-
- ///
- /// The page dimension.
- ///
- public static FrameDimension Page
- {
- get { return s_page; }
- }
- ///
- /// Returns a value indicating whether the specified object is an equivalent to
- /// this .
- ///
- public override bool Equals([NotNullWhen(true)] object? o)
- {
- FrameDimension? format = o as FrameDimension;
- if (format == null)
- return false;
- return _guid == format._guid;
- }
-
- public override int GetHashCode()
- {
- return _guid.GetHashCode();
- }
-
- ///
- /// Converts this to a human-readable string.
- ///
- public override string ToString()
- {
- if (this == s_time) return "Time";
- if (this == s_resolution) return "Resolution";
- if (this == s_page) return "Page";
- return $"[FrameDimension: {_guid}]";
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs
deleted file mode 100644
index 21853ff7c8480..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageAttributes.cs
+++ /dev/null
@@ -1,541 +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.Runtime.InteropServices;
-using System.Diagnostics;
-using System.Drawing.Drawing2D;
-using System.Globalization;
-using System.IO;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- // sdkinc\GDIplusImageAttributes.h
-
- // There are 5 possible sets of color adjustments:
- // ColorAdjustDefault,
- // ColorAdjustBitmap,
- // ColorAdjustBrush,
- // ColorAdjustPen,
- // ColorAdjustText,
-
- // Bitmaps, Brushes, Pens, and Text will all use any color adjustments
- // that have been set into the default ImageAttributes until their own
- // color adjustments have been set. So as soon as any "Set" method is
- // called for Bitmaps, Brushes, Pens, or Text, then they start from
- // scratch with only the color adjustments that have been set for them.
- // Calling Reset removes any individual color adjustments for a type
- // and makes it revert back to using all the default color adjustments
- // (if any). The SetToIdentity method is a way to force a type to
- // have no color adjustments at all, regardless of what previous adjustments
- // have been set for the defaults or for that type.
-
- ///
- /// Contains information about how image colors are manipulated during rendering.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public sealed class ImageAttributes : ICloneable, IDisposable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- internal IntPtr nativeImageAttributes;
-
- internal void SetNativeImageAttributes(IntPtr handle)
- {
- if (handle == IntPtr.Zero)
- throw new ArgumentNullException(nameof(handle));
-
- nativeImageAttributes = handle;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ImageAttributes()
- {
- IntPtr newImageAttributes;
-
- int status = Gdip.GdipCreateImageAttributes(out newImageAttributes);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- SetNativeImageAttributes(newImageAttributes);
- }
-
- internal ImageAttributes(IntPtr newNativeImageAttributes)
- {
- SetNativeImageAttributes(newNativeImageAttributes);
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
-#if FINALIZATION_WATCH
- if (!disposing && nativeImageAttributes != IntPtr.Zero)
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
-#endif
- if (nativeImageAttributes != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDisposeImageAttributes(new HandleRef(this, nativeImageAttributes));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsSecurityOrCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during Dispose: " + ex.ToString());
- }
- finally
- {
- nativeImageAttributes = IntPtr.Zero;
- }
- }
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- ~ImageAttributes()
- {
- Dispose(false);
- }
-
- ///
- /// Creates an exact copy of this .
- ///
- public object Clone()
- {
- IntPtr clone;
-
- int status = Gdip.GdipCloneImageAttributes(
- new HandleRef(this, nativeImageAttributes),
- out clone);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return new ImageAttributes(clone);
- }
-
- ///
- /// Sets the 5 X 5 color adjust matrix to the specified .
- ///
- public void SetColorMatrix(ColorMatrix newColorMatrix)
- {
- SetColorMatrix(newColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
- }
-
- ///
- /// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the specified 'ColorMatrixFlags'.
- ///
- public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag flags)
- {
- SetColorMatrix(newColorMatrix, flags, ColorAdjustType.Default);
- }
-
- ///
- /// Sets the 5 X 5 color adjust matrix to the specified 'Matrix' with the specified 'ColorMatrixFlags'.
- ///
- public void SetColorMatrix(ColorMatrix newColorMatrix, ColorMatrixFlag mode, ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesColorMatrix(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- newColorMatrix,
- null,
- mode);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- ///
- /// Clears the color adjust matrix to all zeroes.
- ///
- public void ClearColorMatrix()
- {
- ClearColorMatrix(ColorAdjustType.Default);
- }
-
- ///
- /// Clears the color adjust matrix.
- ///
- public void ClearColorMatrix(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesColorMatrix(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- null,
- null,
- ColorMatrixFlag.Default);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- ///
- /// Sets a color adjust matrix for image colors and a separate gray scale adjust matrix for gray scale values.
- ///
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix)
- {
- SetColorMatrices(newColorMatrix, grayMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
- }
-
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix, ColorMatrixFlag flags)
- {
- SetColorMatrices(newColorMatrix, grayMatrix, flags, ColorAdjustType.Default);
- }
-
- public void SetColorMatrices(ColorMatrix newColorMatrix, ColorMatrix? grayMatrix, ColorMatrixFlag mode,
- ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesColorMatrix(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- newColorMatrix,
- grayMatrix,
- mode);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetThreshold(float threshold)
- {
- SetThreshold(threshold, ColorAdjustType.Default);
- }
-
- public void SetThreshold(float threshold, ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesThreshold(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- threshold);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearThreshold()
- {
- ClearThreshold(ColorAdjustType.Default);
- }
-
- public void ClearThreshold(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesThreshold(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- 0.0f);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetGamma(float gamma)
- {
- SetGamma(gamma, ColorAdjustType.Default);
- }
-
- public void SetGamma(float gamma, ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesGamma(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- gamma);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearGamma()
- {
- ClearGamma(ColorAdjustType.Default);
- }
-
- public void ClearGamma(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesGamma(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- 0.0f);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetNoOp()
- {
- SetNoOp(ColorAdjustType.Default);
- }
-
- public void SetNoOp(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesNoOp(
- new HandleRef(this, nativeImageAttributes),
- type,
- true);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearNoOp()
- {
- ClearNoOp(ColorAdjustType.Default);
- }
-
- public void ClearNoOp(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesNoOp(
- new HandleRef(this, nativeImageAttributes),
- type,
- false);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetColorKey(Color colorLow, Color colorHigh)
- {
- SetColorKey(colorLow, colorHigh, ColorAdjustType.Default);
- }
-
- public void SetColorKey(Color colorLow, Color colorHigh, ColorAdjustType type)
- {
- int lowInt = colorLow.ToArgb();
- int highInt = colorHigh.ToArgb();
-
- int status = Gdip.GdipSetImageAttributesColorKeys(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- lowInt,
- highInt);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearColorKey()
- {
- ClearColorKey(ColorAdjustType.Default);
- }
-
- public void ClearColorKey(ColorAdjustType type)
- {
- int zero = 0;
- int status = Gdip.GdipSetImageAttributesColorKeys(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- zero,
- zero);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetOutputChannel(ColorChannelFlag flags)
- {
- SetOutputChannel(flags, ColorAdjustType.Default);
- }
-
- public void SetOutputChannel(ColorChannelFlag flags, ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesOutputChannel(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- flags);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearOutputChannel()
- {
- ClearOutputChannel(ColorAdjustType.Default);
- }
-
- public void ClearOutputChannel(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesOutputChannel(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- ColorChannelFlag.ColorChannelLast);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetOutputChannelColorProfile(string colorProfileFilename)
- {
- SetOutputChannelColorProfile(colorProfileFilename, ColorAdjustType.Default);
- }
-
- public void SetOutputChannelColorProfile(string colorProfileFilename,
- ColorAdjustType type)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(colorProfileFilename);
-
- int status = Gdip.GdipSetImageAttributesOutputChannelColorProfile(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- colorProfileFilename);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void ClearOutputChannelColorProfile()
- {
- ClearOutputChannel(ColorAdjustType.Default);
- }
-
- public void ClearOutputChannelColorProfile(ColorAdjustType type)
- {
- int status = Gdip.GdipSetImageAttributesOutputChannel(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- ColorChannelFlag.ColorChannelLast);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void SetRemapTable(ColorMap[] map)
- {
- SetRemapTable(map, ColorAdjustType.Default);
- }
-
- public unsafe void SetRemapTable(ColorMap[] map, ColorAdjustType type)
- {
- int index;
- int mapSize = map.Length;
- int size = 4; // Marshal.SizeOf(index.GetType());
- IntPtr memory = Marshal.AllocHGlobal(checked(mapSize * size * 2));
- byte* pMemory = (byte*)memory;
-
- try
- {
- for (index = 0; index < mapSize; index++)
- {
- Marshal.StructureToPtr(map[index].OldColor.ToArgb(), (IntPtr)(pMemory + (nint)index * size * 2), false);
- Marshal.StructureToPtr(map[index].NewColor.ToArgb(), (IntPtr)(pMemory + (nint)index * size * 2 + size), false);
- }
-
- Gdip.CheckStatus(Gdip.GdipSetImageAttributesRemapTable(
- new HandleRef(this, nativeImageAttributes),
- type,
- true,
- mapSize,
- memory));
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
- }
-
- public void ClearRemapTable()
- {
- ClearRemapTable(ColorAdjustType.Default);
- }
-
- public void ClearRemapTable(ColorAdjustType type)
- {
- Gdip.CheckStatus(Gdip.GdipSetImageAttributesRemapTable(
- new HandleRef(this, nativeImageAttributes),
- type,
- false,
- 0,
- IntPtr.Zero));
- }
-
- public void SetBrushRemapTable(ColorMap[] map)
- {
- SetRemapTable(map, ColorAdjustType.Brush);
- }
-
- public void ClearBrushRemapTable()
- {
- ClearRemapTable(ColorAdjustType.Brush);
- }
-
- public void SetWrapMode(WrapMode mode)
- {
- SetWrapMode(mode, default(Color), false);
- }
-
- public void SetWrapMode(WrapMode mode, Color color)
- {
- SetWrapMode(mode, color, false);
- }
-
- public void SetWrapMode(WrapMode mode, Color color, bool clamp)
- {
- int status = Gdip.GdipSetImageAttributesWrapMode(
- new HandleRef(this, nativeImageAttributes),
- unchecked((int)mode),
- color.ToArgb(),
- clamp);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- public void GetAdjustedPalette(ColorPalette palette, ColorAdjustType type)
- {
- // does inplace adjustment
- IntPtr memory = palette.ConvertToMemory();
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetImageAttributesAdjustedPalette(
- new HandleRef(this, nativeImageAttributes),
- memory,
- type));
- palette.ConvertFromMemory(memory);
- }
- finally
- {
- if (memory != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(memory);
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecFlags.cs
deleted file mode 100644
index 1be87e7e0d2fb..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecFlags.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- [Flags]
- public enum ImageCodecFlags
- {
- Encoder = 0x00000001,
- Decoder = 0x00000002,
- SupportBitmap = 0x00000004,
- SupportVector = 0x00000008,
- SeekableEncode = 0x00000010,
- BlockingDecode = 0x00000020,
- Builtin = 0x00010000,
- System = 0x00020000,
- User = 0x00040000
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfo.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfo.cs
deleted file mode 100644
index 750fd9229ad42..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfo.cs
+++ /dev/null
@@ -1,209 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- // sdkinc\imaging.h
- public sealed class ImageCodecInfo
- {
- private Guid _clsid;
- private Guid _formatID;
- private string? _codecName;
- private string? _dllName;
- private string? _formatDescription;
- private string? _filenameExtension;
- private string? _mimeType;
- private ImageCodecFlags _flags;
- private int _version;
- private byte[][]? _signaturePatterns;
- private byte[][]? _signatureMasks;
-
- internal ImageCodecInfo()
- {
- }
-
- public Guid Clsid
- {
- get { return _clsid; }
- set { _clsid = value; }
- }
-
- public Guid FormatID
- {
- get { return _formatID; }
- set { _formatID = value; }
- }
-
- public string? CodecName
- {
- get { return _codecName; }
- set { _codecName = value; }
- }
-
- public string? DllName
- {
- get
- {
- return _dllName;
- }
- set
- {
- _dllName = value;
- }
- }
-
- public string? FormatDescription
- {
- get { return _formatDescription; }
- set { _formatDescription = value; }
- }
-
- public string? FilenameExtension
- {
- get { return _filenameExtension; }
- set { _filenameExtension = value; }
- }
-
- public string? MimeType
- {
- get { return _mimeType; }
- set { _mimeType = value; }
- }
-
- public ImageCodecFlags Flags
- {
- get { return _flags; }
- set { _flags = value; }
- }
-
- public int Version
- {
- get { return _version; }
- set { _version = value; }
- }
-
- [CLSCompliant(false)]
- public byte[][]? SignaturePatterns
- {
- get { return _signaturePatterns; }
- set { _signaturePatterns = value; }
- }
-
- [CLSCompliant(false)]
- public byte[][]? SignatureMasks
- {
- get { return _signatureMasks; }
- set { _signatureMasks = value; }
- }
-
- // Encoder/Decoder selection APIs
-
- public static ImageCodecInfo[] GetImageDecoders()
- {
- ImageCodecInfo[] imageCodecs;
- int numDecoders;
- int size;
-
- int status = Gdip.GdipGetImageDecodersSize(out numDecoders, out size);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- IntPtr memory = Marshal.AllocHGlobal(size);
-
- try
- {
- status = Gdip.GdipGetImageDecoders(numDecoders, size, memory);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numDecoders);
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return imageCodecs;
- }
-
- public static ImageCodecInfo[] GetImageEncoders()
- {
- ImageCodecInfo[] imageCodecs;
- int numEncoders;
- int size;
-
- int status = Gdip.GdipGetImageEncodersSize(out numEncoders, out size);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- IntPtr memory = Marshal.AllocHGlobal(size);
-
- try
- {
- status = Gdip.GdipGetImageEncoders(numEncoders, size, memory);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
-
- imageCodecs = ImageCodecInfo.ConvertFromMemory(memory, numEncoders);
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return imageCodecs;
- }
-
- private static unsafe ImageCodecInfo[] ConvertFromMemory(IntPtr memoryStart, int numCodecs)
- {
- ImageCodecInfo[] codecs = new ImageCodecInfo[numCodecs];
-
- int index;
-
- for (index = 0; index < numCodecs; index++)
- {
- ref readonly ImageCodecInfoPrivate codecp = ref ((ImageCodecInfoPrivate*)memoryStart)[index];
-
- var codec = new ImageCodecInfo();
- codec.Clsid = codecp.Clsid;
- codec.FormatID = codecp.FormatID;
- codec.CodecName = Marshal.PtrToStringUni(codecp.CodecName);
- codec.DllName = Marshal.PtrToStringUni(codecp.DllName);
- codec.FormatDescription = Marshal.PtrToStringUni(codecp.FormatDescription);
- codec.FilenameExtension = Marshal.PtrToStringUni(codecp.FilenameExtension);
- codec.MimeType = Marshal.PtrToStringUni(codecp.MimeType);
-
- codec.Flags = (ImageCodecFlags)codecp.Flags;
- codec.Version = (int)codecp.Version;
-
- codec.SignaturePatterns = new byte[codecp.SigCount][];
- codec.SignatureMasks = new byte[codecp.SigCount][];
-
- for (int j = 0; j < codecp.SigCount; j++)
- {
- codec.SignaturePatterns[j] = new ReadOnlySpan((byte*)codecp.SigPattern + j * codecp.SigSize, codecp.SigSize).ToArray();
- codec.SignatureMasks[j] = new ReadOnlySpan((byte*)codecp.SigMask + j * codecp.SigSize, codecp.SigSize).ToArray();
- }
-
- codecs[index] = codec;
- }
-
- return codecs;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfoPrivate.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfoPrivate.cs
deleted file mode 100644
index ce3a0b9bb7fc0..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageCodecInfoPrivate.cs
+++ /dev/null
@@ -1,30 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
- // sdkinc\imaging.h
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- internal struct ImageCodecInfoPrivate
- {
- public Guid Clsid;
-
- public Guid FormatID;
-
- public IntPtr CodecName;
- public IntPtr DllName;
- public IntPtr FormatDescription;
- public IntPtr FilenameExtension;
- public IntPtr MimeType;
-
- public int Flags;
- public int Version;
- public int SigCount;
- public int SigSize;
-
- public IntPtr SigPattern;
- public IntPtr SigMask;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFlags.cs
deleted file mode 100644
index c1155aa485282..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFlags.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the attributes of the pixel data contained in an object.
- ///
- [Flags]
- public enum ImageFlags
- {
- ///
- /// There is no format information.
- ///
- None = 0,
-
- // Low-word: shared with SINKFLAG_x
-
- ///
- /// Pixel data is scalable.
- ///
- Scalable = 0x0001,
- ///
- /// Pixel data contains alpha information.
- ///
- HasAlpha = 0x0002,
- HasTranslucent = 0x0004,
- ///
- /// Pixel data is partially scalable, but there are some limitations.
- ///
- PartiallyScalable = 0x0008,
-
- // Low-word: color space definition
-
- ///
- /// Pixel data uses an RGB color space.
- ///
- ColorSpaceRgb = 0x0010,
- ///
- /// Pixel data uses a CMYK color space.
- ///
- ColorSpaceCmyk = 0x0020,
- ///
- /// Pixel data is grayscale.
- ///
- ColorSpaceGray = 0x0040,
- ColorSpaceYcbcr = 0x0080,
- ColorSpaceYcck = 0x0100,
-
- // Low-word: image size info
-
- HasRealDpi = 0x1000,
- HasRealPixelSize = 0x2000,
-
- // High-word
-
- ReadOnly = 0x00010000,
- Caching = 0x00020000
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs
deleted file mode 100644
index 41d30e4f88663..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageFormat.cs
+++ /dev/null
@@ -1,205 +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.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.Versioning;
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the format of the image.
- ///
- [TypeConverter(typeof(ImageFormatConverter))]
- public sealed class ImageFormat
- {
- // Format IDs
- // private static ImageFormat undefined = new ImageFormat(new Guid("{b96b3ca9-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_memoryBMP = new ImageFormat(new Guid("{b96b3caa-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_bmp = new ImageFormat(new Guid("{b96b3cab-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_emf = new ImageFormat(new Guid("{b96b3cac-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_wmf = new ImageFormat(new Guid("{b96b3cad-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_jpeg = new ImageFormat(new Guid("{b96b3cae-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_png = new ImageFormat(new Guid("{b96b3caf-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_gif = new ImageFormat(new Guid("{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_tiff = new ImageFormat(new Guid("{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_exif = new ImageFormat(new Guid("{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_icon = new ImageFormat(new Guid("{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_heif = new ImageFormat(new Guid("{b96b3cb6-0728-11d3-9d7b-0000f81ef32e}"));
- private static readonly ImageFormat s_webp = new ImageFormat(new Guid("{b96b3cb7-0728-11d3-9d7b-0000f81ef32e}"));
-
- private readonly Guid _guid;
-
- ///
- /// Initializes a new instance of the class with the specified GUID.
- ///
- public ImageFormat(Guid guid)
- {
- _guid = guid;
- }
-
- ///
- /// Specifies a global unique identifier (GUID) that represents this .
- ///
- public Guid Guid
- {
- get { return _guid; }
- }
-
- ///
- /// Specifies a memory bitmap image format.
- ///
- public static ImageFormat MemoryBmp
- {
- get { return s_memoryBMP; }
- }
-
- ///
- /// Specifies the bitmap image format.
- ///
- public static ImageFormat Bmp
- {
- get { return s_bmp; }
- }
-
- ///
- /// Specifies the enhanced Windows metafile image format.
- ///
- public static ImageFormat Emf
- {
- get { return s_emf; }
- }
-
- ///
- /// Specifies the Windows metafile image format.
- ///
- public static ImageFormat Wmf
- {
- get { return s_wmf; }
- }
-
- ///
- /// Specifies the GIF image format.
- ///
- public static ImageFormat Gif
- {
- get { return s_gif; }
- }
-
- ///
- /// Specifies the JPEG image format.
- ///
- public static ImageFormat Jpeg
- {
- get { return s_jpeg; }
- }
-
- ///
- /// Specifies the W3C PNG image format.
- ///
- public static ImageFormat Png
- {
- get { return s_png; }
- }
-
- ///
- /// Specifies the Tag Image File Format (TIFF) image format.
- ///
- public static ImageFormat Tiff
- {
- get { return s_tiff; }
- }
-
- ///
- /// Specifies the Exchangeable Image Format (EXIF).
- ///
- public static ImageFormat Exif
- {
- get { return s_exif; }
- }
-
- ///
- /// Specifies the Windows icon image format.
- ///
- public static ImageFormat Icon
- {
- get { return s_icon; }
- }
-
- ///
- /// Specifies the High Efficiency Image Format (HEIF).
- ///
- ///
- /// This format is supported since Windows 10 1809.
- ///
- [SupportedOSPlatform("windows10.0.17763.0")]
- public static ImageFormat Heif
- {
- get { return s_heif; }
- }
-
- ///
- /// Specifies the WebP image format.
- ///
- ///
- /// This format is supported since Windows 10 1809.
- ///
- [SupportedOSPlatform("windows10.0.17763.0")]
- public static ImageFormat Webp
- {
- get { return s_webp; }
- }
-
- ///
- /// Returns a value indicating whether the specified object is an equivalent to this
- /// .
- ///
- public override bool Equals([NotNullWhen(true)] object? o)
- {
- ImageFormat? format = o as ImageFormat;
- if (format == null)
- return false;
- return _guid == format._guid;
- }
-
- ///
- /// Returns a hash code.
- ///
- public override int GetHashCode()
- {
- return _guid.GetHashCode();
- }
-
- // Find any random encoder which supports this format
- internal ImageCodecInfo? FindEncoder()
- {
- ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
- foreach (ImageCodecInfo codec in codecs)
- {
- if (codec.FormatID.Equals(_guid))
- return codec;
- }
- return null;
- }
-
- ///
- /// Converts this to a human-readable string.
- ///
- public override string ToString()
- {
- if (this.Guid == s_memoryBMP.Guid) return "MemoryBMP";
- if (this.Guid == s_bmp.Guid) return "Bmp";
- if (this.Guid == s_emf.Guid) return "Emf";
- if (this.Guid == s_wmf.Guid) return "Wmf";
- if (this.Guid == s_gif.Guid) return "Gif";
- if (this.Guid == s_jpeg.Guid) return "Jpeg";
- if (this.Guid == s_png.Guid) return "Png";
- if (this.Guid == s_tiff.Guid) return "Tiff";
- if (this.Guid == s_exif.Guid) return "Exif";
- if (this.Guid == s_icon.Guid) return "Icon";
- if (this.Guid == s_heif.Guid) return "Heif";
- if (this.Guid == s_webp.Guid) return "Webp";
- return $"[ImageFormat: {_guid}]";
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageLockMode.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageLockMode.cs
deleted file mode 100644
index 588ea623860e0..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/ImageLockMode.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- // Access modes used when calling IImage::LockBits
- ///
- /// Indicates the access mode for an .
- ///
- public enum ImageLockMode
- {
- ///
- /// Specifies the image is read-only.
- ///
- ReadOnly = 0x0001,
- ///
- /// Specifies the image is write-only.
- ///
- WriteOnly = 0x0002,
- ///
- /// Specifies the image is read-write.
- ///
- ReadWrite = ReadOnly | WriteOnly,
- ///
- /// Indicates the image resides in a user input buffer, to which the user controls access.
- ///
- UserInputBuffer = 0x0004,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.cs
deleted file mode 100644
index f1a501314d921..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetaHeader.cs
+++ /dev/null
@@ -1,100 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- public sealed class MetaHeader
- {
- // The ENHMETAHEADER structure is defined natively as a union with WmfHeader.
- // Extreme care should be taken if changing the layout of the corresponding managaed
- // structures to minimize the risk of buffer overruns. The affected managed classes
- // are the following: ENHMETAHEADER, MetaHeader, MetafileHeaderWmf, MetafileHeaderEmf.
- private WmfMetaHeader _data;
-
- public MetaHeader()
- {
- }
-
- internal MetaHeader(WmfMetaHeader header)
- {
- _data._type = header._type;
- _data._headerSize = header._headerSize;
- _data._version = header._version;
- _data._size = header._size;
- _data._noObjects = header._noObjects;
- _data._maxRecord = header._maxRecord;
- _data._noParameters = header._noParameters;
- }
-
- ///
- /// Represents the type of the associated .
- ///
- public short Type
- {
- get { return _data._type; }
- set { _data._type = value; }
- }
-
- ///
- /// Represents the sizi, in bytes, of the header file.
- ///
- public short HeaderSize
- {
- get { return _data._headerSize; }
- set { _data._headerSize = value; }
- }
-
- ///
- /// Represents the version number of the header format.
- ///
- public short Version
- {
- get { return _data._version; }
- set { _data._version = value; }
- }
-
- ///
- /// Represents the size, in bytes, of the associated .
- ///
- public int Size
- {
- get { return _data._size; }
- set { _data._size = value; }
- }
-
- public short NoObjects
- {
- get { return _data._noObjects; }
- set { _data._noObjects = value; }
- }
-
- public int MaxRecord
- {
- get { return _data._maxRecord; }
- set { _data._maxRecord = value; }
- }
-
- public short NoParameters
- {
- get { return _data._noParameters; }
- set { _data._noParameters = value; }
- }
-
- internal WmfMetaHeader GetNativeValue() => _data;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- internal struct WmfMetaHeader
- {
- internal short _type;
- internal short _headerSize;
- internal short _version;
- internal int _size;
- internal short _noObjects;
- internal int _maxRecord;
- internal short _noParameters;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs
deleted file mode 100644
index 577761e242fd0..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/Metafile.cs
+++ /dev/null
@@ -1,701 +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.IO;
-using System.ComponentModel;
-using System.Drawing.Internal;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Runtime.Serialization;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Defines a graphic metafile. A metafile contains records that describe a sequence of graphics operations that
- /// can be recorded and played back.
- ///
- [Editor("System.Drawing.Design.MetafileEditor, System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
- "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- [Serializable]
- [TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public sealed class Metafile : Image
- {
- // GDI+ doesn't handle filenames over MAX_PATH very well
- private const int MaxPath = 260;
-
- ///
- /// Initializes a new instance of the class from the specified handle and
- /// .
- ///
- public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader, bool deleteWmf)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromWmf(hmetafile, deleteWmf, wmfHeader, out IntPtr metafile));
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified handle and
- /// .
- ///
- public Metafile(IntPtr henhmetafile, bool deleteEmf)
- {
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromEmf(henhmetafile, deleteEmf, out IntPtr metafile));
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified filename.
- ///
- public Metafile(string filename)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(filename);
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromFile(filename, out IntPtr metafile));
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, Rectangle frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified handle to a device context.
- ///
- public Metafile(IntPtr referenceHdc, EmfType emfType) :
- this(referenceHdc, emfType, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, RectangleF frameRect) :
- this(referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- referenceHdc,
- type,
- ref frameRect,
- frameUnit,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc) :
- this(fileName, referenceHdc, EmfType.EmfPlusDual, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type) :
- this(fileName, referenceHdc, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, string? desc) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, desc)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(fileName);
- if (fileName.Length > MaxPath)
- {
- throw new PathTooLongException();
- }
-
- Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
- fileName,
- referenceHdc,
- type,
- ref frameRect,
- frameUnit,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect) :
- this(fileName, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(fileName, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, string? description) :
- this(fileName, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual, description)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified data stream.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc) :
- this(stream, referenceHdc, EmfType.EmfPlusDual, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified data stream.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, EmfType type) :
- this(stream, referenceHdc, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified data stream.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(stream, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified data stream.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect) :
- this(stream, referenceHdc, frameRect, MetafileFrameUnit.GdiCompatible)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit) :
- this(stream, referenceHdc, frameRect, frameUnit, EmfType.EmfPlusDual)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type) :
- this(stream, referenceHdc, frameRect, frameUnit, type, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified handle and
- /// .
- ///
- public Metafile(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader) :
- this(hmetafile, wmfHeader, false)
- {
- }
-
- ///
- /// Initializes a new instance of the class from the specified stream.
- ///
- public unsafe Metafile(Stream stream)
- {
- ArgumentNullException.ThrowIfNull(stream);
-
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
-
- IntPtr metafile = IntPtr.Zero;
- Gdip.CheckStatus(Gdip.GdipCreateMetafileFromStream(streamWrapper.Ptr, &metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified handle to a device context.
- ///
- public Metafile(IntPtr referenceHdc, EmfType emfType, string? description)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- referenceHdc,
- emfType,
- IntPtr.Zero,
- MetafileFrameUnit.GdiCompatible,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified device context, bounded
- /// by the specified rectangle.
- ///
- public Metafile(IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? desc)
- {
- IntPtr metafile;
-
- if (frameRect.IsEmpty)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafile(
- referenceHdc,
- type,
- IntPtr.Zero,
- MetafileFrameUnit.GdiCompatible,
- desc,
- out metafile));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafileI(
- referenceHdc,
- type,
- ref frameRect,
- frameUnit,
- desc,
- out metafile));
- }
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, EmfType type, string? description)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(fileName);
-
- Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
- fileName,
- referenceHdc,
- type,
- IntPtr.Zero,
- MetafileFrameUnit.GdiCompatible,
- description,
- out IntPtr metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(fileName);
-
- IntPtr metafile;
-
- if (frameRect.IsEmpty)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafileFileName(
- fileName,
- referenceHdc,
- type,
- IntPtr.Zero,
- frameUnit,
- description,
- out metafile));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafileFileNameI(
- fileName,
- referenceHdc,
- type,
- ref frameRect,
- frameUnit,
- description,
- out metafile));
- }
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class from the specified data stream.
- ///
- public unsafe Metafile(Stream stream, IntPtr referenceHdc, EmfType type, string? description)
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
-
- IntPtr metafile = IntPtr.Zero;
- Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
- streamWrapper.Ptr,
- referenceHdc,
- type,
- IntPtr.Zero,
- MetafileFrameUnit.GdiCompatible,
- description,
- &metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public unsafe Metafile(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
-
- IntPtr metafile = IntPtr.Zero;
- Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
- streamWrapper.Ptr,
- referenceHdc,
- type,
- &frameRect,
- frameUnit,
- description,
- &metafile));
-
- SetNativeImage(metafile);
- }
-
- ///
- /// Initializes a new instance of the class with the specified filename.
- ///
- public unsafe Metafile(Stream stream, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string? description)
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
-
- IntPtr metafile = IntPtr.Zero;
- if (frameRect.IsEmpty)
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafileStream(
- streamWrapper.Ptr,
- referenceHdc,
- type,
- IntPtr.Zero,
- frameUnit,
- description,
- &metafile));
- }
- else
- {
- Gdip.CheckStatus(Gdip.GdipRecordMetafileStreamI(
- streamWrapper.Ptr,
- referenceHdc,
- type,
- &frameRect,
- frameUnit,
- description,
- &metafile));
- }
-
- SetNativeImage(metafile);
- }
-
- private Metafile(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
- ///
- /// Initializes a new instance of the class from a native metafile handle.
- ///
- internal Metafile(IntPtr ptr) => SetNativeImage(ptr);
-
- ///
- /// Plays an EMF+ file.
- ///
- public void PlayRecord(EmfPlusRecordType recordType, int flags, int dataSize, byte[] data)
- {
- // Used in conjunction with Graphics.EnumerateMetafile to play an EMF+
- // The data must be DWORD aligned if it's an EMF or EMF+. It must be
- // WORD aligned if it's a WMF.
-
- Gdip.CheckStatus(Gdip.GdipPlayMetafileRecord(
- new HandleRef(this, nativeImage),
- recordType,
- flags,
- dataSize,
- data));
- }
-
- ///
- /// Returns the associated with the specified .
- ///
- public static MetafileHeader GetMetafileHeader(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader)
- {
- MetafileHeader header = new MetafileHeader
- {
- wmf = new MetafileHeaderWmf()
- };
-
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromWmf(hmetafile, wmfHeader, header.wmf));
- return header;
- }
-
- ///
- /// Returns the associated with the specified .
- ///
- public static MetafileHeader GetMetafileHeader(IntPtr henhmetafile)
- {
- MetafileHeader header = new MetafileHeader
- {
- emf = new MetafileHeaderEmf()
- };
-
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromEmf(henhmetafile, header.emf));
- return header;
- }
-
- ///
- /// Returns the associated with the specified .
- ///
- public static MetafileHeader GetMetafileHeader(string fileName)
- {
- // Called in order to emulate exception behavior from .NET Framework related to invalid file paths.
- Path.GetFullPath(fileName);
-
- MetafileHeader header = new MetafileHeader();
-
- IntPtr memory = Marshal.AllocHGlobal(Marshal.SizeOf());
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromFile(fileName, memory));
-
- int[] type = new int[] { 0 };
-
- Marshal.Copy(memory, type, 0, 1);
-
- MetafileType metafileType = (MetafileType)type[0];
-
- if (metafileType == MetafileType.Wmf ||
- metafileType == MetafileType.WmfPlaceable)
- {
- // WMF header
- header.wmf = Marshal.PtrToStructure(memory)!;
- header.emf = null;
- }
- else
- {
- // EMF header
- header.wmf = null;
- header.emf = Marshal.PtrToStructure(memory)!;
- }
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return header;
- }
-
- ///
- /// Returns the associated with the specified .
- ///
- public static MetafileHeader GetMetafileHeader(Stream stream)
- {
- MetafileHeader header;
-
- IntPtr memory = Marshal.AllocHGlobal(Marshal.SizeOf());
-
- try
- {
- using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromStream(streamWrapper.Ptr, memory));
-
- int[] type = new int[] { 0 };
-
- Marshal.Copy(memory, type, 0, 1);
-
- MetafileType metafileType = (MetafileType)type[0];
-
- header = new MetafileHeader();
-
- if (metafileType == MetafileType.Wmf ||
- metafileType == MetafileType.WmfPlaceable)
- {
- // WMF header
- header.wmf = Marshal.PtrToStructure(memory)!;
- header.emf = null;
- }
- else
- {
- // EMF header
- header.wmf = null;
- header.emf = Marshal.PtrToStructure(memory)!;
- }
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return header;
- }
-
- ///
- /// Returns the associated with this .
- ///
- public MetafileHeader GetMetafileHeader()
- {
- MetafileHeader header;
-
- IntPtr memory = Marshal.AllocHGlobal(Marshal.SizeOf());
-
- try
- {
- Gdip.CheckStatus(Gdip.GdipGetMetafileHeaderFromMetafile(new HandleRef(this, nativeImage), memory));
-
- int[] type = new int[] { 0 };
-
- Marshal.Copy(memory, type, 0, 1);
-
- MetafileType metafileType = (MetafileType)type[0];
-
- header = new MetafileHeader();
-
- if (metafileType == MetafileType.Wmf ||
- metafileType == MetafileType.WmfPlaceable)
- {
- // WMF header
- header.wmf = Marshal.PtrToStructure(memory)!;
- header.emf = null;
- }
- else
- {
- // EMF header
- header.wmf = null;
- header.emf = Marshal.PtrToStructure(memory)!;
- }
- }
- finally
- {
- Marshal.FreeHGlobal(memory);
- }
-
- return header;
- }
-
- ///
- /// Returns a Windows handle to an enhanced .
- ///
- public IntPtr GetHenhmetafile()
- {
- Gdip.CheckStatus(Gdip.GdipGetHemfFromMetafile(new HandleRef(this, nativeImage), out IntPtr hEmf));
- return hEmf;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileFrameUnit.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileFrameUnit.cs
deleted file mode 100644
index 8b725c1563614..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileFrameUnit.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the unit of measurement for the rectangle used to size and position a metafile.
- /// This is specified during the creation of the .
- ///
- public enum MetafileFrameUnit
- {
- ///
- /// Specifies a pixel as the unit of measure.
- ///
- Pixel = GraphicsUnit.Pixel,
- ///
- /// Specifies a printer's point as the unit of measure.
- ///
- Point = GraphicsUnit.Point,
- ///
- /// Specifies an inch as the unit of measure.
- ///
- Inch = GraphicsUnit.Inch,
- ///
- /// Specifies 1/300 of an inch as the unit of measure.
- ///
- Document = GraphicsUnit.Document,
- ///
- /// Specifies a millimeter as the unit of measure.
- ///
- Millimeter = GraphicsUnit.Millimeter,
- ///
- /// Specifies .01 millimeter as the unit of measure. Provided for compatibility with GDI.
- ///
- GdiCompatible
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.cs
deleted file mode 100644
index b978161bcac39..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeader.cs
+++ /dev/null
@@ -1,242 +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.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Contains attributes of an associated .
- ///
- [StructLayout(LayoutKind.Sequential)]
- public sealed class MetafileHeader
- {
- // determine which to use by nullity
- internal MetafileHeaderWmf? wmf;
- internal MetafileHeaderEmf? emf;
-
- internal MetafileHeader()
- {
- }
-
- ///
- /// Gets the type of the associated .
- ///
- public MetafileType Type
- {
- get
- {
- return IsWmf() ? wmf!.type : emf!.type;
- }
- }
-
- ///
- /// Gets the size, in bytes, of the associated .
- ///
- public int MetafileSize
- {
- get
- {
- return IsWmf() ? wmf!.size : emf!.size;
- }
- }
-
- ///
- /// Gets the version number of the associated .
- ///
- public int Version
- {
- get
- {
- return IsWmf() ? wmf!.version : emf!.version;
- }
- }
-
- ///
- /// Gets the horizontal resolution, in dots-per-inch, of the associated .
- ///
- public float DpiX
- {
- get
- {
- return IsWmf() ? wmf!.dpiX : emf!.dpiX;
- }
- }
-
- ///
- /// Gets the vertical resolution, in dots-per-inch, of the associated .
- ///
- public float DpiY
- {
- get
- {
- return IsWmf() ? wmf!.dpiY : emf!.dpiY;
- }
- }
-
- ///
- /// Gets a that bounds the associated .
- ///
- public Rectangle Bounds
- {
- get
- {
- return IsWmf() ?
- new Rectangle(wmf!.X, wmf.Y, wmf.Width, wmf.Height) :
- new Rectangle(emf!.X, emf.Y, emf.Width, emf.Height);
- }
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Windows metafile format.
- ///
- public bool IsWmf()
- {
- if ((wmf == null) && (emf == null))
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- if ((wmf != null) &&
- ((wmf.type == MetafileType.Wmf) ||
- (wmf.type == MetafileType.WmfPlaceable)))
- return true;
- else
- return false;
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Windows Placeable metafile format.
- ///
- public bool IsWmfPlaceable()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((wmf != null) && (wmf.type == MetafileType.WmfPlaceable));
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Windows enhanced metafile format.
- ///
- public bool IsEmf()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((emf != null) && (emf.type == MetafileType.Emf));
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Windows enhanced
- /// metafile format or the Windows enhanced metafile plus.
- ///
- public bool IsEmfOrEmfPlus()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((emf != null) && (emf.type >= MetafileType.Emf));
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Windows enhanced
- /// metafile plus format.
- ///
- public bool IsEmfPlus()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((emf != null) && (emf.type >= MetafileType.EmfPlusOnly));
- }
-
- ///
- /// Returns a value indicating whether the associated is in the Dual enhanced metafile
- /// format. This format supports both the enhanced and the enhanced plus format.
- ///
- public bool IsEmfPlusDual()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((emf != null) && (emf.type == MetafileType.EmfPlusDual));
- }
-
- ///
- /// Returns a value indicating whether the associated supports only the Windows
- /// enhanced metafile plus format.
- ///
- public bool IsEmfPlusOnly()
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return ((emf != null) && (emf.type == MetafileType.EmfPlusOnly));
- }
-
- ///
- /// Returns a value indicating whether the associated is device-dependent.
- ///
- public bool IsDisplay()
- {
- return IsEmfPlus() &&
- (((unchecked((int)emf!.emfPlusFlags)) & ((int)EmfPlusFlags.Display)) != 0);
- }
-
- ///
- /// Gets the WMF header file for the associated .
- ///
- public MetaHeader WmfHeader
- {
- get
- {
- if (wmf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return wmf.WmfHeader;
- }
- }
-
- ///
- /// Gets the size, in bytes, of the enhanced metafile plus header file.
- ///
- public int EmfPlusHeaderSize
- {
- get
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return IsWmf() ? wmf!.EmfPlusHeaderSize : emf!.EmfPlusHeaderSize;
- }
- }
-
- ///
- /// Gets the logical horizontal resolution, in dots-per-inch, of the associated .
- ///
- public int LogicalDpiX
- {
- get
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return IsWmf() ? wmf!.LogicalDpiX : emf!.LogicalDpiX;
- }
- }
-
- ///
- /// Gets the logical vertical resolution, in dots-per-inch, of the associated .
- ///
- public int LogicalDpiY
- {
- get
- {
- if (wmf == null && emf == null)
- throw Gdip.StatusException(Gdip.InvalidParameter);
-
- return IsWmf() ? wmf!.LogicalDpiY : emf!.LogicalDpiX;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
deleted file mode 100644
index fc4be30cd6162..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderEmf.cs
+++ /dev/null
@@ -1,51 +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.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing.Imaging
-{
-#if NET7_0_OR_GREATER
- [NativeMarshalling(typeof(PinningMarshaller))]
-#endif
- [StructLayout(LayoutKind.Sequential)]
- internal sealed class MetafileHeaderEmf
- {
- /// The ENHMETAHEADER structure is defined natively as a union with WmfHeader.
- /// Extreme care should be taken if changing the layout of the corresponding managed
- /// structures to minimize the risk of buffer overruns. The affected managed classes
- /// are the following: ENHMETAHEADER, MetaHeader, MetafileHeaderWmf, MetafileHeaderEmf.
- public MetafileType type = MetafileType.Invalid;
- public int size;
- public int version;
- public EmfPlusFlags emfPlusFlags;
- public float dpiX;
- public float dpiY;
- public int X;
- public int Y;
- public int Width;
- public int Height;
- public SafeNativeMethods.ENHMETAHEADER EmfHeader;
- public int EmfPlusHeaderSize;
- public int LogicalDpiX;
- public int LogicalDpiY;
-
- internal ref byte GetPinnableReference() => ref Unsafe.As(ref type);
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(MetafileHeaderEmf), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))]
- internal static unsafe class PinningMarshaller
- {
- public static ref byte GetPinnableReference(MetafileHeaderEmf managed) => ref (managed is null ? ref Unsafe.NullRef() : ref managed.GetPinnableReference());
-
- // All usages in our currently supported scenarios will always go through GetPinnableReference
- public static byte* ConvertToUnmanaged(MetafileHeaderEmf _) => throw new UnreachableException();
- }
-#endif
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
deleted file mode 100644
index 2f5b386e1e04a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileHeaderWmf.cs
+++ /dev/null
@@ -1,165 +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.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing.Imaging
-{
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- internal sealed class MetafileHeaderWmf
- {
- /// The ENHMETAHEADER structure is defined natively as a union with WmfHeader.
- /// Extreme care should be taken if changing the layout of the corresponding managed
- /// structures to minimize the risk of buffer overruns. The affected managed classes
- /// are the following: ENHMETAHEADER, MetaHeader, MetafileHeaderWmf, MetafileHeaderEmf.
- public MetafileType type = MetafileType.Invalid;
- public int size = Marshal.SizeOf();
- public int version;
- public EmfPlusFlags emfPlusFlags;
- public float dpiX;
- public float dpiY;
- public int X;
- public int Y;
- public int Width;
- public int Height;
-
- //The below datatype, WmfHeader, file is defined natively
- //as a union with EmfHeader. Since EmfHeader is a larger
- //structure, we need to pad the struct below so that this
- //will marshal correctly.
-#pragma warning disable CS0618 // Legacy code: We don't care about using obsolete API's.
- [MarshalAs(UnmanagedType.Struct)]
-#pragma warning restore CS0618
- public MetaHeader WmfHeader = new MetaHeader();
- public int dummy1;
- public int dummy2;
- public int dummy3;
- public int dummy4;
- public int dummy5;
- public int dummy6;
- public int dummy7;
- public int dummy8;
- public int dummy9;
- public int dummy10;
- public int dummy11;
- public int dummy12;
- public int dummy13;
- public int dummy14;
- public int dummy15;
- public int dummy16;
-
- public int EmfPlusHeaderSize;
- public int LogicalDpiX;
- public int LogicalDpiY;
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(MetafileHeaderWmf), MarshalMode.ManagedToUnmanagedRef, typeof(InPlaceMarshaller))]
- internal static class Marshaller
- {
- internal unsafe struct InPlaceMarshaller
- {
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- internal struct Native
- {
- /// The ENHMETAHEADER structure is defined natively as a union with WmfHeader.
- /// Extreme care should be taken if changing the layout of the corresponding managed
- /// structures to minimize the risk of buffer overruns. The affected managed classes
- /// are the following: ENHMETAHEADER, MetaHeader, MetafileHeaderWmf, MetafileHeaderEmf.
- internal MetafileType type;
- internal int size;
- internal int version;
- internal EmfPlusFlags emfPlusFlags;
- internal float dpiX;
- internal float dpiY;
- internal int X;
- internal int Y;
- internal int Width;
- internal int Height;
- internal WmfMetaHeader WmfHeader;
- internal int dummy1;
- internal int dummy2;
- internal int dummy3;
- internal int dummy4;
- internal int dummy5;
- internal int dummy6;
- internal int dummy7;
- internal int dummy8;
- internal int dummy9;
- internal int dummy10;
- internal int dummy11;
- internal int dummy12;
- internal int dummy13;
- internal int dummy14;
- internal int dummy15;
- internal int dummy16;
- internal int EmfPlusHeaderSize;
- internal int LogicalDpiX;
- internal int LogicalDpiY;
- }
-
- private MetafileHeaderWmf? _managed;
- private Native _native;
-
- public InPlaceMarshaller()
- {
- _managed = null;
- Unsafe.SkipInit(out _native);
- }
-
- public void FromManaged(MetafileHeaderWmf managed)
- {
- _managed = managed;
- _native.type = managed.type;
- _native.size = managed.size;
- _native.version = managed.version;
- _native.emfPlusFlags = managed.emfPlusFlags;
- _native.dpiX = managed.dpiX;
- _native.dpiY = managed.dpiY;
- _native.X = managed.X;
- _native.Y = managed.Y;
- _native.Width = managed.Width;
- _native.Height = managed.Height;
- _native.WmfHeader = managed.WmfHeader.GetNativeValue();
- _native.dummy16 = managed.dummy16;
- _native.EmfPlusHeaderSize = managed.EmfPlusHeaderSize;
- _native.LogicalDpiX = managed.LogicalDpiX;
- _native.LogicalDpiY = managed.LogicalDpiY;
- }
-
- public Native ToUnmanaged() => _native;
-
- public void FromUnmanaged(Native value) => _native = value;
-
- public MetafileHeaderWmf ToManaged()
- {
- Debug.Assert(_managed is not null);
- _managed.type = _native.type;
- _managed.size = _native.size;
- _managed.version = _native.version;
- _managed.emfPlusFlags = _native.emfPlusFlags;
- _managed.dpiX = _native.dpiX;
- _managed.dpiY = _native.dpiY;
- _managed.X = _native.X;
- _managed.Y = _native.Y;
- _managed.Width = _native.Width;
- _managed.Height = _native.Height;
- _managed.WmfHeader = new MetaHeader(_native.WmfHeader);
- _managed.dummy16 = _native.dummy16;
- _managed.EmfPlusHeaderSize = _native.EmfPlusHeaderSize;
- _managed.LogicalDpiX = _native.LogicalDpiX;
- _managed.LogicalDpiY = _native.LogicalDpiY;
- return _managed;
- }
-
- public void Free() { }
- }
- }
-#endif
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileType.cs
deleted file mode 100644
index 9f657f79d6602..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/MetafileType.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the format of a .
- ///
- public enum MetafileType
- {
- ///
- /// Specifies an invalid type.
- ///
- Invalid,
- ///
- /// Specifies a standard Windows metafile.
- ///
- Wmf,
- ///
- /// Specifies a Windows Placeable metafile.
- ///
- WmfPlaceable,
- ///
- /// Specifies a Windows enhanced metafile.
- ///
- Emf,
- ///
- /// Specifies a Windows enhanced metafile plus.
- ///
- EmfPlusOnly,
- ///
- /// Specifies both enhanced and enhanced plus commands in the same file.
- ///
- EmfPlusDual,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PaletteFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PaletteFlags.cs
deleted file mode 100644
index 3032df9a13fde..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PaletteFlags.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Specifies the type of color data in the system palette. The data can be color data with alpha, grayscale only,
- /// or halftone data.
- ///
- [Flags]
- public enum PaletteFlags
- {
- ///
- /// Specifies alpha data.
- ///
- HasAlpha = 0x0001,
- ///
- /// Specifies grayscale data.
- ///
- GrayScale = 0x0002,
- ///
- /// Specifies halftone data.
- ///
- Halftone = 0x0004
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PixelFormat.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PixelFormat.cs
deleted file mode 100644
index dd6cce55c7d66..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PixelFormat.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- /*
- * In-memory pixel data formats:
- * bits 0-7 = format index
- * bits 8-15 = pixel size (in bits)
- * bits 16-23 = flags
- * bits 24-31 = reserved
- */
-
- // If you modify this file, please update Image.GetColorDepth()
-
- ///
- /// Specifies the format of the color data for each pixel in the image.
- ///
- public enum PixelFormat
- {
- ///
- /// Specifies that pixel data contains color indexed values which means they are an index to colors in the
- /// system color table, as opposed to individual color values.
- ///
- Indexed = 0x00010000,
- ///
- /// Specifies that pixel data contains GDI colors.
- ///
- Gdi = 0x00020000,
- ///
- /// Specifies that pixel data contains alpha values that are not pre-multiplied.
- ///
- Alpha = 0x00040000,
- ///
- /// Specifies that pixel format contains pre-multiplied alpha values.
- ///
- PAlpha = 0x00080000, // What's this?
- Extended = 0x00100000,
- Canonical = 0x00200000,
- ///
- /// Specifies that pixel format is undefined.
- ///
- Undefined = 0,
- ///
- /// Specifies that pixel format is a don't care.
- ///
- DontCare = 0,
- // makes it into devtools, we can change this.
- ///
- /// Specifies that pixel format is 1 bit per pixel indexed color. The color table therefore has two colors in it.
- ///
- Format1bppIndexed = 1 | (1 << 8) | (int)Indexed | (int)Gdi,
- ///
- /// Specifies that pixel format is 4 bits per pixel indexed color. The color table therefore has 16 colors in it.
- ///
- Format4bppIndexed = 2 | (4 << 8) | (int)Indexed | (int)Gdi,
- ///
- /// Specifies that pixel format is 8 bits per pixel indexed color. The color table therefore has 256 colors in it.
- ///
- Format8bppIndexed = 3 | (8 << 8) | (int)Indexed | (int)Gdi,
- Format16bppGrayScale = 4 | (16 << 8) | (int)Extended,
- ///
- /// Specifies that pixel format is 16 bits per pixel. The color information specifies 65536 shades of gray.
- ///
- Format16bppRgb555 = 5 | (16 << 8) | (int)Gdi,
- ///
- /// Specifies that pixel format is 16 bits per pixel. The color information specifies 32768 shades of color of
- /// which 5 bits are red, 5 bits are green and 5 bits are blue.
- ///
- Format16bppRgb565 = 6 | (16 << 8) | (int)Gdi,
- ///
- /// Specifies that pixel format is 16 bits per pixel. The color information specifies 32768 shades of color of
- /// which 5 bits are red, 5 bits are green, 5 bits are blue and 1 bit is alpha.
- ///
- Format16bppArgb1555 = 7 | (16 << 8) | (int)Alpha | (int)Gdi,
- ///
- /// Specifies that pixel format is 24 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 8 bits are red, 8 bits are green and 8 bits are blue.
- ///
- Format24bppRgb = 8 | (24 << 8) | (int)Gdi,
- ///
- /// Specifies that pixel format is 24 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 8 bits are red, 8 bits are green and 8 bits are blue.
- ///
- Format32bppRgb = 9 | (32 << 8) | (int)Gdi,
- ///
- /// Specifies that pixel format is 32 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 8 bits are red, 8 bits are green and 8 bits are blue. The 8 additional bits are alpha bits.
- ///
- Format32bppArgb = 10 | (32 << 8) | (int)Alpha | (int)Gdi | (int)Canonical,
- ///
- /// Specifies that pixel format is 32 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 8 bits are red, 8 bits are green and 8 bits are blue. The 8 additional bits are pre-multiplied alpha bits.
- ///
- Format32bppPArgb = 11 | (32 << 8) | (int)Alpha | (int)PAlpha | (int)Gdi,
- ///
- /// Specifies that pixel format is 48 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 8 bits are red, 8 bits are green and 8 bits are blue. The 8 additional bits are alpha bits.
- ///
- Format48bppRgb = 12 | (48 << 8) | (int)Extended,
- ///
- /// Specifies pixel format is 64 bits per pixel. The color information specifies 16777216 shades of color of
- /// which 16 bits are red, 16 bits are green and 16 bits are blue. The 16 additional bits are alpha bits.
- ///
- Format64bppArgb = 13 | (64 << 8) | (int)Alpha | (int)Canonical | (int)Extended,
- ///
- /// Specifies that pixel format is 64 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 16 bits are red, 16 bits are green and 16 bits are blue. The 16 additional bits are pre-multiplied
- /// alpha bits.
- ///
- Format64bppPArgb = 14 | (64 << 8) | (int)Alpha | (int)PAlpha | (int)Extended,
-
- ///
- /// Specifies that pixel format is 64 bits per pixel. The color information specifies 16777216 shades of color
- /// of which 16 bits are red, 16 bits are green and 16 bits are blue. The 16 additional bits are alpha bits.
- ///
- Max = 15,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PlayRecordCallback.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PlayRecordCallback.cs
deleted file mode 100644
index 3f14fb001fe28..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PlayRecordCallback.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- public delegate void PlayRecordCallback(EmfPlusRecordType recordType, int flags, int dataSize, IntPtr recordData);
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PropertyItem.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PropertyItem.cs
deleted file mode 100644
index cc7974280e30a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/PropertyItem.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Imaging
-{
- // sdkinc\imaging.h
- ///
- /// Encapsulates a metadata property to be included in an image file.
- ///
- public sealed class PropertyItem
- {
- internal PropertyItem()
- {
- }
-
- ///
- /// Represents the ID of the property.
- ///
- public int Id { get; set; }
-
- ///
- /// Represents the length of the property.
- ///
- public int Len { get; set; }
-
- ///
- /// Represents the type of the property.
- ///
- public short Type { get; set; }
-
- ///
- /// Contains the property value.
- ///
- public byte[]? Value { get; set; }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
deleted file mode 100644
index a6761674c0ecc..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Imaging/WmfPlaceableFileHeader.cs
+++ /dev/null
@@ -1,123 +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.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-#if NET7_0_OR_GREATER
-using System.Runtime.InteropServices.Marshalling;
-#endif
-
-namespace System.Drawing.Imaging
-{
- ///
- /// Defines an Placeable Metafile.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public sealed class WmfPlaceableFileHeader
- {
- private int _key = unchecked((int)0x9aC6CDD7);
- private short _hmf;
- private short _bboxLeft;
- private short _bboxTop;
- private short _bboxRight;
- private short _bboxBottom;
- private short _inch;
- private int _reserved;
- private short _checksum;
-
- ///
- /// Indicates the presence of a placeable metafile header.
- ///
- public int Key
- {
- get { return _key; }
- set { _key = value; }
- }
-
- ///
- /// Stores the handle of the metafile in memory.
- ///
- public short Hmf
- {
- get { return _hmf; }
- set { _hmf = value; }
- }
-
- ///
- /// The x-coordinate of the upper-left corner of the bounding rectangle of the metafile image on the output device.
- ///
- public short BboxLeft
- {
- get { return _bboxLeft; }
- set { _bboxLeft = value; }
- }
-
- ///
- /// The y-coordinate of the upper-left corner of the bounding rectangle of the metafile image on the output device.
- ///
- public short BboxTop
- {
- get { return _bboxTop; }
- set { _bboxTop = value; }
- }
-
- ///
- /// The x-coordinate of the lower-right corner of the bounding rectangle of the metafile image on the output device.
- ///
- public short BboxRight
- {
- get { return _bboxRight; }
- set { _bboxRight = value; }
- }
-
- ///
- /// The y-coordinate of the lower-right corner of the bounding rectangle of the metafile image on the output device.
- ///
- public short BboxBottom
- {
- get { return _bboxBottom; }
- set { _bboxBottom = value; }
- }
-
- ///
- /// Indicates the number of twips per inch.
- ///
- public short Inch
- {
- get { return _inch; }
- set { _inch = value; }
- }
-
- ///
- /// Reserved. Do not use.
- ///
- public int Reserved
- {
- get { return _reserved; }
- set { _reserved = value; }
- }
-
- ///
- /// Indicates the checksum value for the previous ten WORDs in the header.
- ///
- public short Checksum
- {
- get { return _checksum; }
- set { _checksum = value; }
- }
-
- internal ref int GetPinnableReference() => ref _key;
-
-#if NET7_0_OR_GREATER
- [CustomMarshaller(typeof(WmfPlaceableFileHeader), MarshalMode.ManagedToUnmanagedIn, typeof(PinningMarshaller))]
- internal static unsafe class PinningMarshaller
- {
- public static ref int GetPinnableReference(WmfPlaceableFileHeader managed) => ref (managed is null ? ref Unsafe.NullRef() : ref managed.GetPinnableReference());
-
- // All usages in our currently supported scenarios will always go through GetPinnableReference
- public static int* ConvertToUnmanaged(WmfPlaceableFileHeader _) => throw new UnreachableException();
- }
-#endif
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.ComWrappers.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.ComWrappers.cs
deleted file mode 100644
index 65079d5698a4b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.ComWrappers.cs
+++ /dev/null
@@ -1,82 +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.Buffers;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Internal
-{
- internal sealed partial class GPStream : Interop.Ole32.IStream
- {
- public unsafe Interop.HRESULT Clone(IntPtr* ppstm)
- {
- if (ppstm == null)
- {
- return Interop.HRESULT.STG_E_INVALIDPOINTER;
- }
-
- // The cloned object should have the same current "position"
- var clone = new GPStream(_dataStream)
- {
- _virtualPosition = _virtualPosition
- };
-
- *ppstm = DrawingCom.Instance.GetOrCreateComInterfaceForObject(clone, CreateComInterfaceFlags.None);
-
- return Interop.HRESULT.S_OK;
- }
-
- public unsafe Interop.HRESULT CopyTo(IntPtr pstm, ulong cb, ulong* pcbRead, ulong* pcbWritten)
- {
- byte[] buffer = ArrayPool.Shared.Rent(4096);
-
- ulong remaining = cb;
- ulong totalWritten = 0;
- ulong totalRead = 0;
-
- fixed (byte* b = buffer)
- {
- while (remaining > 0)
- {
- uint read = remaining < (ulong)buffer.Length ? (uint)remaining : (uint)buffer.Length;
- Read(b, read, &read);
- remaining -= read;
- totalRead += read;
-
- if (read == 0)
- {
- break;
- }
-
- uint written;
- Interop.HRESULT hr = (Interop.HRESULT)WriteToStream(pstm, b, read, &written);
- if (hr != Interop.HRESULT.S_OK)
- {
- return hr;
- }
- totalWritten += written;
- }
- }
-
- ArrayPool.Shared.Return(buffer);
-
- if (pcbRead != null)
- {
- *pcbRead = totalRead;
- }
-
- if (pcbWritten != null)
- {
- *pcbWritten = totalWritten;
- }
-
- return Interop.HRESULT.S_OK;
- }
-
- private static unsafe int WriteToStream(IntPtr pstm, byte* pv, uint cb, uint* pcbWritten)
- {
- return ((delegate* unmanaged)(*(*(void***)pstm + 4 /* IStream.Write slot */)))
- (pstm, pv, cb, pcbWritten);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.cs
deleted file mode 100644
index 524be173b52cf..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GPStream.cs
+++ /dev/null
@@ -1,182 +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.IO;
-
-namespace System.Drawing.Internal
-{
- internal sealed partial class GPStream : Interop.Ole32.IStream
- {
- private readonly Stream _dataStream;
-
- // to support seeking ahead of the stream length...
- private long _virtualPosition = -1;
-
- internal GPStream(Stream stream, bool makeSeekable = true)
- {
- if (makeSeekable && !stream.CanSeek)
- {
- // Copy to a memory stream so we can seek
- MemoryStream memoryStream = new MemoryStream();
- stream.CopyTo(memoryStream);
- _dataStream = memoryStream;
- }
- else
- {
- _dataStream = stream;
- }
- }
-
- private void ActualizeVirtualPosition()
- {
- if (_virtualPosition == -1)
- return;
-
- if (_virtualPosition > _dataStream.Length)
- _dataStream.SetLength(_virtualPosition);
-
- _dataStream.Position = _virtualPosition;
-
- _virtualPosition = -1;
- }
-
- public void Commit(uint grfCommitFlags)
- {
- _dataStream.Flush();
-
- // Extend the length of the file if needed.
- ActualizeVirtualPosition();
- }
-
- public unsafe void Read(byte* pv, uint cb, uint* pcbRead)
- {
- ActualizeVirtualPosition();
-
- // Stream Span API isn't available in 2.0
- Span buffer = new Span(pv, checked((int)cb));
- int read = _dataStream.Read(buffer);
-
- if (pcbRead != null)
- *pcbRead = (uint)read;
- }
-
- public void Revert()
- {
- // We never report ourselves as Transacted, so we can just ignore this.
- }
-
- public unsafe void Seek(long dlibMove, SeekOrigin dwOrigin, ulong* plibNewPosition)
- {
- long position = _virtualPosition;
- if (_virtualPosition == -1)
- {
- position = _dataStream.Position;
- }
-
- long length = _dataStream.Length;
- switch (dwOrigin)
- {
- case SeekOrigin.Begin:
- if (dlibMove <= length)
- {
- _dataStream.Position = dlibMove;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = dlibMove;
- }
- break;
- case SeekOrigin.End:
- if (dlibMove <= 0)
- {
- _dataStream.Position = length + dlibMove;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = length + dlibMove;
- }
- break;
- case SeekOrigin.Current:
- if (dlibMove + position <= length)
- {
- _dataStream.Position = position + dlibMove;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = dlibMove + position;
- }
- break;
- }
-
- if (plibNewPosition == null)
- return;
-
- if (_virtualPosition != -1)
- {
- *plibNewPosition = (ulong)_virtualPosition;
- }
- else
- {
- *plibNewPosition = (ulong)_dataStream.Position;
- }
- }
-
- public void SetSize(ulong value)
- {
- _dataStream.SetLength(checked((long)value));
- }
-
- public unsafe void Stat(Interop.Ole32.STATSTG* pstatstg, Interop.Ole32.STATFLAG grfStatFlag)
- {
- if (pstatstg == null)
- {
- throw new ArgumentNullException(nameof(pstatstg));
- }
-
- *pstatstg = new Interop.Ole32.STATSTG
- {
- cbSize = (ulong)_dataStream.Length,
- type = Interop.Ole32.STGTY.STGTY_STREAM,
-
- // Default read/write access is STGM_READ, which == 0
- grfMode = _dataStream.CanWrite
- ? _dataStream.CanRead
- ? Interop.Ole32.STGM.STGM_READWRITE
- : Interop.Ole32.STGM.STGM_WRITE
- : Interop.Ole32.STGM.Default
- };
-
- if (grfStatFlag == Interop.Ole32.STATFLAG.STATFLAG_DEFAULT)
- {
- // Caller wants a name
- pstatstg->AllocName(_dataStream is FileStream fs ? fs.Name : _dataStream.ToString());
- }
- }
-
- public unsafe void Write(byte* pv, uint cb, uint* pcbWritten)
- {
- ActualizeVirtualPosition();
-
- var buffer = new ReadOnlySpan(pv, checked((int)cb));
- _dataStream.Write(buffer);
-
- if (pcbWritten != null)
- *pcbWritten = cb;
- }
-
- public Interop.HRESULT LockRegion(ulong libOffset, ulong cb, uint dwLockType)
- {
- // Documented way to say we don't support locking
- return Interop.HRESULT.STG_E_INVALIDFUNCTION;
- }
-
- public Interop.HRESULT UnlockRegion(ulong libOffset, ulong cb, uint dwLockType)
- {
- // Documented way to say we don't support locking
- return Interop.HRESULT.STG_E_INVALIDFUNCTION;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GpPathData.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GpPathData.cs
deleted file mode 100644
index 771a95038d825..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/GpPathData.cs
+++ /dev/null
@@ -1,15 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Internal
-{
- [StructLayout(LayoutKind.Sequential)]
- internal unsafe struct GpPathData
- {
- public int Count;
- public PointF* Points;
- public byte* Types;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/ISystemEventTracker.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/ISystemEventTracker.cs
deleted file mode 100644
index b82b21f24d8fd..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/ISystemEventTracker.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.
-
-namespace System.Drawing.Internal
-{
- internal interface ISystemColorTracker
- {
- void OnSystemColorChanged();
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs
deleted file mode 100644
index 384ca75fa78c4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Internal/SystemColorTracker.cs
+++ /dev/null
@@ -1,144 +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.Diagnostics;
-using Microsoft.Win32;
-
-namespace System.Drawing.Internal
-{
- // Keeps track of objects that need to be notified of system color change events.
- // Mostly this means maintaining a list of weak references.
- internal static class SystemColorTracker
- {
- // when I tried the self host, it went over 500 but never over 1000.
- private const int INITIAL_SIZE = 200;
- // If it gets this big, I seriously miscalculated the performance of this object.
- private const int WARNING_SIZE = 100000;
- private const float EXPAND_THRESHOLD = 0.75f;
- private const int EXPAND_FACTOR = 2;
-
- private static WeakReference[] list = new WeakReference[INITIAL_SIZE];
- private static int count;
- private static bool addedTracker;
- private static readonly object lockObject = new object();
-
- internal static void Add(ISystemColorTracker obj)
- {
- lock (lockObject)
- {
- Debug.Assert(list != null, "List is null");
- Debug.Assert(list.Length > 0, "INITIAL_SIZE was initialized after list");
-
- if (list.Length == count)
- {
- GarbageCollectList();
- }
-
- if (!addedTracker)
- {
- addedTracker = true;
- SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(OnUserPreferenceChanged);
- }
-
- // Strictly speaking, we should grab a lock on this class. But since the chances
- // of a problem are so low, the consequences so minimal (something will get accidentally dropped
- // from the list), and the performance of locking so lousy, we'll risk it.
- int index = count;
- count++;
-
- // COM+ takes forever to Finalize() weak references, so it pays to reuse them.
- if (list[index] == null)
- {
- list[index] = new WeakReference(obj);
- }
- else
- {
- Debug.Assert(list[index].Target == null, $"Trying to reuse a weak reference that isn't broken yet: list[{index}], length = {list.Length}");
- list[index].Target = obj;
- }
- }
- }
-
- private static void CleanOutBrokenLinks()
- {
- // Partition the list -- valid references in the low indices, broken references in the high indices.
- // This is taken straight out of Sedgewick (p. 118 on quicksort).
-
- // Basic idea is to find a broken reference on the left side of the list, and swap it with
- // a valid reference on the right
- int right = list.Length - 1;
- int left = 0;
-
- int length = list.Length;
-
- // Loop invariant: everything to the left of "left" is a valid reference,
- // and anything to the right of "right" is broken.
- while (true)
- {
- while (left < length && list[left].Target != null)
- left++;
- while (right >= 0 && list[right].Target == null)
- right--;
-
- if (left >= right)
- {
- count = left;
- break;
- }
-
- WeakReference temp = list[left];
- list[left] = list[right];
- list[right] = temp;
-
- left++;
- right--;
- }
-
- Debug.Assert(count >= 0 && count <= list.Length, "count not a legal index into list");
-
-#if DEBUG
- // Check loop invariant.
-
- // We'd like to assert that any index < count contains a valid pointer,
- // but since garbage collection can happen at any time, it may have been broken
- // after we partitioned it.
- //
- // for (int i = 0; i < count; i++) {
- // Debug.Assert(list[i].Target != null, "Null found on the left side of the list");
- // }
-
- for (int i = count; i < list.Length; i++)
- {
- Debug.Assert(list[i].Target == null, "Partitioning didn't work");
- }
-#endif
- }
-
- private static void GarbageCollectList()
- {
- CleanOutBrokenLinks();
-
- if (count / (float)list.Length > EXPAND_THRESHOLD)
- {
- WeakReference[] newList = new WeakReference[list.Length * EXPAND_FACTOR];
- list.CopyTo(newList, 0);
- list = newList;
-
- Debug.Assert(list.Length < WARNING_SIZE, "SystemColorTracker is using way more memory than expected.");
- }
- }
-
- private static void OnUserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
- {
- // Update pens and brushes
- if (e.Category == UserPreferenceCategory.Color)
- {
- for (int i = 0; i < count; i++)
- {
- Debug.Assert(list[i] != null, "null value in active part of list");
- ((ISystemColorTracker?)list[i].Target)?.OnSystemColorChanged();
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/LocalAppContextSwitches.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/LocalAppContextSwitches.cs
deleted file mode 100644
index 85a6e00fced77..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/LocalAppContextSwitches.cs
+++ /dev/null
@@ -1,30 +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.Runtime.CompilerServices;
-
-namespace System
-{
- internal static partial class LocalAppContextSwitches
- {
- private static int s_dontSupportPngFramesInIcons;
- public static bool DontSupportPngFramesInIcons
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return GetCachedSwitchValue(@"Switch.System.Drawing.DontSupportPngFramesInIcons", ref s_dontSupportPngFramesInIcons);
- }
- }
-
- private static int s_optimizePrintPreview;
- public static bool OptimizePrintPreview
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return GetCachedSwitchValue(@"Switch.System.Drawing.Printing.OptimizePrintPreview", ref s_optimizePrintPreview);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/NativeMethods.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/NativeMethods.cs
deleted file mode 100644
index 4762777ab19fa..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/NativeMethods.cs
+++ /dev/null
@@ -1,54 +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.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- internal static class NativeMethods
- {
- internal static HandleRef NullHandleRef => new HandleRef(null, IntPtr.Zero);
-
- public const int MAX_PATH = 260;
- internal const int SM_REMOTESESSION = 0x1000;
-
- internal const int DIB_RGB_COLORS = 0;
- internal const int BI_BITFIELDS = 3;
- internal const int BI_RGB = 0;
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct BITMAPINFOHEADER
- {
- public int biSize;
- public int biWidth;
- public int biHeight;
- public short biPlanes;
- public short biBitCount;
- public int biCompression;
- public int biSizeImage;
- public int biXPelsPerMeter;
- public int biYPelsPerMeter;
- public int biClrUsed;
- public int biClrImportant;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct PALETTEENTRY
- {
- public byte peRed;
- public byte peGreen;
- public byte peBlue;
- public byte peFlags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct RGBQUAD
- {
- public byte rgbBlue;
- public byte rgbGreen;
- public byte rgbRed;
- public byte rgbReserved;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/NumericsExtensions.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/NumericsExtensions.cs
deleted file mode 100644
index 5cb3fa10ddd02..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/NumericsExtensions.cs
+++ /dev/null
@@ -1,22 +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.Numerics;
-
-namespace System.Drawing
-{
- ///
- /// Helpers to allow using System.Numerics types like the System.Drawing equivalents.
- ///
- internal static class NumericsExtensions
- {
- internal static void Translate(this ref Matrix3x2 matrix, Vector2 offset)
- {
- // Replicating what Matrix.Translate(float offsetX, float offsetY) does.
- matrix.M31 += (offset.X * matrix.M11) + (offset.Y * matrix.M21);
- matrix.M32 += (offset.X * matrix.M12) + (offset.Y * matrix.M22);
- }
-
- internal static bool IsEmpty(this Vector2 vector) => vector.X == 0 && vector.Y == 0;
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs
deleted file mode 100644
index bbe88baa8aa83..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Pen.cs
+++ /dev/null
@@ -1,918 +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.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Drawing2D;
-using System.Drawing.Internal;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// Defines an object used to draw lines and curves.
- ///
- public sealed class Pen : MarshalByRefObject, ICloneable, IDisposable, ISystemColorTracker
- {
-#if FINALIZATION_WATCH
- private string _allocationSite = Graphics.GetAllocationStack();
-#endif
-
- // Handle to native GDI+ pen object.
- private IntPtr _nativePen;
-
- // GDI+ doesn't understand system colors, so we need to cache the value here.
- private Color _color;
- private bool _immutable;
-
- // Tracks whether the dash style has been changed to something else than Solid during the lifetime of this object.
- private bool _dashStyleWasOrIsNotSolid;
-
- ///
- /// Creates a Pen from a native GDI+ object.
- ///
- private Pen(IntPtr nativePen) => SetNativePen(nativePen);
-
- internal Pen(Color color, bool immutable) : this(color) => _immutable = immutable;
-
- ///
- /// Initializes a new instance of the Pen class with the specified .
- ///
- public Pen(Color color) : this(color, (float)1.0)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified
- /// and .
- ///
- public Pen(Color color, float width)
- {
- _color = color;
-
- IntPtr pen;
- int status = Gdip.GdipCreatePen1(color.ToArgb(),
- width,
- (int)GraphicsUnit.World,
- out pen);
- Gdip.CheckStatus(status);
-
- SetNativePen(pen);
-
- if (_color.IsSystemColor)
- {
- SystemColorTracker.Add(this);
- }
- }
-
- ///
- /// Initializes a new instance of the Pen class with the specified .
- ///
- public Pen(Brush brush) : this(brush, (float)1.0)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified and width.
- ///
- public Pen(Brush brush, float width)
- {
- ArgumentNullException.ThrowIfNull(brush);
-
- IntPtr pen;
- int status = Gdip.GdipCreatePen2(new HandleRef(brush, brush.NativeBrush),
- width,
- (int)GraphicsUnit.World,
- out pen);
- Gdip.CheckStatus(status);
-
- SetNativePen(pen);
- }
-
- internal void SetNativePen(IntPtr nativePen)
- {
- Debug.Assert(nativePen != IntPtr.Zero);
- _nativePen = nativePen;
- }
-
- [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
- internal IntPtr NativePen => _nativePen;
-
- ///
- /// Creates an exact copy of this .
- ///
- public object Clone()
- {
- IntPtr clonedPen;
- int status = Gdip.GdipClonePen(new HandleRef(this, NativePen), out clonedPen);
- Gdip.CheckStatus(status);
-
- return new Pen(clonedPen);
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
-#if FINALIZATION_WATCH
- if (!disposing && nativePen != IntPtr.Zero)
- {
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + _allocationSite);
- }
-#endif
-
- if (!disposing)
- {
- // If we are finalizing, then we will be unreachable soon. Finalize calls dispose to
- // release resources, so we must make sure that during finalization we are
- // not immutable.
- _immutable = false;
- }
- else if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- if (_nativePen != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeletePen(new HandleRef(this, NativePen));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- }
- finally
- {
- _nativePen = IntPtr.Zero;
- }
- }
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- ~Pen() => Dispose(false);
-
- ///
- /// Gets or sets the width of this .
- ///
- public float Width
- {
- get
- {
- var width = new float[] { 0 };
- int status = Gdip.GdipGetPenWidth(new HandleRef(this, NativePen), width);
- Gdip.CheckStatus(status);
-
- return width[0];
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenWidth(new HandleRef(this, NativePen), value);
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Sets the values that determine the style of cap used to end lines drawn by this .
- ///
- public void SetLineCap(LineCap startCap, LineCap endCap, DashCap dashCap)
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenLineCap197819(new HandleRef(this, NativePen),
- unchecked((int)startCap), unchecked((int)endCap), unchecked((int)dashCap));
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Gets or sets the cap style used at the beginning of lines drawn with this .
- ///
- public LineCap StartCap
- {
- get
- {
- int startCap;
- int status = Gdip.GdipGetPenStartCap(new HandleRef(this, NativePen), out startCap);
- Gdip.CheckStatus(status);
-
- return (LineCap)startCap;
- }
- set
- {
- switch (value)
- {
- case LineCap.Flat:
- case LineCap.Square:
- case LineCap.Round:
- case LineCap.Triangle:
- case LineCap.NoAnchor:
- case LineCap.SquareAnchor:
- case LineCap.RoundAnchor:
- case LineCap.DiamondAnchor:
- case LineCap.ArrowAnchor:
- case LineCap.AnchorMask:
- case LineCap.Custom:
- break;
- default:
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(LineCap));
- }
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenStartCap(new HandleRef(this, NativePen), unchecked((int)value));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the cap style used at the end of lines drawn with this .
- ///
- public LineCap EndCap
- {
- get
- {
- int endCap;
- int status = Gdip.GdipGetPenEndCap(new HandleRef(this, NativePen), out endCap);
- Gdip.CheckStatus(status);
-
- return (LineCap)endCap;
- }
- set
- {
- switch (value)
- {
- case LineCap.Flat:
- case LineCap.Square:
- case LineCap.Round:
- case LineCap.Triangle:
- case LineCap.NoAnchor:
- case LineCap.SquareAnchor:
- case LineCap.RoundAnchor:
- case LineCap.DiamondAnchor:
- case LineCap.ArrowAnchor:
- case LineCap.AnchorMask:
- case LineCap.Custom:
- break;
- default:
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(LineCap));
- }
-
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenEndCap(new HandleRef(this, NativePen), unchecked((int)value));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets a custom cap style to use at the beginning of lines drawn with this .
- ///
- public CustomLineCap CustomStartCap
- {
- get
- {
- IntPtr lineCap;
- int status = Gdip.GdipGetPenCustomStartCap(new HandleRef(this, NativePen), out lineCap);
- Gdip.CheckStatus(status);
-
- return CustomLineCap.CreateCustomLineCapObject(lineCap);
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenCustomStartCap(new HandleRef(this, NativePen),
- new HandleRef(value, (value == null) ? IntPtr.Zero : value.nativeCap));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets a custom cap style to use at the end of lines drawn with this .
- ///
- public CustomLineCap CustomEndCap
- {
- get
- {
- IntPtr lineCap;
- int status = Gdip.GdipGetPenCustomEndCap(new HandleRef(this, NativePen), out lineCap);
- Gdip.CheckStatus(status);
- return CustomLineCap.CreateCustomLineCapObject(lineCap);
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenCustomEndCap(
- new HandleRef(this, NativePen),
- new HandleRef(value, (value == null) ? IntPtr.Zero : value.nativeCap));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the cap style used at the beginning or end of dashed lines drawn with this .
- ///
- public DashCap DashCap
- {
- get
- {
- int dashCap;
- int status = Gdip.GdipGetPenDashCap197819(new HandleRef(this, NativePen), out dashCap);
- Gdip.CheckStatus(status);
-
- return (DashCap)dashCap;
- }
- set
- {
- if (value != DashCap.Flat && value != DashCap.Round && value != DashCap.Triangle)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(DashCap));
- }
-
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenDashCap197819(new HandleRef(this, NativePen), unchecked((int)value));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the join style for the ends of two overlapping lines drawn with this .
- ///
- public LineJoin LineJoin
- {
- get
- {
- int lineJoin;
- int status = Gdip.GdipGetPenLineJoin(new HandleRef(this, NativePen), out lineJoin);
- Gdip.CheckStatus(status);
-
- return (LineJoin)lineJoin;
- }
- set
- {
- if (value < LineJoin.Miter || value > LineJoin.MiterClipped)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(LineJoin));
- }
-
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenLineJoin(new HandleRef(this, NativePen), unchecked((int)value));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the limit of the thickness of the join on a mitered corner.
- ///
- public float MiterLimit
- {
- get
- {
- var miterLimit = new float[] { 0 };
- int status = Gdip.GdipGetPenMiterLimit(new HandleRef(this, NativePen), miterLimit);
- Gdip.CheckStatus(status);
-
- return miterLimit[0];
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenMiterLimit(new HandleRef(this, NativePen), value);
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the alignment for objects drawn with this .
- ///
- public PenAlignment Alignment
- {
- get
- {
- PenAlignment penMode;
- int status = Gdip.GdipGetPenMode(new HandleRef(this, NativePen), out penMode);
- Gdip.CheckStatus(status);
-
- return penMode;
- }
- set
- {
- if (value < PenAlignment.Center || value > PenAlignment.Right)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(PenAlignment));
- }
-
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenMode(new HandleRef(this, NativePen), value);
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets the geometrical transform for objects drawn with this .
- ///
- public Matrix Transform
- {
- get
- {
- var matrix = new Matrix();
- int status = Gdip.GdipGetPenTransform(new HandleRef(this, NativePen), new HandleRef(matrix, matrix.NativeMatrix));
- Gdip.CheckStatus(status);
-
- return matrix;
- }
-
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- if (value == null)
- {
- throw new ArgumentNullException(nameof(value));
- }
-
- int status = Gdip.GdipSetPenTransform(new HandleRef(this, NativePen), new HandleRef(value, value.NativeMatrix));
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Resets the geometric transform for this to identity.
- ///
- public void ResetTransform()
- {
- int status = Gdip.GdipResetPenTransform(new HandleRef(this, NativePen));
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Multiplies the transform matrix for this by the specified .
- ///
- public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);
-
- ///
- /// Multiplies the transform matrix for this by the specified in the specified order.
- ///
- public void MultiplyTransform(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- if (matrix.NativeMatrix == IntPtr.Zero)
- {
- // Disposed matrices should result in a no-op.
- return;
- }
-
- int status = Gdip.GdipMultiplyPenTransform(new HandleRef(this, NativePen),
- new HandleRef(matrix, matrix.NativeMatrix),
- order);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Translates the local geometrical transform by the specified dimensions. This method prepends the translation
- /// to the transform.
- ///
- public void TranslateTransform(float dx, float dy) => TranslateTransform(dx, dy, MatrixOrder.Prepend);
-
- ///
- /// Translates the local geometrical transform by the specified dimensions in the specified order.
- ///
- public void TranslateTransform(float dx, float dy, MatrixOrder order)
- {
- int status = Gdip.GdipTranslatePenTransform(new HandleRef(this, NativePen),
- dx, dy, order);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Scales the local geometric transform by the specified amounts. This method prepends the scaling matrix to the transform.
- ///
- public void ScaleTransform(float sx, float sy) => ScaleTransform(sx, sy, MatrixOrder.Prepend);
-
- ///
- /// Scales the local geometric transform by the specified amounts in the specified order.
- ///
- public void ScaleTransform(float sx, float sy, MatrixOrder order)
- {
- int status = Gdip.GdipScalePenTransform(new HandleRef(this, NativePen),
- sx, sy, order);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Rotates the local geometric transform by the specified amount. This method prepends the rotation to the transform.
- ///
- public void RotateTransform(float angle) => RotateTransform(angle, MatrixOrder.Prepend);
-
- ///
- /// Rotates the local geometric transform by the specified amount in the specified order.
- ///
- public void RotateTransform(float angle, MatrixOrder order)
- {
- int status = Gdip.GdipRotatePenTransform(new HandleRef(this, NativePen),
- angle, order);
- Gdip.CheckStatus(status);
- }
-
- private void InternalSetColor(Color value)
- {
- int status = Gdip.GdipSetPenColor(new HandleRef(this, NativePen),
- _color.ToArgb());
- Gdip.CheckStatus(status);
-
- _color = value;
- }
-
- ///
- /// Gets the style of lines drawn with this .
- ///
- public PenType PenType
- {
- get
- {
- int type;
- int status = Gdip.GdipGetPenFillType(new HandleRef(this, NativePen), out type);
- Gdip.CheckStatus(status);
-
- return (PenType)type;
- }
- }
-
- ///
- /// Gets or sets the color of this .
- ///
- public Color Color
- {
- get
- {
- if (_color == Color.Empty)
- {
- if (PenType != PenType.SolidColor)
- {
- throw new ArgumentException(SR.GdiplusInvalidParameter);
- }
-
- int colorARGB;
- int status = Gdip.GdipGetPenColor(new HandleRef(this, NativePen), out colorARGB);
- Gdip.CheckStatus(status);
-
- _color = Color.FromArgb(colorARGB);
- }
-
- // GDI+ doesn't understand system colors, so we can't use GdipGetPenColor in the general case.
- return _color;
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- if (value != _color)
- {
- Color oldColor = _color;
- _color = value;
- InternalSetColor(value);
-
- // NOTE: We never remove pens from the active list, so if someone is
- // changing their pen colors a lot, this could be a problem.
- if (value.IsSystemColor && !oldColor.IsSystemColor)
- {
- SystemColorTracker.Add(this);
- }
- }
- }
- }
-
- ///
- /// Gets or sets the that determines attributes of this .
- ///
- public Brush Brush
- {
- get
- {
- Brush? brush = null;
-
- switch (PenType)
- {
- case PenType.SolidColor:
- brush = new SolidBrush(GetNativeBrush());
- break;
-
- case PenType.HatchFill:
- brush = new HatchBrush(GetNativeBrush());
- break;
-
- case PenType.TextureFill:
- brush = new TextureBrush(GetNativeBrush());
- break;
-
- case PenType.PathGradient:
- brush = new PathGradientBrush(GetNativeBrush());
- break;
-
- case PenType.LinearGradient:
- brush = new LinearGradientBrush(GetNativeBrush());
- break;
-
- default:
- break;
- }
-
- return brush!;
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- if (value == null)
- {
- throw new ArgumentNullException(nameof(value));
- }
-
- int status = Gdip.GdipSetPenBrushFill(new HandleRef(this, NativePen),
- new HandleRef(value, value.NativeBrush));
- Gdip.CheckStatus(status);
- }
- }
-
- private IntPtr GetNativeBrush()
- {
- IntPtr nativeBrush;
- int status = Gdip.GdipGetPenBrushFill(new HandleRef(this, NativePen), out nativeBrush);
- Gdip.CheckStatus(status);
-
- return nativeBrush;
- }
-
- ///
- /// Gets or sets the style used for dashed lines drawn with this .
- ///
- public DashStyle DashStyle
- {
- get
- {
- int dashStyle;
- int status = Gdip.GdipGetPenDashStyle(new HandleRef(this, NativePen), out dashStyle);
- Gdip.CheckStatus(status);
-
- return (DashStyle)dashStyle;
- }
- set
- {
- if (value < DashStyle.Solid || value > DashStyle.Custom)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(DashStyle));
- }
-
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenDashStyle(new HandleRef(this, NativePen), unchecked((int)value));
- Gdip.CheckStatus(status);
-
- // If we just set the pen style to Custom without defining the custom dash pattern,
- // make sure that we can return a valid value.
- if (value == DashStyle.Custom)
- {
- EnsureValidDashPattern();
- }
-
- if (value != DashStyle.Solid)
- {
- this._dashStyleWasOrIsNotSolid = true;
- }
- }
- }
-
- ///
- /// This method is called after the user sets the pen's dash style to custom. Here, we make sure that there
- /// is a default value set for the custom pattern.
- ///
- private void EnsureValidDashPattern()
- {
- int retval;
- int status = Gdip.GdipGetPenDashCount(new HandleRef(this, NativePen), out retval);
- Gdip.CheckStatus(status);
-
- if (retval == 0)
- {
- // Set to a solid pattern.
- DashPattern = new float[] { 1 };
- }
- }
-
- ///
- /// Gets or sets the distance from the start of a line to the beginning of a dash pattern.
- ///
- public float DashOffset
- {
- get
- {
- var dashOffset = new float[] { 0 };
- int status = Gdip.GdipGetPenDashOffset(new HandleRef(this, NativePen), dashOffset);
- Gdip.CheckStatus(status);
-
- return dashOffset[0];
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- int status = Gdip.GdipSetPenDashOffset(new HandleRef(this, NativePen), value);
- Gdip.CheckStatus(status);
- }
- }
-
- ///
- /// Gets or sets an array of custom dashes and spaces. The dashes are made up of line segments.
- ///
- public float[] DashPattern
- {
- get
- {
- int status = Gdip.GdipGetPenDashCount(new HandleRef(this, NativePen), out int count);
- Gdip.CheckStatus(status);
-
- float[] pattern;
- // don't call GdipGetPenDashArray with a 0 count
- if (count > 0)
- {
- pattern = new float[count];
- status = Gdip.GdipGetPenDashArray(new HandleRef(this, NativePen), pattern, count);
- Gdip.CheckStatus(status);
- }
- else if (DashStyle == DashStyle.Solid && !this._dashStyleWasOrIsNotSolid)
- {
- // Most likely we're replicating an existing System.Drawing bug here, it doesn't make much sense to
- // ask for a dash pattern when using a solid dash.
- throw new OutOfMemoryException();
- }
- else if (DashStyle == DashStyle.Solid)
- {
- pattern = Array.Empty();
- }
- else
- {
- // special case (not handled inside GDI+)
- pattern = new float[1];
- pattern[0] = 1.0f;
- }
-
- return pattern;
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
-
- if (value == null || value.Length == 0)
- {
- throw new ArgumentException(SR.InvalidDashPattern);
- }
-
- foreach (float val in value)
- {
- if (val <= 0)
- {
- throw new ArgumentException(SR.InvalidDashPattern);
- }
- }
-
- int count = value.Length;
- IntPtr buf = Marshal.AllocHGlobal(checked(4 * count));
-
- try
- {
- Marshal.Copy(value, 0, buf, count);
-
- int status = Gdip.GdipSetPenDashArray(new HandleRef(this, NativePen), new HandleRef(buf, buf), count);
- Gdip.CheckStatus(status);
- }
- finally
- {
- Marshal.FreeHGlobal(buf);
- }
- }
- }
-
- ///
- /// Gets or sets an array of custom dashes and spaces. The dashes are made up of line segments.
- ///
- public float[] CompoundArray
- {
- get
- {
- int count;
- int status = Gdip.GdipGetPenCompoundCount(new HandleRef(this, NativePen), out count);
- Gdip.CheckStatus(status);
-
- var array = new float[count];
- status = Gdip.GdipGetPenCompoundArray(new HandleRef(this, NativePen), array, count);
- Gdip.CheckStatus(status);
-
- return array;
- }
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, nameof(Pen)));
- }
-
- if (value.Length <= 1)
- {
- throw new ArgumentException(SR.GdiplusInvalidParameter);
- }
-
- foreach (float val in value)
- {
- if (val < 0 || val > 1)
- {
- throw new ArgumentException(SR.GdiplusInvalidParameter);
- }
- }
-
- int status = Gdip.GdipSetPenCompoundArray(new HandleRef(this, NativePen), value, value.Length);
- Gdip.CheckStatus(status);
- }
- }
-
- void ISystemColorTracker.OnSystemColorChanged()
- {
- if (NativePen != IntPtr.Zero)
- {
- InternalSetColor(_color);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Pens.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Pens.cs
deleted file mode 100644
index 33ea6e90de1da..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Pens.cs
+++ /dev/null
@@ -1,324 +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 Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public static class Pens
- {
- private static readonly object s_transparentKey = new object();
- private static readonly object s_aliceBlueKey = new object();
- private static readonly object s_antiqueWhiteKey = new object();
- private static readonly object s_aquaKey = new object();
- private static readonly object s_aquamarineKey = new object();
- private static readonly object s_azureKey = new object();
- private static readonly object s_beigeKey = new object();
- private static readonly object s_bisqueKey = new object();
- private static readonly object s_blackKey = new object();
- private static readonly object s_blanchedAlmondKey = new object();
- private static readonly object s_blueKey = new object();
- private static readonly object s_blueVioletKey = new object();
- private static readonly object s_brownKey = new object();
- private static readonly object s_burlyWoodKey = new object();
- private static readonly object s_cadetBlueKey = new object();
- private static readonly object s_chartreuseKey = new object();
- private static readonly object s_chocolateKey = new object();
- private static readonly object s_coralKey = new object();
- private static readonly object s_cornflowerBlueKey = new object();
- private static readonly object s_cornsilkKey = new object();
- private static readonly object s_crimsonKey = new object();
- private static readonly object s_cyanKey = new object();
- private static readonly object s_darkBlueKey = new object();
- private static readonly object s_darkCyanKey = new object();
- private static readonly object s_darkGoldenrodKey = new object();
- private static readonly object s_darkGrayKey = new object();
- private static readonly object s_darkGreenKey = new object();
- private static readonly object s_darkKhakiKey = new object();
- private static readonly object s_darkMagentaKey = new object();
- private static readonly object s_darkOliveGreenKey = new object();
- private static readonly object s_darkOrangeKey = new object();
- private static readonly object s_darkOrchidKey = new object();
- private static readonly object s_darkRedKey = new object();
- private static readonly object s_darkSalmonKey = new object();
- private static readonly object s_darkSeaGreenKey = new object();
- private static readonly object s_darkSlateBlueKey = new object();
- private static readonly object s_darkSlateGrayKey = new object();
- private static readonly object s_darkTurquoiseKey = new object();
- private static readonly object s_darkVioletKey = new object();
- private static readonly object s_deepPinkKey = new object();
- private static readonly object s_deepSkyBlueKey = new object();
- private static readonly object s_dimGrayKey = new object();
- private static readonly object s_dodgerBlueKey = new object();
- private static readonly object s_firebrickKey = new object();
- private static readonly object s_floralWhiteKey = new object();
- private static readonly object s_forestGreenKey = new object();
- private static readonly object s_fuchsiaKey = new object();
- private static readonly object s_gainsboroKey = new object();
- private static readonly object s_ghostWhiteKey = new object();
- private static readonly object s_goldKey = new object();
- private static readonly object s_goldenrodKey = new object();
- private static readonly object s_grayKey = new object();
- private static readonly object s_greenKey = new object();
- private static readonly object s_greenYellowKey = new object();
- private static readonly object s_honeydewKey = new object();
- private static readonly object s_hotPinkKey = new object();
- private static readonly object s_indianRedKey = new object();
- private static readonly object s_indigoKey = new object();
- private static readonly object s_ivoryKey = new object();
- private static readonly object s_khakiKey = new object();
- private static readonly object s_lavenderKey = new object();
- private static readonly object s_lavenderBlushKey = new object();
- private static readonly object s_lawnGreenKey = new object();
- private static readonly object s_lemonChiffonKey = new object();
- private static readonly object s_lightBlueKey = new object();
- private static readonly object s_lightCoralKey = new object();
- private static readonly object s_lightCyanKey = new object();
- private static readonly object s_lightGoldenrodYellowKey = new object();
- private static readonly object s_lightGreenKey = new object();
- private static readonly object s_lightGrayKey = new object();
- private static readonly object s_lightPinkKey = new object();
- private static readonly object s_lightSalmonKey = new object();
- private static readonly object s_lightSeaGreenKey = new object();
- private static readonly object s_lightSkyBlueKey = new object();
- private static readonly object s_lightSlateGrayKey = new object();
- private static readonly object s_lightSteelBlueKey = new object();
- private static readonly object s_lightYellowKey = new object();
- private static readonly object s_limeKey = new object();
- private static readonly object s_limeGreenKey = new object();
- private static readonly object s_linenKey = new object();
- private static readonly object s_magentaKey = new object();
- private static readonly object s_maroonKey = new object();
- private static readonly object s_mediumAquamarineKey = new object();
- private static readonly object s_mediumBlueKey = new object();
- private static readonly object s_mediumOrchidKey = new object();
- private static readonly object s_mediumPurpleKey = new object();
- private static readonly object s_mediumSeaGreenKey = new object();
- private static readonly object s_mediumSlateBlueKey = new object();
- private static readonly object s_mediumSpringGreenKey = new object();
- private static readonly object s_mediumTurquoiseKey = new object();
- private static readonly object s_mediumVioletRedKey = new object();
- private static readonly object s_midnightBlueKey = new object();
- private static readonly object s_mintCreamKey = new object();
- private static readonly object s_mistyRoseKey = new object();
- private static readonly object s_moccasinKey = new object();
- private static readonly object s_navajoWhiteKey = new object();
- private static readonly object s_navyKey = new object();
- private static readonly object s_oldLaceKey = new object();
- private static readonly object s_oliveKey = new object();
- private static readonly object s_oliveDrabKey = new object();
- private static readonly object s_orangeKey = new object();
- private static readonly object s_orangeRedKey = new object();
- private static readonly object s_orchidKey = new object();
- private static readonly object s_paleGoldenrodKey = new object();
- private static readonly object s_paleGreenKey = new object();
- private static readonly object s_paleTurquoiseKey = new object();
- private static readonly object s_paleVioletRedKey = new object();
- private static readonly object s_papayaWhipKey = new object();
- private static readonly object s_peachPuffKey = new object();
- private static readonly object s_peruKey = new object();
- private static readonly object s_pinkKey = new object();
- private static readonly object s_plumKey = new object();
- private static readonly object s_powderBlueKey = new object();
- private static readonly object s_purpleKey = new object();
- private static readonly object s_redKey = new object();
- private static readonly object s_rosyBrownKey = new object();
- private static readonly object s_royalBlueKey = new object();
- private static readonly object s_saddleBrownKey = new object();
- private static readonly object s_salmonKey = new object();
- private static readonly object s_sandyBrownKey = new object();
- private static readonly object s_seaGreenKey = new object();
- private static readonly object s_seaShellKey = new object();
- private static readonly object s_siennaKey = new object();
- private static readonly object s_silverKey = new object();
- private static readonly object s_skyBlueKey = new object();
- private static readonly object s_slateBlueKey = new object();
- private static readonly object s_slateGrayKey = new object();
- private static readonly object s_snowKey = new object();
- private static readonly object s_springGreenKey = new object();
- private static readonly object s_steelBlueKey = new object();
- private static readonly object s_tanKey = new object();
- private static readonly object s_tealKey = new object();
- private static readonly object s_thistleKey = new object();
- private static readonly object s_tomatoKey = new object();
- private static readonly object s_turquoiseKey = new object();
- private static readonly object s_violetKey = new object();
- private static readonly object s_wheatKey = new object();
- private static readonly object s_whiteKey = new object();
- private static readonly object s_whiteSmokeKey = new object();
- private static readonly object s_yellowKey = new object();
- private static readonly object s_yellowGreenKey = new object();
-
- public static Pen Transparent => GetPen(s_transparentKey, Color.Transparent);
-
- public static Pen AliceBlue => GetPen(s_aliceBlueKey, Color.AliceBlue);
- public static Pen AntiqueWhite => GetPen(s_antiqueWhiteKey, Color.AntiqueWhite);
- public static Pen Aqua => GetPen(s_aquaKey, Color.Aqua);
- public static Pen Aquamarine => GetPen(s_aquamarineKey, Color.Aquamarine);
- public static Pen Azure => GetPen(s_azureKey, Color.Azure);
-
- public static Pen Beige => GetPen(s_beigeKey, Color.Beige);
- public static Pen Bisque => GetPen(s_bisqueKey, Color.Bisque);
- public static Pen Black => GetPen(s_blackKey, Color.Black);
- public static Pen BlanchedAlmond => GetPen(s_blanchedAlmondKey, Color.BlanchedAlmond);
- public static Pen Blue => GetPen(s_blueKey, Color.Blue);
- public static Pen BlueViolet => GetPen(s_blueVioletKey, Color.BlueViolet);
- public static Pen Brown => GetPen(s_brownKey, Color.Brown);
- public static Pen BurlyWood => GetPen(s_burlyWoodKey, Color.BurlyWood);
-
- public static Pen CadetBlue => GetPen(s_cadetBlueKey, Color.CadetBlue);
- public static Pen Chartreuse => GetPen(s_chartreuseKey, Color.Chartreuse);
- public static Pen Chocolate => GetPen(s_chocolateKey, Color.Chocolate);
- public static Pen Coral => GetPen(s_coralKey, Color.Coral);
- public static Pen CornflowerBlue => GetPen(s_cornflowerBlueKey, Color.CornflowerBlue);
- public static Pen Cornsilk => GetPen(s_cornsilkKey, Color.Cornsilk);
- public static Pen Crimson => GetPen(s_crimsonKey, Color.Crimson);
- public static Pen Cyan => GetPen(s_cyanKey, Color.Cyan);
-
- public static Pen DarkBlue => GetPen(s_darkBlueKey, Color.DarkBlue);
- public static Pen DarkCyan => GetPen(s_darkCyanKey, Color.DarkCyan);
- public static Pen DarkGoldenrod => GetPen(s_darkGoldenrodKey, Color.DarkGoldenrod);
- public static Pen DarkGray => GetPen(s_darkGrayKey, Color.DarkGray);
- public static Pen DarkGreen => GetPen(s_darkGreenKey, Color.DarkGreen);
- public static Pen DarkKhaki => GetPen(s_darkKhakiKey, Color.DarkKhaki);
- public static Pen DarkMagenta => GetPen(s_darkMagentaKey, Color.DarkMagenta);
- public static Pen DarkOliveGreen => GetPen(s_darkOliveGreenKey, Color.DarkOliveGreen);
- public static Pen DarkOrange => GetPen(s_darkOrangeKey, Color.DarkOrange);
- public static Pen DarkOrchid => GetPen(s_darkOrchidKey, Color.DarkOrchid);
- public static Pen DarkRed => GetPen(s_darkRedKey, Color.DarkRed);
- public static Pen DarkSalmon => GetPen(s_darkSalmonKey, Color.DarkSalmon);
- public static Pen DarkSeaGreen => GetPen(s_darkSeaGreenKey, Color.DarkSeaGreen);
- public static Pen DarkSlateBlue => GetPen(s_darkSlateBlueKey, Color.DarkSlateBlue);
- public static Pen DarkSlateGray => GetPen(s_darkSlateGrayKey, Color.DarkSlateGray);
- public static Pen DarkTurquoise => GetPen(s_darkTurquoiseKey, Color.DarkTurquoise);
- public static Pen DarkViolet => GetPen(s_darkVioletKey, Color.DarkViolet);
- public static Pen DeepPink => GetPen(s_deepPinkKey, Color.DeepPink);
- public static Pen DeepSkyBlue => GetPen(s_deepSkyBlueKey, Color.DeepSkyBlue);
- public static Pen DimGray => GetPen(s_dimGrayKey, Color.DimGray);
- public static Pen DodgerBlue => GetPen(s_dodgerBlueKey, Color.DodgerBlue);
-
- public static Pen Firebrick => GetPen(s_firebrickKey, Color.Firebrick);
- public static Pen FloralWhite => GetPen(s_floralWhiteKey, Color.FloralWhite);
- public static Pen ForestGreen => GetPen(s_forestGreenKey, Color.ForestGreen);
- public static Pen Fuchsia => GetPen(s_fuchsiaKey, Color.Fuchsia);
-
- public static Pen Gainsboro => GetPen(s_gainsboroKey, Color.Gainsboro);
- public static Pen GhostWhite => GetPen(s_ghostWhiteKey, Color.GhostWhite);
- public static Pen Gold => GetPen(s_goldKey, Color.Gold);
- public static Pen Goldenrod => GetPen(s_goldenrodKey, Color.Goldenrod);
- public static Pen Gray => GetPen(s_grayKey, Color.Gray);
- public static Pen Green => GetPen(s_greenKey, Color.Green);
- public static Pen GreenYellow => GetPen(s_greenYellowKey, Color.GreenYellow);
-
- public static Pen Honeydew => GetPen(s_honeydewKey, Color.Honeydew);
- public static Pen HotPink => GetPen(s_hotPinkKey, Color.HotPink);
-
- public static Pen IndianRed => GetPen(s_indianRedKey, Color.IndianRed);
- public static Pen Indigo => GetPen(s_indigoKey, Color.Indigo);
- public static Pen Ivory => GetPen(s_ivoryKey, Color.Ivory);
-
- public static Pen Khaki => GetPen(s_khakiKey, Color.Khaki);
-
- public static Pen Lavender => GetPen(s_lavenderKey, Color.Lavender);
- public static Pen LavenderBlush => GetPen(s_lavenderBlushKey, Color.LavenderBlush);
- public static Pen LawnGreen => GetPen(s_lawnGreenKey, Color.LawnGreen);
- public static Pen LemonChiffon => GetPen(s_lemonChiffonKey, Color.LemonChiffon);
- public static Pen LightBlue => GetPen(s_lightBlueKey, Color.LightBlue);
- public static Pen LightCoral => GetPen(s_lightCoralKey, Color.LightCoral);
- public static Pen LightCyan => GetPen(s_lightCyanKey, Color.LightCyan);
- public static Pen LightGoldenrodYellow => GetPen(s_lightGoldenrodYellowKey, Color.LightGoldenrodYellow);
- public static Pen LightGreen => GetPen(s_lightGreenKey, Color.LightGreen);
- public static Pen LightGray => GetPen(s_lightGrayKey, Color.LightGray);
- public static Pen LightPink => GetPen(s_lightPinkKey, Color.LightPink);
- public static Pen LightSalmon => GetPen(s_lightSalmonKey, Color.LightSalmon);
- public static Pen LightSeaGreen => GetPen(s_lightSeaGreenKey, Color.LightSeaGreen);
- public static Pen LightSkyBlue => GetPen(s_lightSkyBlueKey, Color.LightSkyBlue);
- public static Pen LightSlateGray => GetPen(s_lightSlateGrayKey, Color.LightSlateGray);
- public static Pen LightSteelBlue => GetPen(s_lightSteelBlueKey, Color.LightSteelBlue);
- public static Pen LightYellow => GetPen(s_lightYellowKey, Color.LightYellow);
- public static Pen Lime => GetPen(s_limeKey, Color.Lime);
- public static Pen LimeGreen => GetPen(s_limeGreenKey, Color.LimeGreen);
- public static Pen Linen => GetPen(s_linenKey, Color.Linen);
-
- public static Pen Magenta => GetPen(s_magentaKey, Color.Magenta);
- public static Pen Maroon => GetPen(s_maroonKey, Color.Maroon);
- public static Pen MediumAquamarine => GetPen(s_mediumAquamarineKey, Color.MediumAquamarine);
- public static Pen MediumBlue => GetPen(s_mediumBlueKey, Color.MediumBlue);
- public static Pen MediumOrchid => GetPen(s_mediumOrchidKey, Color.MediumOrchid);
- public static Pen MediumPurple => GetPen(s_mediumPurpleKey, Color.MediumPurple);
- public static Pen MediumSeaGreen => GetPen(s_mediumSeaGreenKey, Color.MediumSeaGreen);
- public static Pen MediumSlateBlue => GetPen(s_mediumSlateBlueKey, Color.MediumSlateBlue);
- public static Pen MediumSpringGreen => GetPen(s_mediumSpringGreenKey, Color.MediumSpringGreen);
- public static Pen MediumTurquoise => GetPen(s_mediumTurquoiseKey, Color.MediumTurquoise);
- public static Pen MediumVioletRed => GetPen(s_mediumVioletRedKey, Color.MediumVioletRed);
- public static Pen MidnightBlue => GetPen(s_midnightBlueKey, Color.MidnightBlue);
- public static Pen MintCream => GetPen(s_mintCreamKey, Color.MintCream);
- public static Pen MistyRose => GetPen(s_mistyRoseKey, Color.MistyRose);
- public static Pen Moccasin => GetPen(s_moccasinKey, Color.Moccasin);
-
- public static Pen NavajoWhite => GetPen(s_navajoWhiteKey, Color.NavajoWhite);
- public static Pen Navy => GetPen(s_navyKey, Color.Navy);
-
- public static Pen OldLace => GetPen(s_oldLaceKey, Color.OldLace);
- public static Pen Olive => GetPen(s_oliveKey, Color.Olive);
- public static Pen OliveDrab => GetPen(s_oliveDrabKey, Color.OliveDrab);
- public static Pen Orange => GetPen(s_orangeKey, Color.Orange);
- public static Pen OrangeRed => GetPen(s_orangeRedKey, Color.OrangeRed);
- public static Pen Orchid => GetPen(s_orchidKey, Color.Orchid);
-
- public static Pen PaleGoldenrod => GetPen(s_paleGoldenrodKey, Color.PaleGoldenrod);
- public static Pen PaleGreen => GetPen(s_paleGreenKey, Color.PaleGreen);
- public static Pen PaleTurquoise => GetPen(s_paleTurquoiseKey, Color.PaleTurquoise);
- public static Pen PaleVioletRed => GetPen(s_paleVioletRedKey, Color.PaleVioletRed);
- public static Pen PapayaWhip => GetPen(s_papayaWhipKey, Color.PapayaWhip);
- public static Pen PeachPuff => GetPen(s_peachPuffKey, Color.PeachPuff);
- public static Pen Peru => GetPen(s_peruKey, Color.Peru);
- public static Pen Pink => GetPen(s_pinkKey, Color.Pink);
- public static Pen Plum => GetPen(s_plumKey, Color.Plum);
- public static Pen PowderBlue => GetPen(s_powderBlueKey, Color.PowderBlue);
- public static Pen Purple => GetPen(s_purpleKey, Color.Purple);
-
- public static Pen Red => GetPen(s_redKey, Color.Red);
- public static Pen RosyBrown => GetPen(s_rosyBrownKey, Color.RosyBrown);
- public static Pen RoyalBlue => GetPen(s_royalBlueKey, Color.RoyalBlue);
-
- public static Pen SaddleBrown => GetPen(s_saddleBrownKey, Color.SaddleBrown);
- public static Pen Salmon => GetPen(s_salmonKey, Color.Salmon);
- public static Pen SandyBrown => GetPen(s_sandyBrownKey, Color.SandyBrown);
- public static Pen SeaGreen => GetPen(s_seaGreenKey, Color.SeaGreen);
- public static Pen SeaShell => GetPen(s_seaShellKey, Color.SeaShell);
- public static Pen Sienna => GetPen(s_siennaKey, Color.Sienna);
- public static Pen Silver => GetPen(s_silverKey, Color.Silver);
- public static Pen SkyBlue => GetPen(s_skyBlueKey, Color.SkyBlue);
- public static Pen SlateBlue => GetPen(s_slateBlueKey, Color.SlateBlue);
- public static Pen SlateGray => GetPen(s_slateGrayKey, Color.SlateGray);
- public static Pen Snow => GetPen(s_snowKey, Color.Snow);
- public static Pen SpringGreen => GetPen(s_springGreenKey, Color.SpringGreen);
- public static Pen SteelBlue => GetPen(s_steelBlueKey, Color.SteelBlue);
-
- public static Pen Tan => GetPen(s_tanKey, Color.Tan);
- public static Pen Teal => GetPen(s_tealKey, Color.Teal);
- public static Pen Thistle => GetPen(s_thistleKey, Color.Thistle);
- public static Pen Tomato => GetPen(s_tomatoKey, Color.Tomato);
- public static Pen Turquoise => GetPen(s_turquoiseKey, Color.Turquoise);
-
- public static Pen Violet => GetPen(s_violetKey, Color.Violet);
-
- public static Pen Wheat => GetPen(s_wheatKey, Color.Wheat);
- public static Pen White => GetPen(s_whiteKey, Color.White);
- public static Pen WhiteSmoke => GetPen(s_whiteSmokeKey, Color.WhiteSmoke);
-
- public static Pen Yellow => GetPen(s_yellowKey, Color.Yellow);
- public static Pen YellowGreen => GetPen(s_yellowGreenKey, Color.YellowGreen);
-
- private static Pen GetPen(object key, Color color)
- {
- Pen? Pen = (Pen?)Gdip.ThreadData[key];
- if (Pen == null)
- {
- Pen = new Pen(color, true);
- Gdip.ThreadData[key] = Pen;
- }
- return Pen;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/PointConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/PointConverter.cs
deleted file mode 100644
index 8079717120c12..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/PointConverter.cs
+++ /dev/null
@@ -1,191 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing {
- using System.Runtime.Serialization.Formatters;
- using System.Runtime.InteropServices;
-
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
-
- using Microsoft.Win32;
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design.Serialization;
- using System.Globalization;
- using System.Reflection;
-
- ///
- ///
- /// PointConverter is a class that can be used to convert
- /// Point from one data type to another. Access this
- /// class through the TypeDescriptor.
- ///
- public class PointConverter : TypeConverter {
-
- ///
- ///
- /// Determines if this converter can convert an object in the given source
- /// type to the native type of the converter.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
- if (sourceType == typeof(string)) {
- return true;
- }
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- ///
- /// Gets a value indicating whether this converter can
- /// convert an object to the given destination type using the context.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type? destinationType) {
- if (destinationType == typeof(InstanceDescriptor)) {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- ///
- ///
- /// Converts the given object to the converter's native type.
- ///
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
-
- string strValue = value as string;
-
- if (strValue != null) {
-
- string text = strValue.Trim();
-
- if (text.Length == 0) {
- return null;
- }
- else {
-
- // Parse 2 integer values.
- //
- culture ??= CultureInfo.CurrentCulture;
- char sep = culture.TextInfo.ListSeparator[0];
- string[] tokens = text.Split(sep);
- int[] values = new int[tokens.Length];
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- for (int i = 0; i < values.Length; i++) {
- // Note: ConvertFromString will raise exception if value cannot be converted.
- values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]);
- }
-
- if (values.Length == 2) {
- return new Point(values[0], values[1]);
- }
- else {
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat,
- text,
- "x, y"));
- }
- }
- }
-
- return base.ConvertFrom(context, culture, value);
- }
-
- ///
- ///
- /// Converts the given object to another type. The most common types to convert
- /// are to and from a string object. The default implementation will make a call
- /// to ToString on the object if the object is valid and if the destination
- /// type is string. If this cannot convert to the destination type, this will
- /// throw a NotSupportedException.
- ///
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
- if (destinationType == null) {
- throw new ArgumentNullException(nameof(destinationType));
- }
-
- if (value is Point){
- if (destinationType == typeof(string)) {
- Point pt = (Point)value;
-
- culture ??= CultureInfo.CurrentCulture;
- string sep = culture.TextInfo.ListSeparator + " ";
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- string[] args = new string[2];
- int nArg = 0;
-
- // Note: ConvertToString will raise exception if value cannot be converted.
- args[nArg++] = intConverter.ConvertToString(context, culture, pt.X);
- args[nArg++] = intConverter.ConvertToString(context, culture, pt.Y);
-
- return string.Join(sep, args);
- }
- if (destinationType == typeof(InstanceDescriptor)) {
- Point pt = (Point)value;
-
- ConstructorInfo ctor = typeof(Point).GetConstructor(new Type[] {typeof(int), typeof(int)});
- if (ctor != null) {
- return new InstanceDescriptor(ctor, new object[] {pt.X, pt.Y});
- }
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- ///
- ///
- /// Creates an instance of this type given a set of property values
- /// for the object. This is useful for objects that are immutable, but still
- /// want to provide changable properties.
- ///
- public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) {
- if ( propertyValues == null ) {
- throw new ArgumentNullException( nameof(propertyValues) );
- }
-
- object x = propertyValues["X"];
- object y = propertyValues["Y"];
-
- if (x == null || y == null ||
- !(x is int) || !(y is int)) {
- throw new ArgumentException(SR.PropertyValueInvalidEntry);
- }
-
-
- return new Point((int)x,
- (int)y);
-
- }
-
- ///
- ///
- /// Determines if changing a value on this object should require a call to
- /// CreateInstance to create a new value.
- ///
- public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- ///
- ///
- /// Retrieves the set of properties for this type. By default, a type has
- /// does not return any properties. An easy implementation of this method
- /// can just call TypeDescriptor.GetProperties for the correct data type.
- ///
- public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
- PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Point), attributes);
- return props.Sort(new string[] {"X", "Y"});
- }
-
-
- ///
- ///
- /// Determines if this object supports properties. By default, this
- /// is false.
- ///
- public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/DefaultPrintController.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/DefaultPrintController.cs
deleted file mode 100644
index 1a78f2e4ebe7e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/DefaultPrintController.cs
+++ /dev/null
@@ -1,149 +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.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Internal;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies a print controller that sends information to a printer.
- ///
- public class StandardPrintController : PrintController
- {
- private DeviceContext? _dc;
- private Graphics? _graphics;
-
- ///
- /// Implements StartPrint for printing to a physical printer.
- ///
- public override void OnStartPrint(PrintDocument document, PrintEventArgs e)
- {
- Debug.Assert(_dc == null && _graphics == null, "PrintController methods called in the wrong order?");
-
- base.OnStartPrint(document, e);
- // the win32 methods below SuppressUnmanagedCodeAttributes so assertin on UnmanagedCodePermission is redundant
- if (!document.PrinterSettings.IsValid)
- throw new InvalidPrinterException(document.PrinterSettings);
-
- Debug.Assert(_modeHandle != null, "_modeHandle should have been set by PrintController.OnStartPrint");
- _dc = document.PrinterSettings.CreateDeviceContext(_modeHandle);
- Interop.Gdi32.DOCINFO info = new Interop.Gdi32.DOCINFO();
- info.lpszDocName = document.DocumentName;
- if (document.PrinterSettings.PrintToFile)
- info.lpszOutput = document.PrinterSettings.OutputPort; //This will be "FILE:"
- else
- info.lpszOutput = null;
- info.lpszDatatype = null;
- info.fwType = 0;
-
- int result = Interop.Gdi32.StartDoc(new HandleRef(_dc, _dc.Hdc), info);
- if (result <= 0)
- {
- int error = Marshal.GetLastPInvokeError();
- if (error == SafeNativeMethods.ERROR_CANCELLED)
- {
- e.Cancel = true;
- }
- else
- {
- throw new Win32Exception(error);
- }
- }
- }
-
- ///
- /// Implements StartPage for printing to a physical printer.
- ///
- public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
- {
- Debug.Assert(_dc != null && _graphics == null, "PrintController methods called in the wrong order?");
- Debug.Assert(_modeHandle != null);
-
- base.OnStartPage(document, e);
- e.PageSettings.CopyToHdevmode(_modeHandle);
- IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, _modeHandle));
- try
- {
- IntPtr result = Interop.Gdi32.ResetDC(new HandleRef(_dc, _dc.Hdc), new HandleRef(null, modePointer));
- Debug.Assert(result == _dc.Hdc, "ResetDC didn't return the same handle I gave it");
- }
- finally
- {
- Interop.Kernel32.GlobalUnlock(new HandleRef(this, _modeHandle));
- }
-
- _graphics = Graphics.FromHdcInternal(_dc.Hdc);
-
- if (document.OriginAtMargins)
- {
- // Adjust the origin of the graphics object to be at the
- // user-specified margin location
- //
- int dpiX = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- int dpiY = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSY);
- int hardMarginX_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX);
- int hardMarginY_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY);
- float hardMarginX = hardMarginX_DU * 100 / dpiX;
- float hardMarginY = hardMarginY_DU * 100 / dpiY;
-
- _graphics.TranslateTransform(-hardMarginX, -hardMarginY);
- _graphics.TranslateTransform(document.DefaultPageSettings.Margins.Left, document.DefaultPageSettings.Margins.Top);
- }
-
-
- int result2 = Interop.Gdi32.StartPage(new HandleRef(_dc, _dc.Hdc));
- if (result2 <= 0)
- throw new Win32Exception();
- return _graphics;
- }
-
- ///
- /// Implements EndPage for printing to a physical printer.
- ///
- public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
- {
- Debug.Assert(_dc != null && _graphics != null, "PrintController methods called in the wrong order?");
-
- try
- {
- int result = Interop.Gdi32.EndPage(new HandleRef(_dc, _dc.Hdc));
- if (result <= 0)
- throw new Win32Exception();
- }
- finally
- {
- _graphics.Dispose(); // Dispose of GDI+ Graphics; keep the DC
- _graphics = null;
- }
- base.OnEndPage(document, e);
- }
-
- ///
- /// Implements EndPrint for printing to a physical printer.
- ///
- public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
- {
- Debug.Assert(_dc != null && _graphics == null, "PrintController methods called in the wrong order?");
-
- if (_dc != null)
- {
- try
- {
- int result = (e.Cancel) ? Interop.Gdi32.AbortDoc(new HandleRef(_dc, _dc.Hdc)) : Interop.Gdi32.EndDoc(new HandleRef(_dc, _dc.Hdc));
- if (result <= 0)
- throw new Win32Exception();
- }
- finally
- {
- _dc.Dispose();
- _dc = null;
- }
- }
-
- base.OnEndPrint(document, e);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Duplex.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Duplex.cs
deleted file mode 100644
index 2cafdd74cec71..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Duplex.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the printer's duplex setting.
- ///
- public enum Duplex
- {
- ///
- /// The printer's default duplex setting.
- ///
- Default = -1,
-
- ///
- /// Single-sided printing.
- ///
- Simplex = SafeNativeMethods.DMDUP_SIMPLEX,
-
- ///
- /// Double-sided, horizontal printing.
- ///
- Horizontal = SafeNativeMethods.DMDUP_HORIZONTAL,
-
- ///
- /// Double-sided, vertical printing.
- ///
- Vertical = SafeNativeMethods.DMDUP_VERTICAL,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Core.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Core.cs
deleted file mode 100644
index 4f8e6b67dc289..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Core.cs
+++ /dev/null
@@ -1,27 +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.Runtime.Serialization;
-
-/*
- * This file is not intended to be used by Mono.
- * Instead InvalidPrinterException.Serializable.cs should be used.
- */
-
-namespace System.Drawing.Printing
-{
- [System.Runtime.CompilerServices.TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
- public partial class InvalidPrinterException
- {
- protected InvalidPrinterException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- // Ignoring not deserializable input
- }
-
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData(info, context);
- info.AddValue("settings", null);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Serializable.cs
deleted file mode 100644
index 603bd2ef43818..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.Serializable.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This file isn't built into the .csproj in the runtime libraries but is consumed by Mono.
-
-using System.Runtime.Serialization;
-
-namespace System.Drawing.Printing
-{
- partial class InvalidPrinterException
- {
- protected InvalidPrinterException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- _settings = (PrinterSettings)info.GetValue("settings", typeof(PrinterSettings));
- }
-
- public override void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- base.GetObjectData(info, context);
- info.AddValue("settings", _settings);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.cs
deleted file mode 100644
index 5a9979fe9e63a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/InvalidPrinterException.cs
+++ /dev/null
@@ -1,44 +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.Security;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Represents the exception that is thrown when trying to access a printer using invalid printer settings.
- ///
- [Serializable]
- public partial class InvalidPrinterException : SystemException
- {
- private readonly PrinterSettings? _settings;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public InvalidPrinterException(PrinterSettings settings)
- : base(GenerateMessage(settings))
- {
- _settings = settings;
- }
-
- private static string GenerateMessage(PrinterSettings settings)
- {
- if (settings.IsDefaultPrinter)
- {
- return SR.InvalidPrinterException_NoDefaultPrinter;
- }
- else
- {
- try
- {
- return SR.Format(SR.InvalidPrinterException_InvalidPrinter, settings.PrinterName);
- }
- catch (SecurityException)
- {
- return SR.Format(SR.InvalidPrinterException_InvalidPrinter, SR.CantTellPrinterName);
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.Serializable.cs
deleted file mode 100644
index dddcf62f2cb6d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.Serializable.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This file isn't built into the .csproj in the runtime libraries but is consumed by Mono.
-
-using System.Runtime.Serialization;
-
-namespace System.Drawing.Printing
-{
- [Serializable]
- partial class Margins
- {
- [OnDeserialized]
- private void OnDeserializedMethod(StreamingContext context)
- {
- if (_doubleLeft == 0 && _left != 0)
- {
- _doubleLeft = (double)_left;
- }
-
- if (_doubleRight == 0 && _right != 0)
- {
- _doubleRight = (double)_right;
- }
-
- if (_doubleTop == 0 && _top != 0)
- {
- _doubleTop = (double)_top;
- }
-
- if (_doubleBottom == 0 && _bottom != 0)
- {
- _doubleBottom = (double)_bottom;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.cs
deleted file mode 100644
index bcf82122dc533..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/Margins.cs
+++ /dev/null
@@ -1,240 +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.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Runtime.Serialization;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the margins of a printed page.
- ///
- [TypeConverter(typeof(MarginsConverter))]
- public partial class Margins : ICloneable
- {
- private int _left;
- private int _right;
- private int _bottom;
- private int _top;
-
- [OptionalField]
- private double _doubleLeft;
-
- [OptionalField]
- private double _doubleRight;
-
- [OptionalField]
- private double _doubleTop;
-
- [OptionalField]
- private double _doubleBottom;
-
- ///
- /// Initializes a new instance of a the class with one-inch margins.
- ///
- public Margins() : this(100, 100, 100, 100)
- {
- }
-
- ///
- /// Initializes a new instance of a the class with the specified left, right, top, and bottom margins.
- ///
- public Margins(int left, int right, int top, int bottom)
- {
- CheckMargin(left, nameof(left));
- CheckMargin(right, nameof(right));
- CheckMargin(top, nameof(top));
- CheckMargin(bottom, nameof(bottom));
-
- _left = left;
- _right = right;
- _top = top;
- _bottom = bottom;
-
- _doubleLeft = (double)left;
- _doubleRight = (double)right;
- _doubleTop = (double)top;
- _doubleBottom = (double)bottom;
- }
-
- ///
- /// Gets or sets the left margin, in hundredths of an inch.
- ///
- public int Left
- {
- get => _left;
- set
- {
- CheckMargin(value, nameof(value));
- _left = value;
- _doubleLeft = (double)value;
- }
- }
-
- ///
- /// Gets or sets the right margin, in hundredths of an inch.
- ///
- public int Right
- {
- get => _right;
- set
- {
- CheckMargin(value, nameof(value));
- _right = value;
- _doubleRight = (double)value;
- }
- }
-
- ///
- /// Gets or sets the top margin, in hundredths of an inch.
- ///
- public int Top
- {
- get => _top;
- set
- {
- CheckMargin(value, nameof(value));
- _top = value;
- _doubleTop = (double)value;
- }
- }
-
- ///
- /// Gets or sets the bottom margin, in hundredths of an inch.
- ///
- public int Bottom
- {
- get => _bottom;
- set
- {
- CheckMargin(value, nameof(value));
- _bottom = value;
- _doubleBottom = (double)value;
- }
- }
-
- ///
- /// Gets or sets the left margin with double value, in hundredths of an inch.
- /// When use the setter, the ranger of setting double value should between
- /// 0 to Int.MaxValue;
- ///
- internal double DoubleLeft
- {
- get => _doubleLeft;
- set
- {
- Left = (int)Math.Round(value);
- _doubleLeft = value;
- }
- }
-
- ///
- /// Gets or sets the right margin with double value, in hundredths of an inch.
- /// When use the setter, the ranger of setting double value should between
- /// 0 to Int.MaxValue;
- ///
- internal double DoubleRight
- {
- get => _doubleRight;
- set
- {
- Right = (int)Math.Round(value);
- _doubleRight = value;
- }
- }
-
- ///
- /// Gets or sets the top margin with double value, in hundredths of an inch.
- /// When use the setter, the ranger of setting double value should between
- /// 0 to Int.MaxValue;
- ///
- internal double DoubleTop
- {
- get => _doubleTop;
- set
- {
- Top = (int)Math.Round(value);
- _doubleTop = value;
- }
- }
-
- ///
- /// Gets or sets the bottom margin with double value, in hundredths of an inch.
- /// When use the setter, the ranger of setting double value should between
- /// 0 to Int.MaxValue;
- ///
- internal double DoubleBottom
- {
- get => _doubleBottom;
- set
- {
- Bottom = (int)Math.Round(value);
- _doubleBottom = value;
- }
- }
-
- private static void CheckMargin(int margin, string name)
- {
- if (margin < 0)
- {
- throw new ArgumentOutOfRangeException(name, margin, SR.Format(SR.InvalidLowBoundArgumentEx, name, margin, 0));
- }
- }
-
- ///
- /// Retrieves a duplicate of this object, member by member.
- ///
- public object Clone() => MemberwiseClone();
-
- ///
- /// Compares this to a specified to see whether they
- /// are equal.
- ///
- public override bool Equals([NotNullWhen(true)] object? obj)
- {
- if (!(obj is Margins margins))
- {
- return false;
- }
-
- return margins.Left == Left
- && margins.Right == Right
- && margins.Top == Top
- && margins.Bottom == Bottom;
- }
-
- ///
- /// Calculates and retrieves a hash code based on the left, right, top, and bottom margins.
- ///
- public override int GetHashCode() => HashCode.Combine(Left, Right, Top, Bottom);
-
- ///
- /// Tests whether two objects are identical.
- ///
- public static bool operator ==(Margins? m1, Margins? m2)
- {
- if (m1 is null)
- {
- return m2 is null;
- }
- if (m2 is null)
- {
- return false;
- }
-
- return m1.Equals(m2);
- }
-
- ///
- /// Tests whether two objects are different.
- ///
- public static bool operator !=(Margins? m1, Margins? m2) => !(m1 == m2);
-
- ///
- /// Provides some interesting information for the Margins in String form.
- ///
- public override string ToString() => $"[Margins Left={Left} Right={Right} Top={Top} Bottom={Bottom}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/MarginsConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/MarginsConverter.cs
deleted file mode 100644
index 30836c4470e47..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/MarginsConverter.cs
+++ /dev/null
@@ -1,160 +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.Collections;
-using System.ComponentModel;
-using System.ComponentModel.Design.Serialization;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Reflection;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Provides a type converter to convert to and from various other representations, such as a string.
- ///
- public class MarginsConverter : ExpandableObjectConverter
- {
- ///
- /// Determines if a converter can convert an object of the given source
- /// type to the native type of the converter.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
- {
- if (sourceType == typeof(string))
- {
- return true;
- }
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- /// Gets a value indicating whether this converter can
- /// convert an object to the given destination type using the context.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
- {
- if (destinationType == typeof(InstanceDescriptor))
- {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- ///
- /// Converts the given object to the converter's native type.
- ///
- public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
- {
- if (value is string strValue)
- {
- string text = strValue.Trim();
-
- if (text.Length == 0)
- {
- return null;
- }
- else
- {
- // Parse 4 integer values.
- culture ??= CultureInfo.CurrentCulture;
- char sep = culture.TextInfo.ListSeparator[0];
- string[] tokens = text.Split(sep);
- int[] values = new int[tokens.Length];
- TypeConverter intConverter = GetIntConverter();
- for (int i = 0; i < values.Length; i++)
- {
- // Note: ConvertFromString will raise exception if value cannot be converted.
- values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i])!;
- }
- if (values.Length != 4)
- {
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat, text, "left, right, top, bottom"));
- }
- return new Margins(values[0], values[1], values[2], values[3]);
- }
- }
- return base.ConvertFrom(context, culture, value);
- }
-
- [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
- Justification = "TypeDescriptor.GetConverter is safe for primitive types.")]
- private static TypeConverter GetIntConverter() => TypeDescriptor.GetConverter(typeof(int));
-
- ///
- /// Converts the given object to another type. The most common types to convert
- /// are to and from a string object. The default implementation will make a call
- /// to ToString on the object if the object is valid and if the destination
- /// type is string. If this cannot convert to the destination type, this will
- /// throw a NotSupportedException.
- ///
- public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
- {
- ArgumentNullException.ThrowIfNull(destinationType);
-
- if (value is Margins margins)
- {
- if (destinationType == typeof(string))
- {
- culture ??= CultureInfo.CurrentCulture;
- string sep = culture.TextInfo.ListSeparator + " ";
- TypeConverter intConverter = GetIntConverter();
- string?[] args = new string[4];
- int nArg = 0;
-
- // Note: ConvertToString will raise exception if value cannot be converted.
- args[nArg++] = intConverter.ConvertToString(context, culture, margins.Left);
- args[nArg++] = intConverter.ConvertToString(context, culture, margins.Right);
- args[nArg++] = intConverter.ConvertToString(context, culture, margins.Top);
- args[nArg++] = intConverter.ConvertToString(context, culture, margins.Bottom);
-
- return string.Join(sep, args);
- }
- if (destinationType == typeof(InstanceDescriptor))
- {
- ConstructorInfo? ctor = typeof(Margins).GetConstructor(new Type[] {
- typeof(int), typeof(int), typeof(int), typeof(int)});
-
- if (ctor != null)
- {
- return new InstanceDescriptor(ctor, new object[] {
- margins.Left, margins.Right, margins.Top, margins.Bottom});
- }
- }
- }
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- ///
- /// Determines if changing a value on this object should require a call to
- /// CreateInstance to create a new value.
- ///
- public override bool GetCreateInstanceSupported(ITypeDescriptorContext? context) => true;
-
- ///
- /// Creates an instance of this type given a set of property values
- /// for the object. This is useful for objects that are immutable, but still
- /// want to provide changable properties.
- ///
- public override object CreateInstance(ITypeDescriptorContext? context, IDictionary propertyValues)
- {
- ArgumentNullException.ThrowIfNull(propertyValues);
-
- object? left = propertyValues["Left"];
- object? right = propertyValues["Right"];
- object? top = propertyValues["Top"];
- object? bottom = propertyValues["Bottom"];
-
- if (left == null || right == null || bottom == null || top == null ||
- !(left is int) || !(right is int) || !(bottom is int) || !(top is int))
- {
- throw new ArgumentException(SR.PropertyValueInvalidEntry);
- }
-
- return new Margins((int)left,
- (int)right,
- (int)top,
- (int)bottom);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/ModeField.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/ModeField.cs
deleted file mode 100644
index 746eae41576dc..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/ModeField.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- // Some of the fields in DEVMODE
- internal enum ModeField
- {
- Orientation,
- PaperSize,
- PaperLength,
- PaperWidth,
- Copies,
- DefaultSource,
- PrintQuality,
- Color,
- Duplex,
- YResolution,
- TTOption,
- Collate,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Serializable.cs
deleted file mode 100644
index 142be6e690ac7..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.Serializable.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.
-
-namespace System.Drawing.Printing
-{
- [Serializable]
- partial class PageSettings
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs
deleted file mode 100644
index 0c043e5d6b33a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PageSettings.cs
+++ /dev/null
@@ -1,537 +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.Diagnostics;
-using System.Drawing.Internal;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies settings that apply to a single page.
- ///
- public partial class PageSettings : ICloneable
- {
- internal PrinterSettings printerSettings;
-
- private TriState _color = TriState.Default;
- private PaperSize? _paperSize;
- private PaperSource? _paperSource;
- private PrinterResolution? _printerResolution;
- private TriState _landscape = TriState.Default;
- private Margins _margins = new Margins();
-
- ///
- /// Initializes a new instance of the class using the default printer.
- ///
- public PageSettings() : this(new PrinterSettings())
- {
- }
-
- ///
- /// Initializes a new instance of the class using the specified printer.
- ///
- public PageSettings(PrinterSettings printerSettings)
- {
- Debug.Assert(printerSettings != null, "printerSettings == null");
- this.printerSettings = printerSettings;
- }
-
- ///
- /// Gets the bounds of the page, taking into account the Landscape property.
- ///
- public Rectangle Bounds
- {
- get
- {
- IntPtr modeHandle = printerSettings.GetHdevmode();
- Rectangle pageBounds = GetBounds(modeHandle);
-
- Interop.Kernel32.GlobalFree(new HandleRef(this, modeHandle));
- return pageBounds;
- }
- }
-
- ///
- /// Gets or sets a value indicating whether the page is printed in color.
- ///
- public bool Color
- {
- get
- {
- if (_color.IsDefault)
- return printerSettings.GetModeField(ModeField.Color, SafeNativeMethods.DMCOLOR_MONOCHROME) == SafeNativeMethods.DMCOLOR_COLOR;
- else
- return (bool)_color;
- }
- set { _color = value; }
- }
-
- ///
- /// Returns the x dimension of the hard margin
- ///
- public float HardMarginX
- {
- get
- {
- float hardMarginX = 0;
- DeviceContext dc = printerSettings.CreateDeviceContext(this);
-
- try
- {
- int dpiX = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- int hardMarginX_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX);
- hardMarginX = hardMarginX_DU * 100 / dpiX;
- }
- finally
- {
- dc.Dispose();
- }
- return hardMarginX;
- }
- }
-
-
- ///
- /// Returns the y dimension of the hard margin.
- ///
- public float HardMarginY
- {
- get
- {
- float hardMarginY = 0;
- DeviceContext dc = printerSettings.CreateDeviceContext(this);
-
- try
- {
- int dpiY = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSY);
- int hardMarginY_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY);
- hardMarginY = hardMarginY_DU * 100 / dpiY;
- }
- finally
- {
- dc.Dispose();
- }
- return hardMarginY;
- }
- }
-
- ///
- /// Gets or sets a value indicating whether the page should be printed in landscape or portrait orientation.
- ///
- public bool Landscape
- {
- get
- {
- if (_landscape.IsDefault)
- return printerSettings.GetModeField(ModeField.Orientation, SafeNativeMethods.DMORIENT_PORTRAIT) == SafeNativeMethods.DMORIENT_LANDSCAPE;
- else
- return (bool)_landscape;
- }
- set { _landscape = value; }
- }
-
- ///
- /// Gets or sets a value indicating the margins for this page.
- ///
- public Margins Margins
- {
- get { return _margins; }
- set { _margins = value; }
- }
-
- ///
- /// Gets or sets the paper size.
- ///
- public PaperSize PaperSize
- {
- get
- {
- return GetPaperSize(IntPtr.Zero);
- }
- set { _paperSize = value; }
- }
-
- ///
- /// Gets or sets a value indicating the paper source (i.e. upper bin).
- ///
- public PaperSource PaperSource
- {
- get
- {
- if (_paperSource == null)
- {
- IntPtr modeHandle = printerSettings.GetHdevmode();
- IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
-
- PaperSource result = PaperSourceFromMode(mode);
-
- Interop.Kernel32.GlobalUnlock(new HandleRef(this, modeHandle));
- Interop.Kernel32.GlobalFree(new HandleRef(this, modeHandle));
-
- return result;
- }
- else
- return _paperSource;
- }
- set { _paperSource = value; }
- }
-
- ///
- /// Gets the PrintableArea for the printer. Units = 100ths of an inch.
- ///
- public RectangleF PrintableArea
- {
- get
- {
- RectangleF printableArea = default;
- DeviceContext dc = printerSettings.CreateInformationContext(this);
- HandleRef hdc = new HandleRef(dc, dc.Hdc);
-
- try
- {
- int dpiX = Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- int dpiY = Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.LOGPIXELSY);
- if (!Landscape)
- {
- //
- // Need to convert the printable area to 100th of an inch from the device units
- printableArea.X = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX) * 100 / dpiX;
- printableArea.Y = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY) * 100 / dpiY;
- printableArea.Width = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.HORZRES) * 100 / dpiX;
- printableArea.Height = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.VERTRES) * 100 / dpiY;
- }
- else
- {
- //
- // Need to convert the printable area to 100th of an inch from the device units
- printableArea.Y = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX) * 100 / dpiX;
- printableArea.X = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY) * 100 / dpiY;
- printableArea.Height = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.HORZRES) * 100 / dpiX;
- printableArea.Width = (float)Interop.Gdi32.GetDeviceCaps(hdc, Interop.Gdi32.DeviceCapability.VERTRES) * 100 / dpiY;
- }
- }
- finally
- {
- dc.Dispose();
- }
-
- return printableArea;
- }
- }
-
- ///
- /// Gets or sets the printer resolution for the page.
- ///
- public PrinterResolution PrinterResolution
- {
- get
- {
- if (_printerResolution == null)
- {
- IntPtr modeHandle = printerSettings.GetHdevmode();
- IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
-
- PrinterResolution result = PrinterResolutionFromMode(mode);
-
- Interop.Kernel32.GlobalUnlock(new HandleRef(this, modeHandle));
- Interop.Kernel32.GlobalFree(new HandleRef(this, modeHandle));
-
- return result;
- }
- else
- return _printerResolution;
- }
- set
- {
- _printerResolution = value;
- }
- }
-
- ///
- /// Gets or sets the associated printer settings.
- ///
- public PrinterSettings PrinterSettings
- {
- get => printerSettings;
- set => printerSettings = value ?? new PrinterSettings();
- }
-
- ///
- /// Copies the settings and margins.
- ///
- public object Clone()
- {
- PageSettings result = (PageSettings)MemberwiseClone();
- result._margins = (Margins)_margins.Clone();
- return result;
- }
-
- ///
- /// Copies the relevant information out of the PageSettings and into the handle.
- ///
- public void CopyToHdevmode(IntPtr hdevmode)
- {
- IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
-
- if (_color.IsNotDefault && ((mode.dmFields & SafeNativeMethods.DM_COLOR) == SafeNativeMethods.DM_COLOR))
- mode.dmColor = unchecked((short)(((bool)_color) ? SafeNativeMethods.DMCOLOR_COLOR : SafeNativeMethods.DMCOLOR_MONOCHROME));
- if (_landscape.IsNotDefault && ((mode.dmFields & SafeNativeMethods.DM_ORIENTATION) == SafeNativeMethods.DM_ORIENTATION))
- mode.dmOrientation = unchecked((short)(((bool)_landscape) ? SafeNativeMethods.DMORIENT_LANDSCAPE : SafeNativeMethods.DMORIENT_PORTRAIT));
-
- if (_paperSize != null)
- {
- if ((mode.dmFields & SafeNativeMethods.DM_PAPERSIZE) == SafeNativeMethods.DM_PAPERSIZE)
- {
- mode.dmPaperSize = unchecked((short)_paperSize.RawKind);
- }
-
- bool setWidth = false;
- bool setLength = false;
-
- if ((mode.dmFields & SafeNativeMethods.DM_PAPERLENGTH) == SafeNativeMethods.DM_PAPERLENGTH)
- {
- // dmPaperLength is always in tenths of millimeter but paperSizes are in hundredth of inch ..
- // so we need to convert :: use PrinterUnitConvert.Convert(value, PrinterUnit.TenthsOfAMillimeter /*fromUnit*/, PrinterUnit.Display /*ToUnit*/)
- int length = PrinterUnitConvert.Convert(_paperSize.Height, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);
- mode.dmPaperLength = unchecked((short)length);
- setLength = true;
- }
- if ((mode.dmFields & SafeNativeMethods.DM_PAPERWIDTH) == SafeNativeMethods.DM_PAPERWIDTH)
- {
- int width = PrinterUnitConvert.Convert(_paperSize.Width, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);
- mode.dmPaperWidth = unchecked((short)width);
- setWidth = true;
- }
-
- if (_paperSize.Kind == PaperKind.Custom)
- {
- if (!setLength)
- {
- mode.dmFields |= SafeNativeMethods.DM_PAPERLENGTH;
- int length = PrinterUnitConvert.Convert(_paperSize.Height, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);
- mode.dmPaperLength = unchecked((short)length);
- }
- if (!setWidth)
- {
- mode.dmFields |= SafeNativeMethods.DM_PAPERWIDTH;
- int width = PrinterUnitConvert.Convert(_paperSize.Width, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);
- mode.dmPaperWidth = unchecked((short)width);
- }
- }
- }
-
- if (_paperSource != null && ((mode.dmFields & SafeNativeMethods.DM_DEFAULTSOURCE) == SafeNativeMethods.DM_DEFAULTSOURCE))
- {
- mode.dmDefaultSource = unchecked((short)_paperSource.RawKind);
- }
-
- if (_printerResolution != null)
- {
- if (_printerResolution.Kind == PrinterResolutionKind.Custom)
- {
- if ((mode.dmFields & SafeNativeMethods.DM_PRINTQUALITY) == SafeNativeMethods.DM_PRINTQUALITY)
- {
- mode.dmPrintQuality = unchecked((short)_printerResolution.X);
- }
- if ((mode.dmFields & SafeNativeMethods.DM_YRESOLUTION) == SafeNativeMethods.DM_YRESOLUTION)
- {
- mode.dmYResolution = unchecked((short)_printerResolution.Y);
- }
- }
- else
- {
- if ((mode.dmFields & SafeNativeMethods.DM_PRINTQUALITY) == SafeNativeMethods.DM_PRINTQUALITY)
- {
- mode.dmPrintQuality = unchecked((short)_printerResolution.Kind);
- }
- }
- }
-
- Marshal.StructureToPtr(mode, modePointer, false);
-
- // It's possible this page has a DEVMODE for a different printer than the DEVMODE passed in here
- // (Ex: occurs when Doc.DefaultPageSettings.PrinterSettings.PrinterName != Doc.PrinterSettings.PrinterName)
- //
- // if the passed in devmode has fewer bytes than our buffer for the extrainfo, we want to skip the merge as it will cause
- // a buffer overrun
- if (mode.dmDriverExtra >= ExtraBytes)
- {
- int retCode = Interop.Winspool.DocumentProperties(NativeMethods.NullHandleRef, NativeMethods.NullHandleRef, printerSettings.PrinterName, modePointer, modePointer, SafeNativeMethods.DM_IN_BUFFER | SafeNativeMethods.DM_OUT_BUFFER);
- if (retCode < 0)
- {
- Interop.Kernel32.GlobalFree(modePointer);
- }
- }
-
- Interop.Kernel32.GlobalUnlock(hdevmode);
- }
-
- private short ExtraBytes
- {
- get
- {
- IntPtr modeHandle = printerSettings.GetHdevmodeInternal();
- IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
-
- short result = mode?.dmDriverExtra ?? 0;
-
- Interop.Kernel32.GlobalUnlock(new HandleRef(this, modeHandle));
- Interop.Kernel32.GlobalFree(new HandleRef(this, modeHandle));
-
- return result;
- }
- }
-
-
- // This function shows up big on profiles, so we need to make it fast
- internal Rectangle GetBounds(IntPtr modeHandle)
- {
- Rectangle pageBounds;
- PaperSize size = GetPaperSize(modeHandle);
- if (GetLandscape(modeHandle))
- pageBounds = new Rectangle(0, 0, size.Height, size.Width);
- else
- pageBounds = new Rectangle(0, 0, size.Width, size.Height);
-
- return pageBounds;
- }
-
- private bool GetLandscape(IntPtr modeHandle)
- {
- if (_landscape.IsDefault)
- return printerSettings.GetModeField(ModeField.Orientation, SafeNativeMethods.DMORIENT_PORTRAIT, modeHandle) == SafeNativeMethods.DMORIENT_LANDSCAPE;
- else
- return (bool)_landscape;
- }
-
- private PaperSize GetPaperSize(IntPtr modeHandle)
- {
- if (_paperSize == null)
- {
- bool ownHandle = false;
- if (modeHandle == IntPtr.Zero)
- {
- modeHandle = printerSettings.GetHdevmode();
- ownHandle = true;
- }
-
- IntPtr modePointer = Interop.Kernel32.GlobalLock(modeHandle);
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
-
- PaperSize result = PaperSizeFromMode(mode);
-
- Interop.Kernel32.GlobalUnlock(modeHandle);
-
- if (ownHandle)
- {
- Interop.Kernel32.GlobalFree(modeHandle);
- }
-
- return result;
- }
- else
- return _paperSize;
- }
-
- private PaperSize PaperSizeFromMode(Interop.Gdi32.DEVMODE mode)
- {
- PaperSize[] sizes = printerSettings.Get_PaperSizes();
- if ((mode.dmFields & SafeNativeMethods.DM_PAPERSIZE) == SafeNativeMethods.DM_PAPERSIZE)
- {
- for (int i = 0; i < sizes.Length; i++)
- {
- if ((int)sizes[i].RawKind == mode.dmPaperSize)
- return sizes[i];
- }
- }
- return new PaperSize(PaperKind.Custom, "custom",
- //mode.dmPaperWidth, mode.dmPaperLength);
- PrinterUnitConvert.Convert(mode.dmPaperWidth, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display),
- PrinterUnitConvert.Convert(mode.dmPaperLength, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
- }
-
- private PaperSource PaperSourceFromMode(Interop.Gdi32.DEVMODE mode)
- {
- PaperSource[] sources = printerSettings.Get_PaperSources();
- if ((mode.dmFields & SafeNativeMethods.DM_DEFAULTSOURCE) == SafeNativeMethods.DM_DEFAULTSOURCE)
- {
- for (int i = 0; i < sources.Length; i++)
- {
- // the dmDefaultSource == to the RawKind in the Papersource.. and Not the Kind...
- // if the PaperSource is populated with CUSTOM values...
- if (unchecked((short)sources[i].RawKind) == mode.dmDefaultSource)
- {
- return sources[i];
- }
- }
- }
- return new PaperSource((PaperSourceKind)mode.dmDefaultSource, "unknown");
- }
-
- private PrinterResolution PrinterResolutionFromMode(Interop.Gdi32.DEVMODE mode)
- {
- PrinterResolution[] resolutions = printerSettings.Get_PrinterResolutions();
- for (int i = 0; i < resolutions.Length; i++)
- {
- if (mode.dmPrintQuality >= 0 && ((mode.dmFields & SafeNativeMethods.DM_PRINTQUALITY) == SafeNativeMethods.DM_PRINTQUALITY)
- && ((mode.dmFields & SafeNativeMethods.DM_YRESOLUTION) == SafeNativeMethods.DM_YRESOLUTION))
- {
- if (resolutions[i].X == unchecked((int)(PrinterResolutionKind)mode.dmPrintQuality)
- && resolutions[i].Y == unchecked((int)(PrinterResolutionKind)mode.dmYResolution))
- return resolutions[i];
- }
- else
- {
- if ((mode.dmFields & SafeNativeMethods.DM_PRINTQUALITY) == SafeNativeMethods.DM_PRINTQUALITY)
- {
- if (resolutions[i].Kind == (PrinterResolutionKind)mode.dmPrintQuality)
- return resolutions[i];
- }
- }
- }
- return new PrinterResolution(PrinterResolutionKind.Custom,
- mode.dmPrintQuality, mode.dmYResolution);
- }
-
- ///
- /// Copies the relevant information out of the handle and into the PageSettings.
- ///
- public void SetHdevmode(IntPtr hdevmode)
- {
- if (hdevmode == IntPtr.Zero)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPrinterHandle, hdevmode));
- }
-
- IntPtr pointer = Interop.Kernel32.GlobalLock(hdevmode);
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(pointer)!;
-
- if ((mode.dmFields & SafeNativeMethods.DM_COLOR) == SafeNativeMethods.DM_COLOR)
- {
- _color = (mode.dmColor == SafeNativeMethods.DMCOLOR_COLOR);
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_ORIENTATION) == SafeNativeMethods.DM_ORIENTATION)
- {
- _landscape = (mode.dmOrientation == SafeNativeMethods.DMORIENT_LANDSCAPE);
- }
-
- _paperSize = PaperSizeFromMode(mode);
- _paperSource = PaperSourceFromMode(mode);
- _printerResolution = PrinterResolutionFromMode(mode);
-
- Interop.Kernel32.GlobalUnlock(hdevmode);
- }
-
- ///
- /// Provides some interesting information about the PageSettings in String form.
- ///
- public override string ToString() =>
- $"[{nameof(PageSettings)}: Color={Color}, Landscape={Landscape}, Margins={Margins}, PaperSize={PaperSize}, PaperSource={PaperSource}, PrinterResolution={PrinterResolution}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperKinds.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperKinds.cs
deleted file mode 100644
index b04682c64cdfa..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperKinds.cs
+++ /dev/null
@@ -1,490 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the standard paper sizes.
- ///
- public enum PaperKind
- {
- ///
- /// The paper size is defined by the user.
- ///
- Custom = 0,
-
- // I got this information from two places: MSDN's writeup of DEVMODE
- // (https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-_devicemodea),
- // and the raw C++ header file (wingdi.h). Beyond that, your guess
- // is as good as mine as to what these members mean.
-
- ///
- /// Letter paper (8.5 in. by 11 in.).
- ///
- Letter = SafeNativeMethods.DMPAPER_LETTER,
- ///
- /// Legal paper (8.5 in. by 14 in.).
- ///
- Legal = SafeNativeMethods.DMPAPER_LEGAL,
- ///
- /// A4 paper (210 mm by 297 mm).
- ///
- A4 = SafeNativeMethods.DMPAPER_A4,
- ///
- /// C paper (17 in. by 22 in.).
- ///
- CSheet = SafeNativeMethods.DMPAPER_CSHEET,
- ///
- /// D paper (22 in. by 34 in.).
- ///
- DSheet = SafeNativeMethods.DMPAPER_DSHEET,
- ///
- /// E paper (34 in. by 44 in.).
- ///
- ESheet = SafeNativeMethods.DMPAPER_ESHEET,
- ///
- /// Letter small paper (8.5 in. by 11 in.).
- ///
- LetterSmall = SafeNativeMethods.DMPAPER_LETTERSMALL,
- ///
- /// Tabloid paper (11 in. by 17 in.).
- ///
- Tabloid = SafeNativeMethods.DMPAPER_TABLOID,
- ///
- /// Ledger paper (17 in. by 11 in.).
- ///
- Ledger = SafeNativeMethods.DMPAPER_LEDGER,
- ///
- /// Statement paper (5.5 in. by 8.5 in.).
- ///
- Statement = SafeNativeMethods.DMPAPER_STATEMENT,
- ///
- /// Executive paper (7.25 in. by 10.5 in.).
- ///
- Executive = SafeNativeMethods.DMPAPER_EXECUTIVE,
- ///
- /// A3 paper (297 mm by 420 mm).
- ///
- A3 = SafeNativeMethods.DMPAPER_A3,
- ///
- /// A4 small paper (210 mm by 297 mm).
- ///
- A4Small = SafeNativeMethods.DMPAPER_A4SMALL,
- ///
- /// A5 paper (148 mm by 210 mm).
- ///
- A5 = SafeNativeMethods.DMPAPER_A5,
- ///
- /// B4 paper (250 mm by 353 mm).
- ///
- B4 = SafeNativeMethods.DMPAPER_B4,
- ///
- /// B5 paper (176 mm by 250 mm).
- ///
- B5 = SafeNativeMethods.DMPAPER_B5,
- ///
- /// Folio paper (8.5 in. by 13 in.).
- ///
- Folio = SafeNativeMethods.DMPAPER_FOLIO,
- ///
- /// Quarto paper (215 mm by 275 mm).
- ///
- Quarto = SafeNativeMethods.DMPAPER_QUARTO,
- ///
- /// 10-by-14-inch paper.
- ///
- Standard10x14 = SafeNativeMethods.DMPAPER_10X14,
- ///
- /// 11-by-17-inch paper.
- ///
- Standard11x17 = SafeNativeMethods.DMPAPER_11X17,
- ///
- /// Note paper (8.5 in. by 11 in.).
- ///
- Note = SafeNativeMethods.DMPAPER_NOTE,
- ///
- /// #9 envelope (3.875 in. by 8.875 in.).
- ///
- Number9Envelope = SafeNativeMethods.DMPAPER_ENV_9,
- ///
- /// #10 envelope (4.125 in. by 9.5 in.).
- ///
- Number10Envelope = SafeNativeMethods.DMPAPER_ENV_10,
- ///
- /// #11 envelope (4.5 in. by 10.375 in.).
- ///
- Number11Envelope = SafeNativeMethods.DMPAPER_ENV_11,
- ///
- /// #12 envelope (4.75 in. by 11 in.).
- ///
- Number12Envelope = SafeNativeMethods.DMPAPER_ENV_12,
- ///
- /// #14 envelope (5 in. by 11.5 in.).
- ///
- Number14Envelope = SafeNativeMethods.DMPAPER_ENV_14,
- ///
- /// DL envelope (110 mm by 220 mm).
- ///
- DLEnvelope = SafeNativeMethods.DMPAPER_ENV_DL,
- ///
- /// C5 envelope (162 mm by 229 mm).
- ///
- C5Envelope = SafeNativeMethods.DMPAPER_ENV_C5,
- ///
- /// C3 envelope (324 mm by 458 mm).
- ///
- C3Envelope = SafeNativeMethods.DMPAPER_ENV_C3,
- ///
- /// C4 envelope (229 mm by 324 mm).
- ///
- C4Envelope = SafeNativeMethods.DMPAPER_ENV_C4,
- ///
- /// C6 envelope (114 mm by 162 mm).
- ///
- C6Envelope = SafeNativeMethods.DMPAPER_ENV_C6,
- ///
- /// C65 envelope (114 mm by 229 mm).
- ///
- C65Envelope = SafeNativeMethods.DMPAPER_ENV_C65,
- ///
- /// B4 envelope (250 mm by 353 mm).
- ///
- B4Envelope = SafeNativeMethods.DMPAPER_ENV_B4,
- ///
- /// B5 envelope (176 mm by 250 mm).
- ///
- B5Envelope = SafeNativeMethods.DMPAPER_ENV_B5,
- ///
- /// B6 envelope (176 mm by 125 mm).
- ///
- B6Envelope = SafeNativeMethods.DMPAPER_ENV_B6,
- ///
- /// Italy envelope (110 mm by 230 mm).
- ///
- ItalyEnvelope = SafeNativeMethods.DMPAPER_ENV_ITALY,
- ///
- /// Monarch envelope (3.875 in. by 7.5 in.).
- ///
- MonarchEnvelope = SafeNativeMethods.DMPAPER_ENV_MONARCH,
- ///
- /// 6 3/4 envelope (3.625 in. by 6.5 in.).
- ///
- PersonalEnvelope = SafeNativeMethods.DMPAPER_ENV_PERSONAL,
- ///
- /// US standard fanfold (14.875 in. by 11 in.).
- ///
- USStandardFanfold = SafeNativeMethods.DMPAPER_FANFOLD_US,
- ///
- /// German standard fanfold (8.5 in. by 12 in.).
- ///
- GermanStandardFanfold = SafeNativeMethods.DMPAPER_FANFOLD_STD_GERMAN,
- ///
- /// German legal fanfold (8.5 in. by 13 in.).
- ///
- GermanLegalFanfold = SafeNativeMethods.DMPAPER_FANFOLD_LGL_GERMAN,
- ///
- /// ISO B4 (250 mm by 353 mm).
- ///
- IsoB4 = SafeNativeMethods.DMPAPER_ISO_B4,
- ///
- /// Japanese postcard (100 mm by 148 mm).
- ///
- JapanesePostcard = SafeNativeMethods.DMPAPER_JAPANESE_POSTCARD,
- ///
- /// 9-by-11-inch paper.
- ///
- Standard9x11 = SafeNativeMethods.DMPAPER_9X11,
- ///
- /// 10-by-11-inch paper.
- ///
- Standard10x11 = SafeNativeMethods.DMPAPER_10X11,
- ///
- /// 15-by-11-inch paper.
- ///
- Standard15x11 = SafeNativeMethods.DMPAPER_15X11,
- ///
- /// Invite envelope (220 mm by 220 mm).
- ///
- InviteEnvelope = SafeNativeMethods.DMPAPER_ENV_INVITE,
- ///
- /// Letter extra paper (9.275 in. by 12 in.).
- /// This value is specific to the PostScript driver and is used only by Linotronic printers in order to conserve paper.
- ///
- LetterExtra = SafeNativeMethods.DMPAPER_LETTER_EXTRA,
- ///
- /// Legal extra paper (9.275 in. by 15 in.).
- /// This value is specific to the PostScript driver and is used only by Linotronic printers in order to conserve paper.
- ///
- LegalExtra = SafeNativeMethods.DMPAPER_LEGAL_EXTRA,
- ///
- /// Tabloid extra paper (11.69 in. by 18 in.).
- /// This value is specific to the PostScript driver and is used only by Linotronic printers in order to conserve paper.
- ///
- TabloidExtra = SafeNativeMethods.DMPAPER_TABLOID_EXTRA,
- ///
- /// A4 extra paper (236 mm by 322 mm).
- /// This value is specific to the PostScript driver and is used only by Linotronic printers in order to conserve paper.
- ///
- A4Extra = SafeNativeMethods.DMPAPER_A4_EXTRA,
- ///
- /// Letter transverse paper (8.275 in. by 11 in.).
- ///
- LetterTransverse = SafeNativeMethods.DMPAPER_LETTER_TRANSVERSE,
- ///
- /// A4 transverse paper (210 mm by 297 mm).
- ///
- A4Transverse = SafeNativeMethods.DMPAPER_A4_TRANSVERSE,
- ///
- /// Letter extra transverse paper (9.275 in. by 12 in.).
- ///
- LetterExtraTransverse = SafeNativeMethods.DMPAPER_LETTER_EXTRA_TRANSVERSE,
- ///
- /// SuperA/SuperA/A4 paper (227 mm by 356 mm).
- ///
- APlus = SafeNativeMethods.DMPAPER_A_PLUS,
- ///
- /// SuperB/SuperB/A3 paper (305 mm by 487 mm).
- ///
- BPlus = SafeNativeMethods.DMPAPER_B_PLUS,
- ///
- /// Letter plus paper (8.5 in. by 12.69 in.).
- ///
- LetterPlus = SafeNativeMethods.DMPAPER_LETTER_PLUS,
- ///
- /// A4 plus paper (210 mm by 330 mm).
- ///
- A4Plus = SafeNativeMethods.DMPAPER_A4_PLUS,
- ///
- /// A5 transverse paper (148 mm by 210 mm).
- ///
- A5Transverse = SafeNativeMethods.DMPAPER_A5_TRANSVERSE,
- ///
- /// JIS B5 transverse paper (182 mm by 257 mm).
- ///
- B5Transverse = SafeNativeMethods.DMPAPER_B5_TRANSVERSE,
- ///
- /// A3 extra paper (322 mm by 445 mm).
- ///
- A3Extra = SafeNativeMethods.DMPAPER_A3_EXTRA,
- ///
- /// A5 extra paper (174 mm by 235 mm).
- ///
- A5Extra = SafeNativeMethods.DMPAPER_A5_EXTRA,
- ///
- /// ISO B5 extra paper (201 mm by 276 mm).
- ///
- B5Extra = SafeNativeMethods.DMPAPER_B5_EXTRA,
- ///
- /// A2 paper (420 mm by 594 mm).
- ///
- A2 = SafeNativeMethods.DMPAPER_A2,
- ///
- /// A3 transverse paper (297 mm by 420 mm).
- ///
- A3Transverse = SafeNativeMethods.DMPAPER_A3_TRANSVERSE,
- ///
- /// A3 extra transverse paper (322 mm by 445 mm).
- ///
- A3ExtraTransverse = SafeNativeMethods.DMPAPER_A3_EXTRA_TRANSVERSE,
- ///
- /// Japanese double postcard (200 mm by 148mm).
- ///
- JapaneseDoublePostcard = SafeNativeMethods.DMPAPER_DBL_JAPANESE_POSTCARD,
- ///
- /// A6 paper (105 mm by 148 mm).
- ///
- A6 = SafeNativeMethods.DMPAPER_A6,
- ///
- /// Japanese Kaku #2 envelope.
- ///
- JapaneseEnvelopeKakuNumber2 = SafeNativeMethods.DMPAPER_JENV_KAKU2,
- ///
- /// Japanese Kaku #3 envelope.
- ///
- JapaneseEnvelopeKakuNumber3 = SafeNativeMethods.DMPAPER_JENV_KAKU3,
- ///
- /// Japanese Chou #3 envelope.
- ///
- JapaneseEnvelopeChouNumber3 = SafeNativeMethods.DMPAPER_JENV_CHOU3,
- ///
- /// Japanese Chou #4 envelope.
- ///
- JapaneseEnvelopeChouNumber4 = SafeNativeMethods.DMPAPER_JENV_CHOU4,
- ///
- /// Letter rotated paper (11 in. by 8.5 in.).
- ///
- LetterRotated = SafeNativeMethods.DMPAPER_LETTER_ROTATED,
- ///
- /// A3 rotated paper (420mm by 297 mm).
- ///
- A3Rotated = SafeNativeMethods.DMPAPER_A3_ROTATED,
- ///
- /// A4 rotated paper (297 mm by 210 mm).
- ///
- A4Rotated = SafeNativeMethods.DMPAPER_A4_ROTATED,
- ///
- /// A5 rotated paper (210 mm by 148 mm).
- ///
- A5Rotated = SafeNativeMethods.DMPAPER_A5_ROTATED,
- ///
- /// JIS B4 rotated paper (364 mm by 257 mm).
- ///
- B4JisRotated = SafeNativeMethods.DMPAPER_B4_JIS_ROTATED,
- ///
- /// JIS B5 rotated paper (257 mm by 182 mm).
- ///
- B5JisRotated = SafeNativeMethods.DMPAPER_B5_JIS_ROTATED,
- ///
- /// Japanese rotated postcard (148 mm by 100 mm).
- ///
- JapanesePostcardRotated = SafeNativeMethods.DMPAPER_JAPANESE_POSTCARD_ROTATED,
- ///
- /// Japanese rotated double postcard (148 mm by 200 mm).
- ///
- JapaneseDoublePostcardRotated = SafeNativeMethods.DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED,
- ///
- /// A6 rotated paper (148 mm by 105 mm).
- ///
- A6Rotated = SafeNativeMethods.DMPAPER_A6_ROTATED,
- ///
- /// Japanese rotated Kaku #2 envelope.
- ///
- JapaneseEnvelopeKakuNumber2Rotated = SafeNativeMethods.DMPAPER_JENV_KAKU2_ROTATED,
- ///
- /// Japanese rotated Kaku #3 envelope.
- ///
- JapaneseEnvelopeKakuNumber3Rotated = SafeNativeMethods.DMPAPER_JENV_KAKU3_ROTATED,
- ///
- /// Japanese rotated Chou #3 envelope.
- ///
- JapaneseEnvelopeChouNumber3Rotated = SafeNativeMethods.DMPAPER_JENV_CHOU3_ROTATED,
- ///
- /// Japanese rotated Chou #4 envelope.
- ///
- JapaneseEnvelopeChouNumber4Rotated = SafeNativeMethods.DMPAPER_JENV_CHOU4_ROTATED,
- ///
- /// JIS B6 paper (128 mm by 182 mm).
- ///
- B6Jis = SafeNativeMethods.DMPAPER_B6_JIS,
- ///
- /// JIS B6 rotated paper (182 mm by 128 mm).
- ///
- B6JisRotated = SafeNativeMethods.DMPAPER_B6_JIS_ROTATED,
- ///
- /// 12-by-11-inch paper.
- ///
- Standard12x11 = SafeNativeMethods.DMPAPER_12X11,
- ///
- /// Japanese You #4 envelope.
- ///
- JapaneseEnvelopeYouNumber4 = SafeNativeMethods.DMPAPER_JENV_YOU4,
- ///
- /// Japanese You #4 rotated envelope.
- ///
- JapaneseEnvelopeYouNumber4Rotated = SafeNativeMethods.DMPAPER_JENV_YOU4_ROTATED,
- ///
- /// PRC 16K paper (146 mm by 215 mm).
- ///
- Prc16K = SafeNativeMethods.DMPAPER_P16K,
- ///
- /// PRC 32K paper (97 mm by 151 mm).
- ///
- Prc32K = SafeNativeMethods.DMPAPER_P32K,
- ///
- /// PRC 32K big paper (97 mm by 151 mm).
- ///
- Prc32KBig = SafeNativeMethods.DMPAPER_P32KBIG,
- ///
- /// PRC #1 envelope (102 mm by 165 mm).
- ///
- PrcEnvelopeNumber1 = SafeNativeMethods.DMPAPER_PENV_1,
- ///
- /// PRC #2 envelope (102 mm by 176 mm).
- ///
- PrcEnvelopeNumber2 = SafeNativeMethods.DMPAPER_PENV_2,
- ///
- /// PRC #3 envelope (125 mm by 176 mm).
- ///
- PrcEnvelopeNumber3 = SafeNativeMethods.DMPAPER_PENV_3,
- ///
- /// PRC #4 envelope (110 mm by 208 mm).
- ///
- PrcEnvelopeNumber4 = SafeNativeMethods.DMPAPER_PENV_4,
- ///
- /// PRC #5 envelope (110 mm by 220 mm).
- ///
- PrcEnvelopeNumber5 = SafeNativeMethods.DMPAPER_PENV_5,
- ///
- /// PRC #6 envelope (120 mm by 230 mm).
- ///
- PrcEnvelopeNumber6 = SafeNativeMethods.DMPAPER_PENV_6,
- ///
- /// PRC #7 envelope (160 mm by 230 mm).
- ///
- PrcEnvelopeNumber7 = SafeNativeMethods.DMPAPER_PENV_7,
- ///
- /// PRC #8 envelope (120 mm by 309 mm).
- ///
- PrcEnvelopeNumber8 = SafeNativeMethods.DMPAPER_PENV_8,
- ///
- /// PRC #9 envelope (229 mm by 324 mm).
- ///
- PrcEnvelopeNumber9 = SafeNativeMethods.DMPAPER_PENV_9,
- ///
- /// PRC #10 envelope (324 mm by 458 mm).
- ///
- PrcEnvelopeNumber10 = SafeNativeMethods.DMPAPER_PENV_10,
- ///
- /// PRC 16K rotated paper (146 mm by 215 mm).
- ///
- Prc16KRotated = SafeNativeMethods.DMPAPER_P16K_ROTATED,
- ///
- /// PRC 32K rotated paper (97 mm by 151 mm).
- ///
- Prc32KRotated = SafeNativeMethods.DMPAPER_P32K_ROTATED,
- ///
- /// PRC 32K big rotated paper (97 mm by 151 mm).
- ///
- Prc32KBigRotated = SafeNativeMethods.DMPAPER_P32KBIG_ROTATED,
- ///
- /// PRC #1 rotated envelope (165 mm by 102 mm).
- ///
- PrcEnvelopeNumber1Rotated = SafeNativeMethods.DMPAPER_PENV_1_ROTATED,
- ///
- /// PRC #2 rotated envelope (176 mm by 102 mm).
- ///
- PrcEnvelopeNumber2Rotated = SafeNativeMethods.DMPAPER_PENV_2_ROTATED,
- ///
- /// PRC #3 rotated envelope (176 mm by 125 mm).
- ///
- PrcEnvelopeNumber3Rotated = SafeNativeMethods.DMPAPER_PENV_3_ROTATED,
- ///
- /// PRC #4 rotated envelope (208 mm by 110 mm).
- ///
- PrcEnvelopeNumber4Rotated = SafeNativeMethods.DMPAPER_PENV_4_ROTATED,
- ///
- /// PRC #5 rotated envelope (220 mm by 110 mm).
- ///
- PrcEnvelopeNumber5Rotated = SafeNativeMethods.DMPAPER_PENV_5_ROTATED,
- ///
- /// PRC #6 rotated envelope (230 mm by 120 mm).
- ///
- PrcEnvelopeNumber6Rotated = SafeNativeMethods.DMPAPER_PENV_6_ROTATED,
- ///
- /// PRC #7 rotated envelope (230 mm by 160 mm).
- ///
- PrcEnvelopeNumber7Rotated = SafeNativeMethods.DMPAPER_PENV_7_ROTATED,
- ///
- /// PRC #8 rotated envelope (309 mm by 120 mm).
- ///
- PrcEnvelopeNumber8Rotated = SafeNativeMethods.DMPAPER_PENV_8_ROTATED,
- ///
- /// PRC #9 rotated envelope (324 mm by 229 mm).
- ///
- PrcEnvelopeNumber9Rotated = SafeNativeMethods.DMPAPER_PENV_9_ROTATED,
- ///
- /// PRC #10 rotated envelope (458 mm by 324 mm).
- ///
- PrcEnvelopeNumber10Rotated = SafeNativeMethods.DMPAPER_PENV_10_ROTATED,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.Serializable.cs
deleted file mode 100644
index e19373e972868..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.Serializable.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This file isn't built into the .csproj in the runtime libraries but is consumed by Mono.
-
-namespace System.Drawing.Printing
-{
- [Serializable]
- partial class PaperSize
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.cs
deleted file mode 100644
index 75e69bb466a06..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSize.cs
+++ /dev/null
@@ -1,132 +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.Globalization;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the size of a piece of paper.
- ///
- public partial class PaperSize
- {
- private PaperKind _kind;
- private string _name;
-
- // standard hundredths of an inch units
- private int _width;
- private int _height;
- private readonly bool _createdByDefaultConstructor;
-
- ///
- /// Initializes a new instance of the class with default properties.
- ///
- public PaperSize()
- {
- _kind = PaperKind.Custom;
- _name = string.Empty;
- _createdByDefaultConstructor = true;
- }
-
- internal PaperSize(PaperKind kind, string name, int width, int height)
- {
- _kind = kind;
- _name = name;
- _width = width;
- _height = height;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PaperSize(string name, int width, int height)
- {
- _kind = PaperKind.Custom;
- _name = name;
- _width = width;
- _height = height;
- }
-
- ///
- /// Gets or sets the height of the paper, in hundredths of an inch.
- ///
- public int Height
- {
- get => _height;
- set
- {
- if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
- {
- throw new ArgumentException(SR.PSizeNotCustom, nameof(value));
- }
-
- _height = value;
- }
- }
-
- ///
- /// Gets the type of paper.
- ///
- public PaperKind Kind
- {
- get
- {
- if (_kind <= (PaperKind)SafeNativeMethods.DMPAPER_LAST &&
- !(_kind == (PaperKind)SafeNativeMethods.DMPAPER_RESERVED_48 || _kind == (PaperKind)SafeNativeMethods.DMPAPER_RESERVED_49))
- {
- return _kind;
- }
-
- return PaperKind.Custom;
- }
- }
-
- ///
- /// Gets or sets the name of the type of paper.
- ///
- public string PaperName
- {
- get => _name;
- set
- {
- if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
- {
- throw new ArgumentException(SR.PSizeNotCustom, nameof(value));
- }
-
- _name = value;
- }
- }
-
- ///
- /// Same as Kind, but values larger than or equal to DMPAPER_LAST do not map to PaperKind.Custom.
- ///
- public int RawKind
- {
- get => unchecked((int)_kind);
- set => _kind = unchecked((PaperKind)value);
- }
-
- ///
- /// Gets or sets the width of the paper, in hundredths of an inch.
- ///
- public int Width
- {
- get => _width;
- set
- {
- if (_kind != PaperKind.Custom && !_createdByDefaultConstructor)
- {
- throw new ArgumentException(SR.PSizeNotCustom, nameof(value));
- }
-
- _width = value;
- }
- }
-
- ///
- /// Provides some interesting information about the PaperSize in String form.
- ///
- public override string ToString() => $"[PaperSize {PaperName} Kind={Kind} Height={Height.ToString(CultureInfo.InvariantCulture)} Width={Width.ToString(CultureInfo.InvariantCulture)}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.Serializable.cs
deleted file mode 100644
index e590de765a514..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.Serializable.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This file isn't built into the .csproj in the runtime libraries but is consumed by Mono.
-
-namespace System.Drawing.Printing
-{
- [Serializable]
- partial class PaperSource
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.cs
deleted file mode 100644
index 5a321cc4d81f3..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSource.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the paper tray from which the printer gets paper.
- ///
- public partial class PaperSource
- {
- private string _name;
- private PaperSourceKind _kind;
-
- ///
- /// Initializes a new instance of the class with default properties.
- ///
- public PaperSource()
- {
- _kind = PaperSourceKind.Custom;
- _name = string.Empty;
- }
-
- internal PaperSource(PaperSourceKind kind, string name)
- {
- _kind = kind;
- _name = name;
- }
-
- ///
- /// Gets a value indicating the type of paper source.
- ///
- public PaperSourceKind Kind
- {
- get
- {
- if ((unchecked((int)_kind)) >= SafeNativeMethods.DMBIN_USER)
- {
- return PaperSourceKind.Custom;
- }
-
- return _kind;
- }
- }
-
- ///
- /// Same as Kind, but values larger than DMBIN_USER do not map to PaperSourceKind.Custom.
- ///
- public int RawKind
- {
- get => unchecked((int)_kind);
- set => _kind = unchecked((PaperSourceKind)value);
- }
-
- ///
- /// Gets the name of the paper source.
- ///
- public string SourceName
- {
- get => _name;
- set => _name = value;
- }
-
- ///
- /// Provides some interesting information about the PaperSource in String form.
- ///
- public override string ToString() => $"[PaperSource {SourceName} Kind={Kind}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSourceKind.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSourceKind.cs
deleted file mode 100644
index 0fc82103ac84e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PaperSourceKind.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Standard paper sources.
- ///
- public enum PaperSourceKind
- {
- // Please keep these in SafeNativeMethods.cs order
-
- ///
- /// The upper bin of a printer (or, if the printer only has one bin, the only bin).
- ///
- Upper = SafeNativeMethods.DMBIN_UPPER,
-
- ///
- /// The lower bin of a printer.
- ///
- Lower = SafeNativeMethods.DMBIN_LOWER,
-
- ///
- /// The middle bin of a printer.
- ///
- Middle = SafeNativeMethods.DMBIN_MIDDLE,
-
- ///
- /// Manually-fed paper.
- ///
- Manual = SafeNativeMethods.DMBIN_MANUAL,
-
- ///
- /// An envelope.
- ///
- Envelope = SafeNativeMethods.DMBIN_ENVELOPE,
-
- ///
- /// A manually-fed envelope.
- ///
- ManualFeed = SafeNativeMethods.DMBIN_ENVMANUAL,
-
- ///
- /// Automatic-fed paper.
- ///
- AutomaticFeed = SafeNativeMethods.DMBIN_AUTO,
-
- ///
- /// A tractor feed.
- ///
- TractorFeed = SafeNativeMethods.DMBIN_TRACTOR,
-
- ///
- /// Small-format paper.
- ///
- SmallFormat = SafeNativeMethods.DMBIN_SMALLFMT,
-
- ///
- /// Large-format paper.
- ///
- LargeFormat = SafeNativeMethods.DMBIN_LARGEFMT,
-
- ///
- /// A large-capacity bin printer.
- ///
- LargeCapacity = SafeNativeMethods.DMBIN_LARGECAPACITY,
-
- ///
- /// A paper cassette.
- ///
- Cassette = SafeNativeMethods.DMBIN_CASSETTE,
-
- FormSource = SafeNativeMethods.DMBIN_FORMSOURCE,
-
- ///
- /// A printer-specific paper source.
- ///
- Custom = SafeNativeMethods.DMBIN_USER + 1,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPageInfo.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPageInfo.cs
deleted file mode 100644
index 85761ecce6ad2..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPageInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies print preview information for a single page. This class cannot be inherited.
- ///
- public sealed class PreviewPageInfo
- {
- private readonly Image _image;
-
- // Physical measures in hundredths of an inch
- private Size _physicalSize = Size.Empty;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PreviewPageInfo(Image image, Size physicalSize)
- {
- _image = image;
- _physicalSize = physicalSize;
- }
-
- ///
- /// Gets the image of the printed page.
- ///
- public Image Image
- {
- get { return _image; }
- }
-
- ///
- /// Gets the size of the printed page, in hundredths of an inch.
- ///
- public Size PhysicalSize
- {
- get { return _physicalSize; }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs
deleted file mode 100644
index e5c135914b8a4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PreviewPrintController.cs
+++ /dev/null
@@ -1,137 +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.Collections;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.Drawing.Text;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Printing
-{
- ///
- /// A PrintController which "prints" to a series of images.
- ///
- public class PreviewPrintController : PrintController
- {
- private Graphics? _graphics;
- private DeviceContext? _dc;
- private readonly ArrayList _list = new ArrayList();
-
- public override bool IsPreview => true;
-
- public virtual bool UseAntiAlias { get; set; }
-
- public PreviewPageInfo[] GetPreviewPageInfo()
- {
- var temp = new PreviewPageInfo[_list.Count];
- _list.CopyTo(temp, 0);
- return temp;
- }
-
- ///
- /// Implements StartPrint for generating print preview information.
- ///
- public override void OnStartPrint(PrintDocument document, PrintEventArgs e)
- {
- base.OnStartPrint(document, e);
-
- if (!document.PrinterSettings.IsValid)
- {
- throw new InvalidPrinterException(document.PrinterSettings);
- }
-
- // We need a DC as a reference; we don't actually draw on it.
- // We make sure to reuse the same one to improve performance.
- _dc = document.PrinterSettings.CreateInformationContext(_modeHandle!);
- }
-
- ///
- /// Implements StartEnd for generating print preview information.
- ///
- public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
- {
- base.OnStartPage(document, e);
-
- if (e.CopySettingsToDevMode)
- {
- e.PageSettings.CopyToHdevmode(_modeHandle!);
- }
-
- Size size = e.PageBounds.Size;
-
- // Metafile framing rectangles apparently use hundredths of mm as their unit of measurement,
- // instead of the GDI+ standard hundredth of an inch.
- Size metafileSize = PrinterUnitConvert.Convert(size, PrinterUnit.Display, PrinterUnit.HundredthsOfAMillimeter);
-
- // Create a Metafile which accepts only GDI+ commands since we are the ones creating
- // and using this ...
- // Framework creates a dual-mode EMF for each page in the preview.
- // When these images are displayed in preview,
- // they are added to the dual-mode EMF. However,
- // GDI+ breaks during this process if the image
- // is sufficiently large and has more than 254 colors.
- // This code path can easily be avoided by requesting
- // an EmfPlusOnly EMF..
- Metafile metafile = new Metafile(_dc!.Hdc, new Rectangle(0, 0, metafileSize.Width, metafileSize.Height), MetafileFrameUnit.GdiCompatible, EmfType.EmfPlusOnly);
-
- PreviewPageInfo info = new PreviewPageInfo(metafile, size);
- _list.Add(info);
- PrintPreviewGraphics printGraphics = new PrintPreviewGraphics(document, e);
- _graphics = Graphics.FromImage(metafile);
-
- if (document.OriginAtMargins)
- {
- // Adjust the origin of the graphics object to be at the
- // user-specified margin location
- int dpiX = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- int dpiY = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSY);
- int hardMarginX_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX);
- int hardMarginY_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(_dc, _dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY);
- float hardMarginX = hardMarginX_DU * 100f / dpiX;
- float hardMarginY = hardMarginY_DU * 100f / dpiY;
-
- _graphics.TranslateTransform(-hardMarginX, -hardMarginY);
- _graphics.TranslateTransform(document.DefaultPageSettings.Margins.Left, document.DefaultPageSettings.Margins.Top);
- }
-
- _graphics.PrintingHelper = printGraphics;
-
- if (UseAntiAlias)
- {
- _graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
- _graphics.SmoothingMode = SmoothingMode.AntiAlias;
- }
- return _graphics;
- }
-
- ///
- /// Implements EndPage for generating print preview information.
- ///
- public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
- {
- if (_graphics != null)
- {
- _graphics.Dispose();
- _graphics = null;
- }
-
- base.OnEndPage(document, e);
- }
-
- ///
- /// Implements EndPrint for generating print preview information.
- ///
- public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
- {
- if (_dc != null)
- {
- _dc.Dispose();
- _dc = null;
- }
-
- base.OnEndPrint(document, e);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintAction.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintAction.cs
deleted file mode 100644
index 2ff2d3983035f..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintAction.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the type of action for the .
- ///
- public enum PrintAction
- {
- ///
- /// Printing to a file.
- ///
- PrintToFile,
- ///
- /// Printing to a preview.
- ///
- PrintToPreview,
- ///
- /// Printing to a printer.
- ///
- PrintToPrinter
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.cs
deleted file mode 100644
index 2fe1e955f1218..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintController.cs
+++ /dev/null
@@ -1,280 +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.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Controls how a document is printed.
- ///
- public abstract class PrintController
- {
- ///
- /// Represents a SafeHandle for a Printer's Device Mode struct handle (DEVMODE)
- ///
- ///
- /// DEVMODEs are pretty expensive, so we cache one here and share it
- /// with the Standard and Preview print controllers.
- ///
- internal sealed class SafeDeviceModeHandle : SafeHandle
- {
- public SafeDeviceModeHandle() : base(IntPtr.Zero, ownsHandle: true)
- {
- }
-
- internal SafeDeviceModeHandle(IntPtr handle) : base(IntPtr.Zero, ownsHandle: true)
- {
- SetHandle(handle);
- }
-
- public override bool IsInvalid => handle == IntPtr.Zero;
-
- ///
- /// Specifies how to free the handle.
- /// The boolean returned should be true for success and false if the runtime
- /// should fire a SafeHandleCriticalFailure MDA (CustomerDebugProbe) if that
- /// MDA is enabled.
- ///
- protected override bool ReleaseHandle()
- {
- if (!IsInvalid)
- {
- Interop.Kernel32.GlobalFree(new HandleRef(this, handle));
- }
-
- handle = IntPtr.Zero;
- return true;
- }
-
- public static implicit operator IntPtr(SafeDeviceModeHandle handle)
- {
- return (handle == null) ? IntPtr.Zero : handle.handle;
- }
-
- public static explicit operator SafeDeviceModeHandle(IntPtr handle)
- {
- return new SafeDeviceModeHandle(handle);
- }
- }
-
- private protected SafeDeviceModeHandle? _modeHandle;
-
- protected PrintController()
- {
- }
-
- public virtual bool IsPreview => false;
-
- ///
- /// When overridden in a derived class, begins the control sequence of when and how to print a page in a document.
- ///
- public virtual Graphics? OnStartPage(PrintDocument document, PrintPageEventArgs e)
- {
- return null;
- }
-
- ///
- /// When overridden in a derived class, completes the control sequence of when and how to print a page in a document.
- ///
- public virtual void OnEndPage(PrintDocument document, PrintPageEventArgs e)
- {
- }
-
- ///
- /// If you have nested PrintControllers, this method won't get called on the inner one.
- /// Add initialization code to StartPrint or StartPage instead.
- ///
- internal void Print(PrintDocument document)
- {
- // Get the PrintAction for this event
- PrintAction printAction;
- if (IsPreview)
- {
- printAction = PrintAction.PrintToPreview;
- }
- else
- {
- printAction = document.PrinterSettings.PrintToFile ? PrintAction.PrintToFile : PrintAction.PrintToPrinter;
- }
-
- // Check that user has permission to print to this particular printer
- PrintEventArgs printEvent = new PrintEventArgs(printAction);
- document.OnBeginPrint(printEvent);
- if (printEvent.Cancel)
- {
- document.OnEndPrint(printEvent);
- return;
- }
-
- OnStartPrint(document, printEvent);
- if (printEvent.Cancel)
- {
- document.OnEndPrint(printEvent);
- OnEndPrint(document, printEvent);
- return;
- }
-
- bool canceled = true;
-
- try
- {
- // To enable optimization of the preview dialog, add the following to the config file:
- //
- //
- //
- //
- canceled = LocalAppContextSwitches.OptimizePrintPreview ? PrintLoopOptimized(document) : PrintLoop(document);
- }
- finally
- {
- try
- {
- document.OnEndPrint(printEvent);
- printEvent.Cancel = canceled | printEvent.Cancel;
- }
- finally
- {
- OnEndPrint(document, printEvent);
- }
- }
- }
-
- ///
- /// Returns true if print was aborted.
- ///
- ///
- /// If you have nested PrintControllers, this method won't get called on the inner one
- /// Add initialization code to StartPrint or StartPage instead.
- ///
- private bool PrintLoop(PrintDocument document)
- {
- QueryPageSettingsEventArgs queryEvent = new QueryPageSettingsEventArgs((PageSettings)document.DefaultPageSettings.Clone());
- while (true)
- {
- document.OnQueryPageSettings(queryEvent);
- if (queryEvent.Cancel)
- {
- return true;
- }
-
- PrintPageEventArgs pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
- Graphics? graphics = OnStartPage(document, pageEvent);
- pageEvent.SetGraphics(graphics);
-
- try
- {
- document.OnPrintPage(pageEvent);
- OnEndPage(document, pageEvent);
- }
- finally
- {
- pageEvent.Dispose();
- }
-
- if (pageEvent.Cancel)
- {
- return true;
- }
- else if (!pageEvent.HasMorePages)
- {
- return false;
- }
- }
- }
-
- private bool PrintLoopOptimized(PrintDocument document)
- {
- PrintPageEventArgs? pageEvent = null;
- PageSettings documentPageSettings = (PageSettings)document.DefaultPageSettings.Clone();
- QueryPageSettingsEventArgs queryEvent = new QueryPageSettingsEventArgs(documentPageSettings);
- while (true)
- {
- queryEvent.PageSettingsChanged = false;
- document.OnQueryPageSettings(queryEvent);
- if (queryEvent.Cancel)
- {
- return true;
- }
-
- if (!queryEvent.PageSettingsChanged)
- {
- // QueryPageSettings event handler did not change the page settings,
- // thus we use default page settings from the document object.
- if (pageEvent == null)
- {
- pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
- }
- else
- {
- // This is not the first page and the settings had not changed since the previous page,
- // thus don't re-apply them.
- pageEvent.CopySettingsToDevMode = false;
- }
-
- Graphics? graphics = OnStartPage(document, pageEvent);
- pageEvent.SetGraphics(graphics);
- }
- else
- {
- // Page settings were customized, so use the customized ones in the start page event.
- pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
- Graphics? graphics = OnStartPage(document, pageEvent);
- pageEvent.SetGraphics(graphics);
- }
-
- try
- {
- document.OnPrintPage(pageEvent);
- OnEndPage(document, pageEvent);
- }
- finally
- {
- pageEvent.Graphics!.Dispose();
- pageEvent.SetGraphics(null);
- }
-
- if (pageEvent.Cancel)
- {
- return true;
- }
- else if (!pageEvent.HasMorePages)
- {
- return false;
- }
- }
- }
-
- private PrintPageEventArgs CreatePrintPageEvent(PageSettings pageSettings)
- {
- Debug.Assert((_modeHandle != null), "modeHandle is null. Someone must have forgot to call base.StartPrint");
-
-
- Rectangle pageBounds = pageSettings.GetBounds(_modeHandle);
- Rectangle marginBounds = new Rectangle(pageSettings.Margins.Left,
- pageSettings.Margins.Top,
- pageBounds.Width - (pageSettings.Margins.Left + pageSettings.Margins.Right),
- pageBounds.Height - (pageSettings.Margins.Top + pageSettings.Margins.Bottom));
-
- PrintPageEventArgs pageEvent = new PrintPageEventArgs(null, marginBounds, pageBounds, pageSettings);
- return pageEvent;
- }
-
- ///
- /// When overridden in a derived class, begins the control sequence of when and how to print a document.
- ///
- public virtual void OnStartPrint(PrintDocument document, PrintEventArgs e)
- {
- _modeHandle = (SafeDeviceModeHandle)document.PrinterSettings.GetHdevmode(document.DefaultPageSettings);
- }
-
- ///
- /// When overridden in a derived class, completes the control sequence of when and how to print a document.
- ///
- public virtual void OnEndPrint(PrintDocument document, PrintEventArgs e)
- {
- _modeHandle?.Close();
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs
deleted file mode 100644
index c315870ec680a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintDocument.cs
+++ /dev/null
@@ -1,234 +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.ComponentModel;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Defines a reusable object that sends output to the printer.
- ///
- [DefaultProperty("DocumentName"), DefaultEvent("PrintPage"), SRDescription(nameof(SR.PrintDocumentDesc))]
- public class PrintDocument : Component
- {
- private string _documentName = "document";
-
- private PrintEventHandler? _beginPrintHandler;
- private PrintEventHandler? _endPrintHandler;
- private PrintPageEventHandler? _printPageHandler;
- private QueryPageSettingsEventHandler? _queryHandler;
-
- private PrinterSettings _printerSettings = new PrinterSettings();
- private PageSettings _defaultPageSettings;
-
- private PrintController? _printController;
-
- private bool _originAtMargins;
- private bool _userSetPageSettings;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PrintDocument()
- {
- _defaultPageSettings = new PageSettings(_printerSettings);
- }
-
- ///
- /// Gets or sets the default page settings for the document being printed.
- ///
- [
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SRDescription(nameof(SR.PDOCdocumentPageSettingsDescr))
- ]
- public PageSettings DefaultPageSettings
- {
- get { return _defaultPageSettings; }
- set
- {
- _defaultPageSettings = value ?? new PageSettings();
- _userSetPageSettings = true;
- }
- }
-
- ///
- /// Gets or sets the name to display to the user while printing the document; for example, in a print status
- /// dialog or a printer queue.
- ///
- [
- DefaultValue("document"),
- SRDescription(nameof(SR.PDOCdocumentNameDescr))
- ]
- public string DocumentName
- {
- get => _documentName;
- set => _documentName = value ?? "";
- }
-
- // If true, positions the origin of the graphics object
- // associated with the page at the point just inside
- // the user-specified margins of the page.
- // If false, the graphics origin is at the top-left
- // corner of the printable area of the page.
- [
- DefaultValue(false),
- SRDescription(nameof(SR.PDOCoriginAtMarginsDescr))
- ]
- public bool OriginAtMargins
- {
- get
- {
- return _originAtMargins;
- }
- set
- {
- _originAtMargins = value;
- }
- }
-
- ///
- /// Gets or sets the that guides the printing process.
- ///
- [
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SRDescription(nameof(SR.PDOCprintControllerDescr))
- ]
- public PrintController PrintController
- {
- get => _printController ??= new StandardPrintController();
- set => _printController = value;
- }
-
- ///
- /// Gets or sets the printer on which the document is printed.
- ///
- [
- Browsable(false),
- DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden),
- SRDescription(nameof(SR.PDOCprinterSettingsDescr))
- ]
- public PrinterSettings PrinterSettings
- {
- get { return _printerSettings; }
- set
- {
- value ??= new PrinterSettings();
- _printerSettings = value;
- // reset the PageSettings that match the PrinterSettings only if we have created the defaultPageSettings..
- if (!_userSetPageSettings)
- {
- _defaultPageSettings = _printerSettings.DefaultPageSettings;
- }
- }
- }
-
- ///
- /// Occurs when the method is called, before the first page prints.
- ///
- [SRDescription(nameof(SR.PDOCbeginPrintDescr))]
- public event PrintEventHandler BeginPrint
- {
- add
- {
- _beginPrintHandler += value;
- }
- remove
- {
- _beginPrintHandler -= value;
- }
- }
-
- ///
- /// Occurs when is called, after the last page is printed.
- ///
- [SRDescription(nameof(SR.PDOCendPrintDescr))]
- public event PrintEventHandler EndPrint
- {
- add
- {
- _endPrintHandler += value;
- }
- remove
- {
- _endPrintHandler -= value;
- }
- }
-
- ///
- /// Occurs when a page is printed.
- ///
- [SRDescription(nameof(SR.PDOCprintPageDescr))]
- public event PrintPageEventHandler PrintPage
- {
- add
- {
- _printPageHandler += value;
- }
- remove
- {
- _printPageHandler -= value;
- }
- }
-
- [SRDescription(nameof(SR.PDOCqueryPageSettingsDescr))]
- public event QueryPageSettingsEventHandler QueryPageSettings
- {
- add
- {
- _queryHandler += value;
- }
- remove
- {
- _queryHandler -= value;
- }
- }
-
- ///
- /// Raises the event.
- ///
- protected internal virtual void OnBeginPrint(PrintEventArgs e)
- {
- _beginPrintHandler?.Invoke(this, e);
- }
-
- ///
- /// Raises the event.
- ///
- protected internal virtual void OnEndPrint(PrintEventArgs e)
- {
- _endPrintHandler?.Invoke(this, e);
- }
-
- ///
- /// Raises the event.
- ///
- protected internal virtual void OnPrintPage(PrintPageEventArgs e)
- {
- _printPageHandler?.Invoke(this, e);
- }
-
- ///
- /// Raises the event.
- ///
- protected internal virtual void OnQueryPageSettings(QueryPageSettingsEventArgs e)
- {
- _queryHandler?.Invoke(this, e);
- }
-
- ///
- /// Prints the document.
- ///
- public void Print()
- {
- PrintController controller = PrintController;
- controller.Print(this);
- }
-
- ///
- /// Provides some interesting information about the PrintDocument in String form.
- ///
- public override string ToString() => $"[PrintDocument {DocumentName}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventArgs.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventArgs.cs
deleted file mode 100644
index 1abd0698fdd34..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventArgs.cs
+++ /dev/null
@@ -1,41 +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.ComponentModel;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Provides data for the and events.
- ///
- public class PrintEventArgs : CancelEventArgs
- {
- private readonly PrintAction _printAction;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PrintEventArgs()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- internal PrintEventArgs(PrintAction action)
- {
- _printAction = action;
- }
-
- ///
- /// Specifies which is causing this event.
- ///
- public PrintAction PrintAction
- {
- get
- {
- return _printAction;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventHandler.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventHandler.cs
deleted file mode 100644
index 45a5f3f0f25dc..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintEventHandler.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Represents the method that will handle the ,
- /// , or
- /// event of a .
- ///
- public delegate void PrintEventHandler(object sender, PrintEventArgs e);
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventArgs.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventArgs.cs
deleted file mode 100644
index 7c79df0029701..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventArgs.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Provides data for the event.
- ///
- // NOTE: Please keep this class consistent with PaintEventArgs.
- public class PrintPageEventArgs : EventArgs
- {
- private bool _hasMorePages;
- private bool _cancel;
-
- private Graphics? _graphics;
- private readonly Rectangle _marginBounds;
- private readonly Rectangle _pageBounds;
- private readonly PageSettings _pageSettings;
-
- // Apply page settings to the printer.
- internal bool CopySettingsToDevMode = true;
-
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PrintPageEventArgs(Graphics? graphics, Rectangle marginBounds, Rectangle pageBounds, PageSettings pageSettings)
- {
- _graphics = graphics; // may be null, see PrintController
- _marginBounds = marginBounds;
- _pageBounds = pageBounds;
- _pageSettings = pageSettings;
- }
-
- ///
- /// Gets or sets a value indicating whether the print job should be canceled.
- ///
- public bool Cancel
- {
- get { return _cancel; }
- set { _cancel = value; }
- }
-
- ///
- /// Gets the used to paint the item.
- ///
- public Graphics? Graphics
- {
- get
- {
- return _graphics;
- }
- }
-
- ///
- /// Gets or sets a value indicating whether an additional page should be printed.
- ///
- public bool HasMorePages
- {
- get { return _hasMorePages; }
- set { _hasMorePages = value; }
- }
-
- ///
- /// Gets the rectangular area that represents the portion of the page between the margins.
- ///
- public Rectangle MarginBounds
- {
- get
- {
- return _marginBounds;
- }
- }
-
- ///
- /// Gets the rectangular area that represents the total area of the page.
- ///
- public Rectangle PageBounds
- {
- get
- {
- return _pageBounds;
- }
- }
-
- ///
- /// Gets the page settings for the current page.
- ///
- public PageSettings PageSettings
- {
- get
- {
- return _pageSettings;
- }
- }
-
- ///
- /// Disposes of the resources (other than memory) used by the .
- ///
- internal void Dispose()
- {
- _graphics!.Dispose();
- }
-
- internal void SetGraphics(Graphics? value)
- {
- _graphics = value;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventHandler.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventHandler.cs
deleted file mode 100644
index 8836bb597549e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPageEventHandler.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.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Represents the method that will handle the event of a .
- ///
- public delegate void PrintPageEventHandler(object sender, PrintPageEventArgs e);
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPreviewGraphics.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPreviewGraphics.cs
deleted file mode 100644
index f4907591b8d34..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintPreviewGraphics.cs
+++ /dev/null
@@ -1,58 +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.Drawing.Internal;
-using System.Drawing.Printing;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- ///
- /// Retrieves the printer graphics during preview.
- ///
- internal sealed class PrintPreviewGraphics
- {
- private readonly PrintPageEventArgs _printPageEventArgs;
- private readonly PrintDocument _printDocument;
-
- public PrintPreviewGraphics(PrintDocument document, PrintPageEventArgs e)
- {
- _printPageEventArgs = e;
- _printDocument = document;
- }
-
- ///
- /// Gets the Visible bounds of this graphics object. Used during print preview.
- ///
- public RectangleF VisibleClipBounds
- {
- get
- {
- IntPtr hdevMode = _printPageEventArgs.PageSettings.PrinterSettings.GetHdevmodeInternal();
-
- using (DeviceContext dc = _printPageEventArgs.PageSettings.PrinterSettings.CreateDeviceContext(hdevMode))
- {
- using (Graphics graphics = Graphics.FromHdcInternal(dc.Hdc))
- {
- if (_printDocument.OriginAtMargins)
- {
- // Adjust the origin of the graphics object to be at the user-specified margin location
- // Note: Graphics.FromHdc internally calls SaveDC(hdc), we can still use the saved hdc to get the resolution.
- int dpiX = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- int dpiY = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.LOGPIXELSY);
- int hardMarginX_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETX);
- int hardMarginY_DU = Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), Interop.Gdi32.DeviceCapability.PHYSICALOFFSETY);
- float hardMarginX = hardMarginX_DU * 100 / dpiX;
- float hardMarginY = hardMarginY_DU * 100 / dpiY;
-
- graphics.TranslateTransform(-hardMarginX, -hardMarginY);
- graphics.TranslateTransform(_printDocument.DefaultPageSettings.Margins.Left, _printDocument.DefaultPageSettings.Margins.Top);
- }
-
- return graphics.VisibleClipBounds;
- }
- }
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintRange.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintRange.cs
deleted file mode 100644
index a1f3f6576c92b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrintRange.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies the option buttons in the print dialog box that designate the part of the document to print.
- ///
- public enum PrintRange
- {
- ///
- /// All pages are printed.
- ///
- AllPages = SafeNativeMethods.PD_ALLPAGES,
-
- ///
- /// The pages between and are printed.
- ///
- SomePages = SafeNativeMethods.PD_PAGENUMS,
-
- ///
- /// The selected pages are printed.
- ///
- Selection = SafeNativeMethods.PD_SELECTION,
-
- ///
- /// The current page is printed. The print dialog box requires Windows 2000 or later for this setting; if used
- /// with an earlier operating system, all pages will be printed.
- ///
- CurrentPage = SafeNativeMethods.PD_CURRENTPAGE,
-
- // When adding new members, be sure to update PrintDialog.printRangeMask.
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.Serializable.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.Serializable.cs
deleted file mode 100644
index 6cabac964b7d9..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.Serializable.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// This file isn't built into the .csproj in the runtime libraries but is consumed by Mono.
-
-namespace System.Drawing.Printing
-{
- [Serializable]
- partial class PrinterResolution
- {
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.cs
deleted file mode 100644
index 20b0091cfe870..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolution.cs
+++ /dev/null
@@ -1,82 +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.ComponentModel;
-using System.Globalization;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Retrieves the resolution supported by a printer.
- ///
- public partial class PrinterResolution
- {
- private int _x;
- private int _y;
- private PrinterResolutionKind _kind;
-
- ///
- /// Initializes a new instance of the class with default properties.
- ///
- public PrinterResolution()
- {
- _kind = PrinterResolutionKind.Custom;
- }
-
- internal PrinterResolution(PrinterResolutionKind kind, int x, int y)
- {
- _kind = kind;
- _x = x;
- _y = y;
- }
-
- ///
- /// Gets a value indicating the kind of printer resolution.
- ///
- public PrinterResolutionKind Kind
- {
- get => _kind;
- set
- {
- if (value < PrinterResolutionKind.High || value > PrinterResolutionKind.Custom)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(PrinterResolutionKind));
- }
-
- _kind = value;
- }
- }
-
- ///
- /// Gets the printer resolution in the horizontal direction, in dots per inch.
- ///
- public int X
- {
- get => _x;
- set => _x = value;
- }
-
- ///
- /// Gets the printer resolution in the vertical direction, in dots per inch.
- ///
- public int Y
- {
- get => _y;
- set => _y = value;
- }
-
- ///
- /// Provides some interesting information about the PrinterResolution in String form.
- ///
- public override string ToString()
- {
- if (_kind != PrinterResolutionKind.Custom)
- {
- return $"[PrinterResolution {Kind}]";
- }
-
-
- return FormattableString.Invariant($"[PrinterResolution X={X} Y={Y}]");
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolutionKind.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolutionKind.cs
deleted file mode 100644
index 19ecb4247a75f..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterResolutionKind.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies a printer resolution.
- ///
- public enum PrinterResolutionKind
- {
- ///
- /// High resolution.
- ///
- High = SafeNativeMethods.DMRES_HIGH,
- ///
- /// Medium resolution.
- ///
- Medium = SafeNativeMethods.DMRES_MEDIUM,
- ///
- /// Low resolution.
- ///
- Low = SafeNativeMethods.DMRES_LOW,
- ///
- /// Draft-quality resolution.
- ///
- Draft = SafeNativeMethods.DMRES_DRAFT,
- ///
- /// Custom resolution.
- ///
- Custom = 0,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs
deleted file mode 100644
index 441809b55b13c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterSettings.cs
+++ /dev/null
@@ -1,1654 +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.Collections;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Drawing.Imaging;
-using System.Drawing.Internal;
-using System.Globalization;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Information about how a document should be printed, including which printer to print it on.
- ///
- public class PrinterSettings : ICloneable
- {
- // All read/write data is stored in managed code, and whenever we need to call Win32,
- // we create new DEVMODE and DEVNAMES structures. We don't store device capabilities,
- // though.
- //
- // Also, all properties have hidden tri-state logic -- yes/no/default
- private const int Padding64Bit = 4;
-
- private string? _printerName; // default printer.
- private string _driverName = "";
- private string _outputPort = "";
- private bool _printToFile;
-
- // Whether the PrintDialog has been shown (not whether it's currently shown). This is how we enforce SafePrinting.
- private bool _printDialogDisplayed;
-
- private short _extrabytes;
- private byte[]? _extrainfo;
-
- private short _copies = -1;
- private Duplex _duplex = System.Drawing.Printing.Duplex.Default;
- private TriState _collate = TriState.Default;
- private readonly PageSettings _defaultPageSettings;
- private int _fromPage;
- private int _toPage;
- private int _maxPage = 9999;
- private int _minPage;
- private PrintRange _printRange;
-
- private short _devmodebytes;
- private byte[]? _cachedDevmode;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PrinterSettings()
- {
- _defaultPageSettings = new PageSettings(this);
- }
-
- ///
- /// Gets a value indicating whether the printer supports duplex (double-sided) printing.
- ///
- public bool CanDuplex
- {
- get { return DeviceCapabilities(SafeNativeMethods.DC_DUPLEX, IntPtr.Zero, 0) == 1; }
- }
-
- ///
- /// Gets or sets the number of copies to print.
- ///
- public short Copies
- {
- get
- {
- if (_copies != -1)
- return _copies;
- else
- return GetModeField(ModeField.Copies, 1);
- }
- set
- {
- if (value < 0)
- throw new ArgumentException(SR.Format(SR.InvalidLowBoundArgumentEx,
- nameof(value), value.ToString(CultureInfo.CurrentCulture),
- (0).ToString(CultureInfo.CurrentCulture)));
- /*
- We shouldnt allow copies to be set since the copies can be a large number
- and can be reflected in PrintDialog. So for the Copies property,
- we prefer that for SafePrinting, copied cannot be set programmatically
- but through the print dialog.
- Any lower security could set copies to anything.
- */
- _copies = value;
- }
- }
-
- ///
- /// Gets or sets a value indicating whether the print out is collated.
- ///
- public bool Collate
- {
- get
- {
- if (!_collate.IsDefault)
- return (bool)_collate;
- else
- return GetModeField(ModeField.Collate, SafeNativeMethods.DMCOLLATE_FALSE) == SafeNativeMethods.DMCOLLATE_TRUE;
- }
- set { _collate = value; }
- }
-
- ///
- /// Gets the default page settings for this printer.
- ///
- public PageSettings DefaultPageSettings
- {
- get { return _defaultPageSettings; }
- }
-
- // As far as I can tell, Windows no longer pays attention to driver names and output ports.
- // But I'm leaving this code in place in case I'm wrong.
- internal string DriverName
- {
- get { return _driverName; }
- }
-
- ///
- /// Gets or sets the printer's duplex setting.
- ///
- public Duplex Duplex
- {
- get
- {
- if (_duplex != Duplex.Default)
- {
- return _duplex;
- }
-
- return (Duplex)GetModeField(ModeField.Duplex, SafeNativeMethods.DMDUP_SIMPLEX);
- }
- set
- {
- if (value < Duplex.Default || value > Duplex.Horizontal)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(Duplex));
- }
-
- _duplex = value;
- }
- }
-
- ///
- /// Gets or sets the first page to print.
- ///
- public int FromPage
- {
- get { return _fromPage; }
- set
- {
- if (value < 0)
- throw new ArgumentException(SR.Format(SR.InvalidLowBoundArgumentEx,
- nameof(value), value.ToString(CultureInfo.CurrentCulture),
- (0).ToString(CultureInfo.CurrentCulture)));
- _fromPage = value;
- }
- }
-
-
-
- ///
- /// Gets the names of all printers installed on the machine.
- ///
- public static unsafe StringCollection InstalledPrinters
- {
- get
- {
- int sizeofstruct;
- // Note: The call to get the size of the buffer required for level 5 does not work properly on NT platforms.
- const int Level = 4;
- // PRINTER_INFO_4 is 12 or 24 bytes in size depending on the architecture.
- if (IntPtr.Size == 8)
- {
- sizeofstruct = (IntPtr.Size * 2) + (sizeof(int) * 1) + Padding64Bit;
- }
- else
- {
- sizeofstruct = (IntPtr.Size * 2) + (sizeof(int) * 1);
- }
-
- int bufferSize;
- int count;
- Interop.Winspool.EnumPrinters(SafeNativeMethods.PRINTER_ENUM_LOCAL | SafeNativeMethods.PRINTER_ENUM_CONNECTIONS, null, Level, IntPtr.Zero, 0, out bufferSize, out _);
-
- IntPtr buffer = Marshal.AllocCoTaskMem(bufferSize);
- int returnCode = Interop.Winspool.EnumPrinters(SafeNativeMethods.PRINTER_ENUM_LOCAL | SafeNativeMethods.PRINTER_ENUM_CONNECTIONS,
- null, Level, buffer,
- bufferSize, out _, out count);
- var array = new string[count];
-
- if (returnCode == 0)
- {
- Marshal.FreeCoTaskMem(buffer);
- throw new Win32Exception();
- }
-
- byte* pBuffer = (byte*)buffer;
- for (int i = 0; i < count; i++)
- {
- // The printer name is at offset 0
- IntPtr namePointer = *(IntPtr*)(pBuffer + (nint)i * sizeofstruct);
- array[i] = Marshal.PtrToStringAuto(namePointer)!;
- }
-
- Marshal.FreeCoTaskMem(buffer);
-
- return new StringCollection(array);
- }
- }
-
- ///
- /// Gets a value indicating whether the property designates the default printer.
- ///
- public bool IsDefaultPrinter
- {
- get
- {
- return (_printerName == null || _printerName == GetDefaultPrinterName());
- }
- }
-
- ///
- /// Gets a value indicating whether the printer is a plotter, as opposed to a raster printer.
- ///
- public bool IsPlotter
- {
- get
- {
- return GetDeviceCaps(Interop.Gdi32.DeviceCapability.TECHNOLOGY) == Interop.Gdi32.DeviceTechnology.DT_PLOTTER;
- }
- }
-
- ///
- /// Gets a value indicating whether the property designates a valid printer.
- ///
- public bool IsValid
- {
- get
- {
- return DeviceCapabilities(SafeNativeMethods.DC_COPIES, IntPtr.Zero, -1) != -1;
- }
- }
-
- ///
- /// Gets the angle, in degrees, which the portrait orientation is rotated to produce the landscape orientation.
- ///
- public int LandscapeAngle
- {
- get { return DeviceCapabilities(SafeNativeMethods.DC_ORIENTATION, IntPtr.Zero, 0); }
- }
-
- ///
- /// Gets the maximum number of copies allowed by the printer.
- ///
- public int MaximumCopies
- {
- get { return DeviceCapabilities(SafeNativeMethods.DC_COPIES, IntPtr.Zero, 1); }
- }
-
- ///
- /// Gets or sets the highest or which may be selected in a print dialog box.
- ///
- public int MaximumPage
- {
- get { return _maxPage; }
- set
- {
- if (value < 0)
- throw new ArgumentException(SR.Format(SR.InvalidLowBoundArgumentEx,
- nameof(value), value.ToString(CultureInfo.CurrentCulture),
- (0).ToString(CultureInfo.CurrentCulture)));
- _maxPage = value;
- }
- }
-
- ///
- /// Gets or sets the lowest or which may be selected in a print dialog box.
- ///
- public int MinimumPage
- {
- get { return _minPage; }
- set
- {
- if (value < 0)
- throw new ArgumentException(SR.Format(SR.InvalidLowBoundArgumentEx,
- nameof(value), value.ToString(CultureInfo.CurrentCulture),
- (0).ToString(CultureInfo.CurrentCulture)));
- _minPage = value;
- }
- }
-
- internal string OutputPort
- {
- get
- {
- return _outputPort;
- }
- set
- {
- _outputPort = value;
- }
- }
-
- ///
- /// Indicates the name of the printerfile.
- ///
- public string PrintFileName
- {
- get
- {
- string printFileName = OutputPort;
- return printFileName;
- }
- set
- {
- if (string.IsNullOrEmpty(value))
- {
- throw new ArgumentNullException(value);
- }
- OutputPort = value;
- }
- }
-
- ///
- /// Gets the paper sizes supported by this printer.
- ///
- public PaperSizeCollection PaperSizes
- {
- get { return new PaperSizeCollection(Get_PaperSizes()); }
- }
-
- ///
- /// Gets the paper sources available on this printer.
- ///
- public PaperSourceCollection PaperSources
- {
- get { return new PaperSourceCollection(Get_PaperSources()); }
- }
-
- ///
- /// Whether the print dialog has been displayed. In SafePrinting mode, a print dialog is required to print.
- /// After printing, this property is set to false if the program does not have AllPrinting; this guarantees
- /// a document is only printed once each time the print dialog is shown.
- ///
- internal bool PrintDialogDisplayed
- {
- get
- {
- return _printDialogDisplayed;
- }
-
- set
- {
- _printDialogDisplayed = value;
- }
- }
-
- ///
- /// Gets or sets the pages the user has asked to print.
- ///
- public PrintRange PrintRange
- {
- get { return _printRange; }
- set
- {
- if (!Enum.IsDefined(value))
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(PrintRange));
-
- _printRange = value;
- }
- }
-
- ///
- /// Indicates whether to print to a file instead of a port.
- ///
- public bool PrintToFile
- {
- get
- {
- return _printToFile;
- }
- set
- {
- _printToFile = value;
- }
- }
-
- ///
- /// Gets or sets the name of the printer.
- ///
- public string PrinterName
- {
- get
- {
- return PrinterNameInternal;
- }
-
- set
- {
- PrinterNameInternal = value;
- }
- }
-
- private string PrinterNameInternal
- {
- get
- {
- if (_printerName == null)
- return GetDefaultPrinterName();
- else
- return _printerName;
- }
- set
- {
- // Reset the DevMode and Extrabytes...
- _cachedDevmode = null;
- _extrainfo = null;
- _printerName = value;
- // PrinterName can be set through a fulltrusted assembly without using the PrintDialog.
- // So dont set this variable here.
- //PrintDialogDisplayed = true;
- }
- }
-
- ///
- /// Gets the resolutions supported by this printer.
- ///
- public PrinterResolutionCollection PrinterResolutions
- {
- get { return new PrinterResolutionCollection(Get_PrinterResolutions()); }
- }
-
- ///
- /// If the image is a JPEG or a PNG (Image.RawFormat) and the printer returns true from
- /// ExtEscape(CHECKJPEGFORMAT) or ExtEscape(CHECKPNGFORMAT) then this function returns true.
- ///
- public bool IsDirectPrintingSupported(ImageFormat imageFormat)
- {
- bool isDirectPrintingSupported = false;
- if (imageFormat.Equals(ImageFormat.Jpeg) || imageFormat.Equals(ImageFormat.Png))
- {
- int nEscape = imageFormat.Equals(ImageFormat.Jpeg) ? Interop.Gdi32.CHECKJPEGFORMAT : Interop.Gdi32.CHECKPNGFORMAT;
- int outData;
- DeviceContext dc = CreateInformationContext(DefaultPageSettings);
- HandleRef hdc = new HandleRef(dc, dc.Hdc);
- try
- {
- isDirectPrintingSupported = Interop.Gdi32.ExtEscape(hdc, Interop.Gdi32.QUERYESCSUPPORT, sizeof(int), ref nEscape, 0, out outData) > 0;
- }
- finally
- {
- dc.Dispose();
- }
- }
- return isDirectPrintingSupported;
- }
-
- ///
- /// This method utilizes the CHECKJPEGFORMAT/CHECKPNGFORMAT printer escape functions
- /// to determine whether the printer can handle a JPEG image.
- ///
- /// If the image is a JPEG or a PNG (Image.RawFormat) and the printer returns true
- /// from ExtEscape(CHECKJPEGFORMAT) or ExtEscape(CHECKPNGFORMAT) then this function returns true.
- ///
- public bool IsDirectPrintingSupported(Image image)
- {
- bool isDirectPrintingSupported = false;
- if (image.RawFormat.Equals(ImageFormat.Jpeg) || image.RawFormat.Equals(ImageFormat.Png))
- {
- MemoryStream stream = new MemoryStream();
- try
- {
- image.Save(stream, image.RawFormat);
-
- byte[] pvImage = stream.ToArray();
-
- int nEscape = image.RawFormat.Equals(ImageFormat.Jpeg) ? Interop.Gdi32.CHECKJPEGFORMAT : Interop.Gdi32.CHECKPNGFORMAT;
- int outData = 0;
-
- DeviceContext dc = CreateInformationContext(DefaultPageSettings);
- HandleRef hdc = new HandleRef(dc, dc.Hdc);
- try
- {
- bool querySupported = Interop.Gdi32.ExtEscape(hdc, Interop.Gdi32.QUERYESCSUPPORT, sizeof(int), ref nEscape, 0, out outData) > 0;
- if (querySupported)
- {
- isDirectPrintingSupported = (Interop.Gdi32.ExtEscape(hdc, nEscape, pvImage.Length, pvImage, sizeof(int), out outData) > 0)
- && (outData == 1);
- }
- }
- finally
- {
- dc.Dispose();
- }
- }
- finally
- {
- stream.Close();
- }
- }
- return isDirectPrintingSupported;
- }
-
- ///
- /// Gets a value indicating whether the printer supports color printing.
- ///
- public bool SupportsColor
- {
- get
- {
- // If the printer supports color printing, the return value is 1; otherwise, the return value is zero.
- // The pointerToBuffer parameter is not used.
- return DeviceCapabilities(
- capability: SafeNativeMethods.DC_COLORDEVICE,
- pointerToBuffer: IntPtr.Zero,
- defaultValue: 0) == 1;
- }
- }
-
- ///
- /// Gets or sets the last page to print.
- ///
- public int ToPage
- {
- get { return _toPage; }
- set
- {
- if (value < 0)
- throw new ArgumentException(SR.Format(SR.InvalidLowBoundArgumentEx,
- nameof(value), value.ToString(CultureInfo.CurrentCulture),
- (0).ToString(CultureInfo.CurrentCulture)));
- _toPage = value;
- }
- }
-
- ///
- /// Creates an identical copy of this object.
- ///
- public object Clone()
- {
- PrinterSettings clone = (PrinterSettings)MemberwiseClone();
- clone._printDialogDisplayed = false;
- return clone;
- }
- // what is done in copytohdevmode cannot give unwanted access AllPrinting permission
- internal DeviceContext CreateDeviceContext(PageSettings pageSettings)
- {
- IntPtr modeHandle = GetHdevmodeInternal();
- DeviceContext? dc = null;
-
- try
- {
- //Copy the PageSettings to the DEVMODE...
- pageSettings.CopyToHdevmode(modeHandle);
- dc = CreateDeviceContext(modeHandle);
- }
- finally
- {
- Interop.Kernel32.GlobalFree(modeHandle);
- }
- return dc;
- }
-
- internal DeviceContext CreateDeviceContext(IntPtr hdevmode)
- {
- IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- DeviceContext dc = DeviceContext.CreateDC(DriverName, PrinterNameInternal, fileName:null, modePointer);
- Interop.Kernel32.GlobalUnlock(hdevmode);
- return dc;
- }
-
- // A read-only DC, which is faster than CreateHdc
- // what is done in copytohdevmode cannot give unwanted access AllPrinting permission
- internal DeviceContext CreateInformationContext(PageSettings pageSettings)
- {
- IntPtr modeHandle = GetHdevmodeInternal();
- DeviceContext dc;
-
- try
- {
- //Copy the PageSettings to the DEVMODE...
- pageSettings.CopyToHdevmode(modeHandle);
- dc = CreateInformationContext(modeHandle);
- }
- finally
- {
- Interop.Kernel32.GlobalFree(modeHandle);
- }
- return dc;
- }
-
- // A read-only DC, which is faster than CreateHdc
- internal DeviceContext CreateInformationContext(IntPtr hdevmode)
- {
- IntPtr modePointer = Interop.Kernel32.GlobalLock(hdevmode);
- DeviceContext dc = DeviceContext.CreateIC(DriverName, PrinterNameInternal, fileName:null, modePointer);
- Interop.Kernel32.GlobalUnlock(hdevmode);
- return dc;
- }
-
- public Graphics CreateMeasurementGraphics()
- {
- return CreateMeasurementGraphics(DefaultPageSettings);
- }
-
- //whatever the call stack calling HardMarginX and HardMarginY here is safe
- public Graphics CreateMeasurementGraphics(bool honorOriginAtMargins)
- {
- Graphics g = CreateMeasurementGraphics();
- if (honorOriginAtMargins)
- {
- g.TranslateTransform(-_defaultPageSettings.HardMarginX, -_defaultPageSettings.HardMarginY);
- g.TranslateTransform(_defaultPageSettings.Margins.Left, _defaultPageSettings.Margins.Top);
- }
- return g;
- }
-
- public Graphics CreateMeasurementGraphics(PageSettings pageSettings)
- {
- // returns the Graphics object for the printer
- DeviceContext dc = CreateDeviceContext(pageSettings);
- Graphics g = Graphics.FromHdcInternal(dc.Hdc);
- g.PrintingHelper = dc; // Graphics will dispose of the DeviceContext.
- return g;
- }
-
- //whatever the call stack calling HardMarginX and HardMarginY here is safe
- public Graphics CreateMeasurementGraphics(PageSettings pageSettings, bool honorOriginAtMargins)
- {
- Graphics g = CreateMeasurementGraphics();
- if (honorOriginAtMargins)
- {
- g.TranslateTransform(-pageSettings.HardMarginX, -pageSettings.HardMarginY);
- g.TranslateTransform(pageSettings.Margins.Left, pageSettings.Margins.Top);
- }
- return g;
- }
-
- // Create a PRINTDLG with a few useful defaults.
- // Try to keep this consistent with PrintDialog.CreatePRINTDLG.
- private static unsafe void CreatePRINTDLGX86(out Interop.Comdlg32.PRINTDLGX86 data)
- {
- data = default;
- data.lStructSize = sizeof(Interop.Comdlg32.PRINTDLGX86);
- data.nFromPage = 1;
- data.nToPage = 1;
- data.nMinPage = 0;
- data.nMaxPage = 9999;
- data.nCopies = 1;
- }
-
- // Create a PRINTDLG with a few useful defaults.
- // Try to keep this consistent with PrintDialog.CreatePRINTDLG.
- private static unsafe void CreatePRINTDLG(out Interop.Comdlg32.PRINTDLG data)
- {
- data = default;
- data.lStructSize = sizeof(Interop.Comdlg32.PRINTDLG);
- data.nFromPage = 1;
- data.nToPage = 1;
- data.nMinPage = 0;
- data.nMaxPage = 9999;
- data.nCopies = 1;
- }
-
- // Use FastDeviceCapabilities where possible -- computing PrinterName is quite slow
- private int DeviceCapabilities(short capability, IntPtr pointerToBuffer, int defaultValue)
- {
- string printerName = PrinterName;
- return FastDeviceCapabilities(capability, pointerToBuffer, defaultValue, printerName);
- }
-
- // We pass PrinterName in as a parameter rather than computing it ourselves because it's expensive to compute.
- // We need to pass IntPtr.Zero since passing HDevMode is non-performant.
- private static int FastDeviceCapabilities(short capability, IntPtr pointerToBuffer, int defaultValue, string printerName)
- {
- int result = Interop.Winspool.DeviceCapabilities(printerName, GetOutputPort(),
- capability, pointerToBuffer, IntPtr.Zero);
- if (result == -1)
- return defaultValue;
- return result;
- }
-
- // Called by get_PrinterName
- private static string GetDefaultPrinterName()
- {
- if (IntPtr.Size == 8)
- {
- CreatePRINTDLG(out Interop.Comdlg32.PRINTDLG data);
- data.Flags = SafeNativeMethods.PD_RETURNDEFAULT;
- bool status = Interop.Comdlg32.PrintDlg(ref data);
-
- if (!status)
- return SR.NoDefaultPrinter;
-
- IntPtr handle = data.hDevNames;
- IntPtr names = Interop.Kernel32.GlobalLock(handle);
- if (names == IntPtr.Zero)
- throw new Win32Exception();
-
- string name = ReadOneDEVNAME(names, 1);
- Interop.Kernel32.GlobalUnlock(handle);
-
- // Windows allocates them, but we have to free them
- Interop.Kernel32.GlobalFree(data.hDevNames);
- Interop.Kernel32.GlobalFree(data.hDevMode);
-
- return name;
- }
- else
- {
- CreatePRINTDLGX86(out Interop.Comdlg32.PRINTDLGX86 data);
- data.Flags = SafeNativeMethods.PD_RETURNDEFAULT;
- bool status = Interop.Comdlg32.PrintDlg(ref data);
-
- if (!status)
- return SR.NoDefaultPrinter;
-
- IntPtr handle = data.hDevNames;
- IntPtr names = Interop.Kernel32.GlobalLock(handle);
- if (names == IntPtr.Zero)
- throw new Win32Exception();
-
- string name = ReadOneDEVNAME(names, 1);
- Interop.Kernel32.GlobalUnlock(handle);
-
- // Windows allocates them, but we have to free them
- Interop.Kernel32.GlobalFree(data.hDevNames);
- Interop.Kernel32.GlobalFree(data.hDevMode);
-
- return name;
- }
- }
-
-
- // Called by get_OutputPort
- private static string GetOutputPort()
- {
- if (IntPtr.Size == 8)
- {
- CreatePRINTDLG(out Interop.Comdlg32.PRINTDLG data);
- data.Flags = SafeNativeMethods.PD_RETURNDEFAULT;
- bool status = Interop.Comdlg32.PrintDlg(ref data);
- if (!status)
- return SR.NoDefaultPrinter;
-
- IntPtr handle = data.hDevNames;
- IntPtr names = Interop.Kernel32.GlobalLock(handle);
- if (names == IntPtr.Zero)
- throw new Win32Exception();
-
- string name = ReadOneDEVNAME(names, 2);
-
- Interop.Kernel32.GlobalUnlock(handle);
-
- // Windows allocates them, but we have to free them
- Interop.Kernel32.GlobalFree(data.hDevNames);
- Interop.Kernel32.GlobalFree(data.hDevMode);
-
- return name;
- }
- else
- {
- CreatePRINTDLGX86(out Interop.Comdlg32.PRINTDLGX86 data);
- data.Flags = SafeNativeMethods.PD_RETURNDEFAULT;
- bool status = Interop.Comdlg32.PrintDlg(ref data);
-
- if (!status)
- return SR.NoDefaultPrinter;
-
- IntPtr handle = data.hDevNames;
- IntPtr names = Interop.Kernel32.GlobalLock(handle);
- if (names == IntPtr.Zero)
- throw new Win32Exception();
-
- string name = ReadOneDEVNAME(names, 2);
-
- Interop.Kernel32.GlobalUnlock(handle);
-
- // Windows allocates them, but we have to free them
- Interop.Kernel32.GlobalFree(data.hDevNames);
- Interop.Kernel32.GlobalFree(data.hDevMode);
-
- return name;
- }
- }
-
- private int GetDeviceCaps(Interop.Gdi32.DeviceCapability capability)
- {
- using (DeviceContext dc = CreateInformationContext(DefaultPageSettings))
- {
- return Interop.Gdi32.GetDeviceCaps(new HandleRef(dc, dc.Hdc), capability);
- }
- }
-
- ///
- /// Creates a handle to a DEVMODE structure which correspond too the printer settings.When you are done with the
- /// handle, you must deallocate it yourself:
- /// Interop.Kernel32.GlobalFree(handle);
- /// Where "handle" is the return value from this method.
- ///
- public IntPtr GetHdevmode()
- {
- IntPtr modeHandle = GetHdevmodeInternal();
- _defaultPageSettings.CopyToHdevmode(modeHandle);
- return modeHandle;
- }
-
- internal IntPtr GetHdevmodeInternal()
- {
- // getting the printer name is quite expensive if PrinterName is left default,
- // because it needs to figure out what the default printer is
- return GetHdevmodeInternal(PrinterNameInternal);
- }
-
- private unsafe IntPtr GetHdevmodeInternal(string printer)
- {
- // Create DEVMODE
- int modeSize = Interop.Winspool.DocumentProperties(NativeMethods.NullHandleRef, NativeMethods.NullHandleRef, printer, IntPtr.Zero, NativeMethods.NullHandleRef, 0);
- if (modeSize < 1)
- {
- throw new InvalidPrinterException(this);
- }
- IntPtr handle = Interop.Kernel32.GlobalAlloc(SafeNativeMethods.GMEM_MOVEABLE, (uint)modeSize); // cannot be <0 anyway
- IntPtr pointer = Interop.Kernel32.GlobalLock(handle);
-
- //Get the DevMode only if its not cached....
- if (_cachedDevmode != null)
- {
- Marshal.Copy(_cachedDevmode, 0, pointer, _devmodebytes);
- }
- else
- {
- int returnCode = Interop.Winspool.DocumentProperties(NativeMethods.NullHandleRef, NativeMethods.NullHandleRef, printer, pointer, NativeMethods.NullHandleRef, SafeNativeMethods.DM_OUT_BUFFER);
- if (returnCode < 0)
- {
- throw new Win32Exception();
- }
- }
-
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(pointer)!;
-
- if (_extrainfo != null)
- {
- // guard against buffer overrun attacks (since design allows client to set a new printer name without updating the devmode)
- // by checking for a large enough buffer size before copying the extrainfo buffer
- if (_extrabytes <= mode.dmDriverExtra)
- {
- IntPtr pointeroffset = (IntPtr)((byte*)pointer + mode.dmSize);
- Marshal.Copy(_extrainfo, 0, pointeroffset, _extrabytes);
- }
- }
- if ((mode.dmFields & SafeNativeMethods.DM_COPIES) == SafeNativeMethods.DM_COPIES)
- {
- if (_copies != -1)
- mode.dmCopies = _copies;
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_DUPLEX) == SafeNativeMethods.DM_DUPLEX)
- {
- if (unchecked((int)_duplex) != -1)
- mode.dmDuplex = unchecked((short)_duplex);
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_COLLATE) == SafeNativeMethods.DM_COLLATE)
- {
- if (_collate.IsNotDefault)
- mode.dmCollate = (short)(((bool)_collate) ? SafeNativeMethods.DMCOLLATE_TRUE : SafeNativeMethods.DMCOLLATE_FALSE);
- }
-
- Marshal.StructureToPtr(mode, pointer, false);
-
- int retCode = Interop.Winspool.DocumentProperties(NativeMethods.NullHandleRef, NativeMethods.NullHandleRef, printer, pointer, pointer, SafeNativeMethods.DM_IN_BUFFER | SafeNativeMethods.DM_OUT_BUFFER);
- if (retCode < 0)
- {
- Interop.Kernel32.GlobalFree(handle);
- Interop.Kernel32.GlobalUnlock(handle);
- return IntPtr.Zero;
- }
-
-
- Interop.Kernel32.GlobalUnlock(handle);
- return handle;
- }
-
- ///
- /// Creates a handle to a DEVMODE structure which correspond to the printer and page settings.
- /// When you are done with the handle, you must deallocate it yourself:
- /// Interop.Kernel32.GlobalFree(handle);
- /// Where "handle" is the return value from this method.
- ///
- public IntPtr GetHdevmode(PageSettings pageSettings)
- {
- IntPtr modeHandle = GetHdevmodeInternal();
- pageSettings.CopyToHdevmode(modeHandle);
-
- return modeHandle;
- }
-
- ///
- /// Creates a handle to a DEVNAMES structure which correspond to the printer settings.
- /// When you are done with the handle, you must deallocate it yourself:
- /// Interop.Kernel32.GlobalFree(handle);
- /// Where "handle" is the return value from this method.
- ///
- public unsafe IntPtr GetHdevnames()
- {
- string printerName = PrinterName; // the PrinterName property is slow when using the default printer
- string driver = DriverName; // make sure we are writing out exactly the same string as we got the length of
- string outPort = OutputPort;
-
- // Create DEVNAMES structure
- // +4 for null terminator
- int namesCharacters = checked(4 + printerName.Length + driver.Length + outPort.Length);
-
- // 8 = size of fixed portion of DEVNAMES
- short offset = (short)(8 / Marshal.SystemDefaultCharSize); // Offsets are in characters, not bytes
- uint namesSize = (uint)checked(Marshal.SystemDefaultCharSize * (offset + namesCharacters)); // always >0
- IntPtr handle = Interop.Kernel32.GlobalAlloc(SafeNativeMethods.GMEM_MOVEABLE | SafeNativeMethods.GMEM_ZEROINIT, namesSize);
- IntPtr namesPointer = Interop.Kernel32.GlobalLock(handle);
- byte* pNamesPointer = (byte*)namesPointer;
-
- *(short*)(pNamesPointer) = offset; // wDriverOffset
- offset += WriteOneDEVNAME(driver, namesPointer, offset);
- *(short*)(pNamesPointer + 2) = offset; // wDeviceOffset
- offset += WriteOneDEVNAME(printerName, namesPointer, offset);
- *(short*)(pNamesPointer + 4) = offset; // wOutputOffset
- offset += WriteOneDEVNAME(outPort, namesPointer, offset);
- *(short*)(pNamesPointer + 6) = offset; // wDefault
-
- Interop.Kernel32.GlobalUnlock(handle);
- return handle;
- }
-
- // Handles creating then disposing a default DEVMODE
- internal short GetModeField(ModeField field, short defaultValue)
- {
- return GetModeField(field, defaultValue, IntPtr.Zero);
- }
-
- internal short GetModeField(ModeField field, short defaultValue, IntPtr modeHandle)
- {
- bool ownHandle = false;
- short result;
- try
- {
- if (modeHandle == IntPtr.Zero)
- {
- try
- {
- modeHandle = GetHdevmodeInternal();
- ownHandle = true;
- }
- catch (InvalidPrinterException)
- {
- return defaultValue;
- }
- }
-
- IntPtr modePointer = Interop.Kernel32.GlobalLock(new HandleRef(this, modeHandle));
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(modePointer)!;
- switch (field)
- {
- case ModeField.Orientation:
- result = mode.dmOrientation;
- break;
- case ModeField.PaperSize:
- result = mode.dmPaperSize;
- break;
- case ModeField.PaperLength:
- result = mode.dmPaperLength;
- break;
- case ModeField.PaperWidth:
- result = mode.dmPaperWidth;
- break;
- case ModeField.Copies:
- result = mode.dmCopies;
- break;
- case ModeField.DefaultSource:
- result = mode.dmDefaultSource;
- break;
- case ModeField.PrintQuality:
- result = mode.dmPrintQuality;
- break;
- case ModeField.Color:
- result = mode.dmColor;
- break;
- case ModeField.Duplex:
- result = mode.dmDuplex;
- break;
- case ModeField.YResolution:
- result = mode.dmYResolution;
- break;
- case ModeField.TTOption:
- result = mode.dmTTOption;
- break;
- case ModeField.Collate:
- result = mode.dmCollate;
- break;
- default:
- Debug.Fail("Invalid field in GetModeField");
- result = defaultValue;
- break;
- }
- Interop.Kernel32.GlobalUnlock(new HandleRef(this, modeHandle));
- }
- finally
- {
- if (ownHandle)
- {
- Interop.Kernel32.GlobalFree(new HandleRef(this, modeHandle));
- }
- }
- return result;
- }
-
- internal unsafe PaperSize[] Get_PaperSizes()
- {
- string printerName = PrinterName; // this is quite expensive if PrinterName is left default
-
- int count = FastDeviceCapabilities(SafeNativeMethods.DC_PAPERNAMES, IntPtr.Zero, -1, printerName);
- if (count == -1)
- return Array.Empty();
- int stringSize = Marshal.SystemDefaultCharSize * 64;
- IntPtr namesBuffer = Marshal.AllocCoTaskMem(checked(stringSize * count));
- FastDeviceCapabilities(SafeNativeMethods.DC_PAPERNAMES, namesBuffer, -1, printerName);
-
- Debug.Assert(FastDeviceCapabilities(SafeNativeMethods.DC_PAPERS, IntPtr.Zero, -1, printerName) == count,
- "Not the same number of paper kinds as paper names?");
- IntPtr kindsBuffer = Marshal.AllocCoTaskMem(2 * count);
- FastDeviceCapabilities(SafeNativeMethods.DC_PAPERS, kindsBuffer, -1, printerName);
-
- Debug.Assert(FastDeviceCapabilities(SafeNativeMethods.DC_PAPERSIZE, IntPtr.Zero, -1, printerName) == count,
- "Not the same number of paper kinds as paper names?");
- IntPtr dimensionsBuffer = Marshal.AllocCoTaskMem(8 * count);
- FastDeviceCapabilities(SafeNativeMethods.DC_PAPERSIZE, dimensionsBuffer, -1, printerName);
-
- PaperSize[] result = new PaperSize[count];
- byte* pNamesBuffer = (byte*)namesBuffer;
- short* pKindsBuffer = (short*)kindsBuffer;
- int* pDimensionsBuffer = (int*)dimensionsBuffer;
- for (int i = 0; i < count; i++)
- {
- string name = Marshal.PtrToStringAuto((nint)(pNamesBuffer + stringSize * (nint)i), 64)!;
- int index = name.IndexOf('\0');
- if (index > -1)
- {
- name = name.Substring(0, index);
- }
- short kind = pKindsBuffer[i];
- int width = pDimensionsBuffer[i * 2];
- int height = pDimensionsBuffer[i * 2 + 1];
- result[i] = new PaperSize((PaperKind)kind, name,
- PrinterUnitConvert.Convert(width, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display),
- PrinterUnitConvert.Convert(height, PrinterUnit.TenthsOfAMillimeter, PrinterUnit.Display));
- }
-
- Marshal.FreeCoTaskMem(namesBuffer);
- Marshal.FreeCoTaskMem(kindsBuffer);
- Marshal.FreeCoTaskMem(dimensionsBuffer);
- return result;
- }
-
- internal unsafe PaperSource[] Get_PaperSources()
- {
- string printerName = PrinterName; // this is quite expensive if PrinterName is left default
-
- int count = FastDeviceCapabilities(SafeNativeMethods.DC_BINNAMES, IntPtr.Zero, -1, printerName);
- if (count == -1)
- return Array.Empty();
-
- // Contrary to documentation, DeviceCapabilities returns char[count, 24],
- // not char[count][24]
- int stringSize = Marshal.SystemDefaultCharSize * 24;
- IntPtr namesBuffer = Marshal.AllocCoTaskMem(checked(stringSize * count));
- FastDeviceCapabilities(SafeNativeMethods.DC_BINNAMES, namesBuffer, -1, printerName);
-
- Debug.Assert(FastDeviceCapabilities(SafeNativeMethods.DC_BINS, IntPtr.Zero, -1, printerName) == count,
- "Not the same number of bin kinds as bin names?");
- IntPtr kindsBuffer = Marshal.AllocCoTaskMem(2 * count);
- FastDeviceCapabilities(SafeNativeMethods.DC_BINS, kindsBuffer, -1, printerName);
-
- byte* pNamesBuffer = (byte*)namesBuffer;
- short* pKindsBuffer = (short*)kindsBuffer;
- PaperSource[] result = new PaperSource[count];
- for (int i = 0; i < count; i++)
- {
- string name = Marshal.PtrToStringAuto((nint)(pNamesBuffer + stringSize * (nint)i), 24)!;
- int index = name.IndexOf('\0');
- if (index > -1)
- {
- name = name.Substring(0, index);
- }
-
- short kind = pKindsBuffer[i];
- result[i] = new PaperSource((PaperSourceKind)kind, name);
- }
-
- Marshal.FreeCoTaskMem(namesBuffer);
- Marshal.FreeCoTaskMem(kindsBuffer);
- return result;
- }
-
- internal unsafe PrinterResolution[] Get_PrinterResolutions()
- {
- string printerName = PrinterName; // this is quite expensive if PrinterName is left default
- PrinterResolution[] result;
-
- int count = FastDeviceCapabilities(SafeNativeMethods.DC_ENUMRESOLUTIONS, IntPtr.Zero, -1, printerName);
- if (count == -1)
- {
- //Just return the standard values if custom resolutions are absent ....
- result = new PrinterResolution[4];
- result[0] = new PrinterResolution(PrinterResolutionKind.High, -4, -1);
- result[1] = new PrinterResolution(PrinterResolutionKind.Medium, -3, -1);
- result[2] = new PrinterResolution(PrinterResolutionKind.Low, -2, -1);
- result[3] = new PrinterResolution(PrinterResolutionKind.Draft, -1, -1);
-
- return result;
- }
-
- result = new PrinterResolution[count + 4];
- result[0] = new PrinterResolution(PrinterResolutionKind.High, -4, -1);
- result[1] = new PrinterResolution(PrinterResolutionKind.Medium, -3, -1);
- result[2] = new PrinterResolution(PrinterResolutionKind.Low, -2, -1);
- result[3] = new PrinterResolution(PrinterResolutionKind.Draft, -1, -1);
-
- IntPtr buffer = Marshal.AllocCoTaskMem(checked(8 * count));
- FastDeviceCapabilities(SafeNativeMethods.DC_ENUMRESOLUTIONS, buffer, -1, printerName);
-
- byte* pBuffer = (byte*)buffer;
- for (int i = 0; i < count; i++)
- {
- int x = *(int*)(pBuffer + i * 8);
- int y = *(int*)(pBuffer + i * 8 + 4);
- result[i + 4] = new PrinterResolution(PrinterResolutionKind.Custom, x, y);
- }
-
- Marshal.FreeCoTaskMem(buffer);
- return result;
- }
-
- // names is pointer to DEVNAMES
- private static unsafe string ReadOneDEVNAME(IntPtr pDevnames, int slot)
- {
- byte* bDevNames = (byte*)pDevnames;
- int offset = Marshal.SystemDefaultCharSize * ((ushort*)bDevNames)[slot];
- string result = Marshal.PtrToStringAuto((nint)(bDevNames + offset))!;
- return result;
- }
-
- ///
- /// Copies the relevant information out of the handle and into the PrinterSettings.
- ///
- public unsafe void SetHdevmode(IntPtr hdevmode)
- {
- if (hdevmode == IntPtr.Zero)
- throw new ArgumentException(SR.Format(SR.InvalidPrinterHandle, hdevmode));
-
- IntPtr pointer = Interop.Kernel32.GlobalLock(hdevmode);
- Interop.Gdi32.DEVMODE mode = Marshal.PtrToStructure(pointer)!;
-
- //Copy entire public devmode as a byte array...
- _devmodebytes = mode.dmSize;
- if (_devmodebytes > 0)
- {
- _cachedDevmode = new byte[_devmodebytes];
- Marshal.Copy(pointer, _cachedDevmode, 0, _devmodebytes);
- }
-
- //Copy private devmode as a byte array..
- _extrabytes = mode.dmDriverExtra;
- if (_extrabytes > 0)
- {
- _extrainfo = new byte[_extrabytes];
- Marshal.Copy((nint)((byte*)pointer + mode.dmSize), _extrainfo, 0, _extrabytes);
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_COPIES) == SafeNativeMethods.DM_COPIES)
- {
- _copies = mode.dmCopies;
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_DUPLEX) == SafeNativeMethods.DM_DUPLEX)
- {
- _duplex = (Duplex)mode.dmDuplex;
- }
-
- if ((mode.dmFields & SafeNativeMethods.DM_COLLATE) == SafeNativeMethods.DM_COLLATE)
- {
- _collate = (mode.dmCollate == SafeNativeMethods.DMCOLLATE_TRUE);
- }
-
- Interop.Kernel32.GlobalUnlock(hdevmode);
- }
-
- ///
- /// Copies the relevant information out of the handle and into the PrinterSettings.
- ///
- public void SetHdevnames(IntPtr hdevnames)
- {
- if (hdevnames == IntPtr.Zero)
- {
- throw new ArgumentException(SR.Format(SR.InvalidPrinterHandle, hdevnames));
- }
-
- IntPtr namesPointer = Interop.Kernel32.GlobalLock(hdevnames);
-
- _driverName = ReadOneDEVNAME(namesPointer, 0);
- _printerName = ReadOneDEVNAME(namesPointer, 1);
- _outputPort = ReadOneDEVNAME(namesPointer, 2);
-
- PrintDialogDisplayed = true;
-
- Interop.Kernel32.GlobalUnlock(hdevnames);
- }
-
- ///
- /// Provides some interesting information about the PrinterSettings in String form.
- ///
- public override string ToString()
- {
- string printerName = PrinterName;
- return "[PrinterSettings "
- + printerName
- + " Copies=" + Copies.ToString(CultureInfo.InvariantCulture)
- + " Collate=" + Collate.ToString(CultureInfo.InvariantCulture)
- + " Duplex=" + Duplex.ToString()
- + " FromPage=" + FromPage.ToString(CultureInfo.InvariantCulture)
- + " LandscapeAngle=" + LandscapeAngle.ToString(CultureInfo.InvariantCulture)
- + " MaximumCopies=" + MaximumCopies.ToString(CultureInfo.InvariantCulture)
- + " OutputPort=" + OutputPort.ToString(CultureInfo.InvariantCulture)
- + " ToPage=" + ToPage.ToString(CultureInfo.InvariantCulture)
- + "]";
- }
-
- // Write null terminated string, return length of string in characters (including null)
- private static unsafe short WriteOneDEVNAME(string str, IntPtr bufferStart, int index)
- {
- str ??= "";
- byte* address = (byte*)bufferStart + (nint)index * Marshal.SystemDefaultCharSize;
-
- char[] data = str.ToCharArray();
- Marshal.Copy(data, 0, (nint)address, data.Length);
- *(short*)(address + data.Length * 2) = 0;
-
- return checked((short)(str.Length + 1));
- }
-
- ///
- /// Collection of PaperSize's...
- ///
- public class PaperSizeCollection : ICollection
- {
- private PaperSize[] _array;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PaperSizeCollection(PaperSize[] array)
- {
- _array = array;
- }
-
- ///
- /// Gets a value indicating the number of paper sizes.
- ///
- public int Count
- {
- get
- {
- return _array.Length;
- }
- }
-
- ///
- /// Retrieves the PaperSize with the specified index.
- ///
- public virtual PaperSize this[int index]
- {
- get
- {
- return _array[index];
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new ArrayEnumerator(_array, Count);
- }
-
- int ICollection.Count
- {
- get
- {
- return Count;
- }
- }
-
-
- bool ICollection.IsSynchronized
- {
- get
- {
- return false;
- }
- }
-
- object ICollection.SyncRoot
- {
- get
- {
- return this;
- }
- }
-
- void ICollection.CopyTo(Array array, int index)
- {
- Array.Copy(_array, index, array, 0, _array.Length);
- }
-
- public void CopyTo(PaperSize[] paperSizes, int index)
- {
- Array.Copy(_array, index, paperSizes, 0, _array.Length);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- [
- EditorBrowsable(EditorBrowsableState.Never)
- ]
- public int Add(PaperSize paperSize)
- {
- PaperSize[] newArray = new PaperSize[Count + 1];
- ((ICollection)this).CopyTo(newArray, 0);
- newArray[Count] = paperSize;
- _array = newArray;
- return Count;
- }
- }
-
- public class PaperSourceCollection : ICollection
- {
- private PaperSource[] _array;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PaperSourceCollection(PaperSource[] array)
- {
- _array = array;
- }
-
- ///
- /// Gets a value indicating the number of paper sources.
- ///
- public int Count
- {
- get
- {
- return _array.Length;
- }
- }
-
- ///
- /// Gets the PaperSource with the specified index.
- ///
- public virtual PaperSource this[int index]
- {
- get
- {
- return _array[index];
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new ArrayEnumerator(_array, Count);
- }
-
- int ICollection.Count
- {
- get
- {
- return Count;
- }
- }
-
-
- bool ICollection.IsSynchronized
- {
- get
- {
- return false;
- }
- }
-
- object ICollection.SyncRoot
- {
- get
- {
- return this;
- }
- }
-
- void ICollection.CopyTo(Array array, int index)
- {
- Array.Copy(_array, index, array, 0, _array.Length);
- }
-
- public void CopyTo(PaperSource[] paperSources, int index)
- {
- Array.Copy(_array, index, paperSources, 0, _array.Length);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int Add(PaperSource paperSource)
- {
- PaperSource[] newArray = new PaperSource[Count + 1];
- ((ICollection)this).CopyTo(newArray, 0);
- newArray[Count] = paperSource;
- _array = newArray;
- return Count;
- }
- }
-
- public class PrinterResolutionCollection : ICollection
- {
- private PrinterResolution[] _array;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public PrinterResolutionCollection(PrinterResolution[] array)
- {
- _array = array;
- }
-
- ///
- /// Gets a value indicating the number of available printer resolutions.
- ///
- public int Count
- {
- get
- {
- return _array.Length;
- }
- }
-
- ///
- /// Retrieves the PrinterResolution with the specified index.
- ///
- public virtual PrinterResolution this[int index]
- {
- get
- {
- return _array[index];
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new ArrayEnumerator(_array, Count);
- }
-
- int ICollection.Count
- {
- get
- {
- return Count;
- }
- }
-
- bool ICollection.IsSynchronized
- {
- get
- {
- return false;
- }
- }
-
- object ICollection.SyncRoot
- {
- get
- {
- return this;
- }
- }
-
- void ICollection.CopyTo(Array array, int index)
- {
- Array.Copy(_array, index, array, 0, _array.Length);
- }
-
- public void CopyTo(PrinterResolution[] printerResolutions, int index)
- {
- Array.Copy(_array, index, printerResolutions, 0, _array.Length);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int Add(PrinterResolution printerResolution)
- {
- PrinterResolution[] newArray = new PrinterResolution[Count + 1];
- ((ICollection)this).CopyTo(newArray, 0);
- newArray[Count] = printerResolution;
- _array = newArray;
- return Count;
- }
- }
-
- public class StringCollection : ICollection
- {
- private string[] _array;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StringCollection(string[] array)
- {
- _array = array;
- }
-
- ///
- /// Gets a value indicating the number of strings.
- ///
- public int Count
- {
- get
- {
- return _array.Length;
- }
- }
-
- ///
- /// Gets the string with the specified index.
- ///
- public virtual string this[int index]
- {
- get
- {
- return _array[index];
- }
- }
-
- public IEnumerator GetEnumerator()
- {
- return new ArrayEnumerator(_array, Count);
- }
-
- int ICollection.Count
- {
- get
- {
- return Count;
- }
- }
-
- bool ICollection.IsSynchronized
- {
- get
- {
- return false;
- }
- }
-
- object ICollection.SyncRoot
- {
- get
- {
- return this;
- }
- }
-
- void ICollection.CopyTo(Array array, int index)
- {
- Array.Copy(_array, index, array, 0, _array.Length);
- }
-
-
- public void CopyTo(string[] strings, int index)
- {
- Array.Copy(_array, index, strings, 0, _array.Length);
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- [
- EditorBrowsable(EditorBrowsableState.Never)
- ]
- public int Add(string value)
- {
- string[] newArray = new string[Count + 1];
- ((ICollection)this).CopyTo(newArray, 0);
- newArray[Count] = value;
- _array = newArray;
- return Count;
- }
- }
-
- private sealed class ArrayEnumerator : IEnumerator
- {
- private readonly object[] _array;
- private readonly int _endIndex;
- private int _index;
- private object? _item;
-
- public ArrayEnumerator(object[] array, int count)
- {
- _array = array;
- _endIndex = count;
- }
-
- public object? Current => _item;
-
- public bool MoveNext()
- {
- if (_index >= _endIndex)
- return false;
- _item = _array[_index++];
- return true;
- }
-
- public void Reset()
- {
- // Position enumerator before first item
- _index = 0;
- _item = null;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnit.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnit.cs
deleted file mode 100644
index e0e80c46cfcfd..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnit.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies several of the units of measure Microsoft Win32 uses for printing.
- ///
- public enum PrinterUnit
- {
- ///
- /// The default unit (0.01 in.).
- ///
- Display = 0,
-
- ///
- /// One thousandth of an inch (0.001 in.).
- ///
- // Used by PAGESETUPDLG.rtMargin and rtMinMargin
- ThousandthsOfAnInch = 1,
-
- ///
- /// One hundredth of a millimeter (0.01 mm).
- ///
- // Used by PAGESETUPDLG.rtMargin and rtMinMargin
- HundredthsOfAMillimeter = 2,
-
- ///
- /// One tenth of a millimeter (0.1 mm).
- ///
- // DeviceCapabilities(DC_PAPERSIZE)
- TenthsOfAMillimeter = 3,
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnitConvert.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnitConvert.cs
deleted file mode 100644
index c943ec3c9698b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/PrinterUnitConvert.cs
+++ /dev/null
@@ -1,112 +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.Diagnostics;
-
-namespace System.Drawing.Printing
-{
- ///
- /// Specifies a series of conversion methods that are useful when interoperating with the raw Win32 printing API.
- /// This class cannot be inherited.
- ///
- public sealed class PrinterUnitConvert
- {
- private PrinterUnitConvert()
- {
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static double Convert(double value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- double fromUnitsPerDisplay = UnitsPerDisplay(fromUnit);
- double toUnitsPerDisplay = UnitsPerDisplay(toUnit);
- return value * toUnitsPerDisplay / fromUnitsPerDisplay;
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static int Convert(int value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- return (int)Math.Round(Convert((double)value, fromUnit, toUnit));
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static Point Convert(Point value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- return new Point(
- Convert(value.X, fromUnit, toUnit),
- Convert(value.Y, fromUnit, toUnit)
- );
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static Size Convert(Size value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- return new Size(
- Convert(value.Width, fromUnit, toUnit),
- Convert(value.Height, fromUnit, toUnit)
- );
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static Rectangle Convert(Rectangle value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- return new Rectangle(
- Convert(value.X, fromUnit, toUnit),
- Convert(value.Y, fromUnit, toUnit),
- Convert(value.Width, fromUnit, toUnit),
- Convert(value.Height, fromUnit, toUnit)
- );
- }
-
- ///
- /// Converts the value, in fromUnit units, to toUnit units.
- ///
- public static Margins Convert(Margins value, PrinterUnit fromUnit, PrinterUnit toUnit)
- {
- Margins result = new Margins();
-
- result.DoubleLeft = Convert(value.DoubleLeft, fromUnit, toUnit);
- result.DoubleRight = Convert(value.DoubleRight, fromUnit, toUnit);
- result.DoubleTop = Convert(value.DoubleTop, fromUnit, toUnit);
- result.DoubleBottom = Convert(value.DoubleBottom, fromUnit, toUnit);
-
- return result;
- }
-
- private static double UnitsPerDisplay(PrinterUnit unit)
- {
- double result;
- switch (unit)
- {
- case PrinterUnit.Display:
- result = 1.0;
- break;
- case PrinterUnit.ThousandthsOfAnInch:
- result = 10.0;
- break;
- case PrinterUnit.HundredthsOfAMillimeter:
- result = 25.4;
- break;
- case PrinterUnit.TenthsOfAMillimeter:
- result = 2.54;
- break;
- default:
- Debug.Fail("Unknown PrinterUnit " + unit);
- result = 1.0;
- break;
- }
-
- return result;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventArgs.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventArgs.cs
deleted file mode 100644
index ea8f3e5dfc21c..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventArgs.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Provides data for the event.
- ///
- public class QueryPageSettingsEventArgs : PrintEventArgs
- {
- private PageSettings _pageSettings;
-
- ///
- /// It's too expensive to compare 2 instances of PageSettings class, as the getters
- /// are accessing the printer spooler, thus we track any explicit invocations of the setters or getters on this class,
- /// and this field tracks if PageSettings property was accessed. It will return a false
- /// positive when the user is reading property values, but we'll take a perf hit in this case assuming this event is not
- /// used often.
- ///
- internal bool PageSettingsChanged;
-
- ///
- /// Initializes a new instance of the class.
- ///
- public QueryPageSettingsEventArgs(PageSettings pageSettings) : base()
- {
- _pageSettings = pageSettings;
- }
-
- ///
- /// Gets or sets the page settings for the page to be printed.
- ///
- public PageSettings PageSettings
- {
- get
- {
- PageSettingsChanged = true;
- return _pageSettings;
- }
- set
- {
- value ??= new PageSettings();
- _pageSettings = value;
- PageSettingsChanged = true;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventHandler.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventHandler.cs
deleted file mode 100644
index cb9d6f06226cc..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/QueryPageSettingsEventHandler.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Printing
-{
- ///
- /// Represents the method that will handle the event of a
- /// .
- ///
- public delegate void QueryPageSettingsEventHandler(object sender, QueryPageSettingsEventArgs e);
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs
deleted file mode 100644
index bb7b163d1ce95..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Printing/TriState.cs
+++ /dev/null
@@ -1,59 +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.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-
-namespace System.Drawing.Printing
-{
- internal readonly partial struct TriState : IEquatable
- {
- private readonly byte _value; // 0 is "default", not false
-
- public static readonly TriState Default = new TriState(0);
- public static readonly TriState False = new TriState(1);
- public static readonly TriState True = new TriState(2);
-
- private TriState(byte value) => _value = value;
-
- public bool IsDefault => this == Default;
-
- public bool IsFalse => this == False;
-
- public bool IsNotDefault => this != Default;
-
- public bool IsTrue => this == True;
-
- public static bool operator ==(TriState left, TriState right) => left.Equals(right);
-
- public static bool operator !=(TriState left, TriState right) => !left.Equals(right);
-
- public override bool Equals([NotNullWhen(true)] object? o)
- {
- Debug.Assert(o is TriState);
- return Equals((TriState)o);
- }
-
- public bool Equals(TriState other) => _value == other._value;
-
- public override int GetHashCode() => _value;
-
- public static implicit operator TriState(bool value) => value ? True : False;
-
- public static explicit operator bool(TriState value)
- {
- if (value.IsDefault)
- {
- throw new InvalidCastException(SR.TriStateCompareError);
- }
-
- return (value == TriState.True);
- }
-
- /// Provides some interesting information about the TriState in String form.
- public override string ToString() =>
- this == Default ? "Default" :
- this == False ? "False" :
- "True";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs
deleted file mode 100644
index e64c042c6d90e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/PropertyItemInternal.cs
+++ /dev/null
@@ -1,17 +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.Runtime.InteropServices;
-
-namespace System.Drawing.Imaging
-{
- internal unsafe struct PropertyItemInternal
- {
- public int id;
- public int len;
- public short type;
- public byte* value;
-
- public Span Value => new Span(value, len);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
deleted file mode 100644
index b589d5fc15b4e..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/RectangleConverter.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing {
- using System.Runtime.Serialization.Formatters;
- using System.Runtime.InteropServices;
-
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
-
- using Microsoft.Win32;
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design.Serialization;
- using System.Globalization;
- using System.Reflection;
-
- ///
- ///
- /// RectangleConverter is a class that can be used to convert
- /// rectangles from one data type to another. Access this
- /// class through the TypeDescriptor.
- ///
- public class RectangleConverter : TypeConverter {
-
- ///
- ///
- /// Determines if this converter can convert an object in the given source
- /// type to the native type of the converter.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
- if (sourceType == typeof(string)) {
- return true;
- }
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- ///
- /// Gets a value indicating whether this converter can
- /// convert an object to the given destination type using the context.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type? destinationType) {
- if (destinationType == typeof(InstanceDescriptor)) {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- ///
- ///
- /// Converts the given object to the converter's native type.
- ///
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
-
- string strValue = value as string;
-
- if (strValue != null) {
-
- string text = strValue.Trim();
-
- if (text.Length == 0) {
- return null;
- }
- else {
-
- // Parse 4 integer values.
- //
- culture ??= CultureInfo.CurrentCulture;
- char sep = culture.TextInfo.ListSeparator[0];
- string[] tokens = text.Split(sep);
- int[] values = new int[tokens.Length];
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- for (int i = 0; i < values.Length; i++) {
- // Note: ConvertFromString will raise exception if value cannot be converted.
- values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]);
- }
-
- if (values.Length == 4) {
- return new Rectangle(values[0], values[1], values[2], values[3]);
- }
- else {
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat,
- text,
- "x, y, width, height"));
- }
- }
- }
-
- return base.ConvertFrom(context, culture, value);
- }
-
- ///
- ///
- /// Converts the given object to another type. The most common types to convert
- /// are to and from a string object. The default implementation will make a call
- /// to ToString on the object if the object is valid and if the destination
- /// type is string. If this cannot convert to the destination type, this will
- /// throw a NotSupportedException.
- ///
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
- if (destinationType == null) {
- throw new ArgumentNullException(nameof(destinationType));
- }
-
- if ( value is Rectangle ){
- if (destinationType == typeof(string)) {
- Rectangle rect = (Rectangle)value;
-
- culture ??= CultureInfo.CurrentCulture;
- string sep = culture.TextInfo.ListSeparator + " ";
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- string[] args = new string[4];
- int nArg = 0;
-
- // Note: ConvertToString will raise exception if value cannot be converted.
- args[nArg++] = intConverter.ConvertToString(context, culture, rect.X);
- args[nArg++] = intConverter.ConvertToString(context, culture, rect.Y);
- args[nArg++] = intConverter.ConvertToString(context, culture, rect.Width);
- args[nArg++] = intConverter.ConvertToString(context, culture, rect.Height);
-
- return string.Join(sep, args);
- }
- if (destinationType == typeof(InstanceDescriptor)) {
- Rectangle rect = (Rectangle)value;
- ConstructorInfo ctor = typeof(Rectangle).GetConstructor(new Type[] {
- typeof(int), typeof(int), typeof(int), typeof(int)});
-
- if (ctor != null) {
- return new InstanceDescriptor(ctor, new object[] {
- rect.X, rect.Y, rect.Width, rect.Height});
- }
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- ///
- ///
- /// Creates an instance of this type given a set of property values
- /// for the object. This is useful for objects that are immutable, but still
- /// want to provide changable properties.
- ///
- public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) {
- if ( propertyValues == null ){
- throw new ArgumentNullException( nameof(propertyValues) );
- }
-
- object x = propertyValues["X"];
- object y = propertyValues["Y"];
- object width = propertyValues["Width"];
- object height = propertyValues["Height"];
-
- if (x == null || y == null || width == null || height == null ||
- !(x is int) || !(y is int) || !(width is int) || !(height is int) ) {
- throw new ArgumentException(SR.PropertyValueInvalidEntry);
- }
- return new Rectangle((int)x,
- (int)y,
- (int)width,
- (int)height);
- }
-
- ///
- ///
- /// Determines if changing a value on this object should require a call to
- /// CreateInstance to create a new value.
- ///
- public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- ///
- ///
- /// Retrieves the set of properties for this type. By default, a type has
- /// does not return any properties. An easy implementation of this method
- /// can just call TypeDescriptor.GetProperties for the correct data type.
- ///
- public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
- PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Rectangle), attributes);
- return props.Sort(new string[] {"X", "Y", "Width", "Height"});
- }
-
- ///
- ///
- /// Determines if this object supports properties. By default, this
- /// is false.
- ///
- public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs
deleted file mode 100644
index f7ff48efb3dd1..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Region.cs
+++ /dev/null
@@ -1,428 +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.Diagnostics;
-using System.Drawing.Drawing2D;
-using System.Drawing.Internal;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public sealed class Region : MarshalByRefObject, IDisposable
- {
-#if FINALIZATION_WATCH
- private string allocationSite = Graphics.GetAllocationStack();
-#endif
-
- internal IntPtr NativeRegion { get; private set; }
-
- public Region()
- {
- Gdip.CheckStatus(Gdip.GdipCreateRegion(out IntPtr region));
- SetNativeRegion(region);
- }
-
- public Region(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCreateRegionRect(ref rect, out IntPtr region));
- SetNativeRegion(region);
- }
-
- public Region(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCreateRegionRectI(ref rect, out IntPtr region));
- SetNativeRegion(region);
- }
-
- public Region(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCreateRegionPath(new HandleRef(path, path._nativePath), out IntPtr region));
- SetNativeRegion(region);
- }
-
- public Region(RegionData rgnData)
- {
- ArgumentNullException.ThrowIfNull(rgnData);
-
- Gdip.CheckStatus(Gdip.GdipCreateRegionRgnData(
- rgnData.Data,
- rgnData.Data.Length,
- out IntPtr region));
-
- SetNativeRegion(region);
- }
-
- internal Region(IntPtr nativeRegion) => SetNativeRegion(nativeRegion);
-
- public static Region FromHrgn(IntPtr hrgn)
- {
- Gdip.CheckStatus(Gdip.GdipCreateRegionHrgn(hrgn, out IntPtr region));
- return new Region(region);
- }
-
- private void SetNativeRegion(IntPtr nativeRegion)
- {
- if (nativeRegion == IntPtr.Zero)
- throw new ArgumentNullException(nameof(nativeRegion));
-
- NativeRegion = nativeRegion;
- }
-
- public Region Clone()
- {
- Gdip.CheckStatus(Gdip.GdipCloneRegion(new HandleRef(this, NativeRegion), out IntPtr region));
- return new Region(region);
- }
- public void ReleaseHrgn(IntPtr regionHandle)
- {
- if (regionHandle == IntPtr.Zero)
- {
- throw new ArgumentNullException(nameof(regionHandle));
- }
-
- Interop.Gdi32.DeleteObject(new HandleRef(this, regionHandle));
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
-#if FINALIZATION_WATCH
- if (!disposing && nativeRegion != IntPtr.Zero)
- Debug.WriteLine("**********************\nDisposed through finalization:\n" + allocationSite);
-#endif
- if (NativeRegion != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteRegion(new HandleRef(this, NativeRegion));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- }
- finally
- {
- NativeRegion = IntPtr.Zero;
- }
- }
- }
-
- ~Region() => Dispose(false);
-
- public void MakeInfinite()
- {
- Gdip.CheckStatus(Gdip.GdipSetInfinite(new HandleRef(this, NativeRegion)));
- }
-
- public void MakeEmpty()
- {
- Gdip.CheckStatus(Gdip.GdipSetEmpty(new HandleRef(this, NativeRegion)));
- }
-
- public void Intersect(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRect(new HandleRef(this, NativeRegion), ref rect, CombineMode.Intersect));
- }
-
- public void Intersect(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRectI(new HandleRef(this, NativeRegion), ref rect, CombineMode.Intersect));
- }
-
- public void Intersect(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionPath(new HandleRef(this, NativeRegion), new HandleRef(path, path._nativePath), CombineMode.Intersect));
- }
-
- public void Intersect(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionRegion(new HandleRef(this, NativeRegion), new HandleRef(region, region.NativeRegion), CombineMode.Intersect));
- }
-
- public void Union(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRect(new HandleRef(this, NativeRegion), ref rect, CombineMode.Union));
- }
-
- public void Union(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRectI(new HandleRef(this, NativeRegion), ref rect, CombineMode.Union));
- }
-
- public void Union(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionPath(new HandleRef(this, NativeRegion), new HandleRef(path, path._nativePath), CombineMode.Union));
- }
-
- public void Union(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionRegion(new HandleRef(this, NativeRegion), new HandleRef(region, region.NativeRegion), CombineMode.Union));
- }
-
- public void Xor(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRect(new HandleRef(this, NativeRegion), ref rect, CombineMode.Xor));
- }
-
- public void Xor(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRectI(new HandleRef(this, NativeRegion), ref rect, CombineMode.Xor));
- }
-
- public void Xor(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionPath(new HandleRef(this, NativeRegion), new HandleRef(path, path._nativePath), CombineMode.Xor));
- }
-
- public void Xor(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionRegion(new HandleRef(this, NativeRegion), new HandleRef(region, region.NativeRegion), CombineMode.Xor));
- }
-
- public void Exclude(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRect(new HandleRef(this, NativeRegion), ref rect, CombineMode.Exclude));
- }
-
- public void Exclude(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRectI(new HandleRef(this, NativeRegion), ref rect, CombineMode.Exclude));
- }
-
- public void Exclude(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionPath(
- new HandleRef(this, NativeRegion),
- new HandleRef(path, path._nativePath),
- CombineMode.Exclude));
- }
-
- public void Exclude(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionRegion(
- new HandleRef(this, NativeRegion),
- new HandleRef(region, region.NativeRegion),
- CombineMode.Exclude));
- }
-
- public void Complement(RectangleF rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRect(new HandleRef(this, NativeRegion), ref rect, CombineMode.Complement));
- }
-
- public void Complement(Rectangle rect)
- {
- Gdip.CheckStatus(Gdip.GdipCombineRegionRectI(new HandleRef(this, NativeRegion), ref rect, CombineMode.Complement));
- }
-
- public void Complement(GraphicsPath path)
- {
- ArgumentNullException.ThrowIfNull(path);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionPath(new HandleRef(this, NativeRegion), new HandleRef(path, path._nativePath), CombineMode.Complement));
- }
-
- public void Complement(Region region)
- {
- ArgumentNullException.ThrowIfNull(region);
-
- Gdip.CheckStatus(Gdip.GdipCombineRegionRegion(new HandleRef(this, NativeRegion), new HandleRef(region, region.NativeRegion), CombineMode.Complement));
- }
-
- public void Translate(float dx, float dy)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateRegion(new HandleRef(this, NativeRegion), dx, dy));
- }
-
- public void Translate(int dx, int dy)
- {
- Gdip.CheckStatus(Gdip.GdipTranslateRegionI(new HandleRef(this, NativeRegion), dx, dy));
- }
-
- public void Transform(Matrix matrix)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- Gdip.CheckStatus(Gdip.GdipTransformRegion(
- new HandleRef(this, NativeRegion),
- new HandleRef(matrix, matrix.NativeMatrix)));
- }
-
- public RectangleF GetBounds(Graphics g)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipGetRegionBounds(new HandleRef(this, NativeRegion), new HandleRef(g, g.NativeGraphics), out RectangleF bounds));
- return bounds;
- }
-
- public IntPtr GetHrgn(Graphics g)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipGetRegionHRgn(new HandleRef(this, NativeRegion), new HandleRef(g, g.NativeGraphics), out IntPtr hrgn));
- return hrgn;
- }
-
- public bool IsEmpty(Graphics g)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipIsEmptyRegion(new HandleRef(this, NativeRegion), new HandleRef(g, g.NativeGraphics), out int isEmpty));
- return isEmpty != 0;
- }
-
- public bool IsInfinite(Graphics g)
- {
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipIsInfiniteRegion(new HandleRef(this, NativeRegion), new HandleRef(g, g.NativeGraphics), out int isInfinite));
- return isInfinite != 0;
- }
-
- public bool Equals(Region region, Graphics g)
- {
- ArgumentNullException.ThrowIfNull(region);
- ArgumentNullException.ThrowIfNull(g);
-
- Gdip.CheckStatus(Gdip.GdipIsEqualRegion(new HandleRef(this, NativeRegion), new HandleRef(region, region.NativeRegion), new HandleRef(g, g.NativeGraphics), out int isEqual));
- return isEqual != 0;
- }
-
- public RegionData? GetRegionData()
- {
- Gdip.CheckStatus(Gdip.GdipGetRegionDataSize(new HandleRef(this, NativeRegion), out int regionSize));
-
- if (regionSize == 0)
- return null;
-
- byte[] regionData = new byte[regionSize];
- Gdip.CheckStatus(Gdip.GdipGetRegionData(new HandleRef(this, NativeRegion), regionData, regionSize, out _));
- return new RegionData(regionData);
- }
-
- public bool IsVisible(float x, float y) => IsVisible(new PointF(x, y), null);
-
- public bool IsVisible(PointF point) => IsVisible(point, null);
-
- public bool IsVisible(float x, float y, Graphics? g) => IsVisible(new PointF(x, y), g);
-
- public bool IsVisible(PointF point, Graphics? g)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRegionPoint(
- new HandleRef(this, NativeRegion),
- point.X, point.Y,
- new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero),
- out int isVisible));
-
- return isVisible != 0;
- }
-
- public bool IsVisible(float x, float y, float width, float height) => IsVisible(new RectangleF(x, y, width, height), null);
-
- public bool IsVisible(RectangleF rect) => IsVisible(rect, null);
-
- public bool IsVisible(float x, float y, float width, float height, Graphics? g) => IsVisible(new RectangleF(x, y, width, height), g);
-
- public bool IsVisible(RectangleF rect, Graphics? g)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRegionRect(
- new HandleRef(this, NativeRegion),
- rect.X, rect.Y, rect.Width, rect.Height,
- new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero),
- out int isVisible));
-
- return isVisible != 0;
- }
-
- public bool IsVisible(int x, int y, Graphics? g) => IsVisible(new Point(x, y), g);
-
- public bool IsVisible(Point point) => IsVisible(point, null);
-
- public bool IsVisible(Point point, Graphics? g)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRegionPointI(
- new HandleRef(this, NativeRegion),
- point.X, point.Y,
- new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero),
- out int isVisible));
-
- return isVisible != 0;
- }
-
- public bool IsVisible(int x, int y, int width, int height) => IsVisible(new Rectangle(x, y, width, height), null);
-
- public bool IsVisible(Rectangle rect) => IsVisible(rect, null);
-
- public bool IsVisible(int x, int y, int width, int height, Graphics? g) => IsVisible(new Rectangle(x, y, width, height), g);
-
- public bool IsVisible(Rectangle rect, Graphics? g)
- {
- Gdip.CheckStatus(Gdip.GdipIsVisibleRegionRectI(
- new HandleRef(this, NativeRegion),
- rect.X, rect.Y, rect.Width, rect.Height,
- new HandleRef(g, g?.NativeGraphics ?? IntPtr.Zero),
- out int isVisible));
-
- return isVisible != 0;
- }
-
- public unsafe RectangleF[] GetRegionScans(Matrix matrix)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- Gdip.CheckStatus(Gdip.GdipGetRegionScansCount(
- new HandleRef(this, NativeRegion),
- out int count,
- new HandleRef(matrix, matrix.NativeMatrix)));
-
- RectangleF[] rectangles = new RectangleF[count];
-
- // Pinning an empty array gives null, libgdiplus doesn't like this.
- // As invoking isn't necessary, just return the empty array.
- if (count == 0)
- return rectangles;
-
- fixed (RectangleF* r = rectangles)
- {
- Gdip.CheckStatus(Gdip.GdipGetRegionScans
- (new HandleRef(this, NativeRegion),
- r,
- out count,
- new HandleRef(matrix, matrix.NativeMatrix)));
- }
-
- return rectangles;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/RotateFlipType.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/RotateFlipType.cs
deleted file mode 100644
index 11bffa2b66a5a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/RotateFlipType.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the different patterns available 'RotateFlipType' objects.
- ///
- public enum RotateFlipType
- {
- RotateNoneFlipNone = 0,
- Rotate90FlipNone = 1,
- Rotate180FlipNone = 2,
- Rotate270FlipNone = 3,
- RotateNoneFlipX = 4,
- Rotate90FlipX = 5,
- Rotate180FlipX = 6,
- Rotate270FlipX = 7,
- RotateNoneFlipY = Rotate180FlipX,
- Rotate90FlipY = Rotate270FlipX,
- Rotate180FlipY = RotateNoneFlipX,
- Rotate270FlipY = Rotate90FlipX,
- RotateNoneFlipXY = Rotate180FlipNone,
- Rotate90FlipXY = Rotate270FlipNone,
- Rotate180FlipXY = RotateNoneFlipNone,
- Rotate270FlipXY = Rotate90FlipNone
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SRDescriptionAttribute.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SRDescriptionAttribute.cs
deleted file mode 100644
index 00d110b34f3a5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SRDescriptionAttribute.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-//
-// System.Drawing.SRDescriptionAttribute.cs
-//
-// Authors:
-// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-// (C) 2004 Andreas Nahr
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.ComponentModel;
-
-namespace System.Drawing
-{
- [AttributeUsage(AttributeTargets.All)]
- internal sealed class SRDescriptionAttribute : DescriptionAttribute
- {
- public SRDescriptionAttribute(string description)
- : base(description)
- {
- }
-
- public override string Description
- {
- get
- {
- return DescriptionValue;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs
deleted file mode 100644
index d19d9c1e79670..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ScreenDC.cs
+++ /dev/null
@@ -1,24 +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.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- ///
- /// Simple wrapper to create a screen HDC within a using statement.
- ///
- internal struct ScreenDC : IDisposable
- {
- private IntPtr _handle;
-
- public static ScreenDC Create() => new ScreenDC
- {
- _handle = Interop.User32.GetDC(IntPtr.Zero)
- };
-
- public static implicit operator IntPtr(ScreenDC screenDC) => screenDC._handle;
-
- public void Dispose() => Interop.User32.ReleaseDC(IntPtr.Zero, _handle);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SizeConverter.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SizeConverter.cs
deleted file mode 100644
index caa46f7d03298..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SizeConverter.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing {
- using System.Runtime.Serialization.Formatters;
- using System.Runtime.InteropServices;
-
- using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
-
- using Microsoft.Win32;
- using System.Collections;
- using System.ComponentModel;
- using System.ComponentModel.Design.Serialization;
- using System.Globalization;
- using System.Reflection;
-
- ///
- ///
- /// SizeConverter is a class that can be used to convert
- /// Size from one data type to another. Access this
- /// class through the TypeDescriptor.
- ///
- public class SizeConverter : TypeConverter {
-
- ///
- ///
- /// Determines if this converter can convert an object in the given source
- /// type to the native type of the converter.
- ///
- public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) {
- if (sourceType == typeof(string)) {
- return true;
- }
- return base.CanConvertFrom(context, sourceType);
- }
-
- ///
- ///
- /// Gets a value indicating whether this converter can
- /// convert an object to the given destination type using the context.
- ///
- public override bool CanConvertTo(ITypeDescriptorContext context, [NotNullWhen(true)] Type? destinationType) {
- if (destinationType == typeof(InstanceDescriptor)) {
- return true;
- }
- return base.CanConvertTo(context, destinationType);
- }
-
- ///
- ///
- /// Converts the given object to the converter's native type.
- ///
- public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
-
- string strValue = value as string;
-
- if (strValue != null) {
-
- string text = strValue.Trim();
-
- if (text.Length == 0) {
- return null;
- }
- else {
-
- // Parse 2 integer values.
- //
- culture ??= CultureInfo.CurrentCulture;
- char sep = culture.TextInfo.ListSeparator[0];
- string[] tokens = text.Split(sep);
- int[] values = new int[tokens.Length];
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
- for (int i = 0; i < values.Length; i++) {
- // Note: ConvertFromString will raise exception if value cannot be converted.
- values[i] = (int)intConverter.ConvertFromString(context, culture, tokens[i]);
- }
-
- if (values.Length == 2) {
- return new Size(values[0], values[1]);
- }
- else {
- throw new ArgumentException(SR.Format(SR.TextParseFailedFormat,
- text,
- "Width,Height"));
- }
- }
- }
-
- return base.ConvertFrom(context, culture, value);
- }
-
- ///
- ///
- /// Converts the given object to another type. The most common types to convert
- /// are to and from a string object. The default implementation will make a call
- /// to ToString on the object if the object is valid and if the destination
- /// type is string. If this cannot convert to the destination type, this will
- /// throw a NotSupportedException.
- ///
- public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
- if (destinationType == null) {
- throw new ArgumentNullException(nameof(destinationType));
- }
-
- if (value is Size){
- if (destinationType == typeof(string)) {
- Size size = (Size)value;
-
- culture ??= CultureInfo.CurrentCulture;
- string sep = culture.TextInfo.ListSeparator + " ";
- TypeConverter intConverter = TypeDescriptor.GetConverter(typeof(int));
-
- // Note: ConvertToString will raise exception if value cannot be converted.
- return
- intConverter.ConvertToString(context, culture, size.Width) +
- sep +
- intConverter.ConvertToString(context, culture, size.Height);
- args[nArg++] = intConverter.ConvertToString(context, culture, size.Width);
- args[nArg++] = intConverter.ConvertToString(context, culture, size.Height);
- }
- if (destinationType == typeof(InstanceDescriptor)) {
- Size size = (Size)value;
-
- ConstructorInfo ctor = typeof(Size).GetConstructor(new Type[] {typeof(int), typeof(int)});
- if (ctor != null) {
- return new InstanceDescriptor(ctor, new object[] {size.Width, size.Height});
- }
- }
- }
-
- return base.ConvertTo(context, culture, value, destinationType);
- }
-
- ///
- ///
- /// Creates an instance of this type given a set of property values
- /// for the object. This is useful for objects that are immutable, but still
- /// want to provide changable properties.
- ///
- public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) {
- if ( propertyValues == null ){
- throw new ArgumentNullException( nameof(propertyValues) );
- }
-
-
- object width = propertyValues["Width"];
- object height = propertyValues["Height"];
-
- if (width == null || height == null ||
- !(width is int) || !(height is int)) {
- throw new ArgumentException(SR.PropertyValueInvalidEntry);
- }
- return new Size((int)width,
- (int)height);
- }
-
- ///
- ///
- /// Determines if changing a value on this object should require a call to
- /// CreateInstance to create a new value.
- ///
- public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) {
- return true;
- }
-
- ///
- ///
- /// Retrieves the set of properties for this type. By default, a type has
- /// does not return any properties. An easy implementation of this method
- /// can just call TypeDescriptor.GetProperties for the correct data type.
- ///
- public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) {
- PropertyDescriptorCollection props = TypeDescriptor.GetProperties(typeof(Size), attributes);
- return props.Sort(new string[] {"Width", "Height"});
- }
-
-
- ///
- ///
- /// Determines if this object supports properties. By default, this
- /// is false.
- ///
- public override bool GetPropertiesSupported(ITypeDescriptorContext context) {
- return true;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SolidBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SolidBrush.cs
deleted file mode 100644
index d19d983688d99..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SolidBrush.cs
+++ /dev/null
@@ -1,124 +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.Diagnostics;
-using System.Drawing.Internal;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public sealed class SolidBrush : Brush, ISystemColorTracker
- {
- // GDI+ doesn't understand system colors, so we need to cache the value here.
- private Color _color = Color.Empty;
- private bool _immutable;
-
- public SolidBrush(Color color)
- {
- _color = color;
-
- IntPtr nativeBrush;
- int status = Gdip.GdipCreateSolidFill(_color.ToArgb(), out nativeBrush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(nativeBrush);
-
- if (_color.IsSystemColor)
- {
- SystemColorTracker.Add(this);
- }
- }
-
- internal SolidBrush(Color color, bool immutable) : this(color)
- {
- _immutable = immutable;
- }
-
- internal SolidBrush(IntPtr nativeBrush)
- {
- Debug.Assert(nativeBrush != IntPtr.Zero, "Initializing native brush with null.");
- SetNativeBrushInternal(nativeBrush);
- }
-
- public override object Clone()
- {
- IntPtr clonedBrush;
- int status = Gdip.GdipCloneBrush(new HandleRef(this, NativeBrush), out clonedBrush);
- Gdip.CheckStatus(status);
-
- // Clones of immutable brushes are not immutable.
- return new SolidBrush(clonedBrush);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (!disposing)
- {
- _immutable = false;
- }
- else if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, "Brush"));
- }
-
- base.Dispose(disposing);
- }
-
- public Color Color
- {
- get
- {
- if (_color == Color.Empty)
- {
- int colorARGB;
- int status = Gdip.GdipGetSolidFillColor(new HandleRef(this, NativeBrush), out colorARGB);
- Gdip.CheckStatus(status);
-
- _color = Color.FromArgb(colorARGB);
- }
-
- // GDI+ doesn't understand system colors, so we can't use GdipGetSolidFillColor in the general case.
- return _color;
- }
-
- set
- {
- if (_immutable)
- {
- throw new ArgumentException(SR.Format(SR.CantChangeImmutableObjects, "Brush"));
- }
-
- if (_color != value)
- {
- Color oldColor = _color;
- InternalSetColor(value);
-
- // NOTE: We never remove brushes from the active list, so if someone is
- // changing their brush colors a lot, this could be a problem.
- if (value.IsSystemColor && !oldColor.IsSystemColor)
- {
- SystemColorTracker.Add(this);
- }
- }
- }
- }
-
- // Sets the color even if the brush is considered immutable.
- private void InternalSetColor(Color value)
- {
- int status = Gdip.GdipSetSolidFillColor(new HandleRef(this, NativeBrush), value.ToArgb());
- Gdip.CheckStatus(status);
-
- _color = value;
- }
-
- void ISystemColorTracker.OnSystemColorChanged()
- {
- if (NativeBrush != IntPtr.Zero)
- {
- InternalSetColor(_color);
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringAlignment.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringAlignment.cs
deleted file mode 100644
index fa21770868ca5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringAlignment.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the alignment of a text string relative to its layout rectangle.
- ///
- public enum StringAlignment
- {
- // left or top in English
- ///
- /// Specifies the text be aligned near the layout. In a left-to-right layout, the near position is left. In a
- /// right-to-left layout, the near position is right.
- ///
- Near = 0,
-
- ///
- /// Specifies that text is aligned in the center of the layout rectangle.
- ///
- Center = 1,
-
- // right or bottom in English
- ///
- /// Specifies that text is aligned far from the origin position of the layout rectangle. In a left-to-right
- /// layout, the far position is right. In a right-to-left layout, the far position is left.
- ///
- Far = 2
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringDigitSubstitute.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringDigitSubstitute.cs
deleted file mode 100644
index 44a0b21e46f71..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringDigitSubstitute.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// font style constants (sdkinc\GDIplusEnums.h)
-
-namespace System.Drawing
-{
- ///
- /// Specifies style information applied to String Digit Substitute.
- ///
- public enum StringDigitSubstitute
- {
- User = 0, // As NLS setting
- None = 1,
- National = 2,
- Traditional = 3
- };
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormat.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormat.cs
deleted file mode 100644
index c22bba3ba6b70..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormat.cs
+++ /dev/null
@@ -1,442 +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.Diagnostics;
-using System.ComponentModel;
-using System.Drawing.Text;
-using System.Runtime.InteropServices;
-using System.Globalization;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// Encapsulates text layout information (such as alignment and linespacing), display manipulations (such as
- /// ellipsis insertion and national digit substitution) and OpenType features.
- ///
- public sealed class StringFormat : MarshalByRefObject, ICloneable, IDisposable
- {
- internal IntPtr nativeFormat;
-
- private StringFormat(IntPtr format)
- {
- nativeFormat = format;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public StringFormat() : this(0, 0)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified .
- ///
- public StringFormat(StringFormatFlags options) :
- this(options, 0)
- {
- }
-
- ///
- /// Initializes a new instance of the class with the specified
- /// and language.
- ///
- public StringFormat(StringFormatFlags options, int language)
- {
- int status = Gdip.GdipCreateStringFormat(options, language, out nativeFormat);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- ///
- /// Initializes a new instance of the class from the specified
- /// existing .
- ///
- public StringFormat(StringFormat format)
- {
- ArgumentNullException.ThrowIfNull(format);
-
- int status = Gdip.GdipCloneStringFormat(new HandleRef(format, format.nativeFormat), out nativeFormat);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- private void Dispose(bool disposing)
- {
- if (nativeFormat != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeleteStringFormat(new HandleRef(this, nativeFormat));
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex)
- {
- if (ClientUtils.IsCriticalException(ex))
- {
- throw;
- }
-
- Debug.Fail("Exception thrown during Dispose: " + ex.ToString());
- }
- finally
- {
- nativeFormat = IntPtr.Zero;
- }
- }
- }
-
- ///
- /// Creates an exact copy of this .
- ///
- public object Clone()
- {
- IntPtr cloneFormat;
-
- int status = Gdip.GdipCloneStringFormat(new HandleRef(this, nativeFormat), out cloneFormat);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- StringFormat newCloneStringFormat = new StringFormat(cloneFormat);
-
- return newCloneStringFormat;
- }
-
-
- ///
- /// Gets or sets a that contains formatting information.
- ///
- public StringFormatFlags FormatFlags
- {
- get
- {
- StringFormatFlags format;
-
- int status = Gdip.GdipGetStringFormatFlags(new HandleRef(this, nativeFormat), out format);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return format;
- }
- set
- {
- int status = Gdip.GdipSetStringFormatFlags(new HandleRef(this, nativeFormat), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Sets the measure of characters to the specified range.
- ///
- public void SetMeasurableCharacterRanges(CharacterRange[] ranges)
- {
- int status = Gdip.GdipSetStringFormatMeasurableCharacterRanges(new HandleRef(this, nativeFormat), ranges.Length, ranges);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- // For English, this is horizontal alignment
- ///
- /// Specifies text alignment information.
- ///
- public StringAlignment Alignment
- {
- get
- {
- StringAlignment alignment;
- int status = Gdip.GdipGetStringFormatAlign(new HandleRef(this, nativeFormat), out alignment);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return alignment;
- }
- set
- {
- if (value < StringAlignment.Near || value > StringAlignment.Far)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(StringAlignment));
- }
-
- int status = Gdip.GdipSetStringFormatAlign(new HandleRef(this, nativeFormat), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- // For English, this is vertical alignment
- ///
- /// Gets or sets the line alignment.
- ///
- public StringAlignment LineAlignment
- {
- get
- {
- StringAlignment alignment;
- int status = Gdip.GdipGetStringFormatLineAlign(new HandleRef(this, nativeFormat), out alignment);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return alignment;
- }
- set
- {
- if (value < 0 || value > StringAlignment.Far)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(StringAlignment));
- }
-
- int status = Gdip.GdipSetStringFormatLineAlign(new HandleRef(this, nativeFormat), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Gets or sets the for this .
- ///
- public HotkeyPrefix HotkeyPrefix
- {
- get
- {
- HotkeyPrefix hotkeyPrefix;
- int status = Gdip.GdipGetStringFormatHotkeyPrefix(new HandleRef(this, nativeFormat), out hotkeyPrefix);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return hotkeyPrefix;
- }
- set
- {
- if (value < HotkeyPrefix.None || value > HotkeyPrefix.Hide)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(HotkeyPrefix));
- }
-
- int status = Gdip.GdipSetStringFormatHotkeyPrefix(new HandleRef(this, nativeFormat), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Sets tab stops for this .
- ///
- public void SetTabStops(float firstTabOffset, float[] tabStops)
- {
- if (firstTabOffset < 0)
- {
- throw new ArgumentException(SR.Format(SR.InvalidArgumentValue, nameof(firstTabOffset), firstTabOffset));
- }
-
- foreach (float tabStop in tabStops) // Emulate Windows GDI+ behavior.
- {
- if (float.IsNegativeInfinity(tabStop))
- {
- throw new NotImplementedException();
- }
- }
-
- int status = Gdip.GdipSetStringFormatTabStops(new HandleRef(this, nativeFormat), firstTabOffset, tabStops.Length, tabStops);
-
- if (status != Gdip.Ok)
- {
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Gets the tab stops for this .
- ///
- public float[] GetTabStops(out float firstTabOffset)
- {
- int count;
- int status = Gdip.GdipGetStringFormatTabStopCount(new HandleRef(this, nativeFormat), out count);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- float[] tabStops = new float[count];
- status = Gdip.GdipGetStringFormatTabStops(new HandleRef(this, nativeFormat), count, out firstTabOffset, tabStops);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return tabStops;
- }
-
-
- // String trimming. How to handle more text than can be displayed
- // in the limits available.
-
- ///
- /// Gets or sets the for this .
- ///
- public StringTrimming Trimming
- {
- get
- {
- StringTrimming trimming;
- int status = Gdip.GdipGetStringFormatTrimming(new HandleRef(this, nativeFormat), out trimming);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- return trimming;
- }
-
- set
- {
- if (value < StringTrimming.None || value > StringTrimming.EllipsisPath)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(StringTrimming));
- }
-
- int status = Gdip.GdipSetStringFormatTrimming(new HandleRef(this, nativeFormat), value);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
- }
-
- ///
- /// Gets a generic default .
- /// Remarks from MSDN: A generic, default StringFormat object has the following characteristics:
- /// - No string format flags are set.
- /// - Character alignment and line alignment are set to StringAlignmentNear.
- /// - Language ID is set to neutral language, which means that the current language associated with the calling thread is used.
- /// - String digit substitution is set to StringDigitSubstituteUser.
- /// - Hot key prefix is set to HotkeyPrefixNone.
- /// - Number of tab stops is set to zero.
- /// - String trimming is set to StringTrimmingCharacter.
- ///
- public static StringFormat GenericDefault
- {
- get
- {
- IntPtr format;
- int status = Gdip.GdipStringFormatGetGenericDefault(out format);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return new StringFormat(format);
- }
- }
-
- ///
- /// Gets a generic typographic .
- /// Remarks from MSDN: A generic, typographic StringFormat object has the following characteristics:
- /// - String format flags StringFormatFlagsLineLimit, StringFormatFlagsNoClip, and StringFormatFlagsNoFitBlackBox are set.
- /// - Character alignment and line alignment are set to StringAlignmentNear.
- /// - Language ID is set to neutral language, which means that the current language associated with the calling thread is used.
- /// - String digit substitution is set to StringDigitSubstituteUser.
- /// - Hot key prefix is set to HotkeyPrefixNone.
- /// - Number of tab stops is set to zero.
- /// - String trimming is set to StringTrimmingNone.
- ///
- public static StringFormat GenericTypographic
- {
- get
- {
- IntPtr format;
- int status = Gdip.GdipStringFormatGetGenericTypographic(out format);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return new StringFormat(format);
- }
- }
-
- public void SetDigitSubstitution(int language, StringDigitSubstitute substitute)
- {
- int status = Gdip.GdipSetStringFormatDigitSubstitution(new HandleRef(this, nativeFormat), language, substitute);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
- }
-
- ///
- /// Gets the for this .
- ///
- public StringDigitSubstitute DigitSubstitutionMethod
- {
- get
- {
- StringDigitSubstitute digitSubstitute;
-
- int status = Gdip.GdipGetStringFormatDigitSubstitution(new HandleRef(this, nativeFormat), out _, out digitSubstitute);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return digitSubstitute;
- }
- }
-
- ///
- /// Gets the language of for this .
- ///
- public int DigitSubstitutionLanguage
- {
- get
- {
- int language;
- int status = Gdip.GdipGetStringFormatDigitSubstitution(new HandleRef(this, nativeFormat), out language, out _);
-
- if (status != Gdip.Ok)
- throw Gdip.StatusException(status);
-
- return language;
- }
- }
-
- internal int GetMeasurableCharacterRangeCount()
- {
- int cnt;
- int status = Gdip.GdipGetStringFormatMeasurableCharacterRangeCount(new HandleRef(this, nativeFormat), out cnt);
-
- Gdip.CheckStatus(status);
- return cnt;
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- ~StringFormat()
- {
- Dispose(false);
- }
-
- ///
- /// Converts this to a human-readable string.
- ///
- public override string ToString() => $"[StringFormat, FormatFlags={FormatFlags}]";
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormatFlags.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormatFlags.cs
deleted file mode 100644
index 3ae7c17b74af5..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringFormatFlags.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the display and layout information for text strings.
- ///
- [Flags]
- public enum StringFormatFlags
- {
- ///
- /// Specifies that text is right to left.
- ///
- DirectionRightToLeft = 0x00000001,
-
- ///
- /// Specifies that text is vertical.
- ///
- DirectionVertical = 0x00000002,
-
- ///
- /// Specifies that no part of any glyph overhangs the bounding rectangle. By default some glyphs
- /// overhang the rectangle slightly where necessary to appear at the edge visually. For example
- /// when an italic lower case letter f in a font such as Garamond is aligned at the far left
- /// of a rectangle, the lower part of the f will reach slightly further left than the left edge
- /// of the rectangle. Setting this flag will ensure no painting outside the rectangle but will
- /// cause the aligned edges of adjacent lines of text to appear uneven.
- ///
- /// WARNING:
- /// The GDI+ equivalent for this is StringFormatFlags::StringFormatFlagsNoFitBlackBox,
- /// which is defined as 0x4. This was a mistake introduced since the first version of
- /// the product and fixing it at this point would be a breaking change.
- ///
- ///
- FitBlackBox = 0x00000004,
-
- ///
- /// Causes control characters such as the left-to-right mark to be shown in the output with a representative glyph.
- ///
- DisplayFormatControl = 0x00000020,
-
- ///
- /// Disables fallback to alternate fonts for characters not supported in the requested font. Any missing characters are
- /// displayed with the fonts missing glyph, usually an open square.
- ///
- NoFontFallback = 0x00000400,
-
- ///
- /// Specifies that the space at the end of each line is included in a string measurement.
- ///
- MeasureTrailingSpaces = 0x00000800,
-
- ///
- /// Specifies that the wrapping of text to the next line is disabled. NoWrap is implied when a point of origin
- /// is used instead of a layout rectangle. When drawing text within a rectangle, by default, text is broken at
- /// the last word boundary that is inside the rectangle's boundary and wrapped to the next line.
- ///
- NoWrap = 0x00001000,
-
- ///
- /// Specifies that only entire lines are laid out in the layout rectangle. By default, layout
- /// continues until the end of the text or until no more lines are visible as a result of clipping,
- /// whichever comes first. The default settings allow the last line to be partially obscured by a
- /// layout rectangle that is not a whole multiple of the line height.
- /// To ensure that only whole lines are seen, set this flag and be careful to provide a layout
- /// rectangle at least as tall as the height of one line.
- ///
- LineLimit = 0x00002000,
-
- ///
- /// Specifies that characters overhanging the layout rectangle and text extending outside the layout
- /// rectangle are allowed to show. By default, all overhanging characters and text that extends outside
- /// the layout rectangle are clipped. Any trailing spaces (spaces that are at the end of a line) that
- /// extend outside the layout rectangle are clipped. Therefore, the setting of this flag will have an
- /// effect on a string measurement if trailing spaces are being included in the measurement.
- /// If clipping is enabled, trailing spaces that extend outside the layout rectangle are not included
- /// in the measurement. If clipping is disabled, all trailing spaces are included in the measurement,
- /// regardless of whether they are outside the layout rectangle.
- ///
- NoClip = 0x00004000
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringTrimming.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringTrimming.cs
deleted file mode 100644
index 6d358cc329791..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringTrimming.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies how to trim characters from a string that does not completely fit into a layout shape.
- ///
- public enum StringTrimming
- {
- ///
- /// Specifies no trimming.
- ///
- None = 0,
-
- ///
- /// Specifies that the string is broken at the boundary of the last character
- /// that is inside the layout rectangle. This is the default.
- ///
- Character = 1,
-
- ///
- /// Specifies that the string is broken at the boundary of the last word that is inside the layout rectangle.
- ///
- Word = 2,
-
- ///
- /// Specifies that the string is broken at the boundary of the last character that is inside
- /// the layout rectangle and an ellipsis (...) is inserted after the character.
- ///
- EllipsisCharacter = 3,
-
- ///
- /// Specifies that the string is broken at the boundary of the last word that is inside the
- /// layout rectangle and an ellipsis (...) is inserted after the word.
- ///
- EllipsisWord = 4,
-
- ///
- /// Specifies that the center is removed from the string and replaced by an ellipsis.
- /// The algorithm keeps as much of the last portion of the string as possible.
- ///
- EllipsisPath = 5
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/StringUnit.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/StringUnit.cs
deleted file mode 100644
index cdf90f3364921..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/StringUnit.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing
-{
- ///
- /// Specifies the units of measure for a text string.
- ///
- public enum StringUnit
- {
- ///
- /// Specifies world units as the unit of measure.
- ///
- World = GraphicsUnit.World,
- ///
- /// Specifies the device unit as the unit of measure.
- ///
- Display = GraphicsUnit.Display,
- ///
- /// Specifies a pixel as the unit of measure.
- ///
- Pixel = GraphicsUnit.Pixel,
- ///
- /// Specifies a printer's point as the unit of measure.
- ///
- Point = GraphicsUnit.Point,
- ///
- /// Specifies an inch as the unit of measure.
- ///
- Inch = GraphicsUnit.Inch,
- ///
- /// Specifies 1/300 of an inch as the unit of measure.
- ///
- Document = GraphicsUnit.Document,
- ///
- /// Specifies a millimeter as the unit of measure
- ///
- Millimeter = GraphicsUnit.Millimeter,
- ///
- /// Specifies a printer's em size of 32 as the unit of measure.
- ///
- Em = 32
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs
deleted file mode 100644
index 868531ce1b692..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemBrushes.cs
+++ /dev/null
@@ -1,81 +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.Diagnostics;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public static class SystemBrushes
- {
- private static readonly object s_systemBrushesKey = new object();
-
- public static Brush ActiveBorder => FromSystemColor(SystemColors.ActiveBorder);
- public static Brush ActiveCaption => FromSystemColor(SystemColors.ActiveCaption);
- public static Brush ActiveCaptionText => FromSystemColor(SystemColors.ActiveCaptionText);
- public static Brush AppWorkspace => FromSystemColor(SystemColors.AppWorkspace);
-
- public static Brush ButtonFace => FromSystemColor(SystemColors.ButtonFace);
- public static Brush ButtonHighlight => FromSystemColor(SystemColors.ButtonHighlight);
- public static Brush ButtonShadow => FromSystemColor(SystemColors.ButtonShadow);
-
- public static Brush Control => FromSystemColor(SystemColors.Control);
- public static Brush ControlLightLight => FromSystemColor(SystemColors.ControlLightLight);
- public static Brush ControlLight => FromSystemColor(SystemColors.ControlLight);
- public static Brush ControlDark => FromSystemColor(SystemColors.ControlDark);
- public static Brush ControlDarkDark => FromSystemColor(SystemColors.ControlDarkDark);
- public static Brush ControlText => FromSystemColor(SystemColors.ControlText);
-
- public static Brush Desktop => FromSystemColor(SystemColors.Desktop);
-
- public static Brush GradientActiveCaption => FromSystemColor(SystemColors.GradientActiveCaption);
- public static Brush GradientInactiveCaption => FromSystemColor(SystemColors.GradientInactiveCaption);
- public static Brush GrayText => FromSystemColor(SystemColors.GrayText);
-
- public static Brush Highlight => FromSystemColor(SystemColors.Highlight);
- public static Brush HighlightText => FromSystemColor(SystemColors.HighlightText);
- public static Brush HotTrack => FromSystemColor(SystemColors.HotTrack);
-
- public static Brush InactiveCaption => FromSystemColor(SystemColors.InactiveCaption);
- public static Brush InactiveBorder => FromSystemColor(SystemColors.InactiveBorder);
- public static Brush InactiveCaptionText => FromSystemColor(SystemColors.InactiveCaptionText);
- public static Brush Info => FromSystemColor(SystemColors.Info);
- public static Brush InfoText => FromSystemColor(SystemColors.InfoText);
-
- public static Brush Menu => FromSystemColor(SystemColors.Menu);
- public static Brush MenuBar => FromSystemColor(SystemColors.MenuBar);
- public static Brush MenuHighlight => FromSystemColor(SystemColors.MenuHighlight);
- public static Brush MenuText => FromSystemColor(SystemColors.MenuText);
-
- public static Brush ScrollBar => FromSystemColor(SystemColors.ScrollBar);
-
- public static Brush Window => FromSystemColor(SystemColors.Window);
- public static Brush WindowFrame => FromSystemColor(SystemColors.WindowFrame);
- public static Brush WindowText => FromSystemColor(SystemColors.WindowText);
-
- public static Brush FromSystemColor(Color c)
- {
- if (!c.IsSystemColor)
- {
- throw new ArgumentException(SR.Format(SR.ColorNotSystemColor, c.ToString()));
- }
-
- Brush[]? systemBrushes = (Brush[]?)Gdip.ThreadData[s_systemBrushesKey];
- if (systemBrushes == null)
- {
- systemBrushes = new Brush[(int)KnownColor.WindowText + (int)KnownColor.MenuHighlight - (int)KnownColor.YellowGreen];
- Gdip.ThreadData[s_systemBrushesKey] = systemBrushes;
- }
- int idx = (int)c.ToKnownColor();
- if (idx > (int)KnownColor.YellowGreen)
- {
- idx -= (int)KnownColor.YellowGreen - (int)KnownColor.WindowText;
- }
- idx--;
-
- Debug.Assert(idx >= 0 && idx < systemBrushes.Length, "System colors have been added but our system color array has not been expanded.");
-
- return systemBrushes[idx] ??= new SolidBrush(c, true);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemFonts.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemFonts.cs
deleted file mode 100644
index 60476b121c427..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemFonts.cs
+++ /dev/null
@@ -1,288 +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.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing
-{
- public static class SystemFonts
- {
- public static Font? GetFontByName(string systemFontName)
- {
- if (nameof(CaptionFont).Equals(systemFontName))
- {
- return CaptionFont;
- }
- else if (nameof(DefaultFont).Equals(systemFontName))
- {
- return DefaultFont;
- }
- else if (nameof(DialogFont).Equals(systemFontName))
- {
- return DialogFont;
- }
- else if (nameof(IconTitleFont).Equals(systemFontName))
- {
- return IconTitleFont;
- }
- else if (nameof(MenuFont).Equals(systemFontName))
- {
- return MenuFont;
- }
- else if (nameof(MessageBoxFont).Equals(systemFontName))
- {
- return MessageBoxFont;
- }
- else if (nameof(SmallCaptionFont).Equals(systemFontName))
- {
- return SmallCaptionFont;
- }
- else if (nameof(StatusFont).Equals(systemFontName))
- {
- return StatusFont;
- }
-
- return null;
- }
-
- private static unsafe bool GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics)
- {
- metrics = new Interop.User32.NONCLIENTMETRICS { cbSize = (uint)sizeof(Interop.User32.NONCLIENTMETRICS) };
- fixed (void* m = &metrics)
- {
- return Interop.User32.SystemParametersInfoW(Interop.User32.SystemParametersAction.SPI_GETNONCLIENTMETRICS, metrics.cbSize, m, 0);
- }
- }
-
- public static Font? CaptionFont
- {
- get
- {
- Font? captionFont = null;
-
- if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
- {
- captionFont = GetFontFromData(metrics.lfCaptionFont);
- captionFont.SetSystemFontName(nameof(CaptionFont));
- }
-
- return captionFont;
- }
- }
-
- public static Font? SmallCaptionFont
- {
- get
- {
- Font? smcaptionFont = null;
-
- if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
- {
- smcaptionFont = GetFontFromData(metrics.lfSmCaptionFont);
- smcaptionFont.SetSystemFontName(nameof(SmallCaptionFont));
- }
-
- return smcaptionFont;
- }
- }
-
- public static Font? MenuFont
- {
- get
- {
- Font? menuFont = null;
-
- if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
- {
- menuFont = GetFontFromData(metrics.lfMenuFont);
- menuFont.SetSystemFontName(nameof(MenuFont));
- }
-
- return menuFont;
- }
- }
-
- public static Font? StatusFont
- {
- get
- {
- Font? statusFont = null;
-
- if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
- {
- statusFont = GetFontFromData(metrics.lfStatusFont);
- statusFont.SetSystemFontName(nameof(StatusFont));
- }
-
- return statusFont;
- }
- }
-
- public static Font? MessageBoxFont
- {
- get
- {
- Font? messageBoxFont = null;
-
- if (GetNonClientMetrics(out Interop.User32.NONCLIENTMETRICS metrics))
- {
- messageBoxFont = GetFontFromData(metrics.lfMessageFont);
- messageBoxFont.SetSystemFontName(nameof(MessageBoxFont));
- }
-
- return messageBoxFont;
- }
- }
-
- private static bool IsCriticalFontException(Exception ex)
- {
- return !(
- // In any of these cases we'll handle the exception.
- ex is ExternalException ||
- ex is ArgumentException ||
- ex is OutOfMemoryException || // GDI+ throws this one for many reasons other than actual OOM.
- ex is InvalidOperationException ||
- ex is NotImplementedException ||
- ex is FileNotFoundException);
- }
-
- public static unsafe Font? IconTitleFont
- {
- get
- {
- Font? iconTitleFont = null;
-
- Interop.User32.LOGFONT itfont = default;
- if (Interop.User32.SystemParametersInfoW(Interop.User32.SystemParametersAction.SPI_GETICONTITLELOGFONT, (uint)sizeof(Interop.User32.LOGFONT), &itfont, 0))
- {
- iconTitleFont = GetFontFromData(itfont);
- iconTitleFont.SetSystemFontName(nameof(IconTitleFont));
- }
-
- return iconTitleFont;
- }
- }
-
- public static Font DefaultFont
- {
- get
- {
- Font? defaultFont = null;
-
- // For Arabic systems, always return Tahoma 8.
- if ((ushort)Interop.Kernel32.GetSystemDefaultLCID() == 0x0001)
- {
- try
- {
- defaultFont = new Font("Tahoma", 8);
- }
- catch (Exception ex) when (!IsCriticalFontException(ex)) { }
- }
-
- // First try DEFAULT_GUI.
- if (defaultFont == null)
- {
- IntPtr handle = Interop.Gdi32.GetStockObject(Interop.Gdi32.StockObject.DEFAULT_GUI_FONT);
- try
- {
- using (Font fontInWorldUnits = Font.FromHfont(handle))
- {
- defaultFont = FontInPoints(fontInWorldUnits);
- }
- }
- catch (ArgumentException)
- {
- // This can happen in theory if we end up pulling a non-TrueType font
- }
- }
-
- // If DEFAULT_GUI didn't work, try Tahoma.
- if (defaultFont == null)
- {
- try
- {
- defaultFont = new Font("Tahoma", 8);
- }
- catch (ArgumentException)
- {
- }
- }
-
- // Use GenericSansSerif as a last resort - this will always work.
- defaultFont ??= new Font(FontFamily.GenericSansSerif, 8);
-
- if (defaultFont.Unit != GraphicsUnit.Point)
- {
- defaultFont = FontInPoints(defaultFont);
- }
-
- Debug.Assert(defaultFont != null, "defaultFont wasn't set.");
-
- defaultFont.SetSystemFontName(nameof(DefaultFont));
- return defaultFont;
- }
- }
-
- public static Font DialogFont
- {
- get
- {
- Font? dialogFont = null;
-
- if ((ushort)Interop.Kernel32.GetSystemDefaultLCID() == 0x0011)
- {
- // Always return DefaultFont for Japanese cultures.
- dialogFont = DefaultFont;
- }
- else
- {
- try
- {
- // Use MS Shell Dlg 2, 8pt for anything other than Japanese.
- dialogFont = new Font("MS Shell Dlg 2", 8);
- }
- catch (ArgumentException)
- {
- // This can happen in theory if we end up pulling a non-TrueType font
- }
- }
-
- if (dialogFont == null)
- {
- dialogFont = DefaultFont;
- }
- else if (dialogFont.Unit != GraphicsUnit.Point)
- {
- dialogFont = FontInPoints(dialogFont);
- }
-
- // For Japanese cultures, SystemFonts.DefaultFont returns a new Font object every time it is invoked.
- // So for Japanese we return the DefaultFont with its SystemFontName set to DialogFont.
- dialogFont!.SetSystemFontName(nameof(DialogFont));
- return dialogFont;
- }
- }
-
- private static Font FontInPoints(Font font)
- {
- return new Font(font.FontFamily, font.SizeInPoints, font.Style, GraphicsUnit.Point, font.GdiCharSet, font.GdiVerticalFont);
- }
-
- private static Font GetFontFromData(Interop.User32.LOGFONT logFont)
- {
- Font? font = null;
- try
- {
- font = Font.FromLogFont(ref logFont);
- }
- catch (Exception ex) when (!IsCriticalFontException(ex)) { }
-
- return
- font == null ? DefaultFont :
- font.Unit != GraphicsUnit.Point ? FontInPoints(font) :
- font;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.cs
deleted file mode 100644
index 8fe2f51ec9f28..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemIcons.cs
+++ /dev/null
@@ -1,58 +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.Diagnostics;
-
-namespace System.Drawing
-{
- public static class SystemIcons
- {
- private static Icon? s_application;
- private static Icon? s_asterisk;
- private static Icon? s_error;
- private static Icon? s_exclamation;
- private static Icon? s_hand;
- private static Icon? s_information;
- private static Icon? s_question;
- private static Icon? s_warning;
- private static Icon? s_winlogo;
- private static Icon? s_shield;
-
- public static Icon Application => GetIcon(ref s_application, SafeNativeMethods.IDI_APPLICATION);
-
- public static Icon Asterisk => GetIcon(ref s_asterisk, SafeNativeMethods.IDI_ASTERISK);
-
- public static Icon Error => GetIcon(ref s_error, SafeNativeMethods.IDI_ERROR);
-
- public static Icon Exclamation => GetIcon(ref s_exclamation, SafeNativeMethods.IDI_EXCLAMATION);
-
- public static Icon Hand => GetIcon(ref s_hand, SafeNativeMethods.IDI_HAND);
-
- public static Icon Information => GetIcon(ref s_information, SafeNativeMethods.IDI_INFORMATION);
-
- public static Icon Question => GetIcon(ref s_question, SafeNativeMethods.IDI_QUESTION);
-
- public static Icon Warning => GetIcon(ref s_warning, SafeNativeMethods.IDI_WARNING);
-
- public static Icon WinLogo => GetIcon(ref s_winlogo, SafeNativeMethods.IDI_WINLOGO);
-
- public static Icon Shield
- {
- get
- {
- if (s_shield == null)
- {
- s_shield = new Icon(typeof(SystemIcons), "ShieldIcon.ico");
- Debug.Assert(s_shield != null, "ShieldIcon.ico must be present as an embedded resource in System.Drawing.Common.");
- }
-
- return s_shield;
- }
- }
-
- private static Icon GetIcon(ref Icon? icon, int iconId)
- {
- return icon ??= new Icon(Interop.User32.LoadIcon(NativeMethods.NullHandleRef, (IntPtr)iconId));
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemPens.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/SystemPens.cs
deleted file mode 100644
index 52a3dc3985cb1..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/SystemPens.cs
+++ /dev/null
@@ -1,82 +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.Diagnostics;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public static class SystemPens
- {
- private static readonly object s_systemPensKey = new object();
-
- public static Pen ActiveBorder => FromSystemColor(SystemColors.ActiveBorder);
- public static Pen ActiveCaption => FromSystemColor(SystemColors.ActiveCaption);
- public static Pen ActiveCaptionText => FromSystemColor(SystemColors.ActiveCaptionText);
- public static Pen AppWorkspace => FromSystemColor(SystemColors.AppWorkspace);
-
- public static Pen ButtonFace => FromSystemColor(SystemColors.ButtonFace);
- public static Pen ButtonHighlight => FromSystemColor(SystemColors.ButtonHighlight);
-
- public static Pen ButtonShadow => FromSystemColor(SystemColors.ButtonShadow);
-
- public static Pen Control => FromSystemColor(SystemColors.Control);
- public static Pen ControlText => FromSystemColor(SystemColors.ControlText);
- public static Pen ControlDark => FromSystemColor(SystemColors.ControlDark);
- public static Pen ControlDarkDark => FromSystemColor(SystemColors.ControlDarkDark);
- public static Pen ControlLight => FromSystemColor(SystemColors.ControlLight);
- public static Pen ControlLightLight => FromSystemColor(SystemColors.ControlLightLight);
-
- public static Pen Desktop => FromSystemColor(SystemColors.Desktop);
-
- public static Pen GradientActiveCaption => FromSystemColor(SystemColors.GradientActiveCaption);
- public static Pen GradientInactiveCaption => FromSystemColor(SystemColors.GradientInactiveCaption);
- public static Pen GrayText => FromSystemColor(SystemColors.GrayText);
-
- public static Pen Highlight => FromSystemColor(SystemColors.Highlight);
- public static Pen HighlightText => FromSystemColor(SystemColors.HighlightText);
- public static Pen HotTrack => FromSystemColor(SystemColors.HotTrack);
-
- public static Pen InactiveBorder => FromSystemColor(SystemColors.InactiveBorder);
- public static Pen InactiveCaption => FromSystemColor(SystemColors.InactiveCaption);
- public static Pen InactiveCaptionText => FromSystemColor(SystemColors.InactiveCaptionText);
- public static Pen Info => FromSystemColor(SystemColors.Info);
- public static Pen InfoText => FromSystemColor(SystemColors.InfoText);
-
- public static Pen Menu => FromSystemColor(SystemColors.Menu);
- public static Pen MenuBar => FromSystemColor(SystemColors.MenuBar);
- public static Pen MenuHighlight => FromSystemColor(SystemColors.MenuHighlight);
- public static Pen MenuText => FromSystemColor(SystemColors.MenuText);
-
- public static Pen ScrollBar => FromSystemColor(SystemColors.ScrollBar);
-
- public static Pen Window => FromSystemColor(SystemColors.Window);
- public static Pen WindowFrame => FromSystemColor(SystemColors.WindowFrame);
- public static Pen WindowText => FromSystemColor(SystemColors.WindowText);
-
- public static Pen FromSystemColor(Color c)
- {
- if (!c.IsSystemColor)
- {
- throw new ArgumentException(SR.Format(SR.ColorNotSystemColor, c.ToString()));
- }
-
- Pen[]? systemPens = (Pen[]?)Gdip.ThreadData[s_systemPensKey];
- if (systemPens == null)
- {
- systemPens = new Pen[(int)KnownColor.WindowText + (int)KnownColor.MenuHighlight - (int)KnownColor.YellowGreen];
- Gdip.ThreadData[s_systemPensKey] = systemPens;
- }
-
- int idx = (int)c.ToKnownColor();
- if (idx > (int)KnownColor.YellowGreen)
- {
- idx -= (int)KnownColor.YellowGreen - (int)KnownColor.WindowText;
- }
- idx--;
- Debug.Assert(idx >= 0 && idx < systemPens.Length, "System colors have been added but our system color array has not been expanded.");
-
- return systemPens[idx] ??= new Pen(c, true);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/FontCollection.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/FontCollection.cs
deleted file mode 100644
index e774b82c205c0..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/FontCollection.cs
+++ /dev/null
@@ -1,63 +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.Diagnostics;
-using System.Runtime.InteropServices;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Text
-{
- ///
- /// When inherited, enumerates the FontFamily objects in a collection of fonts.
- ///
- public abstract class FontCollection : IDisposable
- {
- internal IntPtr _nativeFontCollection;
-
- internal FontCollection() => _nativeFontCollection = IntPtr.Zero;
-
- ///
- /// Disposes of this
- ///
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing) { }
-
- ///
- /// Gets the array of objects associated
- /// with this .
- ///
- public FontFamily[] Families
- {
- get
- {
- int numSought;
- int status = Gdip.GdipGetFontCollectionFamilyCount(new HandleRef(this, _nativeFontCollection), out numSought);
- Gdip.CheckStatus(status);
-
- var gpfamilies = new IntPtr[numSought];
- int numFound;
- status = Gdip.GdipGetFontCollectionFamilyList(new HandleRef(this, _nativeFontCollection), numSought, gpfamilies,
- out numFound);
- Gdip.CheckStatus(status);
-
- Debug.Assert(numSought == numFound, "GDI+ can't give a straight answer about how many fonts there are");
- var families = new FontFamily[numFound];
- for (int f = 0; f < numFound; f++)
- {
- IntPtr native;
- Gdip.GdipCloneFontFamily(gpfamilies[f], out native);
- families[f] = new FontFamily(native);
- }
-
- return families;
- }
- }
-
- ~FontCollection() => Dispose(false);
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/GenericFontFamilies.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/GenericFontFamilies.cs
deleted file mode 100644
index 5b142ec1d2a17..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/GenericFontFamilies.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Text
-{
- ///
- /// Specifies a generic .
- ///
- public enum GenericFontFamilies
- {
- ///
- /// A generic Serif .
- ///
- Serif,
-
- ///
- /// A generic SansSerif .
- ///
- SansSerif,
-
- ///
- /// A generic Monospace .
- ///
- Monospace
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/HotkeyPrefix.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/HotkeyPrefix.cs
deleted file mode 100644
index b066a36946ee4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/HotkeyPrefix.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Text
-{
- ///
- /// Specifies the type of display for hotkey prefixes for text.
- ///
- public enum HotkeyPrefix
- {
- ///
- /// No hotkey prefix.
- ///
- None = 0,
-
- ///
- /// Display the hotkey prefix.
- ///
- Show = 1,
-
- ///
- /// Do not display the hotkey prefix.
- ///
- Hide = 2
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/InstalledFontCollection.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/InstalledFontCollection.cs
deleted file mode 100644
index 85bf4682d9d45..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/InstalledFontCollection.cs
+++ /dev/null
@@ -1,21 +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 Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Text
-{
- ///
- /// Represents the fonts installed on the system.
- ///
- public sealed class InstalledFontCollection : FontCollection
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public InstalledFontCollection() : base()
- {
- int status = Gdip.GdipNewInstalledFontCollection(out _nativeFontCollection);
- Gdip.CheckStatus(status);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/PrivateFontCollection.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/PrivateFontCollection.cs
deleted file mode 100644
index 6d61b4e5af593..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/PrivateFontCollection.cs
+++ /dev/null
@@ -1,102 +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.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Globalization;
-using System.IO;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing.Text
-{
- ///
- /// Encapsulates a collection of objects.
- ///
- public sealed class PrivateFontCollection : FontCollection
- {
- ///
- /// Initializes a new instance of the class.
- ///
- public PrivateFontCollection() : base()
- {
- int status = Gdip.GdipNewPrivateFontCollection(out _nativeFontCollection);
- Gdip.CheckStatus(status);
- }
-
- ///
- /// Cleans up Windows resources for this .
- ///
- protected override void Dispose(bool disposing)
- {
- if (_nativeFontCollection != IntPtr.Zero)
- {
- try
- {
-#if DEBUG
- int status = !Gdip.Initialized ? Gdip.Ok :
-#endif
- Gdip.GdipDeletePrivateFontCollection(ref _nativeFontCollection);
-#if DEBUG
- Debug.Assert(status == Gdip.Ok, $"GDI+ returned an error status: {status.ToString(CultureInfo.InvariantCulture)}");
-#endif
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- }
- finally
- {
- _nativeFontCollection = IntPtr.Zero;
- }
- }
-
- base.Dispose(disposing);
- }
-
- ///
- /// Adds a font from the specified file to this .
- ///
- public void AddFontFile(string filename)
- {
- if (_nativeFontCollection == IntPtr.Zero)
- {
-#pragma warning disable CA2208 // Instantiate argument exceptions correctly
- // This is the default behavior on Desktop. The ArgumentException originates from GdipPrivateAddFontFile which would
- // refuse the null pointer.
- throw new ArgumentException();
-#pragma warning restore CA2208
- }
-
- if (filename == null)
- {
- throw new ArgumentNullException(nameof(filename));
- }
-
- // this ensure the filename is valid (or throw the correct exception)
- string fullPath = Path.GetFullPath(filename);
-
- if (!File.Exists(fullPath))
- {
- throw new FileNotFoundException();
- }
-
- int status = Gdip.GdipPrivateAddFontFile(new HandleRef(this, _nativeFontCollection), fullPath);
- Gdip.CheckStatus(status);
-
- // Register private font with GDI as well so pure GDI-based controls (TextBox, Button for instance) can access it.
- GdiAddFontFile(filename);
- }
-
- ///
- /// Adds a font contained in system memory to this .
- ///
- public void AddMemoryFont(IntPtr memory, int length)
- {
- Gdip.CheckStatus(Gdip.GdipPrivateAddMemoryFont(new HandleRef(this, _nativeFontCollection), memory, length));
- }
-
- private static void GdiAddFontFile(string filename)
- {
- Interop.Gdi32.AddFontFile(filename);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/TextRenderingHint.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/Text/TextRenderingHint.cs
deleted file mode 100644
index 5f3b55934edab..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/Text/TextRenderingHint.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Text
-{
- ///
- /// Specifies the quality of text rendering.
- ///
- public enum TextRenderingHint
- {
- ///
- /// Glyph with system default rendering hint.
- ///
- SystemDefault = 0,
-
- ///
- /// Glyph bitmap with hinting.
- ///
- SingleBitPerPixelGridFit,
-
- ///
- /// Glyph bitmap without hinting.
- ///
- SingleBitPerPixel,
-
- ///
- /// Anti-aliasing with hinting.
- ///
- AntiAliasGridFit,
-
- ///
- /// Glyph anti-alias bitmap without hinting.
- ///
- AntiAlias,
-
- ///
- /// Glyph CT bitmap with hinting.
- ///
- ClearTypeGridFit
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/TextureBrush.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/TextureBrush.cs
deleted file mode 100644
index 4f7755ee4250d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/TextureBrush.cs
+++ /dev/null
@@ -1,255 +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.Runtime.InteropServices;
-using System.Diagnostics;
-using System.ComponentModel;
-using System.Drawing.Drawing2D;
-using System.Drawing.Imaging;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- public sealed class TextureBrush : Brush
- {
- // When creating a texture brush from a metafile image, the dstRect
- // is used to specify the size that the metafile image should be
- // rendered at in the device units of the destination graphics.
- // It is NOT used to crop the metafile image, so only the width
- // and height values matter for metafiles.
-
- public TextureBrush(Image bitmap) : this(bitmap, WrapMode.Tile)
- {
- }
-
- public TextureBrush(Image image, WrapMode wrapMode)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- if (wrapMode < WrapMode.Tile || wrapMode > WrapMode.Clamp)
- {
- throw new InvalidEnumArgumentException(nameof(wrapMode), unchecked((int)wrapMode), typeof(WrapMode));
- }
-
- IntPtr brush;
- int status = Gdip.GdipCreateTexture(new HandleRef(image, image.nativeImage),
- (int)wrapMode,
- out brush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(brush);
- }
-
- public TextureBrush(Image image, WrapMode wrapMode, RectangleF dstRect)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- if (wrapMode < WrapMode.Tile || wrapMode > WrapMode.Clamp)
- {
- throw new InvalidEnumArgumentException(nameof(wrapMode), unchecked((int)wrapMode), typeof(WrapMode));
- }
-
- IntPtr brush;
- int status = Gdip.GdipCreateTexture2(new HandleRef(image, image.nativeImage),
- unchecked((int)wrapMode),
- dstRect.X,
- dstRect.Y,
- dstRect.Width,
- dstRect.Height,
- out brush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(brush);
- }
-
- public TextureBrush(Image image, WrapMode wrapMode, Rectangle dstRect)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- if (wrapMode < WrapMode.Tile || wrapMode > WrapMode.Clamp)
- {
- throw new InvalidEnumArgumentException(nameof(wrapMode), unchecked((int)wrapMode), typeof(WrapMode));
- }
-
- IntPtr brush;
- int status = Gdip.GdipCreateTexture2I(new HandleRef(image, image.nativeImage),
- unchecked((int)wrapMode),
- dstRect.X,
- dstRect.Y,
- dstRect.Width,
- dstRect.Height,
- out brush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(brush);
- }
-
- public TextureBrush(Image image, RectangleF dstRect) : this(image, dstRect, null) { }
-
- public TextureBrush(Image image, RectangleF dstRect, ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- IntPtr brush;
- int status = Gdip.GdipCreateTextureIA(new HandleRef(image, image.nativeImage),
- new HandleRef(imageAttr, (imageAttr == null) ?
- IntPtr.Zero : imageAttr.nativeImageAttributes),
- dstRect.X,
- dstRect.Y,
- dstRect.Width,
- dstRect.Height,
- out brush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(brush);
- }
-
- public TextureBrush(Image image, Rectangle dstRect) : this(image, dstRect, null) { }
-
- public TextureBrush(Image image, Rectangle dstRect, ImageAttributes? imageAttr)
- {
- ArgumentNullException.ThrowIfNull(image);
-
- IntPtr brush;
- int status = Gdip.GdipCreateTextureIAI(new HandleRef(image, image.nativeImage),
- new HandleRef(imageAttr, (imageAttr == null) ?
- IntPtr.Zero : imageAttr.nativeImageAttributes),
- dstRect.X,
- dstRect.Y,
- dstRect.Width,
- dstRect.Height,
- out brush);
- Gdip.CheckStatus(status);
-
- SetNativeBrushInternal(brush);
- }
-
- internal TextureBrush(IntPtr nativeBrush)
- {
- Debug.Assert(nativeBrush != IntPtr.Zero, "Initializing native brush with null.");
- SetNativeBrushInternal(nativeBrush);
- }
-
- public override object Clone()
- {
- IntPtr cloneBrush;
- int status = Gdip.GdipCloneBrush(new HandleRef(this, NativeBrush), out cloneBrush);
- Gdip.CheckStatus(status);
-
- return new TextureBrush(cloneBrush);
- }
-
- public Matrix Transform
- {
- get
- {
- var matrix = new Matrix();
- int status = Gdip.GdipGetTextureTransform(new HandleRef(this, NativeBrush), new HandleRef(matrix, matrix.NativeMatrix));
- Gdip.CheckStatus(status);
-
- return matrix;
- }
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException(nameof(value));
- }
-
- int status = Gdip.GdipSetTextureTransform(new HandleRef(this, NativeBrush), new HandleRef(value, value.NativeMatrix));
- Gdip.CheckStatus(status);
- }
- }
-
- public WrapMode WrapMode
- {
- get
- {
- int mode;
- int status = Gdip.GdipGetTextureWrapMode(new HandleRef(this, NativeBrush), out mode);
- Gdip.CheckStatus(status);
-
- return (WrapMode)mode;
- }
- set
- {
- if (value < WrapMode.Tile || value > WrapMode.Clamp)
- {
- throw new InvalidEnumArgumentException(nameof(value), unchecked((int)value), typeof(WrapMode));
- }
-
- int status = Gdip.GdipSetTextureWrapMode(new HandleRef(this, NativeBrush), unchecked((int)value));
- Gdip.CheckStatus(status);
- }
- }
-
- public Image Image
- {
- get
- {
- IntPtr image;
- int status = Gdip.GdipGetTextureImage(new HandleRef(this, NativeBrush), out image);
- Gdip.CheckStatus(status);
-
- return Image.CreateImageObject(image);
- }
- }
-
- public void ResetTransform()
- {
- int status = Gdip.GdipResetTextureTransform(new HandleRef(this, NativeBrush));
- Gdip.CheckStatus(status);
- }
-
- public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);
-
- public void MultiplyTransform(Matrix matrix, MatrixOrder order)
- {
- ArgumentNullException.ThrowIfNull(matrix);
-
- // Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
- // with the libgdiplus backend. Simulate a nop for compatibility with GDI+.
- if (matrix.NativeMatrix == IntPtr.Zero)
- {
- return;
- }
-
- int status = Gdip.GdipMultiplyTextureTransform(new HandleRef(this, NativeBrush),
- new HandleRef(matrix, matrix.NativeMatrix),
- order);
- Gdip.CheckStatus(status);
- }
-
- public void TranslateTransform(float dx, float dy) => TranslateTransform(dx, dy, MatrixOrder.Prepend);
-
- public void TranslateTransform(float dx, float dy, MatrixOrder order)
- {
- int status = Gdip.GdipTranslateTextureTransform(new HandleRef(this, NativeBrush),
- dx,
- dy,
- order);
- Gdip.CheckStatus(status);
- }
-
- public void ScaleTransform(float sx, float sy) => ScaleTransform(sx, sy, MatrixOrder.Prepend);
-
- public void ScaleTransform(float sx, float sy, MatrixOrder order)
- {
- int status = Gdip.GdipScaleTextureTransform(new HandleRef(this, NativeBrush),
- sx,
- sy,
- order);
- Gdip.CheckStatus(status);
- }
-
- public void RotateTransform(float angle) => RotateTransform(angle, MatrixOrder.Prepend);
-
- public void RotateTransform(float angle, MatrixOrder order)
- {
- int status = Gdip.GdipRotateTextureTransform(new HandleRef(this, NativeBrush),
- angle,
- order);
- Gdip.CheckStatus(status);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs
deleted file mode 100644
index 51206af735372..0000000000000
--- a/src/libraries/System.Drawing.Common/src/System/Drawing/ToolboxBitmapAttribute.cs
+++ /dev/null
@@ -1,332 +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.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing.Imaging;
-using System.IO;
-using DpiHelper = System.Windows.Forms.DpiHelper;
-using Gdip = System.Drawing.SafeNativeMethods.Gdip;
-
-namespace System.Drawing
-{
- ///
- /// ToolboxBitmapAttribute defines the images associated with a specified component.
- /// The component can offer a small and large image (large is optional).
- ///
- [AttributeUsage(AttributeTargets.Class)]
- public class ToolboxBitmapAttribute : Attribute
- {
- private Image? _smallImage;
- private Image? _largeImage;
-
- private readonly string? _imageFile;
- private readonly Type? _imageType;
-
- private readonly string? _imageName;
-
- private static readonly Size s_largeSize = new Size(32, 32);
- private static readonly Size s_smallSize = new Size(16, 16);
-
- public ToolboxBitmapAttribute(string imageFile) : this(GetImageFromFile(imageFile, false), GetImageFromFile(imageFile, true))
- {
- _imageFile = imageFile;
- }
-
- public ToolboxBitmapAttribute(Type t) : this(GetImageFromResource(t, null, false), GetImageFromResource(t, null, true))
- {
- _imageType = t;
- }
-
- public ToolboxBitmapAttribute(Type t, string name)
- : this(GetImageFromResource(t, name, false), GetImageFromResource(t, name, true))
- {
- _imageType = t;
- _imageName = name;
- }
-
- private ToolboxBitmapAttribute(Image? smallImage, Image? largeImage)
- {
- _smallImage = smallImage;
- _largeImage = largeImage;
- }
-
- public override bool Equals([NotNullWhen(true)] object? value)
- {
- if (value == this)
- {
- return true;
- }
-
- if (value is ToolboxBitmapAttribute attr)
- {
- return attr._smallImage == _smallImage && attr._largeImage == _largeImage;
- }
-
- return false;
- }
-
- public override int GetHashCode() => base.GetHashCode();
-
- public Image? GetImage(object? component) => GetImage(component, true);
-
- public Image? GetImage(object? component, bool large)
- {
- if (component != null)
- {
- return GetImage(component.GetType(), large);
- }
-
- return null;
- }
-
- public Image? GetImage(Type type) => GetImage(type, false);
-
- public Image? GetImage(Type type, bool large) => GetImage(type, null, large);
-
- public Image? GetImage(Type type, string? imgName, bool large)
- {
- if ((large && _largeImage == null) || (!large && _smallImage == null))
- {
- Image? img = large ? _largeImage : _smallImage;
- img ??= GetImageFromResource(type, imgName, large);
-
- // last resort for large images.
- if (large && _largeImage == null && _smallImage != null)
- {
- img = new Bitmap((Bitmap)_smallImage, s_largeSize.Width, s_largeSize.Height);
- }
-
- if (img is Bitmap b)
- {
- MakeBackgroundAlphaZero(b);
- }
-
- if (img == null)
- {
- img = s_defaultComponent.GetImage(type, large);
-
- // We don't want to hand out the static shared image
- // because otherwise it might get disposed.
- if (img != null)
- {
- img = (Image)img.Clone();
- }
- }
-
- if (large)
- {
- _largeImage = img;
- }
- else
- {
- _smallImage = img;
- }
- }
-
- Image? toReturn = (large) ? _largeImage : _smallImage;
-
- if (Equals(Default))
- {
- _largeImage = null;
- _smallImage = null;
- }
-
- return toReturn;
- }
-
- // Helper to get the right icon from the given stream that represents an icon.
- private static Bitmap? GetIconFromStream(Stream? stream, bool large, bool scaled)
- {
- if (stream == null)
- {
- return null;
- }
- Icon ico = new Icon(stream);
- Icon sizedico = new Icon(ico, large ? s_largeSize : s_smallSize);
- Bitmap? b = sizedico.ToBitmap();
- if (DpiHelper.IsScalingRequired && scaled)
- {
- DpiHelper.ScaleBitmapLogicalToDevice(ref b);
- }
- return b;
- }
-
- // Just forwards to Image.FromFile eating any non-critical exceptions that may result.
- private static Image? GetImageFromFile(string? imageFile, bool large, bool scaled = true)
- {
- Image? image = null;
- try
- {
- if (imageFile != null)
- {
- string? ext = Path.GetExtension(imageFile);
- if (ext != null && string.Equals(ext, ".ico", StringComparison.OrdinalIgnoreCase))
- {
- //ico files support both large and small, so we respect the large flag here.
- using (FileStream reader = File.OpenRead(imageFile!))
- {
- image = GetIconFromStream(reader, large, scaled);
- }
- }
- else if (!large)
- {
- //we only read small from non-ico files.
- image = Image.FromFile(imageFile!);
- Bitmap? b = image as Bitmap;
- if (DpiHelper.IsScalingRequired && scaled)
- {
- DpiHelper.ScaleBitmapLogicalToDevice(ref b);
- }
- }
- }
- }
- catch (Exception e) when (!ClientUtils.IsCriticalException(e))
- {
- }
-
- return image;
- }
-
- private static Image? GetBitmapFromResource(Type t, string? bitmapname, bool large, bool scaled)
- {
- if (bitmapname == null)
- {
- return null;
- }
-
- Image? img = null;
-
- // Load the image from the manifest resources.
- Stream? stream = BitmapSelector.GetResourceStream(t, bitmapname);
- if (stream != null)
- {
- Bitmap? b = new Bitmap(stream);
- img = b;
- MakeBackgroundAlphaZero(b);
- if (large)
- {
- img = new Bitmap(b, s_largeSize.Width, s_largeSize.Height);
- }
- if (DpiHelper.IsScalingRequired && scaled)
- {
- b = (Bitmap)img;
- DpiHelper.ScaleBitmapLogicalToDevice(ref b);
- img = b;
- }
- }
- return img;
- }
-
- private static Bitmap? GetIconFromResource(Type t, string? bitmapname, bool large, bool scaled)
- {
- if (bitmapname == null)
- {
- return null;
- }
-
- return GetIconFromStream(BitmapSelector.GetResourceStream(t, bitmapname), large, scaled);
- }
-
- public static Image? GetImageFromResource(Type t, string? imageName, bool large)
- {
- return GetImageFromResource(t, imageName, large, scaled: true);
- }
-
- internal static Image? GetImageFromResource(Type t, string? imageName, bool large, bool scaled)
- {
- Image? img = null;
- try
- {
- string? name = imageName;
- string? iconname = null;
- string? bmpname = null;
- string? rawbmpname = null;
-
- // If we didn't get a name, use the class name
- if (name == null)
- {
- name = t.FullName!;
- int indexDot = name.LastIndexOf('.');
- if (indexDot != -1)
- {
- name = name.Substring(indexDot + 1);
- }
-
- // All bitmap images from winforms runtime are changed to Icons
- // and logical names, now, does not contain any extension.
- rawbmpname = name;
- iconname = name + ".ico";
- bmpname = name + ".bmp";
- }
- else
- {
- if (string.Equals(Path.GetExtension(imageName), ".ico", StringComparison.CurrentCultureIgnoreCase))
- {
- iconname = name;
- }
- else if (string.Equals(Path.GetExtension(imageName), ".bmp", StringComparison.CurrentCultureIgnoreCase))
- {
- bmpname = name;
- }
- else
- {
- // We don't recognize the name as either bmp or ico. we need to try three things.
- // 1. the name as a bitmap (back compat)
- // 2. name+.bmp
- // 3. name+.ico
- rawbmpname = name;
- bmpname = name + ".bmp";
- iconname = name + ".ico";
- }
- }
- if (rawbmpname != null)
- {
- img = GetBitmapFromResource(t, rawbmpname, large, scaled);
- }
- if (img == null && bmpname != null)
- {
- img = GetBitmapFromResource(t, bmpname, large, scaled);
- }
- if (img == null && iconname != null)
- {
- img = GetIconFromResource(t, iconname, large, scaled);
- }
- }
- catch (Exception) { }
- return img;
- }
-
- private static void MakeBackgroundAlphaZero(Bitmap img)
- {
- // Bitmap derived from Icon is already transparent.
- if (img.RawFormat.Guid == ImageFormat.Icon.Guid)
- return;
-
- Color bottomLeft = img.GetPixel(0, img.Height - 1);
- img.MakeTransparent();
-
- Color newBottomLeft = Color.FromArgb(0, bottomLeft);
- img.SetPixel(0, img.Height - 1, newBottomLeft);
- }
-
- public static readonly ToolboxBitmapAttribute Default = new ToolboxBitmapAttribute(null, (Image?)null);
-
- private static readonly ToolboxBitmapAttribute s_defaultComponent;
-
-#pragma warning disable CA1810 // DummyFunction apparently needs to be invoked prior to the rest of the initialization
- static ToolboxBitmapAttribute()
- {
- // When we call Gdip.DummyFunction, JIT will make sure Gdip..cctor will be called.
- Gdip.DummyFunction();
-
- Stream? stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp");
- Debug.Assert(stream != null, "DefaultComponent.bmp must be present as an embedded resource.");
-
- var bitmap = new Bitmap(stream);
- MakeBackgroundAlphaZero(bitmap);
- s_defaultComponent = new ToolboxBitmapAttribute(bitmap, null);
- }
-#pragma warning restore CA1810
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/DbgUtil.cs b/src/libraries/System.Drawing.Common/src/misc/DbgUtil.cs
deleted file mode 100644
index 7fcbc938436ba..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/DbgUtil.cs
+++ /dev/null
@@ -1,63 +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.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-
-namespace System.Drawing.Internal
-{
- internal sealed class DbgUtil
- {
- ///
- /// Call this method from your Dispose(bool) to assert that unmanaged resources has been explicitly disposed.
- ///
- [Conditional("DEBUG")]
- public static void AssertFinalization(object obj, bool disposing)
- {
-#if GDI_FINALIZATION_WATCH
- if ( disposing || AppDomain.CurrentDomain.IsFinalizingForUnload() )
- {
- return;
- }
-
- try
- {
- BindingFlags bindingFlags = BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance;
- FieldInfo allocSiteFld = obj.GetType().GetField("AllocationSite", bindingFlags);
- string allocationSite = allocSiteFld != null ? allocSiteFld.GetValue( obj ).ToString() : "";
-
- // ignore ojects created by WindowsGraphicsCacheManager.
- if ( allocationSite.Contains("WindowsGraphicsCacheManager") )
- {
- return;
- }
-
- Debug.Fail("Object Disposed through finalization - it should be explicitly disposed.");
- Debug.WriteLine("Allocation stack:\r\n" + allocationSite);
- }
- catch (Exception ex)
- {
- try
- {
- Debug.WriteLine("Exception thrown while trying to get allocation stack: " + ex);
- }
- catch
- {
- }
- }
-#endif
- }
-
- [Conditional("DEBUG")]
- public static void AssertWin32(bool expression, string format, params object[] args)
- {
- if (!expression)
- {
- var e = new Win32Exception();
- string message = string.Format(CultureInfo.CurrentCulture, format, args);
- Debug.Fail($"{message}\r\nError: 0x{e.NativeErrorCode:x8} - {e.Message}");
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs b/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs
deleted file mode 100644
index 20c441a2df50d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/DpiHelper.cs
+++ /dev/null
@@ -1,229 +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.Configuration;
-using System.Diagnostics.CodeAnalysis;
-using System.Drawing;
-using System.Drawing.Drawing2D;
-using System.Runtime.InteropServices;
-
-namespace System.Windows.Forms
-{
- ///
- /// Helper class for scaling coordinates and images according to current DPI scaling set in Windows for the primary screen.
- ///
- internal static class DpiHelper
- {
- private const double LogicalDpi = 96.0;
- private static bool s_isInitialized;
- ///
- /// The primary screen's (device) current horizontal DPI
- ///
- private static double s_deviceDpiX = LogicalDpi;
-
- ///
- /// The primary screen's (device) current vertical DPI
- ///
- private static double s_deviceDpiY = LogicalDpi;
-
- private static double s_logicalToDeviceUnitsScalingFactorX;
- private static double s_logicalToDeviceUnitsScalingFactorY;
- private static InterpolationMode s_interpolationMode = InterpolationMode.Invalid;
-
- private static void Initialize()
- {
- if (s_isInitialized)
- {
- return;
- }
-
- IntPtr hDC = Interop.User32.GetDC(IntPtr.Zero);
- if (hDC != IntPtr.Zero)
- {
- s_deviceDpiX = Interop.Gdi32.GetDeviceCaps(hDC, Interop.Gdi32.DeviceCapability.LOGPIXELSX);
- s_deviceDpiY = Interop.Gdi32.GetDeviceCaps(hDC, Interop.Gdi32.DeviceCapability.LOGPIXELSY);
-
- Interop.User32.ReleaseDC(IntPtr.Zero, hDC);
- }
-
- s_isInitialized = true;
- }
-
- private static double LogicalToDeviceUnitsScalingFactorX
- {
- get
- {
- if (s_logicalToDeviceUnitsScalingFactorX == 0.0)
- {
- Initialize();
- s_logicalToDeviceUnitsScalingFactorX = s_deviceDpiX / LogicalDpi;
- }
-
- return s_logicalToDeviceUnitsScalingFactorX;
- }
- }
-
- private static double LogicalToDeviceUnitsScalingFactorY
- {
- get
- {
- if (s_logicalToDeviceUnitsScalingFactorY == 0.0)
- {
- Initialize();
- s_logicalToDeviceUnitsScalingFactorY = s_deviceDpiY / LogicalDpi;
- }
-
- return s_logicalToDeviceUnitsScalingFactorY;
- }
- }
-
- private static InterpolationMode InterpolationMode
- {
- get
- {
- if (s_interpolationMode == InterpolationMode.Invalid)
- {
- int dpiScalePercent = (int)Math.Round(LogicalToDeviceUnitsScalingFactorX * 100);
-
- // We will prefer NearestNeighbor algorithm for 200, 300, 400, etc zoom factors, in which each pixel become a 2x2, 3x3, 4x4, etc rectangle.
- // This produces sharp edges in the scaled image and doesn't cause distorsions of the original image.
- // For any other scale factors we will prefer a high quality resizing algorithm. While that introduces fuzziness in the resulting image,
- // it will not distort the original (which is extremely important for small zoom factors like 125%, 150%).
- // We'll use Bicubic in those cases, except on reducing (zoom < 100, which we shouldn't have anyway), in which case Linear produces better
- // results because it uses less neighboring pixels.
- if ((dpiScalePercent % 100) == 0)
- {
- s_interpolationMode = InterpolationMode.NearestNeighbor;
- }
- else if (dpiScalePercent < 100)
- {
- s_interpolationMode = InterpolationMode.HighQualityBilinear;
- }
- else
- {
- s_interpolationMode = InterpolationMode.HighQualityBicubic;
- }
- }
- return s_interpolationMode;
- }
- }
-
- private static Bitmap ScaleBitmapToSize(Bitmap logicalImage, Size deviceImageSize)
- {
- Bitmap deviceImage = new Bitmap(deviceImageSize.Width, deviceImageSize.Height, logicalImage.PixelFormat);
-
- using (Graphics graphics = Graphics.FromImage(deviceImage))
- {
- graphics.InterpolationMode = InterpolationMode;
-
- RectangleF sourceRect = new RectangleF(0, 0, logicalImage.Size.Width, logicalImage.Size.Height);
- RectangleF destRect = new RectangleF(0, 0, deviceImageSize.Width, deviceImageSize.Height);
-
- // Specify a source rectangle shifted by half of pixel to account for GDI+ considering the source origin the center of top-left pixel
- // Failing to do so will result in the right and bottom of the bitmap lines being interpolated with the graphics' background color,
- // and will appear black even if we cleared the background with transparent color.
- // The apparition of these artifacts depends on the interpolation mode, on the dpi scaling factor, etc.
- // E.g. at 150% DPI, Bicubic produces them and NearestNeighbor is fine, but at 200% DPI NearestNeighbor also shows them.
- sourceRect.Offset(-0.5f, -0.5f);
-
- graphics.DrawImage(logicalImage, destRect, sourceRect, GraphicsUnit.Pixel);
- }
-
- return deviceImage;
- }
-
- private static Bitmap CreateScaledBitmap(Bitmap logicalImage)
- {
- Size deviceImageSize = LogicalToDeviceUnits(logicalImage.Size);
- return ScaleBitmapToSize(logicalImage, deviceImageSize);
- }
-
- ///
- /// Returns whether scaling is required when converting between logical-device units,
- /// if the application opted in the automatic scaling in the .config file.
- ///
- public static bool IsScalingRequired
- {
- get
- {
- Initialize();
- return s_deviceDpiX != LogicalDpi || s_deviceDpiY != LogicalDpi;
- }
- }
-
- ///
- /// Transforms a horizontal integer coordinate from logical to device units
- /// by scaling it up for current DPI and rounding to nearest integer value
- /// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
- ///
- /// The horizontal value in logical units
- /// The horizontal value in device units
- public static int LogicalToDeviceUnitsX(int value)
- {
- return (int)Math.Round(LogicalToDeviceUnitsScalingFactorX * (double)value);
- }
-
- ///
- /// Transforms a vertical integer coordinate from logical to device units
- /// by scaling it up for current DPI and rounding to nearest integer value
- /// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
- ///
- /// The vertical value in logical units
- /// The vertical value in device units
- public static int LogicalToDeviceUnitsY(int value)
- {
- return (int)Math.Round(LogicalToDeviceUnitsScalingFactorY * (double)value);
- }
-
- ///
- /// Returns a new Size with the input's
- /// dimensions converted from logical units to device units.
- /// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
- ///
- /// Size in logical units
- /// Size in device units
- public static Size LogicalToDeviceUnits(Size logicalSize)
- {
- return new Size(LogicalToDeviceUnitsX(logicalSize.Width),
- LogicalToDeviceUnitsY(logicalSize.Height));
- }
-
- ///
- /// Create and return a new bitmap scaled to the specified size.
- /// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
- ///
- /// The image to scale from logical units to device units
- /// The size to scale image to
- [return: NotNullIfNotNull(nameof(logicalImage))]
- public static Bitmap? CreateResizedBitmap(Bitmap? logicalImage, Size targetImageSize)
- {
- if (logicalImage == null)
- {
- return null;
- }
-
- return ScaleBitmapToSize(logicalImage, targetImageSize);
- }
-
- ///
- /// Create a new bitmap scaled for the device units.
- /// When displayed on the device, the scaled image will have same size as the original image would have when displayed at 96dpi.
- /// Note: this method should be called only inside an if (DpiHelper.IsScalingRequired) clause
- ///
- /// The image to scale from logical units to device units
- public static void ScaleBitmapLogicalToDevice([NotNullIfNotNull(nameof(logicalBitmap))]ref Bitmap? logicalBitmap)
- {
- if (logicalBitmap == null)
- {
- return;
- }
-
- Bitmap deviceBitmap = CreateScaledBitmap(logicalBitmap);
- if (deviceBitmap != null)
- {
- logicalBitmap.Dispose();
- logicalBitmap = deviceBitmap;
- }
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/ApplyGraphicsProperties.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/ApplyGraphicsProperties.cs
deleted file mode 100644
index 0be6abb95692d..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/ApplyGraphicsProperties.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Internal
-{
- ///
- /// Enumeration defining the different Graphics properties to apply to a WindowsGraphics when creating it from a
- /// Graphics object.
- ///
- [Flags]
- internal enum ApplyGraphicsProperties
- {
- // No properties to be applied to the DC obtained from the Graphics object.
- None = 0x00000000,
- // Apply clipping region.
- Clipping = 0x00000001,
- // Apply coordinate transformation.
- TranslateTransform = 0x00000002,
- // Apply all supported Graphics properties.
- All = Clipping | TranslateTransform
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs
deleted file mode 100644
index 707e0ac85123a..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContext.cs
+++ /dev/null
@@ -1,350 +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.Collections;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Internal
-{
- ///
- /// Represents a Win32 device context. Provides operations for setting some of the properties of a device context.
- /// It's the managed wrapper for an HDC.
- ///
- /// This class is divided into two files separating the code that needs to be compiled into retail builds and
- /// debugging code.
- ///
- internal sealed partial class DeviceContext : MarshalByRefObject, IDisposable
- {
- ///
- /// This class is a wrapper to a Win32 device context, and the Hdc property is the way to get a
- /// handle to it.
- ///
- /// The hDc is released/deleted only when owned by the object, meaning it was created internally;
- /// in this case, the object is responsible for releasing/deleting it.
- /// In the case the object is created from an existing hdc, it is not released; this is consistent
- /// with the Win32 guideline that says if you call GetDC/CreateDC/CreatIC/CreateEnhMetafile, you are
- /// responsible for calling ReleaseDC/DeleteDC/DeleteEnhMetafile respectively.
- ///
- /// This class implements some of the operations commonly performed on the properties of a dc in WinForms,
- /// specially for interacting with GDI+, like clipping and coordinate transformation.
- /// Several properties are not persisted in the dc but instead they are set/reset during a more comprehensive
- /// operation like text rendering or painting; for instance text alignment is set and reset during DrawText (GDI),
- /// DrawString (GDI+).
- ///
- /// Other properties are persisted from operation to operation until they are reset, like clipping,
- /// one can make several calls to Graphics or WindowsGraphics object after setting the dc clip area and
- /// before resetting it; these kinds of properties are the ones implemented in this class.
- /// This kind of properties place an extra challenge in the scenario where a DeviceContext is obtained
- /// from a Graphics object that has been used with GDI+, because GDI+ saves the hdc internally, rendering the
- /// DeviceContext underlying hdc out of sync. DeviceContext needs to support these kind of properties to
- /// be able to keep the GDI+ and GDI HDCs in sync.
- ///
- /// A few other persisting properties have been implemented in DeviceContext2, among them:
- /// 1. Window origin.
- /// 2. Bounding rectangle.
- /// 3. DC origin.
- /// 4. View port extent.
- /// 5. View port origin.
- /// 6. Window extent
- ///
- /// Other non-persisted properties just for information: Background/Foreground color, Palette, Color adjustment,
- /// Color space, ICM mode and profile, Current pen position, Binary raster op (not supported by GDI+),
- /// Background mode, Logical Pen, DC pen color, ARc direction, Miter limit, Logical brush, DC brush color,
- /// Brush origin, Polygon filling mode, Bitmap stretching mode, Logical font, Intercharacter spacing,
- /// Font mapper flags, Text alignment, Test justification, Layout, Path, Meta region.
- /// See book "Windows Graphics Programming - Feng Yuang", P315 - Device Context Attributes.
- ///
-
- private IntPtr _hDC;
- private readonly DeviceContextType _dcType;
-
- public event EventHandler? Disposing;
-
- private bool _disposed;
-
- private IntPtr _hInitialPen;
- private IntPtr _hInitialBrush;
- private IntPtr _hInitialBmp;
- private IntPtr _hInitialFont;
-
- private IntPtr _hCurrentPen;
- private IntPtr _hCurrentBrush;
- private IntPtr _hCurrentBmp;
- private IntPtr _hCurrentFont;
-
- private Stack? _contextStack;
-
-#if GDI_FINALIZATION_WATCH
- private string AllocationSite = DbgUtil.StackTrace;
- private string DeAllocationSite = "";
-#endif
-
- ///
- /// This object's hdc. If this property is called, then the object will be used as an HDC wrapper, so the hdc
- /// is cached and calls to GetHdc/ReleaseHdc won't PInvoke into GDI. Call Dispose to properly release the hdc.
- ///
- public IntPtr Hdc => _hDC;
-
- // Due to a problem with calling DeleteObject() on currently selected GDI objects, we now track the initial set
- // of objects when a DeviceContext is created. Then, we also track which objects are currently selected in the
- // DeviceContext. When a currently selected object is disposed, it is first replaced in the DC and then deleted.
- private void CacheInitialState()
- {
- Debug.Assert(_hDC != IntPtr.Zero, "Cannot get initial state without a valid HDC");
- _hCurrentPen = _hInitialPen = Interop.Gdi32.GetCurrentObject(new HandleRef(this, _hDC), Interop.Gdi32.ObjectType.OBJ_PEN);
- _hCurrentBrush = _hInitialBrush = Interop.Gdi32.GetCurrentObject(new HandleRef(this, _hDC), Interop.Gdi32.ObjectType.OBJ_BRUSH);
- _hCurrentBmp = _hInitialBmp = Interop.Gdi32.GetCurrentObject(new HandleRef(this, _hDC), Interop.Gdi32.ObjectType.OBJ_BITMAP);
- _hCurrentFont = _hInitialFont = Interop.Gdi32.GetCurrentObject(new HandleRef(this, _hDC), Interop.Gdi32.ObjectType.OBJ_FONT);
- }
-
- ///
- /// Constructor to construct a DeviceContext object from an existing Win32 device context handle.
- ///
- private DeviceContext(IntPtr hDC, DeviceContextType dcType)
- {
- _hDC = hDC;
- _dcType = dcType;
-
- CacheInitialState();
- DeviceContexts.AddDeviceContext(this);
-
-#if TRACK_HDC
- Debug.WriteLine(DbgUtil.StackTraceToStr($"DeviceContext(hDC=0x{(int)hDC:X8}, Type={dcType})"));
-#endif
- }
-
- ///
- /// CreateDC creates a DeviceContext object wrapping an hdc created with the Win32 CreateDC function.
- ///
- public static DeviceContext CreateDC(string driverName, string deviceName, string? fileName, IntPtr devMode)
- {
- // Note: All input params can be null but not at the same time. See MSDN for information.
- IntPtr hdc = Interop.Gdi32.CreateDCW(driverName, deviceName, fileName, devMode);
- return new DeviceContext(hdc, DeviceContextType.NamedDevice);
- }
-
- ///
- /// CreateIC creates a DeviceContext object wrapping an hdc created with the Win32 CreateIC function.
- ///
- public static DeviceContext CreateIC(string driverName, string deviceName, string? fileName, IntPtr devMode)
- {
- // Note: All input params can be null but not at the same time. See MSDN for information.
-
- IntPtr hdc = Interop.Gdi32.CreateICW(driverName, deviceName, fileName, devMode);
- return new DeviceContext(hdc, DeviceContextType.Information);
- }
-
- ///
- /// Used for wrapping an existing hdc. In this case, this object doesn't own the hdc so calls to
- /// GetHdc/ReleaseHdc don't PInvoke into GDI.
- ///
- public static DeviceContext FromHdc(IntPtr hdc)
- {
- Debug.Assert(hdc != IntPtr.Zero, "hdc == 0");
- return new DeviceContext(hdc, DeviceContextType.Unknown);
- }
-
- ~DeviceContext() => Dispose(false);
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- internal void Dispose(bool disposing)
- {
- if (_disposed)
- {
- return;
- }
-
- Disposing?.Invoke(this, EventArgs.Empty);
-
- _disposed = true;
-
- switch (_dcType)
- {
- case DeviceContextType.Information:
- case DeviceContextType.NamedDevice:
- Interop.Gdi32.DeleteDC(new HandleRef(this, _hDC));
- _hDC = IntPtr.Zero;
- break;
- case DeviceContextType.Memory:
- Interop.Gdi32.DeleteDC(new HandleRef(this, _hDC));
- _hDC = IntPtr.Zero;
- break;
- // case DeviceContextType.Metafile: - not yet supported.
- case DeviceContextType.Unknown:
- default:
- return;
- // do nothing, the hdc is not owned by this object.
- // in this case it is ok if disposed through finalization.
- }
-
- DbgUtil.AssertFinalization(this, disposing);
- }
-
- ///
- /// Restores the device context to the specified state. The DC is restored by popping state information off a
- /// stack created by earlier calls to the SaveHdc function.
- /// The stack can contain the state information for several instances of the DC. If the state specified by the
- /// specified parameter is not at the top of the stack, RestoreDC deletes all state information between the top
- /// of the stack and the specified instance.
- /// Specifies the saved state to be restored. If this parameter is positive, nSavedDC represents a specific
- /// instance of the state to be restored. If this parameter is negative, nSavedDC represents an instance relative
- /// to the current state. For example, -1 restores the most recently saved state.
- /// See MSDN for more info.
- ///
- public void RestoreHdc()
- {
-#if TRACK_HDC
- bool result =
-#endif
- // Note: Don't use the Hdc property here, it would force handle creation.
- Interop.Gdi32.RestoreDC(new HandleRef(this, _hDC), -1);
-#if TRACK_HDC
- // Note: Winforms may call this method during app exit at which point the DC may have been finalized already causing this assert to popup.
- Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("ret[0]=DC.RestoreHdc(hDc=0x{1:x8}, state={2})", result, unchecked((int) _hDC), restoreState) ));
-#endif
- Debug.Assert(_contextStack != null, "Someone is calling RestoreHdc() before SaveHdc()");
-
- if (_contextStack != null)
- {
- GraphicsState g = (GraphicsState)_contextStack.Pop()!;
-
- _hCurrentBmp = g.hBitmap;
- _hCurrentBrush = g.hBrush;
- _hCurrentPen = g.hPen;
- _hCurrentFont = g.hFont;
- }
-
-#if OPTIMIZED_MEASUREMENTDC
- // in this case, GDI will copy back the previously saved font into the DC.
- // we dont actually know what the font is in our measurement DC so
- // we need to clear it off.
- MeasurementDCInfo.ResetIfIsMeasurementDC(_hDC);
-#endif
- }
-
- ///
- /// Saves the current state of the device context by copying data describing selected objects and graphic
- /// modes (such as the bitmap, brush, palette, font, pen, region, drawing mode, and mapping mode) to a
- /// context stack.
- /// The SaveDC function can be used any number of times to save any number of instances of the DC state.
- /// A saved state can be restored by using the RestoreHdc method.
- /// See MSDN for more details.
- ///
- public int SaveHdc()
- {
- HandleRef hdc = new HandleRef(this, _hDC);
- int state = Interop.Gdi32.SaveDC(hdc);
-
- _contextStack ??= new Stack();
-
- GraphicsState g = new GraphicsState();
- g.hBitmap = _hCurrentBmp;
- g.hBrush = _hCurrentBrush;
- g.hPen = _hCurrentPen;
- g.hFont = _hCurrentFont;
-
- _contextStack.Push(g);
-
-#if TRACK_HDC
- Debug.WriteLine( DbgUtil.StackTraceToStr( string.Format("state[0]=DC.SaveHdc(hDc=0x{1:x8})", state, unchecked((int) _hDC)) ));
-#endif
-
- return state;
- }
-
- ///
- /// Selects a region as the current clipping region for the device context.
- /// Remarks (From MSDN):
- /// - Only a copy of the selected region is used. The region itself can be selected for any number of other device contexts or it can be deleted.
- /// - The SelectClipRgn function assumes that the coordinates for a region are specified in device units.
- /// - To remove a device-context's clipping region, specify a NULL region handle.
- ///
- public void SetClip(WindowsRegion region)
- {
- HandleRef hdc = new HandleRef(this, _hDC);
- HandleRef hRegion = new HandleRef(region, region.HRegion);
-
- Interop.Gdi32.SelectClipRgn(hdc, hRegion);
- }
-
- ///
- /// Creates a new clipping region from the intersection of the current clipping region and the specified rectangle.
- ///
- public void IntersectClip(WindowsRegion wr)
- {
- //if the incoming windowsregion is infinite, there is no need to do any intersecting.
- if (wr.HRegion == IntPtr.Zero)
- {
- return;
- }
-
- WindowsRegion clip = new WindowsRegion(0, 0, 0, 0);
- try
- {
- int result = Interop.Gdi32.GetClipRgn(new HandleRef(this, _hDC), new HandleRef(clip, clip.HRegion));
-
- // If the function succeeds and there is a clipping region for the given device context, the return value is 1.
- if (result == 1)
- {
- Debug.Assert(clip.HRegion != IntPtr.Zero);
- wr.CombineRegion(clip, wr, Interop.Gdi32.CombineMode.RGN_AND);
- }
-
- SetClip(wr);
- }
- finally
- {
- clip.Dispose();
- }
- }
-
- ///
- /// Modifies the viewport origin for a device context using the specified horizontal and vertical offsets in
- /// logical units.
- ///
- public void TranslateTransform(int dx, int dy)
- {
- Point origin = default;
- Interop.Gdi32.OffsetViewportOrgEx(new HandleRef(this, _hDC), dx, dy, ref origin);
- }
-
- ///
- ///
- public override bool Equals(object? obj)
- {
- DeviceContext? other = obj as DeviceContext;
-
- if (other == this)
- {
- return true;
- }
-
- if (other == null)
- {
- return false;
- }
-
- // Note: Use property instead of field so the HDC is initialized. Also, this avoid serialization issues (the obj could be a proxy that does not have access to private fields).
- return other.Hdc == _hDC;
- }
-
- ///
- /// This allows collections to treat DeviceContext objects wrapping the same HDC as the same objects.
- ///
- public override int GetHashCode() => _hDC.GetHashCode();
-
- internal sealed class GraphicsState
- {
- internal IntPtr hBrush;
- internal IntPtr hFont;
- internal IntPtr hPen;
- internal IntPtr hBitmap;
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContextType.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContextType.cs
deleted file mode 100644
index afd80b750b67b..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContextType.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Internal
-{
- ///
- /// Represent the device type the context refers to.
- ///
- internal enum DeviceContextType
- {
- // Unknown device
- Unknown = 0x00,
-
- // Window DC including non-client area - obtained from GetWindowDC
- NCWindow = 0x02,
-
- // Printer DC - obtained from CreateDC.
- NamedDevice = 0x03,
-
- // Information context - obtained from CreateIC.
- Information = 0x04,
-
- // Memory dc - obtained from CreateCompatibleDC.
- Memory = 0x05,
-
- // Metafile dc - obtained from CreateEnhMetafile.
- Metafile = 0x06 // currently not supported.
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContexts.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContexts.cs
deleted file mode 100644
index a9169aef0066f..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/DeviceContexts.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-namespace System.Drawing.Internal
-{
- ///
- /// Keeps a cache of some graphics primitives. Created to improve performance of TextRenderer.MeasureText methods
- /// that don't receive a WindowsGraphics. This class maintains a cache of MRU WindowsFont objects in the process.
- ///
- internal static class DeviceContexts
- {
- [ThreadStatic]
- private static ClientUtils.WeakRefCollection? t_activeDeviceContexts;
-
- ///
- /// WindowsGraphicsCacheManager needs to track DeviceContext objects so it can ask them if a font is in use
- /// before they it's deleted.
- ///
- internal static void AddDeviceContext(DeviceContext dc)
- {
- ClientUtils.WeakRefCollection wrc = t_activeDeviceContexts ??= new ClientUtils.WeakRefCollection()
- {
- RefCheckThreshold = 20
- };
-
- if (!wrc.Contains(dc))
- {
- dc.Disposing += new EventHandler(OnDcDisposing);
- wrc.Add(dc);
- }
- }
-
- private static void OnDcDisposing(object? sender, EventArgs e)
- {
- if (sender is DeviceContext dc)
- {
- dc.Disposing -= new EventHandler(OnDcDisposing);
- RemoveDeviceContext(dc);
- }
- }
-
- internal static void RemoveDeviceContext(DeviceContext dc)
- {
- t_activeDeviceContexts?.RemoveByHashCode(dc);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsGraphics.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsGraphics.cs
deleted file mode 100644
index 37595989ad287..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsGraphics.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-// THIS PARTIAL CLASS CONTAINS THE BASE METHODS FOR CREATING AND DISPOSING A WINDOWSGRAPHICS AS WELL
-// GETTING, DISPOSING AND WORKING WITH A DC.
-
-using System.Diagnostics;
-using System.Drawing.Drawing2D;
-
-namespace System.Drawing.Internal
-{
- ///
- /// WindowsGraphics is a library for rendering text and drawing using GDI; it was created to address performance
- /// and compatibility issues found in GDI+ Graphics class.
- ///
- /// Note: WindowsGraphics is a stateful component, DC properties are persisted from method calls, as opposed to
- /// Graphics (GDI+) which performs atomic operations and always restores the hdc. The underlying hdc is always
- /// saved and restored on dispose so external HDCs won't be modified by WindowsGraphics. So we don't need to
- /// restore previous objects into the dc in method calls.
- ///
- internal sealed partial class WindowsGraphics : MarshalByRefObject, IDisposable, IDeviceContext
- {
- // Wrapper around the window dc this object refers to.
- // Note: this dc is only disposed when owned (created) by the WindowsGraphics.
- private DeviceContext _dc;
- private bool _disposeDc;
- private Graphics? _graphics; // cached when initialized FromGraphics to be able to call g.ReleaseHdc from Dispose.
-
-#if GDI_FINALIZATION_WATCH
- private string AllocationSite = DbgUtil.StackTrace;
-#endif
-
- public WindowsGraphics(DeviceContext dc)
- {
- Debug.Assert(dc != null, "null dc!");
- _dc = dc;
- _dc.SaveHdc();
- }
-
- public static WindowsGraphics FromHdc(IntPtr hDc)
- {
- Debug.Assert(hDc != IntPtr.Zero, "null hDc");
- DeviceContext dc = DeviceContext.FromHdc(hDc);
-
- // we create it, we dispose it.
- return new WindowsGraphics(dc)
- {
- _disposeDc = true
- };
- }
-
- public static WindowsGraphics FromGraphics(Graphics g, ApplyGraphicsProperties properties)
- {
- Debug.Assert(g != null, "null Graphics object.");
-
- WindowsRegion? wr = null;
-
- PointF offset = default;
-
- if (properties != ApplyGraphicsProperties.None)
- {
- Region? clip = null;
-
-#if NETCOREAPP
- if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
- {
- g.GetContextInfo(out offset, out clip);
- }
- else
- {
- g.GetContextInfo(out offset);
- }
-#else
- Matrix? worldTransf = null;
- if (g.GetContextInfo() is object[] data && data.Length == 2)
- {
- if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
- {
- clip = data[0] as Region;
- }
- worldTransf = data[1] as Matrix;
- if (worldTransf != null)
- {
- offset = worldTransf.Offset;
- }
- }
-#endif
-
- if (clip is not null)
- {
- // We have to create the WindowsRegion and dispose the Region object before locking the Graphics object,
- // in case of an unlikely exception before releasing the WindowsRegion, the finalizer will do it for us.
- // (no try-finally block since this method is used frequently - perf).
-
- // If clipping has not been set (Region.IsInfinite) GetContextInfo will return a null Region.
-
- wr = WindowsRegion.FromRegion(clip, g); // WindowsRegion will take ownership of the hRegion.
- clip.Dispose(); // Disposing the Region object doesn't destroy the hRegion.
- }
- }
-
- WindowsGraphics wg = FromHdc(g.GetHdc()); // This locks the Graphics object.
- wg._graphics = g;
-
- // Apply transform and clip
- if (wr is not null)
- {
- using (wr)
- {
- // If the Graphics object was created from a native DC the actual clipping region is the intersection
- // beteween the original DC clip region and the GDI+ one - for display Graphics it is the same as
- // Graphics.VisibleClipBounds.
- wg.DeviceContext.IntersectClip(wr);
- }
- }
-
- if (offset != default)
- {
- // elements (XFORM) = [eM11, eM12, eM21, eM22, eDx, eDy], eDx/eDy specify the translation offset.
- wg.DeviceContext.TranslateTransform((int)offset.X, (int)offset.Y);
- }
-
- return wg;
- }
-
- ~WindowsGraphics() => Dispose(false);
-
- public DeviceContext DeviceContext => _dc;
-
- // Okay to suppress.
- // "WindowsGraphics object does not own the Graphics object. For instance in a control's Paint event we pass
- // the GraphicsContainer object to TextRenderer, which uses WindowsGraphics; if the Graphics object is disposed
- // then further painting will be broken."
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- internal void Dispose(bool disposing)
- {
- if (_dc != null)
- {
- DbgUtil.AssertFinalization(this, disposing);
-
- try
- {
- // Restore original dc.
- _dc.RestoreHdc();
-
- if (_disposeDc)
- {
- _dc.Dispose(disposing);
- }
-
- if (_graphics != null) // if created from a Graphics object...
- {
- _graphics.ReleaseHdcInternal(_dc.Hdc);
- _graphics = null;
- }
- }
- catch (Exception ex) when (!ClientUtils.IsSecurityOrCriticalException(ex))
- {
- Debug.Fail("Exception thrown during disposing: \r\n" + ex.ToString());
- }
- finally
- {
- _dc = null!;
- }
- }
- }
-
- public IntPtr GetHdc() => _dc.Hdc;
-
- public void ReleaseHdc() => _dc.Dispose();
- }
-}
diff --git a/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsRegion.cs b/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsRegion.cs
deleted file mode 100644
index 5aa3ae6ceb9b4..0000000000000
--- a/src/libraries/System.Drawing.Common/src/misc/GDI/WindowsRegion.cs
+++ /dev/null
@@ -1,150 +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.Diagnostics;
-using System.Runtime.InteropServices;
-
-namespace System.Drawing.Internal
-{
- ///
- /// Encapsulates a GDI Region object.
- ///
- internal sealed partial class WindowsRegion : MarshalByRefObject, ICloneable, IDisposable
- {
- private IntPtr _nativeHandle; // The hRegion, this class always takes ownership of the hRegion.
- private bool _ownHandle;
-
-#if GDI_FINALIZATION_WATCH
- private string AllocationSite = DbgUtil.StackTrace;
-#endif
-
- private WindowsRegion()
- {
- }
-
- public WindowsRegion(Rectangle rect)
- {
- CreateRegion(rect);
- }
-
- public WindowsRegion(int x, int y, int width, int height)
- {
- CreateRegion(new Rectangle(x, y, width, height));
- }
-
- ///
- /// Creates a WindowsRegion from a region handle, if 'takeOwnership' is true, the handle is added to the
- /// HandleCollector and is removed & destroyed on dispose.
- ///
- public static WindowsRegion FromHregion(IntPtr hRegion, bool takeOwnership)
- {
- WindowsRegion wr = new WindowsRegion();
-
- // Note: Passing IntPtr.Zero for hRegion is ok. GDI+ infinite regions will have hRegion == null.
- // GDI's SelectClipRgn interprets null region handle as resetting the clip region (all region will be available for painting).
- if (hRegion != IntPtr.Zero)
- {
- wr._nativeHandle = hRegion;
-
- if (takeOwnership)
- {
- wr._ownHandle = true;
- }
- }
- return wr;
- }
-
- ///
- /// Creates a WindowsRegion from a System.Drawing.Region.
- ///
- public static WindowsRegion FromRegion(Region region, Graphics g)
- {
- if (region.IsInfinite(g))
- {
- // An infinite region would cover the entire device region which is the same as
- // not having a clipping region. Observe that this is not the same as having an
- // empty region, which when clipping to it has the effect of excluding the entire
- // device region.
- // To remove the clip region from a dc the SelectClipRgn() function needs to be
- // called with a null region ptr - that's why we use the empty constructor here.
- // GDI+ will return IntPtr.Zero for Region.GetHrgn(Graphics) when the region is
- // Infinite.
- return new WindowsRegion();
- }
-
- return FromHregion(region.GetHrgn(g), true);
- }
-
- public object Clone()
- {
- // WARNING: WindowsRegion currently supports rectangulare regions only, if the WindowsRegion was created
- // from an HRegion and it is not rectangular this method won't work as expected.
- // Note: This method is currently not used and is here just to implement ICloneable.
- return IsInfinite ?
- new WindowsRegion() :
- new WindowsRegion(ToRectangle());
- }
-
- ///
- /// Combines region1 & region2 into this region. The regions cannot be null. The three regions need not be
- /// distinct. For example, the sourceRgn1 can equal this region.
- ///
- public Interop.RegionType CombineRegion(WindowsRegion region1, WindowsRegion region2, Interop.Gdi32.CombineMode mode)
- {
- return Interop.Gdi32.CombineRgn(new HandleRef(this, HRegion), new HandleRef(region1, region1.HRegion), new HandleRef(region2, region2.HRegion), mode);
- }
-
- private void CreateRegion(Rectangle rect)
- {
- Debug.Assert(_nativeHandle == IntPtr.Zero, "nativeHandle should be null, we're leaking handle");
- _nativeHandle = Interop.Gdi32.CreateRectRgn(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
- _ownHandle = true;
- }
-
- public void Dispose() => Dispose(true);
-
- public void Dispose(bool disposing)
- {
- if (_nativeHandle != IntPtr.Zero)
- {
- DbgUtil.AssertFinalization(this, disposing);
-
- if (_ownHandle)
- {
- Interop.Gdi32.DeleteObject(new HandleRef(this, _nativeHandle));
- }
-
- _nativeHandle = IntPtr.Zero;
-
- if (disposing)
- {
- GC.SuppressFinalize(this);
- }
- }
- }
-
- ~WindowsRegion() => Dispose(false);
-
- ///
- /// The native region handle.
- ///
- public IntPtr HRegion => _nativeHandle;
-
- public bool IsInfinite => _nativeHandle == IntPtr.Zero;
-
- ///
- /// A rectangle representing the window region set with the SetWindowRgn function.
- ///
- public Rectangle ToRectangle()
- {
- if (IsInfinite)
- {
- return new Rectangle(-int.MaxValue, -int.MaxValue, int.MaxValue, int.MaxValue);
- }
-
- Interop.Gdi32.RECT rect = default;
- Interop.Gdi32.GetRgnBox(new HandleRef(this, _nativeHandle), ref rect);
- return new Rectangle(new Point(rect.left, rect.top), rect.Size);
- }
- }
-}
diff --git a/src/libraries/System.Drawing.Common/tests/AssemblyInfo.cs b/src/libraries/System.Drawing.Common/tests/AssemblyInfo.cs
deleted file mode 100644
index b1abf9bdf2391..0000000000000
--- a/src/libraries/System.Drawing.Common/tests/AssemblyInfo.cs
+++ /dev/null
@@ -1,8 +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 Xunit;
-
-[assembly: ActiveIssue("https://github.com/dotnet/runtime/issues/35917", typeof(PlatformDetection), nameof(PlatformDetection.IsMonoInterpreter))]
-[assembly: SkipOnPlatform(TestPlatforms.Browser, "System.Drawing.Common is not supported on Browser")]
diff --git a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs b/src/libraries/System.Drawing.Common/tests/BitmapTests.cs
deleted file mode 100644
index 8bbb1077d4b32..0000000000000
--- a/src/libraries/System.Drawing.Common/tests/BitmapTests.cs
+++ /dev/null
@@ -1,1757 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-//
-// (C) 2004 Ximian, Inc. http://www.ximian.com
-// Copyright (C) 2004,2006-2007 Novell, Inc (http://www.novell.com)
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices;
-using Microsoft.DotNet.RemoteExecutor;
-using Microsoft.DotNet.XUnitExtensions;
-using Xunit;
-
-namespace System.Drawing.Tests
-{
- [ActiveIssue("https://github.com/dotnet/runtime/issues/34591", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
- public class BitmapTests : FileCleanupTestBase
- {
- public static IEnumerable