How thejoefin/text-grab works
Project type and purpose
• Text Grab is a Windows desktop OCR utility built with WPF and UWP packaging.
• Purpose: capture text from anywhere on screen (full-screen, framed region) or files/folders, process it via Windows.Media.Ocr, and expose it for copying, editing, quick lookup, or command-line use.
File structure
• Top-level solution:
• Text-Grab.sln
• Projects:
– Text-Grab (WPF application)
– Text-Grab-Package (UWP/MSIX packaging project)
– Tests (unit tests covering OCR, file IO, language, QR, screen layouts, string methods)
• Text-Grab project subfolders reveal layers:
• Views & Controls (UI windows, custom controls, pages)
• Services (HistoryService, SettingsService)
• Utilities (Clipboard, File, OCR, HotKey, Image, Registry, Notification, etc.)
• Models (domain objects like OcrOutput, HistoryInfo, WebSearchUrlModel)
• NativeMethods & OSInterop (P/Invoke wrappers)
• UndoRedoOperations (command pattern for undo/redo)
• Extensions (helper methods extending core types)
• Styles & Images (UI theming)
• Properties (app settings)
• Configuration & build: App.config, app.manifest, build-x64.ps1, .csproj files, .gitignore, GitHub workflows.
README for additional insights
• Four modes: Full-Screen, Grab Frame, Edit Text Window, Quick Simple Lookup
• Command-line interface (mode arguments and file/folder OCR)
• Uses Windows 10+ OCR API, ZXing.Net for QR/barcode, WPFUI for Fluent styling, CliWrap, CommunityToolkit
• Does not run in background by default; can use global hotkeys if background process enabled.
a. Main components:
• UI Layer (WPF): Views, Pages, Controls
• Application Core / Service Layer:
• OCRService (wraps Windows.Media.Ocr)
• HistoryService, SettingsService
• CommandLineProcessor
• UndoRedoManager
• Utility Layer: ClipboardUtilities, FileUtilities, ImageMethods, HotKeyManager, RegistryMonitor, NotificationUtilities, etc.
• Data Models & Domain Objects
• Native Interop Layer: NativeMethods, OSInterop
• Packaging Layer: Text-Grab-Package (UWP / MSIX)
• External Dependencies: Windows.Media.Ocr API, ZXing.Net, WPF UI library, CliWrap, CommunityToolkit
• Persistence: AppSettings (Properties/Settings), History store (local file or settings storage)
b. Relationships & interactions:
• UI ↔ ViewModels / Code-behind invoke Service Layer methods
• Service Layer calls Utility classes and NativeInterop for OS and third-party library operations
• OCRService → Windows.Media.Ocr API → returns OcrResult → mapped into domain Models → passed back to UI
• ClipboardUtilities reads/writes clipboard on behalf of UI and Services
• UndoRedoManager tracks operations initiated in UI (word border edits, image changes)
• CommandLineProcessor can launch specific UI modes or batch OCR via Services
• Text-Grab-Package wraps the WPF app for store deployment
c. Architectural patterns and principles:
• Layered architecture: UI, Application Services, Utilities, NativeInterop, Data Models
• Command pattern for undo/redo operations
• Separation of concerns: each folder corresponds to a distinct responsibility
• Dependency on OS services is abstracted behind utility and interop classes
d. Technologies, frameworks, and libraries:
• .NET 6.0 / .NET desktop and UWP workloads
• WPF for UI, XAML for layout and styling
• Windows.Media.Ocr UWP API
• ZXing.Net for barcode/QR code
• WPF UI (Fluent styling), CommunityToolkit, CliWrap