How emoacht/monitorian works
Project Type and Purpose
• This is a Windows desktop application (WPF) called Monitorian.
• It follows an MVVM pattern: a thin “Monitorian” WPF host, a rich “Monitorian.Core” library containing Models, ViewModels, Views, and several supporting class libraries.
File‐Structure Analysis
• Top‐level projects under Source/:
• Monitorian (WPF EXE)
• Monitorian.Core (class library: MVVM implementation)
• ScreenFrame (class library: window drawing, movers, watchers)
• StartupAgency (class library / EXE: registry/startup task broker)
• Installer (WiX installer)
• Monitorian.Test (unit tests)
• Resources and assets stored under Images/, docs/, and Localization (.resx files).
• Build scripts and configs: .sln, Directory.Build.props, *.csproj, App.configs, WiX .wxs.
a. Presentation Layer
• Monitorian.exe: WPF “App.xaml → AppController → ViewManager”
• UI Windows: MainWindow, MenuWindow
b. Application/Core Layer
• Monitorian.Core:
• Models: MonitorManager, DdcMonitorItem, DisplayInformationProvider, SettingsCore, Logger, etc.
• ViewModels: MainWindowViewModel, MenuWindowViewModel, MonitorViewModel
• Views: XAML, Behaviors, Controls, Converters, Themes
• Services: AppDataService, LanguageService, ConsoleService
• MVVM pattern: Views ←→ ViewModels ←→ Models
c. Infrastructure/Platform Layer
• ScreenFrame.dll: window painting, watchers (WindowWatcher, NotifyIconHelper, WindowPainter, Movers)
• StartupAgency.exe/dll: StartupTaskBroker, BridgeWorker, RegistryWorker (manages “Start on sign in” registry entry or scheduled task)
• OS & External Interfaces:
• DDC/CI brightness control (via native APIs)
• WMI for system events (SessionWatcher, PowerWatcher)
• File system (settings under %LOCALAPPDATA%\Monitorian)
• Registry (HKCU\…\Run)
d. Installer
• WiX project (.wixproj) builds MSI, drops Monitorian.exe, StartupAgent, ScreenFrame, Monitorian.Core, etc., and registers startup agent if needed.
e. Unit Tests
• Monitorian.Test: DeviceConversionTest, MonitorConfigurationTest (validates core algorithms).
Relationships and Data Flows
• View binds to MainWindowViewModel → invokes MonitorManager (Model) → queries DisplayInformationProvider → native DDC/CI calls → returns brightness/contrast
• User moves sliders → ViewModel calls MonitorManager.SetBrightness → DDC/CI command → Model raises event → ViewModel updates View
• Settings changes → AppDataService persists JSON/XML under AppData
• On “Start on sign in,” Monitorian.exe uses StartupAgency API to register the agent in registry or task scheduler
• ScreenFrame.WindowWatcher tracks window focus events, DPI changes → notifies core
Architectural Patterns and Principles
• MVVM (Model–View–ViewModel) to separate UI from business logic
• Modularization: separate assemblies for core logic, UI utilities, OS interaction, installation, and startup management
• Observer pattern: watchers (TimerWatcher, SessionWatcher) fire events to ViewModels
• Dependency inversion: core services (IAppDataService, ILogger) injected/bound at AppController startup
• Resource-based globalization via .resx files in Monitorian.Core