Exemplo n.º 1
0
        private bool SetColor(OutputConfiguration outputConfig, ColorF colorToSet, bool isResend)
        {
            OutputService outputService = outputConfig.OutputService;

            IList <ColorTransformerContext> colorTransformerContexts = outputConfig.ColorTransformerContexts;

            var outputColor = _colorTransformerService.Transform(colorTransformerContexts, colorToSet);

            if (!isResend && outputConfig.LastColor.HasValue && outputService.ColorsEqual(outputColor, outputConfig.LastColor.Value))
            {
                return(false);
            }

            outputConfig.LastColor        = outputColor;
            outputConfig.LastColorSetTime = DateTime.UtcNow;

            if (isResend)
            {
                outputConfig.ResendCount++;
            }
            else
            {
                outputConfig.ResendCount = 0;
            }

            outputService.SetColor(outputColor, outputConfig.OutputInfo);
            return(true);
        }