From 766eb4c6d3ebe45873da312781e9c4b41b5768bd Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Oct 2026 06:57:19 +0000 Subject: [PATCH] Mark the remaining GDI+ members of the 2.0 list obsolete (#412) ModelView.GetContentsAsBitmap, OpenGlCustomize.PaintToBitmap and Substitutes.PaintEventArgs.Graphics are removed in 2.0 but were not [Obsolete] yet. Their messages name the replacement, as #412 requires: - GetContentsAsBitmap always returned null, and OpenGlCustomize.PaintToBitmap always threw. Both point to CADability.Forms.PaintToOpenGL.PaintToBitmap, which already implements the same signature. - No view of CADability reads PaintEventArgs.Graphics; views paint through ICanvas.PaintTo3D. CadCanvas keeps setting it for application views. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5 --- CADability.Forms/CadCanvas.cs | 2 ++ CADability/FormsSubst.cs | 5 +++++ CADability/ModelView.cs | 1 + CADability/PaintToOpenGl.cs | 1 + 4 files changed, 9 insertions(+) diff --git a/CADability.Forms/CadCanvas.cs b/CADability.Forms/CadCanvas.cs index b37d69694..b9cb90f18 100644 --- a/CADability.Forms/CadCanvas.cs +++ b/CADability.Forms/CadCanvas.cs @@ -51,7 +51,9 @@ private static CADability.Substitutes.PaintEventArgs Subst(System.Windows.Forms. return new Substitutes.PaintEventArgs() { ClipRectangle = v.ClipRectangle, +#pragma warning disable CS0618 // still set for views of applications that read it, until CADability 2.0 Graphics = v.Graphics +#pragma warning restore CS0618 }; } private IView view; diff --git a/CADability/FormsSubst.cs b/CADability/FormsSubst.cs index 7af579518..160686e37 100644 --- a/CADability/FormsSubst.cs +++ b/CADability/FormsSubst.cs @@ -74,6 +74,11 @@ public KeyEventArgs(Keys keyData) public class PaintEventArgs { public Rectangle ClipRectangle { get; set; } + /// + /// The GDI+ graphics of the paint event. No view of CADability reads it: views paint through + /// . + /// + [Obsolete("No view of CADability uses it. Paint through ICanvas.PaintTo3D instead. GDI+ is removed from the kernel in CADability 2.0 (issue #412).")] public Graphics Graphics { get; set; } } diff --git a/CADability/ModelView.cs b/CADability/ModelView.cs index 1cda03687..b0969768b 100644 --- a/CADability/ModelView.cs +++ b/CADability/ModelView.cs @@ -3013,6 +3013,7 @@ public void Scroll(int HScrollOffset, int VScrollOffset) /// Not implemented: always returns null. Kept for compatibility with earlier versions. /// /// null + [Obsolete("Not implemented, always returns null. Use CADability.Forms.PaintToOpenGL.PaintToBitmap to render the model into a bitmap. GDI+ is removed from the kernel in CADability 2.0 (issue #412).")] public Bitmap GetContentsAsBitmap() { { diff --git a/CADability/PaintToOpenGl.cs b/CADability/PaintToOpenGl.cs index ebd01fe3b..30c8b7714 100644 --- a/CADability/PaintToOpenGl.cs +++ b/CADability/PaintToOpenGl.cs @@ -657,6 +657,7 @@ internal static void InvokeSetProjection(IntPtr renderContext, IPaintTo3D paintT /// of the bitmap /// the extent to show in the bitmap; if null, the extent of the objects is used /// + [Obsolete("Not implemented in the kernel, always throws a NotImplementedException. Use CADability.Forms.PaintToOpenGL.PaintToBitmap with the same parameters instead. GDI+ is removed from the kernel in CADability 2.0 (issue #412).")] public static Bitmap PaintToBitmap(GeoObjectList list, GeoVector viewDirection, int width, int height, BoundingCube? extent = null) { throw new NotImplementedException("PaintToBitmap not implemented, maybe implement in CADability.Forms");