How snownico0722/papertodo works
Purpose and Runtime
PaperTodo is a Windows x64 desktop sticky-note application: independent borderless WPF windows represent todo lists or Markdown-like notes, with no primary application window. It targets .NET 10/WPF and runs persistently through the system tray. Application startup is defined by App.xaml and App.xaml.cs; project packaging/runtime dependencies are defined in PaperTodo.csproj.
Application Control Plane
AppController.cs is the application-level coordinator for note lifecycle, tray-driven actions, persistence, and global behavior. Its partials separate high-level concerns: settings in AppController.Settings.cs, tray/menu integration in AppController.Tray.cs, and keyboard command handling in AppController.Shortcuts.cs. StartupCommand.cs parses command-line intents such as show/hide/toggle/create/exit, while SingleInstanceHelper.cs forwards subsequent launches to the already-running process.
Persistent State and Asset Storage
The primary model/state boundary is Models.cs plus StateStore.cs: note content, window geometry, settings, and UI state are saved to data.json, with backup/recovery behavior. Note images are deliberately outside JSON: NoteImageStore.cs resolves image references used in Markdown content and persists binaries through LmdbImageDatabase.cs. The latter wraps the packaged native LMDB library via LmdbNative.cs; native source/build/distribution assets live under native/lmdb/.
Note and Todo Window Surface
PaperWindow.cs is the core independent-paper window, divided into lifecycle/native-window concerns and type-specific presentation. PaperWindow.Note.cs hosts text/Markdown editing behavior, while PaperWindow.Todo.cs implements item-oriented todo interactions. PaperWindow.Lifecycle.cs governs showing, hiding, restoring, and disposal; PaperWindow.Native.cs handles Windows-level window behavior. TodoTextBox.cs and MarkdownTextBox.cs are the specialized editing controls behind each paper mode.
Markdown and Embedded Images
Markdown is intentionally a lightweight editor/rendering layer rather than a full document system. MarkdownTextBox.cs provides editor-facing formatting/highlighting behavior; MarkdownFencedCodeScanner.cs identifies fenced code regions, and MarkdownImageReferences.cs parses internal image references. This layer connects note text to NoteImageStore.cs, keeping images transactionally stored in LMDB while preserving references in note content.
Capsule Mode and Edge Docking
Collapsed papers become capsules governed by a distinct state/presentation pipeline. EdgeCapsuleModel.cs represents capsule state, EdgeCapsuleReducer.cs applies state transitions, and EdgeCapsuleTransitionPolicy.cs determines permitted behavior. EdgeCapsuleQueueCoordinator.cs manages per-screen edge queues; EdgeCapsuleTargetPlanner.cs and EdgeCapsuleLayoutService.cs compute docking targets and layout. Rendering and animation are separated through EdgeCapsuleHost.cs, EdgeCapsulePresenter.cs, and EdgeCapsuleFrameScheduler.cs.
Windows and System Integration
AppController.Tray.cs provides the sole global user entry point through the notification-area icon. GlobalHotkeys.cs supports application shortcuts, and FullscreenForegroundWindowDetector.cs enables the fullscreen visibility/always-on-top policy. Window placement and monitor-aware geometry use ScreenGeometry.cs, WindowWorkAreaHelper.cs, and WindowNative.cs. Theme, system appearance, and localized strings are represented by Theme.cs, SystemSettingsHelper.cs, and Resources/Strings*.resx.
External Execution and Distribution
Notes can be handed to Windows-associated external editors and can act as PowerShell-backed script capsules; this behavior is integrated through the application/window command path rather than a server or web boundary. Release automation is in .github/workflows/release.yml, producing signed Windows single-file executables. Native image persistence is built with CMake from native/lmdb/CMakeLists.txt; key managed dependencies are WPF, AvalonEdit, and Hardcodet.NotifyIcon.Wpf.
Main entry points: PaperWindow.cs Paper window · AppController.cs App controller · App.xaml WPF startup · EdgeCapsuleTargetPlanner.cs Capsule target & layout
Components 19
Application Runtime
- WPF startup · Starts the tray-resident, windowless application.
App.xaml - Project package · Defines .NET/WPF packaging and managed dependencies.
PaperTodo.csproj - App controller · Coordinates notes, persistence, tray actions, and global behavior.
AppController.cs - Launch commands · Parses launch intents and forwards later launches to the active process.
StartupCommand.cs - Tray & shortcuts · Provides the primary user entry point and application hotkeys.
AppController.Tray.cs
State & Images
- State store · Persists notes, geometry, settings, and UI state with recovery.
StateStore.cs - Application models
Models.cs - Note image store · Resolves Markdown image references separately from note JSON.
NoteImageStore.cs - LMDB image database · Stores image binaries through the packaged LMDB library.
LmdbImageDatabase.cs
Paper Windows
- Paper window · Independent borderless paper surface and lifecycle host.
PaperWindow.cs - Markdown note editor · Edits and highlights lightweight Markdown notes.
MarkdownTextBox.cs - Todo editor · Supports item-oriented todo interactions.
TodoTextBox.cs - Markdown image references · Parses embedded internal image references.
MarkdownImageReferences.cs
Capsule Docking
- Capsule state machine · Models collapsed papers and applies allowed capsule transitions.
EdgeCapsuleReducer.cs - Capsule target & layout · Plans per-screen edge targets and capsule placement.
EdgeCapsuleTargetPlanner.cs - Capsule rendering · Hosts, presents, and schedules capsule animation frames.
EdgeCapsuleHost.cs
Windows & Distribution
- Windows integration · Handles placement, monitor geometry, native behavior, and fullscreen policy.
WindowNative.cs - Native LMDB build · CMake-built packaged native image-storage library.
native/lmdb/CMakeLists.txt - Release pipeline · Builds signed Windows single-file executables.
.github/workflows/release.yml
Connections 21
- Project package → WPF startup: packages
- WPF startup → App controller: starts
- WPF startup → Launch commands: receives launch intent
- Launch commands → App controller: routes intent
- Tray & shortcuts → App controller: user actions
- App controller → State store: loads and saves
- State store → Application models: serializes
- App controller → Paper window: creates and manages
- Paper window → Markdown note editor: hosts note mode
- Paper window → Todo editor: hosts todo mode
- Markdown note editor → Markdown image references: parses images
- Markdown image references → Note image store: resolves references
- Note image store → LMDB image database: stores binaries
- LMDB image database → Native LMDB build: calls native library
- Paper window → Capsule state machine: collapses and restores
- Capsule state machine → Capsule target & layout: requests placement
- Capsule target & layout → Capsule rendering: positions capsules
- Paper window → Windows integration: uses native behavior
- Windows integration → Capsule target & layout: provides screen geometry
- Release pipeline → Project package: builds and signs
- Release pipeline → Native LMDB build: packages