コード例 #1
0
ファイル: GammaService.cs プロジェクト: qiankunya/LightBulb
        public void SetGamma(ColorConfiguration configuration)
        {
            // Skip if gamma doesn't need refreshing and color configuration didn't change much since last time
            if (!IsGammaStale() && !IsSignificantChange(configuration))
            {
                return;
            }

            EnsureDeviceContextIsValid();

            _deviceContext.SetGamma(
                GetRed(configuration) * configuration.Brightness,
                GetGreen(configuration) * configuration.Brightness,
                GetBlue(configuration) * configuration.Brightness
                );

            _lastConfiguration   = configuration;
            _lastUpdateTimestamp = DateTimeOffset.Now;
        }