No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
joe c388f0dbbf Initial import of PhAT.Wpf
WPF controls for PhAT's vision services, the desktop counterpart of
PhAT.Razor: image viewer with overlays, live camera viewer, mask editor,
message log grid, gauge, sparkline, and the vision job editor.

Builds against the PhAT class library at ..\PhAT (project reference).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 21:24:40 -05:00
Controls Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Imaging Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Themes Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Theming Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Vision Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
.editorconfig Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
.gitignore Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Directory.Build.props Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
Directory.Build.targets Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
PhAT.Wpf.csproj Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00
README.md Initial import of PhAT.Wpf 2026-10-28 21:24:40 -05:00

PhAT.Wpf

WPF controls for PhAT's vision services, the desktop counterpart of PhAT.Razor's vision components. It builds on PhAT as PhAT.Razor does: the logic stays in PhAT, this is only UI. Target net10.0-windows; MVVM with CommunityToolkit.Mvvm. Used by PhAT.VisionTool.

Controls (PhAT.Wpf.Controls)

Control Razor counterpart What it does
ImageViewer ImageViewer (+ .razor.js) Shows an image. Wheel zooms around the pointer; drag or middle-drag pans; double-click or middle-click fits. A status line gives the pixel position, value, size and zoom. Optional dashed guides. Overlays (OverlayItem) are drawn in image pixels, with line and text sizes in screen pixels. Modes: Pan (click picks an overlay item with a Tag), SelectRegion (RegionSelected), Paint (ImagePointer, Space+drag pans). Right-click: fit, 100 %, copy, save, save with overlay.
OverlayRect, OverlayPolygon, OverlayMarker, OverlayText, OverlayImage SVG overlay content Overlay items: stroke, fill, dash, tooltip, Tag (clickable), HoverOnly.
VisionOverlay VisionResultOverlay Overlay items for VisionResultService results; pass/fail colours from the theme.
CameraImageViewer CameraImageViewer Live view from CameraImageService, decoded off the UI thread (the newest frame wins), with the published results and extra overlay items. Can be frozen.
MaskEditor Masks/MaskEditor (+ .razor.js) Paints a mask: brush, filled rectangle, white/black, invert, fill, undo/redo (Ctrl+Z/Y), zoom. Shows the reference picture (or one passed in) under it at an adjustable opacity. Saves to MaskLibrary.
MessageLogGrid MessageLogGrid MessageLogService: filter, only not received, sort, pages; refreshes on change.
Gauge, Sparkline Telemetry/Gauge, Sparkline Dial with warn/alarm colours; trend line.

Vision editors (PhAT.Wpf.Vision)

Type Razor counterpart
JobEditorView + JobEditorViewModel Vision/JobEditor
OpEditor (with the template picker) Vision/OpEditor, TemplatePicker
ProcessorsEditor Vision/ProcessorsEditor
PropertyGrid Vision/PropertyEditor
SourceEditor, WorldEditor Vision/SourceEditor, WorldEditor
AutofocusEditor, ExposureEditor Vision/AutofocusEditor, ExposureEditor
RunView Vision/RunView
ContourList Vision/ContourList
VisionRun, ContourCandidate, ContourPick, VisionText VisionUi.cs (RunSummary, ...)

How the pieces fit:

  • The view model: JobEditorViewModel holds a private copy of the job. It handles save, revert, run and preview, live preview, the op list, ROI drawing, contour picking and JSON.
  • The editors: code-built controls that edit the job object directly and call NotifyChanged(), as the Razor components raise Changed.
  • Run images: stay in VisionRunCache. VisionRun turns them into bitmaps when a view is shown.

Theme

PhATTheme.Apply(app, PhATThemeMode.System | Light | Dark) does three things:

  • sets WPF's Fluent theme (Application.ThemeMode);
  • merges Themes/Palette.Light.xaml or Palette.Dark.xaml (PhAT colours: pass, fail, warn, accent, ...);
  • merges Themes/Styles.xaml (headings, hints, cards, badges, buttons).

It follows Windows' app mode when set to System. Controls that draw themselves redraw on PhATTheme.Changed.

Key Use
PhAT.PassBrush, PhAT.FailBrush, PhAT.WarnBrush Results, gauges
PhAT.AccentBrush, PhAT.MarkedBrush, PhAT.MutedBrush Selected ROI or contour, marked contours, other ROIs
PhAT.TextBrush, PhAT.SubtleTextBrush Text, hints and labels
PhAT.CardBrush, PhAT.PanelBrush, PhAT.BorderBrush, PhAT.SelectedRowBrush Surfaces
PhAT.ViewerBackgroundBrush Behind images
PhAT.Heading, PhAT.Subheading, PhAT.Label, PhAT.Hint, PhAT.Error, PhAT.Card, PhAT.Badge, PhAT.IconButton, PhAT.AccentButton Styles

Using it in an app

  1. Reference it: <ProjectReference Include="..\PhAT.Wpf\PhAT.Wpf.csproj" />, which brings in PhAT too. Add <FrameworkReference Include="Microsoft.AspNetCore.App" /> if you host PhAT's services.
  2. Register the services: in a Generic Host, register what the controls use, as the web apps do (AddCameraImages, AddVisionResults, AddStages, AddMasks, AddCameras, AddVisionJobs, ...). See PhAT.VisionTool's WorkspaceHost.
  3. At startup: PhATTheme.Apply(this, PhATThemeMode.System).
  4. Show the editor: new JobEditorView { DataContext = new JobEditorViewModel(services, jobName) }.

Build note: Directory.Build.props moves obj to ..\build\<project>. The csproj points WPF's temporary markup project (*_wpftmp) at the right project.assets.json; keep that block in any new WPF project here.