# 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`.
