| | |
| | | { |
| | | public class AcControlPage_AddIrButton : FrameLayout |
| | | { |
| | | public AcControlPage_AddIrButton() |
| | | Action action; |
| | | |
| | | public AcControlPage_AddIrButton(Action act) |
| | | { |
| | | action = act; |
| | | } |
| | | public void Show(Function control) |
| | | { |
| | |
| | | |
| | | //添加数据对象 |
| | | AttributesStatus buttonObj = new AttributesStatus(); |
| | | |
| | | //防止key不唯一 |
| | | var attrCount = control.attributes.Count; |
| | | var keyString = "key" + attrCount; |
| | | while (true) |
| | | { |
| | | if (control.attributes.Find((obj) => obj.key == keyString) == null) |
| | | { |
| | | break; |
| | | } |
| | | keyString = "key" + (++attrCount); |
| | | } |
| | | buttonObj.key = "key" + control.attributes.Count.ToString(); |
| | | buttonObj.value = texts; |
| | | |
| | | PirSend.CodeStudy(control.deviceId, buttonObj, (responsePackNew) => |
| | | { |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | Method method = new Method(); |
| | | Method.buttondata = ""; |
| | | var mqttdate = method.MqttDate("按键", control.sid, 25); |
| | | if (mqttdate != null) |
| | | { |
| | | this.RemoveFromParent(); |
| | | control.attributes.Add(new FunctionAttributes() { key = buttonObj.key, value = new System.Collections.Generic.List<string>() { buttonObj.value } }); |
| | | } |
| | | else |
| | | { |
| | | replication.RemView(); |
| | | new TipPopView().FlashingBox(Language.StringByID(StringId.tianjiashibai)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew, ""); |
| | | } |
| | | |
| | | }); |
| | | |
| | | |
| | | PirSend.CodeStudy(new Control() { deviceId = control.deviceId, sid = control.sid }, buttonObj, (mqttData) => |
| | | { |
| | | if (mqttData != null) |
| | | { |
| | | control.attributes.Add(new FunctionAttributes() { key = buttonObj.key, value = new System.Collections.Generic.List<string>() { buttonObj.value } }); |
| | | this.RemoveFromParent(); |
| | | action?.Invoke(); |
| | | //new TipPopView().FlashingBox(Language.StringByID(StringId.tianjiachenggong)); |
| | | } |
| | | else |
| | | { |
| | | this.RemoveFromParent(); |
| | | new TipPopView().FlashingBox(Language.StringByID(StringId.tianjiashibai)); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | } |
| | | } |
| | | } |