Files
inno-installers/PrinterInstallerMap/README.md
cproudlock 1d044cbbdf PrinterInstallerMap: add map wizard page (TBitmapImage hotspots)
Implements the click-to-select site map UI on a custom Inno wizard page,
replacing the blocked Edge .bat-download flow.

- New record fields MapLeft, MapTop on PrinterDataArray; QueryPrinters
  pulls them from the api_printers.asp JSON via the existing
  JsonGetString helper.
- BuildMapPage creates a custom wizard page (CreateCustomPage), places a
  stretched background TBitmapImage with the bundled site map BMP, then
  overlays one TBitmapImage per printer with a non-empty mapleft+maptop.
  Each hotspot is a 14x14 square with its own OnClick.
- MapHotspotClick toggles PrinterSelectionPage.Values[I] for the linked
  printer and swaps the hotspot bitmap (gray<->lime) to reflect the new
  state. Two shared TBitmaps are pre-rendered once via TCanvas.
- PrinterSelectionPage is re-anchored to PrinterMapPage.ID so the
  selections from the map flow into the existing checkbox page where the
  user can review and adjust.
- ShouldSkipPage skips the map page when no printers have map coords,
  preserving legacy behaviour if api_printers.asp is not yet extended or
  if the database has no coordinates set.
- Bundled sitemap2025-dark.bmp (880x680, ~1.7 MB) was scaled down from
  shopdb's sitemap2025-dark.png via PIL (Inno's TBitmap.LoadFromFile is
  BMP-only).

Untested. Needs Inno Setup 6.x compile on Windows + the api_printers.asp
extension to return mapleft, maptop. README documents the privileges
model (admin required, supportuser at UAC) and the Inno class-subset
gotchas verified during design.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 07:43:54 -04:00

61 lines
5.2 KiB
Markdown

# WJDT Printer Installer (Map UI)
Forked from `PrinterInstaller/` on branch `feature/printer-map`.
## Why a fork
The web flow at `printerinstallermap.asp` -> `installprinter.asp` (which downloads a per-selection `.bat` that invokes the original `PrinterInstaller.exe /PRINTER=...`) is blocked by current Edge policy: `.bat` downloads disallowed, unsigned `.exe` runs disallowed.
This variant replaces the web map UI with an in-installer wizard page so the operator never touches a browser. Same drivers, same install logic, same `/PRINTER=` silent path - all that changes is the selection UX.
## What's new vs PrinterInstaller 2.0
- **New wizard page**: site-map bitmap with clickable printer markers placed at `printers.mapleft, maptop` coords from ShopDB. Click toggles selection; selections feed the existing checkbox page.
- **Bundled site map**: `sitemap2025-dark.png` (2550 x 3300, sourced from `shopdb/images/`) baked into `[Files]`, extracted to `{tmp}` at install start.
- **API call extended**: `api_printers.asp` now returns `mapleft, maptop` per row (additive; older clients ignore).
- New `AppId` GUID, new `OutputBaseFilename=PrinterInstallerMap`, new `AppName` so the two installers coexist on the same PC without UninstallString collision.
## What's unchanged
- Driver bundle (HP UPD, Xerox UPD, Brother MFC, HID FARGO).
- `Install-PrinterDriver` + `Install-NetworkPrinter` install logic.
- `/PRINTER="..."` and `/VERYSILENT /NORESTART` silent-install path - existing bat-file deployments would still work if pointed at this EXE binary, but the whole point of the fork is to retire that flow.
- ShopDB API base URL (`http://192.168.122.151:8080/api_printers.asp`).
- Custom branding (`gea-logo.ico`, `patrick.bmp`, `patrick-sm.bmp`).
## Status
Map wizard page implemented end-to-end in `.iss`. Untested: needs Windows + Inno Setup 6.x compiler, plus the `api_printers.asp` extension below to return map coords. ShopDB rows that already have `mapleft + maptop` set will populate hotspots; rows missing coords fall through to the checkbox page (legacy behaviour).
Tracked work:
- [x] Add `MapLeft, MapTop` fields to `PrinterDataArray` record + `JsonGetString` parsing.
- [x] Add `sitemap2025-dark.bmp` (880x680, scaled-down, ~1.7 MB) to `[Files]`. Inno's `TBitmap.LoadFromFile` is BMP-only, so the source PNG was converted with PIL.
- [x] Implement `BuildMapPage` (`CreateCustomPage` + stretched background `TBitmapImage` + per-printer hotspot `TBitmapImage` overlays) and `MapHotspotClick` (toggles `PrinterSelectionPage.Values[I]` + swaps the hotspot's bitmap).
- [x] Anchor `PrinterSelectionPage` after `PrinterMapPage.ID` (was after `wpWelcome`); checkbox page sees the map's selections.
- [x] `ShouldSkipPage` skips the map page when no printers have map coords (graceful degrade if API is not yet extended).
- [ ] **ShopDB**: extend `api_printers.asp` to return `mapleft, maptop` per printer row (additive change).
- [ ] **Build**: Inno Setup compile on Windows. Target: `OutputBaseFilename=PrinterInstallerMap`.
- [ ] **Code-signing cert**: `proudlock.tech` M365 artifact certs are not Authenticode (wrong EKU); pursue GE AD CS cert instead. See project memory note.
- [ ] **Sign + bake into PXE image**.
- [ ] **Test on win11 VM**: cold install, /PRINTER= silent path, map-only-vs-checkbox-only printers, no-coords graceful skip.
## Privileges
`PrivilegesRequired=admin` (inherited from PrinterInstaller). pnputil, TCP/IP port creation, `Add-Printer`, and trusted-publisher cert install all need elevation. Shopfloor user can launch but Windows shows a UAC prompt; supportuser creds satisfy it. Acceptable for the operator-driven adhoc workflow this installer targets. For unattended bulk per-PC deployment, use a GE-Enforce manifest entry (runs as SYSTEM, no UI, no UAC) instead of this installer.
## Implementation notes
- **Map source**: `printers.mapleft, maptop` are top-left-origin pixel coords on a 3300x2550 site map. Inno is also top-left-origin, so coords are used directly with no Y-flip (the Leaflet asp inverts Y because Leaflet `CRS.Simple` is Y-up, which is a Leaflet quirk - not present here).
- **Scaling**: bundled BMP is 880x680 to keep file size sane. At wizard time the BMP is stretch-painted into the wizard surface at fit-and-letterbox scale; hotspots are positioned in the same scaled coordinate space (multiplying `mapleft, maptop` by the same scale factor).
- **Hotspot graphic**: 14x14 square (no transparency, since Inno's exposed TBitmap surface does not document a TransparentColor path). Square reads cleanly enough on the dark map.
- **Inno class subset gotchas verified before coding**:
- `TBitmapImage` has `OnClick(Sender)` only - no `OnMouseDown` with X/Y. Per-hotspot child controls are the documented workaround for click-to-coords.
- `TScrollBox` is not exposed; the bundled BMP is stretched to fit instead of scrolled.
- `TBitmap.LoadFromFile` is BMP-only (PNG path goes through `TPngImage` which has no `LoadFromFile`); PNG was pre-converted.
- `TWizardPage.OnActivate`, `ShouldSkipPage`, `NextButtonClick` all exposed as expected.
## Build / sign / deploy
Same as `PrinterInstaller/`. See `../PrinterInstaller/README.md` for the build matrix. Output filename is `PrinterInstallerMap.exe`.