mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Refactor color temperature operation handling
Introduced `ColorTemperatureOperation` class to manage pending color temperature changes. Updated `MainViewModel` to process operations for specific monitors, improving efficiency and separation of concerns. Added `PendingColorTemperatureOperation` property to `PowerDisplayProperties` for tracking operations. Enhanced IPC messaging with `MonitorId` and `ColorTemperature` in `PowerDisplayActionMessage`. Refactored `PowerDisplayViewModel` and `PowerDisplayPage` to directly apply color temperature to specified monitors. Improved logging for better traceability.
This commit is contained in:
@@ -355,11 +355,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trigger PowerDisplay.exe to apply color temperature from settings file
|
||||
/// Trigger PowerDisplay.exe to apply color temperature to a specific monitor
|
||||
/// Called after user confirms color temperature change in Settings UI
|
||||
/// </summary>
|
||||
public void TriggerApplyColorTemperature()
|
||||
/// <param name="monitorInternalName">Internal name (ID) of the monitor</param>
|
||||
/// <param name="colorTemperature">Color temperature value to apply</param>
|
||||
public void ApplyColorTemperatureToMonitor(string monitorInternalName, int colorTemperature)
|
||||
{
|
||||
// Set the pending operation in settings
|
||||
_settings.Properties.PendingColorTemperatureOperation = new ColorTemperatureOperation
|
||||
{
|
||||
MonitorId = monitorInternalName,
|
||||
ColorTemperature = colorTemperature,
|
||||
};
|
||||
|
||||
// Save settings to persist the operation
|
||||
SettingsUtils.SaveSettings(_settings.ToJsonString(), PowerDisplaySettings.ModuleName);
|
||||
|
||||
// Send IPC message to trigger PowerDisplay to process the operation
|
||||
var actionMessage = new PowerDisplayActionMessage
|
||||
{
|
||||
Action = new PowerDisplayActionMessage.ActionData
|
||||
@@ -368,6 +381,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
ActionName = "ApplyColorTemperature",
|
||||
Value = string.Empty,
|
||||
MonitorId = monitorInternalName,
|
||||
ColorTemperature = colorTemperature,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user