private void HandleButtons(Xk24.XKeyEventArgs e) { //Gets the button number (CID) of the button that has changed state int button = (e.CID - 1000); String ButtonNum = (e.CID - 1000).ToString(); if (e.PressState == true) //button press lblState.Text = ButtonNum + " DOWN"; else lblState.Text = ButtonNum + " UP"; if(currentKeys.ContainsKey(button)) { Key key = currentKeys[button]; if(e.PressState) buttonStates[button] = !(buttonStates[button]); if ((key.type == KeyType.normal && e.PressState == true) || (key.type == KeyType.toggle && e.PressState == true && buttonStates[button]==true)) { applyKeyPosition(button, key.on); client.Publish(key.topic, Encoding.UTF8.GetBytes("1"), 0, false); } else if(key.type == KeyType.normal || (key.type == KeyType.toggle && e.PressState == true)) { applyKeyPosition(button, key.off); client.Publish(key.topic, Encoding.UTF8.GetBytes("0"), 0, false); } } }
private void xk24_1_ButtonChange(Xk24.XKeyEventArgs e) { HandleButtons(e); }
private void HandleButtons(Xk24.XKeyEventArgs e) { //Gets the button number (CID) of the button that has changed state String ButtonNum = (e.CID - 1000).ToString(); if (e.PressState == true) //button press { switch (e.CID) { case 1001: lblButton01.Text = "01-dn"; break; case 1002: lblButton02.Text = "02-dn"; break; case 1003: lblButton03.Text = "03-dn"; break; case 1004: lblButton04.Text = "04-dn"; break; case 1005: lblButton05.Text = "05-dn"; break; case 1006: lblButton06.Text = "06-dn"; break; case 1007: lblButton07.Text = "07-dn"; break; case 1008: lblButton08.Text = "08-dn"; break; case 1009: lblButton09.Text = "09-dn"; break; case 1010: lblButton10.Text = "10-dn"; break; case 1011: lblButton11.Text = "11-dn"; break; case 1012: lblButton12.Text = "12-dn"; break; case 1013: lblButton13.Text = "13-dn"; break; case 1014: lblButton14.Text = "14-dn"; break; case 1015: lblButton15.Text = "15-dn"; break; case 1016: lblButton16.Text = "16-dn"; break; case 1017: lblButton17.Text = "17-dn"; break; case 1018: lblButton18.Text = "18-dn"; break; case 1019: lblButton19.Text = "19-dn"; break; case 1020: lblButton20.Text = "20-dn"; break; case 1021: lblButton21.Text = "21-dn"; break; case 1022: lblButton22.Text = "22-dn"; break; case 1023: lblButton23.Text = "23-dn"; break; case 1024: lblButton24.Text = "24-dn"; break; } } else //button release { switch (e.CID) { case 1001: lblButton01.Text = "01-up"; break; case 1002: lblButton02.Text = "02-up"; break; case 1003: lblButton03.Text = "03-up"; break; case 1004: lblButton04.Text = "04-up"; break; case 1005: lblButton05.Text = "05-up"; break; case 1006: lblButton06.Text = "06-up"; break; case 1007: lblButton07.Text = "07-up"; break; case 1008: lblButton08.Text = "08-up"; break; case 1009: lblButton09.Text = "09-up"; break; case 1010: lblButton10.Text = "10-up"; break; case 1011: lblButton11.Text = "11-up"; break; case 1012: lblButton12.Text = "12-up"; break; case 1013: lblButton13.Text = "13-up"; break; case 1014: lblButton14.Text = "14-up"; break; case 1015: lblButton15.Text = "15-up"; break; case 1016: lblButton16.Text = "16-up"; break; case 1017: lblButton17.Text = "17-up"; break; case 1018: lblButton18.Text = "18-up"; break; case 1019: lblButton19.Text = "19-up"; break; case 1020: lblButton20.Text = "20-up"; break; case 1021: lblButton21.Text = "21-up"; break; case 1022: lblButton22.Text = "22-up"; break; case 1023: lblButton23.Text = "23-up"; break; case 1024: lblButton24.Text = "24-up"; break; } } lblUID.Text = "Unit ID: " + xk24_1.ConnectedDevices[0].UnitID.ToString(); }
private void xk24_1_GenerateReportData(Xk24.XKeyEventArgs e) { HandleButtons(e); }
private void xk24_1_ButtonChange(Xk24.XKeyEventArgs e) { //This method handles the button change event for the device HandleButtons(e); }
private void HandleButtons(Xk24.XKeyEventArgs e) { //Handle state changes of the buttons if (e.PressState == true) //button press { switch (e.CID) { case 1001: lblButton01.Text = "01-dn"; break; case 1002: lblButton02.Text = "02-dn"; break; case 1003: lblButton03.Text = "03-dn"; break; case 1004: lblButton04.Text = "04-dn"; break; case 1005: lblButton05.Text = "05-dn"; break; case 1006: lblButton06.Text = "06-dn"; break; case 1007: lblButton07.Text = "07-dn"; break; case 1008: lblButton08.Text = "08-dn"; break; case 1009: lblButton09.Text = "09-dn"; break; case 1010: lblButton10.Text = "10-dn"; break; case 1011: lblButton11.Text = "11-dn"; break; case 1012: lblButton12.Text = "12-dn"; break; case 1013: lblButton13.Text = "13-dn"; break; case 1014: lblButton14.Text = "14-dn"; break; case 1015: lblButton15.Text = "15-dn"; break; case 1016: lblButton16.Text = "16-dn"; break; case 1017: lblButton17.Text = "17-dn"; break; case 1018: lblButton18.Text = "18-dn"; break; case 1019: lblButton19.Text = "19-dn"; break; case 1020: lblButton20.Text = "20-dn"; break; case 1021: lblButton21.Text = "21-dn"; break; case 1022: lblButton22.Text = "22-dn"; break; case 1023: lblButton23.Text = "23-dn"; break; case 1024: lblButton24.Text = "24-dn"; break; case 1025: lblProgSwitch.Text = "Prog. Switch-dn"; break; } } else //button release { switch (e.CID) { case 1001: lblButton01.Text = "01-up"; break; case 1002: lblButton02.Text = "02-up"; break; case 1003: lblButton03.Text = "03-up"; break; case 1004: lblButton04.Text = "04-up"; break; case 1005: lblButton05.Text = "05-up"; break; case 1006: lblButton06.Text = "06-up"; break; case 1007: lblButton07.Text = "07-up"; break; case 1008: lblButton08.Text = "08-up"; break; case 1009: lblButton09.Text = "09-up"; break; case 1010: lblButton10.Text = "10-up"; break; case 1011: lblButton11.Text = "11-up"; break; case 1012: lblButton12.Text = "12-up"; break; case 1013: lblButton13.Text = "13-up"; break; case 1014: lblButton14.Text = "14-up"; break; case 1015: lblButton15.Text = "15-up"; break; case 1016: lblButton16.Text = "16-up"; break; case 1017: lblButton17.Text = "17-up"; break; case 1018: lblButton18.Text = "18-up"; break; case 1019: lblButton19.Text = "19-up"; break; case 1020: lblButton20.Text = "20-up"; break; case 1021: lblButton21.Text = "21-up"; break; case 1022: lblButton22.Text = "22-up"; break; case 1023: lblButton23.Text = "23-up"; break; case 1024: lblButton24.Text = "24-up"; break; case 1025: lblProgSwitch.Text = "Prog. Switch-up"; break; } } lblUID.Text = "Unit ID: " + xk24_1.ConnectedDevices[0].UnitID.ToString(); //Time Stamp Info long absolutetime = e.TimeStamp; //gives time in ms since boot of X-keys unit long absolutetimesec = absolutetime / 1000; //convert to seconds lblATime.Text = "Absolute Time: " + absolutetimesec.ToString() + " s"; if (saveabsolutetime != -1) { lblDTime.Text = "Delta Time: " + (absolutetime - saveabsolutetime).ToString() + " ms"; //this gives the time between button presses or between any generated data reports } saveabsolutetime = absolutetime; }