示例#1
0
        private bool SetDeviceColors(CorsairDeviceType type, int index, Dictionary <DeviceKeys, Color> keyColors)
        {
            List <CorsairLedColor> colors = new List <CorsairLedColor>();

            if (LedMaps.MapsMap.TryGetValue(type, out var dict) && dict.Count != 0)
            {
                foreach (var led in keyColors)
                {
                    if (dict.TryGetValue(led.Key, out var ledid))
                    {
                        colors.Add(new CorsairLedColor()
                        {
                            LedId = ledid,
                            R     = led.Value.R,
                            G     = led.Value.G,
                            B     = led.Value.B
                        });
                    }
                }
            }
            else
            {
                if (keyColors.TryGetValue(DeviceKeys.Peripheral_Logo, out var clr))
                {
                    foreach (CorsairLedId led in LedMaps.DIYLeds)
                    {
                        colors.Add(new CorsairLedColor()
                        {
                            LedId = led,
                            R     = clr.R,
                            G     = clr.G,
                            B     = clr.B
                        });
                    }
                }
            }

            if (colors.Count == 0)
            {
                return(false);
            }

            return(CUE.SetDeviceColors(index, colors.ToArray()));
        }