Commit Graph

9 Commits

Author SHA1 Message Date
Yu Leng
0fc2fc42d3 Refactor DDC/CI brightness initialization logic
Move brightness setup from MonitorDiscoveryHelper to DdcCiController to avoid slow I2C operations during monitor discovery. Set default brightness to 50 and update after discovery. Remove unused brightness methods and type aliases. Update comments to clarify initialization responsibilities.
2025-12-11 09:27:10 +08:00
Yu Leng
6aa7e2cdf6 Refactor: unify VCP feature handling with VcpFeatureValue
Replaced BrightnessInfo with generic VcpFeatureValue struct to represent any VCP feature (brightness, color temp, input source, etc.). Updated IMonitorController and all controller implementations to use VcpFeatureValue for relevant methods. Simplified and unified VCP set/get logic, removed redundant validation and obsolete DdcCiNative methods, and updated helper classes accordingly. Improved code clarity and maintainability by generalizing VCP feature handling throughout the codebase.
2025-12-10 19:04:19 +08:00
Yu Leng
ecd8331d51 Refactor controller selection and remove CanControlMonitorAsync
Refactored MonitorManager to use dedicated controller fields for
O(1) lookup based on CommunicationMethod, replacing the async
GetControllerForMonitorAsync with a synchronous method. Removed
CanControlMonitorAsync from IMonitorController and all
implementations, simplifying the interface and controller logic.
Updated controller discovery and disposal logic accordingly.
Improved performance and maintainability by eliminating
unnecessary async checks and streamlining controller management.
2025-12-10 17:17:13 +08:00
Yu Leng
77a7c04b2e Improve monitor rotation using GDI device name
Refactor monitor discovery and rotation logic to use the GdiDeviceName property for accurate display targeting, especially in multi-monitor setups. Update the Monitor model to include GdiDeviceName, adjust DisplayRotationService and MonitorManager to use it, and enhance logging for better traceability. Also, unify hardware property application in MonitorViewModel to reduce code duplication. These changes increase reliability and maintainability of monitor control operations.
2025-12-10 14:16:28 +08:00
Yu Leng
102077a29b Remove "Link all monitor brightness" feature
Eliminates the UI and backend logic for synchronizing all monitor brightness levels. Refactors monitor list update logic to distinguish between initial load and refresh, introducing RestoreMonitorSettings for startup state restoration. Streamlines feature visibility application and settings handling for improved maintainability.
2025-12-10 11:42:23 +08:00
Yu Leng
97560ea6c0 Refactor color temp init to be synchronous in DDC/CI
Simplifies color temperature initialization by moving it from async handling in MainViewModel to synchronous initialization during monitor enumeration in DdcCiController. Removes related async methods and UI update logic, reducing complexity and ensuring color temperature values are available immediately after enumeration.
2025-12-10 11:18:28 +08:00
Yu Leng
0a2b433697 Refactor monitor discovery and initialization flow
Move all monitor initialization (capabilities, input source) into the controller discovery phase, eliminating redundant async initialization steps from MonitorManager. Remove obsolete initialization methods from MonitorManager. Add helper methods in DdcCiController for capability and input source setup. Improve logging for monitor capabilities. This streamlines monitor setup, reduces redundant work, and improves performance.
2025-12-10 11:00:36 +08:00
Yu Leng
b75db43988 Improve thread safety and simplify monitor management
Refactored `DisplayChangeWatcher` to enhance thread safety by
introducing `_initialEnumerationComplete` and ensuring state
changes and event handling are dispatched to the UI thread.

Removed `MonitorListChangedEventArgs` and the `MonitorsChanged`
event from `MonitorManager`, simplifying monitor management
logic. Updated `MainViewModel` to remove its dependency on
`MonitorsChanged`.

Cleaned up `TrayIconService` by removing unused `_showWindowAction`
and simplifying resource fallback logic. Fixed minor wording
inconsistencies in XML documentation.

These changes improve maintainability, thread safety, and
performance.
2025-12-08 14:51:02 +08:00
Yu Leng
f07b4942ef Refactor and clean up PowerDisplay codebase
- Removed `GetCurrentRotation` and related methods from `DisplayRotationService.cs` as they are no longer required.
- Removed Kelvin-to-VCP conversion logic and formatting utilities from `MonitorValueConverter.cs`.
- Refactored `ProfileHelper.cs` by consolidating profile name generation logic and removing unused validation methods.
- Removed unused constants from `AppConstants.cs`, including DDC/CI protocol and process synchronization constants.
- Reorganized namespaces, moving `MonitorListChangedEventArgs` and `MonitorManager` to `PowerDisplay.Helpers`.
- Replaced `PowerDisplay.Core` references with `PowerDisplay.Helpers` across multiple files.
- Performed general cleanup, including removing unused `using` directives and redundant code.

These changes simplify the codebase, improve maintainability, and enhance the overall structure.
2025-12-04 06:14:01 +08:00