diff --git a/src/modules/powerdisplay/PowerDisplay.Lib/Services/ProfileService.cs b/src/modules/powerdisplay/PowerDisplay.Lib/Services/ProfileService.cs index 53d8f7163a..b49aa50a0a 100644 --- a/src/modules/powerdisplay/PowerDisplay.Lib/Services/ProfileService.cs +++ b/src/modules/powerdisplay/PowerDisplay.Lib/Services/ProfileService.cs @@ -43,6 +43,7 @@ namespace PowerDisplay.Common.Services public static IProfileService Instance { get; } = new ProfileService(); /// + /// Initializes a new instance of the class. /// Private constructor to enforce singleton pattern for instance-based access. /// Static methods remain available for backward compatibility. /// diff --git a/src/modules/powerdisplay/PowerDisplay.Lib/Services/ThemeChangedEventArgs.cs b/src/modules/powerdisplay/PowerDisplay.Lib/Services/ThemeChangedEventArgs.cs index 3c242b3c33..ee43ec5e3c 100644 --- a/src/modules/powerdisplay/PowerDisplay.Lib/Services/ThemeChangedEventArgs.cs +++ b/src/modules/powerdisplay/PowerDisplay.Lib/Services/ThemeChangedEventArgs.cs @@ -12,12 +12,12 @@ namespace PowerDisplay.Common.Services public class ThemeChangedEventArgs : EventArgs { /// - /// Whether the system is currently in light mode + /// Gets a value indicating whether whether the system is currently in light mode /// public bool IsLightMode { get; } /// - /// Profile name to apply (null if no profile configured for current theme) + /// Gets profile name to apply (null if no profile configured for current theme) /// public string? ProfileToApply { get; } diff --git a/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.Settings.cs b/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.Settings.cs index 08125ebac9..1ff8733fd9 100644 --- a/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.Settings.cs +++ b/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.Settings.cs @@ -121,7 +121,7 @@ public partial class MainViewModel if (monitorVm != null) { // Apply color temperature directly - await ApplyColorTemperatureAsync(monitorVm, pendingOp.ColorTemperatureVcp); + await monitorVm.SetColorTemperatureAsync(pendingOp.ColorTemperatureVcp); Logger.LogInfo($"[Settings] Successfully applied color temperature to monitor '{pendingOp.MonitorId}'"); // Update the monitor's ColorTemperatureVcp in settings to match the applied value @@ -185,7 +185,7 @@ public partial class MainViewModel if (pendingOp.MonitorSettings != null && pendingOp.MonitorSettings.Count > 0) { // Apply profile settings to monitors - await ApplyProfileAsync(pendingOp.ProfileName, pendingOp.MonitorSettings); + await ApplyProfileAsync(pendingOp.MonitorSettings); // Note: We no longer track "current profile" - profiles are just templates Logger.LogInfo($"[Profile] Successfully applied profile '{pendingOp.ProfileName}'"); @@ -235,7 +235,7 @@ public partial class MainViewModel } // Apply the profile - await ApplyProfileAsync(e.ProfileToApply, profile.MonitorSettings); + await ApplyProfileAsync(profile.MonitorSettings); Logger.LogInfo($"[LightSwitch Integration] Successfully applied profile '{e.ProfileToApply}'"); } catch (Exception ex) @@ -248,29 +248,18 @@ public partial class MainViewModel /// /// Apply profile settings to monitors /// - private async Task ApplyProfileAsync(string profileName, List monitorSettings) + private async Task ApplyProfileAsync(List monitorSettings) { var updateTasks = new List(); foreach (var setting in monitorSettings) { - // Find monitor by InternalName first (unique identifier), fall back to HardwareId for old profiles - MonitorViewModel? monitorVm = null; - - if (!string.IsNullOrEmpty(setting.MonitorInternalName)) - { - monitorVm = Monitors.FirstOrDefault(m => m.InternalName == setting.MonitorInternalName); - } - - // Fallback to HardwareId for backward compatibility with old profiles - if (monitorVm == null) - { - monitorVm = Monitors.FirstOrDefault(m => m.HardwareId == setting.HardwareId); - } + // Find monitor by InternalName (unique identifier) + var monitorVm = Monitors.FirstOrDefault(m => m.InternalName == setting.MonitorInternalName); if (monitorVm == null) { - Logger.LogWarning($"[Profile] Monitor with InternalName '{setting.MonitorInternalName}' or HardwareId '{setting.HardwareId}' not found (disconnected?)"); + Logger.LogWarning($"[Profile] Monitor with InternalName '{setting.MonitorInternalName}' not found (disconnected?)"); continue; } @@ -312,15 +301,6 @@ public partial class MainViewModel } } - /// - /// Apply color temperature to a specific monitor - /// - private async Task ApplyColorTemperatureAsync(MonitorViewModel monitorVm, int colorTemperature) - { - // Use MonitorViewModel's unified method - await monitorVm.SetColorTemperatureAsync(colorTemperature); - } - /// /// Restore monitor settings from state file - ONLY called at startup when RestoreSettingsOnStartup is enabled /// diff --git a/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.cs b/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.cs index ecebe78c14..04cb619f40 100644 --- a/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.cs +++ b/src/modules/powerdisplay/PowerDisplay/ViewModels/MainViewModel.cs @@ -238,7 +238,7 @@ public partial class MainViewModel : INotifyPropertyChanged, IDisposable if (profile != null && profile.IsValid()) { Logger.LogInfo($"[Profile] Applying profile '{profile.Name}' from quick apply"); - await ApplyProfileAsync(profile.Name, profile.MonitorSettings); + await ApplyProfileAsync(profile.MonitorSettings); } }