| | |
| | | <Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default"> |
| | | <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs"> |
| | | <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs"> |
| | | <Files> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/BrandList.cs" Line="132" Column="58" IsPinned="True" /> |
| | | <File FileName="../../Application.cs" Line="16" Column="35" IsPinned="True" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="150" Column="18" IsPinned="True" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" Line="133" Column="31" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/AddMiniRemoteControlDirection4Page.cs" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="442" Column="22" /> |
| | | <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TipPopView.cs" Line="895" Column="32" /> |
| | | <File FileName="HDL_ON/UI/UI0-Public/PublicAssmebly.cs" Line="1" Column="1" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/View/Buttons.cs" Line="18" Column="132" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="40" Column="57" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/SetPir.cs" Line="16" Column="40" /> |
| | | <File FileName="HDL_ON/DAL/Mqtt/MqttClient.cs" Line="338" Column="36" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Pir.cs" Line="1" Column="1" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs" Line="153" Column="28" IsPinned="True" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs" Line="393" Column="20" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs" Line="271" Column="21" /> |
| | | <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs" Line="215" Column="23" /> |
| | | <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="504" Column="54" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddButton.cs" Line="137" Column="29" /> |
| | | <File FileName="HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/AddControl.cs" Line="12" Column="27" /> |
| | | <File FileName="HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs" Line="1" Column="1" /> |
| | | </Files> |
| | | <Pads> |
| | | <Pad Id="ProjectPad"> |
| | |
| | | <Node name="4-PersonalCenter" expanded="True"> |
| | | <Node name="PirDevice" expanded="True"> |
| | | <Node name="View" expanded="True" /> |
| | | <Node name="PirMain.cs" selected="True" /> |
| | | <Node name="AddButton.cs" selected="True" /> |
| | | </Node> |
| | | </Node> |
| | | </Node> |
| | |
| | | } |
| | | public void Show(Control control) |
| | | { |
| | | |
| | | |
| | | #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 editfLayout = new FrameLayout |
| | | { |
| | |
| | | } |
| | | //移除添加按钮界面 |
| | | this.RemoveFromParent(); |
| | | |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (view.GetType() == typeof(AddControl)) |
| | | { |
| | | //找到移除 |
| | | view.RemoveFromParent(); |
| | | } |
| | | |
| | | } |
| | | |
| | | //移除之前可能存在的界面 |
| | | Method.RemoveView("AddControl"); |
| | | //加载数据界面 |
| | | AddControl addControl = new AddControl(); |
| | | MainPage.BasePageView.AddChidren(addControl); |
| | |
| | | else |
| | | { |
| | | replication.RemView(); |
| | | new TipPopView().FlashingBox(Language.StringByID(StringId.tianjiashibai)); |
| | | |
| | | Method method = new Method(); |
| | | method.ErrorShow(null,"添加失败"); |
| | | } |
| | | |
| | | }); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 移除界面 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | //刷新指定界面 |
| | | Method.RefreshView("PirMain"); |
| | | base.RemoveFromParent(); |
| | | } |
| | | } |
| | | } |
| | |
| | | this.AddChidren(topView.FLayoutView()); |
| | | topView.clickBackBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | |
| | | |
| | | this.RemoveFromParent(); |
| | | |
| | | }; |
| | |
| | | //保存点击事件 |
| | | saveBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //移除当前界面 |
| | | //移除当前界面 |
| | | this.RemoveFromParent(); |
| | | //可能之前已经存在该界面 |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (view.GetType() == typeof(AddControlComplete)) |
| | | { |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | Method.RemoveView("AddControlComplete"); |
| | | AddControlComplete addControlComplete = new AddControlComplete(); |
| | | MainPage.BasePageView.AddChidren(addControlComplete); |
| | | addControlComplete.Show(control,false); |
| | | addControlComplete.Show(control, false); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | #endregion |
| | |
| | | void RefreshView(VerticalScrolViewLayout vv, bool if_bool, Control control) |
| | | { |
| | | vv.RemoveAll(); |
| | | //定义一个变量记录行数 |
| | | int sum = 0; |
| | | if (control.status.Count % 3 == 0) |
| | | View.Buttons buttons = new View.Buttons(); |
| | | buttons.AddButton2(vv, control.status, (obj) => |
| | | { |
| | | sum = control.status.Count / 3; |
| | | } |
| | | else |
| | | { |
| | | sum = control.status.Count / 3 + 1; |
| | | } |
| | | //计算加载出来的数据需要的高度 |
| | | int h = 16 + sum * (16 + 44) + 104 + 76; |
| | | int line = 0; |
| | | //按钮的父控件 |
| | | var FLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealWidth(h), |
| | | }; |
| | | vv.AddChidren(FLayout); |
| | | for (int i = 1, j = 0; i <= control.status.Count; i++, j++) |
| | | { |
| | | var nameObj = control.status[i - 1]; |
| | | //按钮 |
| | | var buttonNameBtn = new Button |
| | | Method.ThreadSend(control, (responsePackNew) => |
| | | { |
| | | |
| | | Y = Application.GetRealHeight(16 + line * (16 + 44)), |
| | | X = Application.GetRealWidth(16 + (16 + 104) * j), |
| | | Width = Application.GetRealWidth(104), |
| | | Height = Application.GetRealHeight(44), |
| | | Text = nameObj.value, |
| | | TextSize = TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Radius = (uint)Application.GetRealHeight(18), |
| | | BorderWidth = 1, |
| | | BorderColor = CSS.CSS_Color.textCancelColor, |
| | | }; |
| | | FLayout.AddChidren(buttonNameBtn); |
| | | //删除图标 |
| | | var delIconBtn = new Button |
| | | { |
| | | UnSelectedImagePath = "PirIcon/delbuton.png", |
| | | Y = Application.GetRealHeight(12 + line * (16 + 44)), |
| | | X = Application.GetRealWidth((16 + 92) + (104 + 16) * j), |
| | | Width = Application.GetRealWidth(16), |
| | | Height = Application.GetRealWidth(16), |
| | | Tag = nameObj, |
| | | }; |
| | | if (if_bool) |
| | | { |
| | | FLayout.AddChidren(delIconBtn); |
| | | } |
| | | //删除图标的点击事件 |
| | | delIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var obj = delIconBtn.Tag as Entity.AttributesStatus; |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | this.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | var buttonObj = control.status.Find((c) => c.value == obj.value); |
| | | if (buttonObj != null) |
| | | { |
| | | try |
| | | { |
| | | //发送按键删除; |
| | | responsePackNew = PirSend.CodeRemove(obj, control.deviceId); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | var buttonObj = control.status.Find((c) => c.value == obj.value); |
| | | if (buttonObj != null) |
| | | { |
| | | control.status.Remove(buttonObj); |
| | | } |
| | | RefreshView(vv, true, control); |
| | | } |
| | | else { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew,""); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | |
| | | |
| | | }; |
| | | if (i % 3 == 0) |
| | | { |
| | | //满一行重置j=0值; |
| | | j = -1; |
| | | line += 1; |
| | | } |
| | | |
| | | } |
| | | |
| | | control.status.Remove(buttonObj); |
| | | } |
| | | RefreshView(vv, true, control); |
| | | }, "删除按键", "fram", this, null, obj); |
| | | }, if_bool); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | 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.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(); |
| | | method.EditControlName(StringId.editName, list, control.name, (name, dialog) => |
| | | { |
| | | //发送更新名称命令 |
| | | Method.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, () => |
| | | method.ManagementPosition(GetFunction(control.deviceId), () => |
| | | { |
| | | //更新区域 |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(function); |
| | | quyuPatchView.btnText2.Text = Intelligence.Automation.LogicMethod.GetGetRoomName(GetFunction(control.deviceId)); |
| | | }); |
| | | }; |
| | | //继续添加点击事件 |
| | | addBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | if (bool_library) |
| | | { |
| | | {//继续添加库的遥控器 |
| | | Method.RefreshView("PirMain");//刷新指点界面 |
| | | this.RemoveFromParent(); |
| | | RefreshView(); |
| | | } |
| | | else |
| | | { |
| | | {//继续添加自定义的遥控器 |
| | | Method method = new Method(); |
| | | method.AddControl(this, (controlDevice) => |
| | | { |
| | |
| | | //完成点击事件 |
| | | saveView.btnClick.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //刷新指点界面 |
| | | Method.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() |
| | | { |
| | | //刷新指定界面 |
| | | Method.RefreshView("PirMain"); |
| | | base.RemoveFromParent(); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | public EditControl() |
| | | { |
| | | Tag = "PirView"; |
| | | } |
| | | public void Show(Entity.Function control,Action<Entity.Function> action) |
| | | { |
| | |
| | | //测试Text |
| | | testBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var library = libraryList[index-1]; |
| | | var library = libraryList[index - 1]; |
| | | var control = GetControl(spk, testBtn.TextID, library); |
| | | //发送测试码命令 |
| | | CodeTest(control); |
| | | Method.ThreadSend(control, (responsePackNew) => { }, "库码测试", "frame", this, null); |
| | | if (code == 3) { |
| | | //标记最后那个码 |
| | | if_bool = true; |
| | |
| | | var control = GetControl(spk, testBtn.TextID, library); |
| | | Method method = new Method(); |
| | | //发送库添加遥控器命令 |
| | | method.ThreadAddControl(control, this, (cont) => |
| | | method.ThreadAddControl(control, this, (device) => |
| | | { |
| | | MainPage.BasePageView.RemoveViewByTag("PirView"); |
| | | AddControlComplete addControlComplete = new AddControlComplete(); |
| | | MainPage.BasePageView.AddChidren(addControlComplete); |
| | | addControlComplete.Show(cont, true); |
| | | addControlComplete.Show(device, true); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }); |
| | | |
| | |
| | | } |
| | | |
| | | return control; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送库码测试命令 |
| | | /// </summary> |
| | | /// <param name="control"></param> |
| | | private void CodeTest(Control control) |
| | | { |
| | | |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | this.AddChidren(loading); |
| | | HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | responsePackNew = PirSend.CodeTest(control); |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | //Method method = new Method(); |
| | | //method.ErrorShow(responsePackNew); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | public class Method |
| | | { |
| | | |
| | | |
| | | /// <summary> |
| | | /// 红外宝程序主入口 |
| | | /// </summary> |
| | | /// <param name="frame"></param> |
| | | /// <param name="function"></param> |
| | | public void MainView(FrameLayout frame, Entity.Function function,Action action) |
| | | public void MainView(FrameLayout frame, Entity.Function function, Action action) |
| | | { |
| | | Pir pirDevice = new Pir(); |
| | | if (function != null) |
| | |
| | | PirMain.BackAction += () => |
| | | { |
| | | action?.Invoke(); |
| | | PirMain.BackAction = null; |
| | | }; |
| | | }); |
| | | }, Pir.currPir); |
| | |
| | | { |
| | | if (device != null) |
| | | { |
| | | |
| | | control.deviceId = device.deviceId; |
| | | //遥控器添加到列表; |
| | | if (null == Pir.currPir.FunctioList.Find((c) => c.deviceId == device.deviceId)) |
| | | { |
| | | Pir.currPir.FunctioList.Add(device); |
| | | } |
| | | frame.RemoveFromParent();//添加成功关闭弹窗 |
| | | action(control); |
| | | } |
| | |
| | | { |
| | | loading.Hide(); |
| | | Method method = new Method(); |
| | | method.ErrorShow(null,"读取红外宝列表失败"); |
| | | method.ErrorShow(null, "读取红外宝列表失败"); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | /// <param name="view">判断log父控件</param> |
| | | /// <param name="frame">log父控件</param> |
| | | /// <param name="dialog">log父控件</param> |
| | | public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str,string view, FrameLayout frame, Dialog dialog) |
| | | /// <param name="attributesStatus">学习按键</param> |
| | | public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str, string view, FrameLayout frame, Dialog dialog, Entity.AttributesStatus attributesStatus=null) |
| | | { |
| | | |
| | | |
| | | //加载log |
| | | Loading loading = new Loading(); |
| | | if (view == "dialog") |
| | |
| | | } |
| | | else if (str == "删除按键") |
| | | { |
| | | // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); |
| | | if (attributesStatus != null) |
| | | { |
| | | responsePackNew = PirSend.CodeRemove(attributesStatus, control.deviceId); |
| | | } |
| | | } |
| | | else if (str == "获取设备详情") |
| | | { |
| | |
| | | else if (str == "获取遥控器列表") |
| | | { |
| | | responsePackNew = PirSend.ControlList(control.deviceId); |
| | | } |
| | | else if (str == "库码测试") |
| | | { |
| | | responsePackNew = PirSend.CodeTest(control); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | else |
| | | { |
| | | Method method = new Method(); |
| | | method.ErrorShow(responsePackNew, ""); |
| | | //自定义错误提示文本 |
| | | string eorroText = ""; |
| | | if (str == "删除") |
| | | { |
| | | } |
| | | else if (str == "修改名称") |
| | | { |
| | | |
| | | } |
| | | else if (str == "删除按键") |
| | | { |
| | | } |
| | | else if (str == "获取设备详情") |
| | | { |
| | | } |
| | | else if (str == "获取遥控器列表") |
| | | { |
| | | } |
| | | else if (str == "库码测试") |
| | | { |
| | | } |
| | | method.ErrorShow(responsePackNew, eorroText); |
| | | } |
| | | |
| | | }); |
| | |
| | | { |
| | | str = Language.StringByID(StringId.huoqushujushibao); |
| | | } |
| | | else if (text == "添加失败") |
| | | { |
| | | str = Language.StringByID(StringId.tianjiashibai); |
| | | } |
| | | else |
| | | { |
| | | if (responsePackNew != null) |
| | |
| | | case 3: { } break; |
| | | } |
| | | } |
| | | /// <summary> |
| | | ///指定刷新界面 |
| | | /// </summary> |
| | | /// <param name="strView">判断字符</param> |
| | | public static void RefreshView(string strView) |
| | | { |
| | | //标记是不是已经刷新完成 |
| | | bool if_bool = false; |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == "PirMain") |
| | | { |
| | | if (view.GetType() == typeof(PirMain)) |
| | | { |
| | | //强制转换对象 |
| | | var f = (PirMain)view; |
| | | //移除所有子控件 |
| | | f.RemoveAll(); |
| | | //重新加载UI |
| | | f.Show(); |
| | | //退出for循环 |
| | | //break; |
| | | if_bool = true; |
| | | } |
| | | } |
| | | if (if_bool) |
| | | { |
| | | //退出for循环 |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 指定删除界面 |
| | | /// </summary> |
| | | /// <param name="strView">判断字符</param> |
| | | public static void RemoveView(string strView) |
| | | { |
| | | |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (strView == "PirMain") |
| | | { |
| | | if (view.GetType() == typeof(PirMain)) |
| | | { |
| | | //移除界面 |
| | | view.RemoveFromParent(); |
| | | } |
| | | |
| | | } |
| | | else if (strView == "AddControl") |
| | | { |
| | | |
| | | if (view.GetType() == typeof(AddControl)) |
| | | { |
| | | //找到移除 |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | else if (strView == "AddControlComplete") |
| | | { |
| | | |
| | | if (view.GetType() == typeof(AddControlComplete)) |
| | | { |
| | | //找到移除 |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | [Serializable] |
| | |
| | | /// </summary> |
| | | public List<string> library = new List<string>(); |
| | | /// <summary> |
| | | /// |
| | | /// 学习按键列表 |
| | | /// </summary> |
| | | public List<AttributesStatus> status = new List<AttributesStatus>(); |
| | | } |
| | |
| | | |
| | | SetPir setPir = new SetPir(); |
| | | MainPage.BasePageView.AddChidren(setPir); |
| | | setPir.Show(() => |
| | | { |
| | | //BackAction(); |
| | | ////刷新界面 |
| | | UIView(vv); |
| | | }); |
| | | setPir.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | }; |
| | | ///添加遥控器图标点击事件 |
| | |
| | | public override void RemoveFromParent() |
| | | { |
| | | BackAction(); |
| | | BackAction = null; |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | |
| | | { |
| | | public SetPir() |
| | | { |
| | | Tag = "PirMain"; |
| | | Tag = "PirView"; |
| | | } |
| | | Action backAction; |
| | | public void Show(Action action) |
| | | public void Show() |
| | | { |
| | | backAction = action; |
| | | #region 界面布局 |
| | | this.BackgroundColor = CSS.CSS_Color.viewMiddle; |
| | | Intelligence.Automation.LogicView.TopView topView = new Intelligence.Automation.LogicView.TopView(); |
| | | this.AddChidren(topView.FLayoutView()); |
| | | topView.clickBackBtn.MouseUpEventHandler += (e, sen) => |
| | | { |
| | | //action(); |
| | | RemoveFromParent(); |
| | | }; |
| | | topView.topNameBtn.TextID = StringId.setlogic; |
| | |
| | | Pir.pirDeviceList.Remove(Pir.currPir); |
| | | } |
| | | dialog.Close(); |
| | | action(); |
| | | this.RemoveFromParent(); |
| | | for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--) |
| | | { |
| | | var view = MainPage.BasePageView.GetChildren(i); |
| | | if (view.GetType() == typeof(PirMain)) |
| | | { |
| | | view.RemoveFromParent(); |
| | | } |
| | | } |
| | | Method.RemoveView("PirMain"); |
| | | }, "删除", "dialog", null, dialog); |
| | | |
| | | }, () => |
| | |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | backAction(); |
| | | //刷新PirMain界面 |
| | | Method.RefreshView("PirMain"); |
| | | base.RemoveFromParent(); |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// 动态加载按钮列表 |
| | | /// </summary> |
| | | /// <param name="vv">父控件</param> |
| | | /// <param name="list">数据列表</param> |
| | | /// <param name="action">回调</param> |
| | | /// <param name="if_bool">表示是否显示删除图标</param> |
| | | public void AddButton2(VerticalScrolViewLayout vv, List<Entity.AttributesStatus> list, Action<Entity.AttributesStatus> action, bool if_bool) |
| | | { |
| | | //定义一个变量记录行数 |
| | | int sum = 0; |
| | | if (list.Count % 3 == 0) |
| | | { |
| | | sum = list.Count / 3; |
| | | } |
| | | else |
| | | { |
| | | sum = list.Count / 3 + 1; |
| | | } |
| | | //计算加载出来的数据需要的高度 |
| | | int h = 16 + sum * (16 + 44) + 104 + 76; |
| | | int line = 0; |
| | | //按钮的父控件 |
| | | var FLayout = new FrameLayout |
| | | { |
| | | Height = Application.GetRealWidth(h), |
| | | }; |
| | | vv.AddChidren(FLayout); |
| | | for (int i = 1, j = 0; i <= list.Count; i++, j++) |
| | | { |
| | | var nameObj = list[i - 1]; |
| | | //按钮 |
| | | var buttonNameBtn = new Button |
| | | { |
| | | |
| | | Y = Application.GetRealHeight(16 + line * (16 + 44)), |
| | | X = Application.GetRealWidth(16 + (16 + 104) * j), |
| | | Width = Application.GetRealWidth(104), |
| | | Height = Application.GetRealHeight(44), |
| | | Text = nameObj.value, |
| | | TextSize = TextSize.text16, |
| | | TextColor = CSS.CSS_Color.textColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | Radius = (uint)Application.GetRealHeight(18), |
| | | BorderWidth = 1, |
| | | BorderColor = CSS.CSS_Color.textCancelColor, |
| | | }; |
| | | FLayout.AddChidren(buttonNameBtn); |
| | | //删除图标 |
| | | var delIconBtn = new Button |
| | | { |
| | | UnSelectedImagePath = "PirIcon/delbuton.png", |
| | | Y = Application.GetRealHeight(12 + line * (16 + 44)), |
| | | X = Application.GetRealWidth((16 + 92) + (104 + 16) * j), |
| | | Width = Application.GetRealWidth(16), |
| | | Height = Application.GetRealWidth(16), |
| | | Tag = nameObj, |
| | | }; |
| | | if (if_bool) |
| | | { |
| | | FLayout.AddChidren(delIconBtn); |
| | | } |
| | | //删除图标的点击事件 |
| | | delIconBtn.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | var obj = delIconBtn.Tag as Entity.AttributesStatus; |
| | | action(obj); |
| | | }; |
| | | if (i % 3 == 0) |
| | | { |
| | | //满一行重置j=0值; |
| | | j = -1; |
| | | line += 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 动态加载按钮列表 |
| | | /// </summary> |
| | | /// <param name="FLayout">父控件</param> |
| | | /// <param name="action">回调</param> |
| | | /// <param name="sum">多少个FrameLayout控件</param> |