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.
This commit is contained in:
Yu Leng
2025-12-10 11:18:28 +08:00
parent 0a2b433697
commit 97560ea6c0
3 changed files with 21 additions and 140 deletions

View File

@@ -344,56 +344,6 @@ namespace PowerDisplay.Helpers
return Task.FromResult(result);
}
/// <summary>
/// Initialize input source for a monitor (async operation)
/// </summary>
public async Task InitializeInputSourceAsync(string monitorId, CancellationToken cancellationToken = default)
{
try
{
var sourceInfo = await GetInputSourceAsync(monitorId, cancellationToken);
if (sourceInfo.IsValid)
{
var monitor = GetMonitor(monitorId);
if (monitor != null)
{
// Store raw VCP 0x60 value (e.g., 0x11 for HDMI-1)
monitor.CurrentInputSource = sourceInfo.Current;
Logger.LogInfo($"[{monitorId}] Input source initialized: {monitor.InputSourceName}");
}
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to initialize input source for {monitorId}: {ex.Message}");
}
}
/// <summary>
/// Initialize color temperature for a monitor (async operation)
/// </summary>
public async Task InitializeColorTemperatureAsync(string monitorId, CancellationToken cancellationToken = default)
{
try
{
var tempInfo = await GetColorTemperatureAsync(monitorId, cancellationToken);
if (tempInfo.IsValid)
{
var monitor = GetMonitor(monitorId);
if (monitor != null)
{
// Store raw VCP 0x14 preset value (e.g., 0x05 for 6500K)
// No Kelvin conversion - we use discrete presets
monitor.CurrentColorTemperature = tempInfo.Current;
}
}
}
catch (Exception ex)
{
Logger.LogWarning($"Failed to initialize color temperature for {monitorId}: {ex.Message}");
}
}
/// <summary>
/// Get monitor by ID. Uses dictionary lookup for O(1) performance.
/// </summary>