| | |
| | | } |
| | | public void Show(Control control, bool bool_library) |
| | | { |
| | | //数据转换 |
| | | Entity.Function function = new Entity.Function(); |
| | | { |
| | | function.sid = control.sid; |
| | | function.deviceId = control.deviceId; |
| | | function.name = control.name; |
| | | function.spk = control.spk; |
| | | //function.attributes.AddRange(control.status); |
| | | //遥控器添加到列表; |
| | | if (null == Pir.currPir.FunctioList.Find((c) => c.sid == function.sid)) |
| | | { |
| | | Pir.currPir.FunctioList.Add(function); |
| | | } |
| | | } |
| | | #region 界面布局 |
| | | this.BackgroundColor = CSS.CSS_Color.viewMiddle; |
| | | PirDevice.View.TopView topView = new View.TopView(); |
| | | topView.topNameBtn.TextID = StringId.tianjiayaokongqi; |
| | | this.AddChidren(topView.FLayoutView()); |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { RemoveFromParent(); }; |
| | | |
| | | FrameLayout fLayout = new FrameLayout |
| | | { |
| | |
| | | Width = Application.GetRealWidth(375), |
| | | }; |
| | | this.AddChidren(fLayout); |
| | | // |
| | | //成功图标 |
| | | Button iconBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(28), |
| | |
| | | quyuPatchView.frameLayout.Y = namePatchView.frameLayout.Bottom; |
| | | this.AddChidren(quyuPatchView.FLayoutView()); |
| | | quyuPatchView.btnText1.TextID = StringId.suoshuquyu; |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(function); |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId)); |
| | | |
| | | //继续添加 |
| | | Button addBtn = new Button |
| | |
| | | List<string> list = new List<string>(); |
| | | for (int i = 0; i < Pir.currPir.FunctioList.Count; i++) |
| | | { |
| | | //添加所有遥控名称列表 |
| | | list.Add(Pir.currPir.FunctioList[i].name); |
| | | } |
| | | Method method = new Method(); |
| | | PirMethod method = new PirMethod(); |
| | | method.EditControlName(StringId.editName, list, control.name, (name, dialog) => |
| | | { |
| | | Method.ThreadSend(new Control { deviceId = control.deviceId, name = name }, (responsePackNew) => |
| | | //发送更新名称命令 |
| | | PirMethod.ThreadSend(new Control { deviceId = control.deviceId, name = name }, (responsePackNew) => |
| | | { |
| | | //关闭窗口 |
| | | dialog.Close(); |
| | | //更新备注 |
| | | namePatchView.btnText2.Text = name; |
| | | function.name = name; |
| | | |
| | | //更新临时设备名称 |
| | | control.name = name; |
| | | //更换内存设备名称 |
| | | GetFunction(control.deviceId).name = name; |
| | | }, "修改名称", "dialog", null, dialog); |
| | | }, () => { }); |
| | | }; |
| | | //所属区域点击事件 |
| | | quyuPatchView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Method method = new Method(); |
| | | method.ManagementPosition(function, () => |
| | | PirMethod method = new PirMethod(); |
| | | method.ManagementPosition(GetFunction(control.deviceId), () => |
| | | { |
| | | //更新区域 |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(function); |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.CurrLogicMethod.GetGetRoomName(GetFunction(control.deviceId)); |
| | | }); |
| | | }; |
| | | //继续添加点击事件 |
| | | addBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (bool_library) |
| | | { |
| | | {//继续添加库的遥控器 |
| | | PirMethod.RefreshView("PirMain");//刷新指点界面 |
| | | this.RemoveFromParent(); |
| | | RefreshView(); |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | {//继续添加自定义的遥控器 |
| | | PirMethod method = new PirMethod(); |
| | | method.AddControl(this, (controlDevice) => |
| | | { |
| | | AddButton addButton = new AddButton(); |
| | |
| | | //完成点击事件 |
| | | saveView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //刷新指点界面 |
| | | PirMethod.RefreshView("PirMain"); |
| | | //移除所有界面 |
| | | MainPage.BasePageView.RemoveViewByTag("PirView"); |
| | | RefreshView(); |
| | | |
| | | }; |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | | /// 刷新红外宝主界面 |
| | | /// 查找设备对象 |
| | | /// </summary> |
| | | void RefreshView() |
| | | /// <param name="deviceId">设备ID</param> |
| | | /// <returns></returns> |
| | | public Entity.Function GetFunction(string deviceId) |
| | | { |
| | | var fun = Pir.currPir.FunctioList.Find((c) => c.deviceId == deviceId); |
| | | if (fun != null) |
| | | { |
| | | return fun; |
| | | } |
| | | return new Entity.Function(); |
| | | } |
| | | |
| | | //移除红外宝根界面 |
| | | MainPage.BasePageView.RemoveViewByTag("PirMain"); |
| | | //重新加载界面 |
| | | var page = new PirMain(); |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | /// <summary> |
| | | /// 移除界面 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | //刷新指定界面 |
| | | PirMethod.RefreshView("PirMain"); |
| | | base.RemoveFromParent(); |
| | | } |
| | | } |
| | | } |