| | |
| | | ///下一步的点击事件 |
| | | saveBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (control.status.Count>29) { |
| | | if (control.status.Count > 29) |
| | | { |
| | | ///超出30个红外宝内存满了会出现异常 |
| | | new PirMethod().ErrorShow(null, "添加按钮超出30个"); |
| | | return; |
| | |
| | | |
| | | //添加数据对象 |
| | | Entity.AttributesStatus buttonObj = new Entity.AttributesStatus(); |
| | | buttonObj.key = "key" + control.status.Count.ToString(); |
| | | string keyName = GetKeyName(control.status); |
| | | buttonObj.key = keyName; |
| | | buttonObj.value = texts; |
| | | |
| | | PirSend.CodeStudy(control, buttonObj, (mqttdate) => |
| | |
| | | { |
| | | replication.RemView(); |
| | | PirMethod method = new PirMethod(); |
| | | method.ErrorShow(null,"添加失败"); |
| | | method.ErrorShow(null, "添加失败"); |
| | | } |
| | | |
| | | }); |
| | |
| | | PirMethod.RefreshView("PirMain"); |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查找唯一健名值 |
| | | /// </summary> |
| | | /// <param name="listKeyName">已经存在健名列表</param> |
| | | /// <returns></returns> |
| | | private string GetKeyName(List<Entity.AttributesStatus> listKeyName) |
| | | { |
| | | //目前红外宝学习按钮最多是30个; |
| | | for (int i = 0; i < 50; i++) |
| | | { |
| | | string keyName = "key" + i.ToString(); |
| | | ///查找是否存在 |
| | | var currKeyName = listKeyName.Find((c) => c.key == keyName); |
| | | if (currKeyName == null) |
| | | { |
| | | return keyName; |
| | | } |
| | | } |
| | | |
| | | return "key" + listKeyName.Count; |
| | | } |
| | | |
| | | } |
| | | } |