| | |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | //刷新界面 |
| | | UIView(vv); |
| | | //刷新界面 |
| | | UIView(vv); |
| | | }); |
| | | }); |
| | | |
| | |
| | | Height = Application.GetRealHeight(12 + 92 + (50 * pirDevice.FunctioList.Count)), |
| | | }; |
| | | vv.AddChidren(fLayout); |
| | | |
| | | //红外宝显示父控件 |
| | | FrameLayout devfLayout = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(12), |
| | | X = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(375 - 16 * 2), |
| | | Height = Application.GetRealHeight(92 + (50 * pirDevice.FunctioList.Count)), |
| | | BackgroundColor = CSS.CSS_Color.view, |
| | | Radius = (uint)Application.GetRealHeight(12), |
| | | }; |
| | | fLayout.AddChidren(devfLayout); |
| | | |
| | | |
| | | //红外宝图标 |
| | | Button priequipmentBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(16), |
| | | X = Application.GetRealWidth(5), |
| | | Width = Application.GetRealWidth(60), |
| | | Height = Application.GetRealWidth(60), |
| | | UnSelectedImagePath = "PirIcon/priequipment.png", |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | devfLayout.AddChidren(priequipmentBtn); |
| | | View.PirView pirView = new View.PirView(); |
| | | //红外宝名称 |
| | | Button deviceNameBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(16), |
| | | X = priequipmentBtn.Right + Application.GetRealWidth(7), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(20), |
| | | Text = pirDevice.name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text14, |
| | | TextColor = CSS.CSS_Color.textColor, |
| | | IsBold = true, |
| | | }; |
| | | devfLayout.AddChidren(deviceNameBtn); |
| | | //版本号 |
| | | Button versionBtn = new Button |
| | | { |
| | | Y = deviceNameBtn.Bottom + Application.GetRealHeight(4), |
| | | X = priequipmentBtn.Right + Application.GetRealWidth(7), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(17), |
| | | Text = "版本号v1.3.5", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text12, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | }; |
| | | devfLayout.AddChidren(versionBtn); |
| | | // 5/10 |
| | | Button geBtn = new Button |
| | | { |
| | | Y = versionBtn.Bottom + Application.GetRealHeight(2), |
| | | X = priequipmentBtn.Right + Application.GetRealWidth(7), |
| | | Width = Application.GetRealWidth(120), |
| | | Height = Application.GetRealHeight(17), |
| | | Text = pirDevice.FunctioList.Count.ToString(), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text12, |
| | | TextColor = CSS.CSS_Color.textConfirmColor, |
| | | }; |
| | | devfLayout.AddChidren(geBtn); |
| | | geBtn.Width = geBtn.GetTextWidth(); |
| | | // 5/10 |
| | | Button sumBtn = new Button |
| | | { |
| | | Y = versionBtn.Bottom + Application.GetRealHeight(2), |
| | | X = geBtn.Right, |
| | | Width = Application.GetRealWidth(20), |
| | | Height = Application.GetRealHeight(17), |
| | | Text = "/10", |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text12, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | }; |
| | | devfLayout.AddChidren(sumBtn); |
| | | //状态图标 |
| | | Button stateIconBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(23), |
| | | X = Application.GetRealWidth(291), |
| | | Width = Application.GetRealWidth(8), |
| | | Height = Application.GetRealWidth(8), |
| | | UnSelectedImagePath = "PirIcon/online.png", |
| | | SelectedImagePath = "PirIcon/offline.png", |
| | | }; |
| | | devfLayout.AddChidren(stateIconBtn); |
| | | //红外宝状态(在线-离线) |
| | | Button stateTextBtn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(18), |
| | | X = Application.GetRealWidth(303), |
| | | Width = Application.GetRealWidth(30), |
| | | Height = Application.GetRealHeight(17), |
| | | TextID = StringId.zaixianhwb, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text12, |
| | | TextColor = 0xFF67D569,// CSS.CSS_Color.textColor, |
| | | SelectedTextColor = CSS.CSS_Color.textRedColor, |
| | | IsBold = true, |
| | | }; |
| | | devfLayout.AddChidren(stateTextBtn); |
| | | pirView.deviceNameBtn.Text = pirDevice.name; |
| | | //红外宝当前有多少个遥控器 |
| | | pirView.geBtn.Text = pirDevice.FunctioList.Count.ToString(); |
| | | //红外宝是否在线-离线 |
| | | if (pirDevice.online) |
| | | { |
| | | stateIconBtn.IsSelected = true; |
| | | stateTextBtn.IsSelected = true; |
| | | pirView.stateIconBtn.IsSelected = true; |
| | | pirView.stateTextBtn.IsSelected = true; |
| | | } |
| | | else |
| | | { |
| | | stateIconBtn.IsSelected = false; |
| | | stateTextBtn.IsSelected = false; |
| | | pirView.stateIconBtn.IsSelected = false; |
| | | pirView.stateTextBtn.IsSelected = false; |
| | | } |
| | | //线 |
| | | Button lineBtn = new Button |
| | | //标记红外宝 |
| | | pirView.clickBtn.Tag = pirDevice; |
| | | //红外宝点击事件 |
| | | pirView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | Y = Application.GetRealHeight(92) - 1, |
| | | X = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(343 - 16 * 2), |
| | | Height = 1, |
| | | BackgroundColor = CSS.CSS_Color.viewLine, |
| | | }; |
| | | devfLayout.AddChidren(lineBtn); |
| | | //点击事件 |
| | | FrameLayout clickFram = new FrameLayout |
| | | { |
| | | Y = Application.GetRealHeight(12), |
| | | X = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(375 - 16 * 2), |
| | | Height = Application.GetRealHeight(92), |
| | | BackgroundColor = 0x00000000, //CSS.CSS_Color.view, |
| | | Radius = (uint)Application.GetRealHeight(12), |
| | | Tag = Pir.pirDeviceList[i], |
| | | }; |
| | | fLayout.AddChidren(clickFram); |
| | | |
| | | clickFram.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var pirclick = (clickFram.Tag as Pir); |
| | | var pirclick = (pirView.clickBtn.Tag as Pir); |
| | | NewSwitchView(pirclick, vv); |
| | | }; |
| | | |
| | | //加载界面 |
| | | pirView.Show(pirDevice.FunctioList.Count, fLayout); |
| | | if (Pir.pirDeviceList.Count - 1 == i) |
| | | { |
| | | //最后一个后面增加间隔背景 |
| | |
| | | for (int j = 0; j < pirDevice.FunctioList.Count; j++) |
| | | { |
| | | var control = pirDevice.FunctioList[j]; |
| | | RowLayout funControlRow = new RowLayout |
| | | { |
| | | Y = Application.GetRealHeight(92 + (50 * j)), |
| | | Width = Application.GetRealWidth(375 - 16 * 2), |
| | | Height = Application.GetRealHeight(50), |
| | | LineColor = CSS.CSS_Color.textWhiteColor, |
| | | SubViewWidth = Application.GetRealWidth(68), |
| | | }; |
| | | devfLayout.AddChidren(funControlRow); |
| | | |
| | | View.ControlView controlView = new View.ControlView(); |
| | | controlView.Show(pirView.devfLayout, j); |
| | | //遥控器名称 |
| | | Button nameBtn = new Button |
| | | controlView.nameBtn.Text = control.name; |
| | | //遥控器存放区域 |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control); |
| | | //标记遥控器 |
| | | controlView.delBtn.Tag = control; |
| | | //删除点击事件 |
| | | controlView.delBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | X = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(150), |
| | | Height = Application.GetRealHeight(20), |
| | | Text = control.name, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextSize = TextSize.text14, |
| | | TextColor = CSS.CSS_Color.textColor, |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | funControlRow.AddChidren(nameBtn); |
| | | //遥控器区域 |
| | | Button areaBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(311 + 16 - (40 + 100)), |
| | | Width = Application.GetRealWidth(100), |
| | | Height = Application.GetRealHeight(17), |
| | | Text = Intelligence.Automation.LogicMethod.GetGetRoomName(control), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextSize = TextSize.text12, |
| | | TextColor = CSS.CSS_Color.textCancelColor, |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | funControlRow.AddChidren(areaBtn); |
| | | //下一级图标 |
| | | Button nextIconBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(295 + 16), |
| | | Width = Application.GetRealWidth(16), |
| | | Height = Application.GetRealWidth(16), |
| | | UnSelectedImagePath = "PirIcon/next.png", |
| | | Gravity = Gravity.CenterVertical, |
| | | }; |
| | | funControlRow.AddChidren(nextIconBtn); |
| | | //删除 |
| | | Button delBtn = new Button |
| | | { |
| | | Width = Application.GetRealWidth(50), |
| | | Height = Application.GetRealHeight(22), |
| | | TextID = StringId.Del, |
| | | TextAlignment = TextAlignment.Center, |
| | | TextSize = TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textWhiteColor, |
| | | IsBold = true, |
| | | BackgroundColor = CSS.CSS_Color.textRedColor, |
| | | Tag = control, |
| | | }; |
| | | funControlRow.AddRightView(delBtn); |
| | | //线 |
| | | Button line1Btn = new Button |
| | | { |
| | | Y = Application.GetRealHeight(50 - 2), |
| | | X = Application.GetRealWidth(16), |
| | | Width = Application.GetRealWidth(311), |
| | | Height = 1, |
| | | BackgroundColor = CSS.CSS_Color.viewLine, |
| | | }; |
| | | funControlRow.AddChidren(line1Btn); |
| | | if (j == pirDevice.FunctioList.Count - 1) |
| | | { |
| | | //最后改变一个线的颜色 |
| | | line1Btn.BackgroundColor = CSS.CSS_Color.viewTranslucence; |
| | | funControlRow.LineColor = CSS.CSS_Color.viewTranslucence; |
| | | } |
| | | delBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var Function = delBtn.Tag as Entity.Function; |
| | | var Function = controlView.delBtn.Tag as Entity.Function; |
| | | string text = Language.StringByID(StringId.shanchushebei) + Function.name + "?"; |
| | | TipPopView tipPopView = new TipPopView(); |
| | | tipPopView.TipBox(StringId.tip, text, (dialog) => |
| | | { |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | dialog.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | Thread(dialog, (responsePackNew) => |
| | | { |
| | | try |
| | | dialog.Close(); |
| | | var function = pirDevice.FunctioList.Find((c) => c.sid == Function.sid); |
| | | if (function != null) |
| | | { |
| | | responsePackNew = PirSend.DeleteDevice(Function.deviceId); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | pirDevice.FunctioList.Remove(Function); |
| | | if (Pir.currPir != null && pirDevice.sid == Pir.currPir.sid) |
| | | { |
| | | loading.Hide(); |
| | | try |
| | | { |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | dialog.Close(); |
| | | var function = pirDevice.FunctioList.Find((c) => c.sid == Function.sid); |
| | | if (function != null) |
| | | { |
| | | pirDevice.FunctioList.Remove(Function); |
| | | if (Pir.currPir != null && pirDevice.sid == Pir.currPir.sid) |
| | | { |
| | | Pir.currPir.FunctioList = pirDevice.FunctioList; |
| | | } |
| | | } |
| | | UIView(vv); |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew); |
| | | } |
| | | } |
| | | catch { } |
| | | |
| | | }); |
| | | Pir.currPir.FunctioList = pirDevice.FunctioList; |
| | | } |
| | | } |
| | | UIView(vv); |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | }, "删除", Function.deviceId, ""); |
| | | |
| | | }, () => { }, false); |
| | | }; |
| | | EventHandler<MouseEventArgs> editClick = (sender, e) => |
| | | { |
| | | EditControl editControl = new EditControl(); |
| | | MainPage.BasePageView.AddChidren(editControl); |
| | | editControl.Show(control, pirDevice, (device) => |
| | | { |
| | | //回调更新名字/区域 |
| | | nameBtn.Text = device.name; |
| | | areaBtn.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(device); |
| | | //view点击事件 |
| | | controlView.clickBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | EditControl editControl = new EditControl(); |
| | | MainPage.BasePageView.AddChidren(editControl); |
| | | editControl.Show(control, pirDevice, (device) => |
| | | { |
| | | //回调更新名字/区域 |
| | | controlView.nameBtn.Text = device.name; |
| | | controlView.areaBtn.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(device); |
| | | |
| | | }); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | funControlRow.MouseUpEventHandler += editClick; |
| | | nameBtn.MouseUpEventHandler += editClick; |
| | | areaBtn.MouseUpEventHandler += editClick; |
| | | nextIconBtn.MouseUpEventHandler += editClick; |
| | | }); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | if (j == pirDevice.FunctioList.Count - 1) |
| | | { |
| | | //最后改变一个线的颜色 |
| | | controlView.line1Btn.BackgroundColor = CSS.CSS_Color.viewTranslucence; |
| | | controlView.funControlRow.LineColor = CSS.CSS_Color.viewTranslucence; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | Method methodView = new Method(); |
| | | methodView.EditControlName(StringId.xiugaimingzi, list, pirclick.name, (name, view) => |
| | | { |
| | | pirclick.name = name; |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | view.AddChidren(loading); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | Thread(view, (responsePackNew) => |
| | | { |
| | | try |
| | | { |
| | | responsePackNew = PirSend.DeviceRename(pirclick.deviceId, pirclick.name); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | view.Close(); |
| | | UIView(vv); |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | pirclick.name = name; |
| | | view.Close(); |
| | | UIView(vv); |
| | | }, "修改名称", pirclick.deviceId, pirclick.name); |
| | | }, () => |
| | | { |
| | | NewSwitchView(pirclick, vv); |
| | |
| | | TipPopView tipPopView = new TipPopView(); |
| | | tipPopView.TipBox(StringId.tip, text, (dialog) => |
| | | { |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | dialog.AddChidren(loading); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | |
| | | Thread(dialog, (responsePackNew) => |
| | | { |
| | | try |
| | | { |
| | | responsePackNew = PirSend.DeleteDevice(pirclick.deviceId); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | dialog.Close(); |
| | | UIView(vv); |
| | | } |
| | | else |
| | | { |
| | | |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | dialog.Close(); |
| | | UIView(vv); |
| | | }, "删除", pirclick.deviceId, ""); |
| | | }, () => |
| | | { |
| | | NewSwitchView(pirclick, vv); |
| | |
| | | } |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// 发送线程 |
| | | /// </summary> |
| | | /// <param name="dialog"></param> |
| | | /// <param name="action"></param> |
| | | /// <param name="str"></param> |
| | | /// <param name="deviceId"></param> |
| | | /// <param name="obj"></param> |
| | | void Thread(Dialog dialog, Action<HDL_ON.DAL.Server.ResponsePackNew> action, string str, string deviceId, string obj) |
| | | { |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | dialog.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | if (str == "删除") |
| | | { |
| | | responsePackNew = PirSend.DeleteDevice(deviceId); |
| | | } |
| | | else if (str == "修改名称") |
| | | { |
| | | |
| | | responsePackNew = PirSend.DeviceRename(deviceId, obj); |
| | | } |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | action(responsePackNew); |
| | | } |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | } |
| | | } |