private void UpdateConfiguration() { var isSmooth = _settingsService.IsConfigurationSmoothingEnabled && !IsCyclePreviewEnabled; CurrentConfiguration = isSmooth ? CurrentConfiguration.StepTo(TargetConfiguration, 30, 0.008) : TargetConfiguration; _gammaService.SetGamma(CurrentConfiguration); }
private void UpdateConfiguration() { bool IsUpdateNeeded() { // Gamma is stale if (_isGammaStale) { return(true); } // No change if (CurrentColorConfiguration == TargetColorConfiguration) { return(false); } // One of the extreme states if (TargetColorConfiguration == _settingsService.NightConfiguration || TargetColorConfiguration == _settingsService.DayConfiguration) { return(true); } // Change is too small if (Math.Abs(TargetColorConfiguration.Temperature - CurrentColorConfiguration.Temperature) < 25 && Math.Abs(TargetColorConfiguration.Brightness - CurrentColorConfiguration.Brightness) < 0.01) { return(false); } return(true); } // Avoid redundant updates if (!IsUpdateNeeded()) { return; } // Update current configuration var isSmooth = _settingsService.IsConfigurationSmoothingEnabled && !IsCyclePreviewEnabled; CurrentColorConfiguration = isSmooth ? CurrentColorConfiguration.StepTo(TargetColorConfiguration, 30, 0.008) : TargetColorConfiguration; // Set gamma to new value _gammaService.SetGamma(CurrentColorConfiguration); _isGammaStale = false; }