using System; using Shared; using System.Collections.Generic; namespace HDL_ON.UI.UI2.Intelligence.Automation { public class DeviceFunList : FrameLayout { public DeviceFunList() { Tag = "Logic"; } public void Show(Entity.Function device) { this.BackgroundColor = CSS.CSS_Color.viewMiddle; LogicView.TopView topView = new LogicView.TopView(); this.AddChidren(topView.FLayoutView()); topView.clickBackBtn.MouseUpEventHandler += (e, sen) => { RemoveFromParent(); }; topView.topNameBtn.Text = device.name; FrameLayout fLayout = new FrameLayout { Y = Application.GetRealHeight(64), Height = Application.GetRealHeight(667 - 64), }; this.AddChidren(fLayout); Input inputdevice = new Input(); inputdevice.condition_type = "3"; inputdevice.sid = device.sid; switch (device.functionType) { //开关灯光 case FunctionType.Relay: { //for (int i = 0; i < device.function.Count; i++) //{ //} LogicView.SelectTypeView relayView = new LogicView.SelectTypeView(); relayView.btnIcon.Visible = false; relayView.btnState.Visible = true; relayView.btnText.TextSize = LogicView.TextSize.text16; relayView.btnText.Height = Application.GetRealHeight(22); relayView.btnText.TextID =StringId.switchLogic; relayView.btnText.X = Application.GetRealWidth(16); relayView.btnText.Width= Application.GetRealWidth(130); relayView.btnLine.X = Application.GetRealWidth(16); relayView.btnLine.Width = Application.GetRealWidth(343); fLayout.AddChidren(relayView.FLayoutView()); relayView.btnClick.MouseUpEventHandler += (sender, e) => { FrameLayout relayFunView = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence, }; this.AddChidren(relayFunView); LogicView.SwitchView switchView = new LogicView.SwitchView(); switchView.FLayoutView(relayFunView, 2); Button btnOn = new Button { TextAlignment = TextAlignment.Center, TextSize = LogicView.TextSize.text16, TextColor = CSS.CSS_Color.textCancelColor, TextID = StringId.onLogic, Height = Application.GetRealHeight(44), Width = Application.GetRealWidth(343), }; switchView.frameLayout.AddChidren(btnOn); Button btnLine = new Button { Height = 1, BackgroundColor = CSS.CSS_Color.viewLine, Y = btnOn.Bottom, }; switchView.frameLayout.AddChidren(btnLine); Button btnOff = new Button { Y = btnLine.Bottom, TextAlignment = TextAlignment.Center, TextSize = LogicView.TextSize.text16, TextColor = CSS.CSS_Color.textCancelColor, TextID = StringId.offLogic, Height = Application.GetRealHeight(44), Width = Application.GetRealWidth(343), }; switchView.frameLayout.AddChidren(btnOff); Dictionary dic = new Dictionary(); LogicMethod.dictionary(dic, "key", "on_off"); LogicMethod.dictionary(dic, "comparator", "="); LogicMethod.dictionary(dic, "data_type", "string"); inputdevice.condition.Add(dic); btnOn.MouseUpEventHandler += (sender2, e2) => { LogicMethod.dictionary(dic, "value", "on"); RemView(relayFunView); relayView.btnState.TextID = StringId.onLogic; }; btnOff.MouseUpEventHandler += (sender3, e3) => { LogicMethod.dictionary(dic, "value", "off"); RemView(relayFunView); relayView.btnState.TextID = StringId.offLogic; }; }; } break; } #region 保存 ///保存View LogicView.SaveView saveView = new LogicView.SaveView(); saveView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); saveView.btnSave.TextID = StringId.completeLogic; this.AddChidren(saveView.FLayoutView()); saveView.btnClick.MouseUpEventHandler += (sen, e) => { //if (edit) //{ // //移除旧数据 // Logic.currlogic.input.RemoveAt(index); // //新数据插入旧数据的位置; // Logic.currlogic.input.Insert(index, inputdevice); //} //else //{ // //添加一个新的时间点条件 // Logic.currlogic.input.Add(inputdevice); //} //添加一个新的时间点条件 Logic.currlogic.input.Add(inputdevice); RemoveViewByTag("Logic"); AddLogic addLogic = new AddLogic(); MainPage.BasePageView.AddChidren(addLogic); addLogic.Show(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; #endregion } /// /// 移除控件 /// /// public void RemView(FrameLayout frame) { frame.RemoveFromParent(); } } }