Skip to content

Add GDI+ printing extensions to CADability.Forms (#412) - #482

Closed
dsn27 wants to merge 1 commit into
feature/neutral-page-setupfrom
feature/printing-in-forms
Closed

dsn27 wants to merge 1 commit into
feature/neutral-page-setupfrom
feature/printing-in-forms

Conversation

@dsn27

@dsn27 dsn27 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #412 (step 7, printing). Stacked on #474; retarget to master once #474 is merged.

Why

#412 now requires that every class member removed in 2.0 is [Obsolete] in 1.x naming its replacement. #474 marked LayoutView.Print, GDI2DView.PrintSinglePage and PrintToGDI obsolete, but their replacement did not exist yet, so the messages only said "moves into CADability.Forms in 2.0".

What

  • New CADability.Forms.GdiPrinting with extension methods:
    • PrintDocument.Print(LayoutView) replaces LayoutView.Print(PrintDocument)
    • PrintDocument.PrintSinglePage(GDI2DView) replaces GDI2DView.PrintSinglePage(PrintDocument)
    • PrintDocument.PrintSinglePage(Project, string, bool) replaces PrintToGDI.PrintSinglePage(...)
    • Bitmap.DrawModel(Model, Projection, Layer[], bool, bool) replaces new PrintToGDI(bitmap).PrintToBitmap(...)
  • The three [Obsolete] messages now name these replacements.
  • In 1.x the extensions forward to the kernel implementation. It moves into CADability.Forms in 2.0 (step 8).
  • tests/GdiPrintingTests.cs (Windows only) checks that DrawModel renders pixel for pixel like PrintToGDI.PrintToBitmap, and that the line is actually drawn.

Design notes

  • Receiver. The receiver is the PrintDocument or the Bitmap, not the view. An extension LayoutView.Print(PrintDocument) would be hidden by the instance method of the same name until 2.0, so callers could not switch to it.
  • No public PrintToGDI class in Forms in 1.x. A class with the same name in CADability.Forms would make PrintToGDI ambiguous for code that has both using CADability; and using CADability.Forms;, which is a source break. The class itself moves in 2.0.

Deviations from the list in #412

  • No public interface is changed. IUIService.ShowPageSetupDlg/ShowPrintDlg keep their [Obsolete] from Save page settings as a neutral PageSetup (#412, step 7b) #474; they are interface members, which the "name the replacement" rule for class members does not cover.
  • PrintToGDI.LineWidthFactor and PrintToGDI.OnPrintPage get no extension of their own. In this repository only the kernel uses them, and the obsolete message on the class covers them. DontRecalcTriangulation is a member of IPaintTo3D and stays.

Testing

  • CADability.Forms builds.
  • CADability.Tests on Linux: 621 passed, 21 skipped, 0 failed.
  • The test project compiles for net8.0-windows (-p:OS=Windows_NT). The Windows test itself runs on the Windows job of the integration branch ([Draft, do not merge] Integration branch for #412 #467).

🤖 Generated with Claude Code

https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5

The [Obsolete] messages of LayoutView.Print, GDI2DView.PrintSinglePage and
PrintToGDI now name their replacement, as #412 requires for every class
member removed in 2.0: the new extensions of CADability.Forms.GdiPrinting
(PrintDocument.Print(LayoutView), PrintDocument.PrintSinglePage(GDI2DView),
PrintDocument.PrintSinglePage(Project, string, bool) and Bitmap.DrawModel).

In 1.x they forward to the kernel implementation; it moves into
CADability.Forms in 2.0. The extensions take the PrintDocument or Bitmap
as receiver because an extension on LayoutView or GDI2DView with the same
name would be hidden by the instance method until 2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YXvDW91oXpy7RquGHNxgR5

dsn27 commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Closing without merge. The printing extensions only existed to give the [Obsolete] printing members a named replacement for step 8 of #412, which is now deferred. The browser does not need printing to move (#484). Printing stays where it is in 1.x.


Generated by Claude Code

@dsn27 dsn27 closed this Oct 16, 2026
@dsn27
dsn27 deleted the feature/printing-in-forms branch October 17, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants