using System; using System.Collections.Generic; using HDL_ON.UI.UI2.Intelligence.Automation.LogicView; using HDL_ON.UI.UI2.PersonalCenter.PirDevice.View; using Shared; namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice { public class SetPir : FrameLayout { public SetPir() { Tag = "PirMain"; } public void Show(Action 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; FrameLayout viewLayout = new FrameLayout { Y = Application.GetRealHeight(64), Width = Application.GetRealWidth(Intelligence.Automation.LogicView.TextSize.view375), Height = Application.GetRealHeight(Intelligence.Automation.LogicView.TextSize.view667 - 64 - 76), BackgroundColor = CSS.CSS_Color.viewMiddle, }; this.AddChidren(viewLayout); ///名称 FrameLayout50 editNameFLayout = new FrameLayout50(); editNameFLayout.btnText.Text = Language.StringByID(StringId.yaokongqimingcheng) + ":"; editNameFLayout.btnEditText.Text = Pir.currPir.name; editNameFLayout.btnNextIcon.Height = Application.GetRealWidth(28); editNameFLayout.btnNextIcon.Width = Application.GetRealWidth(28); editNameFLayout.btnNextIcon.UnSelectedImagePath = "LogicIcon/editname.png"; viewLayout.AddChidren(editNameFLayout.FLayoutView()); ///版本升级 FrameLayout50 banbenshengjiFL = new FrameLayout50(); banbenshengjiFL.btnText.Text = Language.StringByID(StringId.banbenshengji); banbenshengjiFL.frameLayout.Y = editNameFLayout.frameLayout.Bottom; viewLayout.AddChidren(banbenshengjiFL.FLayoutView()); ///版本号:v1.3.5 FrameLayout50 banbenhaoFLayout = new FrameLayout50(); banbenhaoFLayout.btnNextIcon.Visible = false; banbenhaoFLayout.btnText.Text = Language.StringByID(StringId.banbenhao) + ":v1.3.5"; banbenhaoFLayout.frameLayout.Y = banbenshengjiFL.frameLayout.Bottom; viewLayout.AddChidren(banbenhaoFLayout.FLayoutView()); //删除 FrameLayout frameLayout = new FrameLayout { Y = Application.GetRealHeight(Intelligence.Automation.LogicView.TextSize.view667 - 50), Height = Application.GetRealHeight(50), BackgroundColor = CSS.CSS_Color.view, Gravity = Gravity.BottomCenter,//置底的属性 }; this.AddChidren(frameLayout); Button btnDel = new Button { TextSize = Intelligence.Automation.LogicView.TextSize.text16, Width = Application.GetRealWidth(50), Height = Application.GetRealHeight(22), TextColor = CSS.CSS_Color.textRedColor, Gravity = Gravity.Center, TextID = StringId.Del, }; frameLayout.AddChidren(btnDel); #endregion #region 界面点击事件 //修改名称的点击事件 editNameFLayout.btnClick.MouseUpEventHandler += (sender, e) => { List list = new List(); Method method = new Method(); method.EditControlName(StringId.editName, list, Pir.currPir.name, (name, dialog) => { Method.ThreadSend(new Control { deviceId = Pir.currPir.deviceId, name = name }, (responsePackNew) => { dialog.Close(); editNameFLayout.btnEditText.Text = name; Pir.currPir.name = name; }, "修改名称", "dialog", null, dialog); }, () => { }); }; //删除红外宝的点击事件 EventHandler delClick = (sender, e) => { string text = Language.StringByID(StringId.shanchushebei) + Pir.currPir.name + "?"; TipPopView tipPopView = new TipPopView(); tipPopView.TipBox(StringId.tip, text, (dialog) => { Method.ThreadSend(new Control { deviceId = Pir.currPir.deviceId }, (responsePackNew) => { var pir = Pir.pirDeviceList.Find((c) => c.deviceId == Pir.currPir.deviceId); if (pir != null) { 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(); } } }, "删除", "dialog", null, dialog); }, () => { }, false); }; btnDel.MouseUpEventHandler += delClick; frameLayout.MouseUpEventHandler += delClick; #endregion } } }