private void OnBtnClick(string obj) { bool btnCloseStatus = true; bool isAsync = false; if (hidInfoLst[selectHIDIdx].HIDInfoStruct.Pid == 0x8824) { isAsync = true; } if (obj.Equals(HIDDemoControlConstants.OpenHID)) { if (!hidGUIModel.SetHIDOpen(selectHIDIdx, isAsync)) { btnCloseStatus = false; } } if (obj.Equals(HIDDemoControlConstants.CloseHID)) { hidGUIModel.SetHIDClose(selectHIDIdx); btnCloseStatus = false; } if (obj.Equals(HIDDemoControlConstants.SendHID)) { byte[] data = new byte[64]; data[0] = 0x80; data[1] = 0x01; hidGUIModel.SetHIDSend(selectHIDIdx, data, isAsync); } if (obj.Equals(HIDDemoControlConstants.HeadSetCMD)) { SetStaticColor(selectHIDIdx); //byte[] data2 = new byte[15]; ////data2[0] = 0xFF; //data2[0] = 0x05; //data2[1] = 0x02; //hidGUIModel.SetHIDSend(selectHIDIdx, data2, isAsync); } HIDOPButtonDT btnClose = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.CloseHID)) as HIDOPButtonDT; HIDOPButtonDT btnOpen = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.OpenHID)) as HIDOPButtonDT; HIDOPButtonDT btnSend = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.SendHID)) as HIDOPButtonDT; HIDOPButtonDT btnHead = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.HeadSetCMD)) as HIDOPButtonDT; btnClose.BtnEnabled = btnSend.BtnEnabled = btnHead.BtnEnabled = btnCloseStatus; btnOpen.BtnEnabled = !btnCloseStatus; }
private void DInfoItem_OnRadioButtonChecked1(HIDDisplayInfoItem infoItem) { if (infoItem.MenuChecked) { if (selectHIDIdx > -1) { //Close previous HID hidGUIModel.SetHIDClose(selectHIDIdx); } HIDOPButtonDT btnClose = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.CloseHID)) as HIDOPButtonDT; HIDOPButtonDT btnSend = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.SendHID)) as HIDOPButtonDT; btnClose.BtnEnabled = btnSend.BtnEnabled = false; //Select new one. selectHIDIdx = infoItem.FieldIdx; HIDOPButtonDT btnOpen = HIDOPButtonCollection.FirstOrDefault(x => x.MenuName.Equals(HIDDemoControlConstants.OpenHID)) as HIDOPButtonDT; btnOpen.BtnEnabled = true; MessageText.MsgText += $"\r\nInfoItem [{selectHIDIdx}] selected"; } }