Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CorsairDeviceProvider"/> class.
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown if this constructor is called even if there is already an instance of this class.</exception>
        public CorsairDeviceProvider()
        {
            if (_instance != null)
            {
                throw new InvalidOperationException($"There can be only one instance of type {nameof(CorsairDeviceProvider)}");
            }
            _instance = this;

            UpdateTrigger = new DeviceUpdateTrigger();
            _updateQueue  = new CorsairUpdateQueue(UpdateTrigger);
        }
Example #2
0
        /// <summary>
        /// Initializes the device.
        /// </summary>
        public void Initialize(CorsairUpdateQueue updateQueue)
        {
            UpdateQueue = updateQueue;

            InitializeLayout();

            foreach (Led led in LedMapping.Values)
            {
                CorsairLedId ledId = (CorsairLedId)led.CustomData;
                if (ledId != CorsairLedId.Invalid)
                {
                    InternalLedMapping.Add(ledId, led);
                }
            }

            if (Size == Size.Invalid)
            {
                Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
                Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
            }
        }