using System; using System.Collections.Generic; using Shared; namespace HDL_ON.UI.UI2.Intelligence.Automation { public class AirQuality : FrameLayout { public AirQuality() { Tag = "Logic"; } public void Show() { #region 界面布局 LogicView.TopView topView = new LogicView.TopView(); topView.frameLayout.Height = Application.GetRealHeight(64 + 20); this.AddChidren(topView.FLayoutView()); topView.topNameBtn.TextID = StringId.selectionCondition; topView.Location(); topView.clickBackBtn.MouseUpEventHandler += (e, sen) => { RemoveFromParent(); }; FrameLayout viewLayout = new FrameLayout { Y = Application.GetRealHeight(64 + 20), Width = Application.GetRealWidth(LogicView.TextSize.view375), Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64 - 20), BackgroundColor = CSS.CSS_Color.viewMiddle, }; this.AddChidren(viewLayout); #endregion var list = new List { Language.StringByID(StringId.kongqiyou), Language.StringByID(StringId.kongqiliang), Language.StringByID(StringId.kongqicha), }; for (int i = 0; i < list.Count; i++) { LogicView.SelectTypeView view = new LogicView.SelectTypeView(); view.frameLayout.Y = Application.GetRealHeight(i * 50); view.btnIcon.Visible = false; view.btnNextIcon.Visible = false; view.btnText.X = Application.GetRealWidth(16); view.btnLine.X = Application.GetRealWidth(16); view.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); view.btnText.Text = list[i]; view.btnClick.Tag = list[i]; viewLayout.AddChidren(view.FLayoutView()); view.btnClick.MouseUpEventHandler += (sen, e) => { string value = ""; string text = view.btnClick.Tag.ToString(); if (text == Language.StringByID(StringId.kongqiyou)) { //优 value = "excellent"; } else if (text == Language.StringByID(StringId.kongqiliang)) { //良 value = "good"; } else if (text == Language.StringByID(StringId.kongqicha)) { //差 value = "poor"; } AddDic(value); }; } } /// /// 封装数据 /// /// private void AddDic(string value) { Input input = new Input(); input.sid = LogicMethod.NewSid(); input.condition_type = "9"; Dictionary dic = new Dictionary(); LogicMethod.dictionary(dic, "key", "air_quality"); LogicMethod.dictionary(dic, "comparator", "="); LogicMethod.dictionary(dic, "data_type", "string"); LogicMethod.dictionary(dic, "value", value); input.condition.Add(dic); AddCondition(input); } /// /// 添加条件 /// /// private void AddCondition(Input input) { ///记录索引值 int index = -1; for (var i = 0; i < Logic.currlogic.input.Count; i++) { var condition_type = Logic.currlogic.input[i].condition_type; if (condition_type == "9") { ///找到标记索引,退出循环体 index = i; break; } } if (index != -1) { //移除旧数据 Logic.currlogic.input.RemoveAt(index); //新数据插入旧数据的位置 Logic.currlogic.input.Insert(index, input); } else { Logic.currlogic.input.Add(input); } LogicMethod.RemoveAllView(); AddLogic addLogic = new AddLogic(); MainPage.BasePageView.AddChidren(addLogic); addLogic.Show(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; } } }