public bool Equals(KeyLed other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this._keyId.Equals(other._keyId));
 }
示例#2
0
        private void init()
        {
            int totalLedCount = MAX_LED_COLUMN * MAX_LED_ROW;

            if (activeKeyLeds == null)
            {
                activeKeyLeds = new Dictionary <int, KeyLed>();
                for (int i = 0; i < totalLedCount; i++)
                {
                    int row    = (int)Math.Ceiling((double)(i + 1) / 22);
                    int column = (i + 1);
                    if (column > MAX_LED_COLUMN)
                    {
                        column = (i + 1) - (22 * (row - 1));
                    }
                    var keyItem = new KeyLed(row, column, effectColor, bgColor);
                    activeKeyLeds.Add(int.Parse(row.ToString() + column.ToString()), keyItem);
                }
            }

            if (timer != null)
            {
                timer.Stop();
                timer = null;
            }

            timer          = new Timer();
            timer.Tick    += new EventHandler(TimerEventProcessor);
            timer.Interval = 30;
            timer.Start();

            if (CoolerMasterDLL.IsDevicePlug())
            {
                //MessageBox.Show("Connected");
                CoolerMasterDLL.EnableLedControl(true);
                CoolerMasterDLL.SetFullLedColor(bgColor.R, bgColor.G, bgColor.B);
            }
            else
            {
                MessageBox.Show("Keyboard is not connected");
            }
        }
示例#3
0
        private static void animateLeds(int[] rows, Color color)
        {
            if (CURRENT_LED_COLUMN == MAX_LED_COLUMN - 1)
            {
                currentDirection = DIRECTION.LEFT;
            }

            if (CURRENT_LED_COLUMN <= 0)
            {
                currentDirection = DIRECTION.RIGHT;
            }

            if (currentDirection == DIRECTION.RIGHT)
            {
                foreach (int r in rows)
                {
                    //KeyLed led = activeKeyLeds.Find(x => x._keyId == int.Parse((r).ToString() + (CURRENT_LED_COLUMN + 1).ToString()));
                    int    keyId = int.Parse((r).ToString() + (CURRENT_LED_COLUMN + 1).ToString());
                    KeyLed led   = activeKeyLeds[keyId];
                    led.lightOn();
                }
                CURRENT_LED_COLUMN++;
            }

            if (currentDirection == DIRECTION.LEFT)
            {
                foreach (int r in rows)
                {
                    //KeyLed led = activeKeyLeds.Find(x => x._keyId == int.Parse((r).ToString() + (CURRENT_LED_COLUMN + 1).ToString()));
                    int    keyId = int.Parse((r).ToString() + (CURRENT_LED_COLUMN + 1).ToString());
                    KeyLed led   = activeKeyLeds[keyId];
                    led.lightOn();
                }
                CURRENT_LED_COLUMN--;
            }
        }