| | |
| | | using System; |
| | | using Shared; |
| | | using System.Collections.Generic; |
| | | namespace HDL_ON.UI.UI2.Intelligence.Automation |
| | | { |
| | | public class OutdoorEnvironment : FrameLayout |
| | |
| | | |
| | | //湿度高于 |
| | | LogicView.SelectTypeView humidityhigherView = new LogicView.SelectTypeView(); |
| | | humidityhigherView.frameLayout.Y = temperatureunderView.frameLayout.Bottom+Application.GetRealHeight(8); |
| | | humidityhigherView.frameLayout.Y = temperatureunderView.frameLayout.Bottom + Application.GetRealHeight(8); |
| | | humidityhigherView.btnIcon.Visible = false; |
| | | humidityhigherView.btnText.X = Application.GetRealWidth(16); |
| | | humidityhigherView.btnLine.X = Application.GetRealWidth(16); |
| | |
| | | humidityunderView.btnText.TextID = StringId.shidudiyu; |
| | | viewLayout.AddChidren(humidityunderView.FLayoutView()); |
| | | |
| | | //PM2.5高于 |
| | | //PM2.5 |
| | | LogicView.SelectTypeView pmhigherView = new LogicView.SelectTypeView(); |
| | | pmhigherView.frameLayout.Y = humidityunderView.frameLayout.Bottom + Application.GetRealHeight(8); |
| | | pmhigherView.btnIcon.Visible = false; |
| | | pmhigherView.btnText.X = Application.GetRealWidth(16); |
| | | pmhigherView.btnLine.X = Application.GetRealWidth(16); |
| | | pmhigherView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | pmhigherView.btnText.TextID = StringId.pmgaoyu; |
| | | pmhigherView.btnText.TextID = StringId.PM25; |
| | | viewLayout.AddChidren(pmhigherView.FLayoutView()); |
| | | //PM2.5低于 |
| | | LogicView.SelectTypeView pmunderView = new LogicView.SelectTypeView(); |
| | | pmunderView.frameLayout.Y = pmhigherView.frameLayout.Bottom; |
| | | pmunderView.btnIcon.Visible = false; |
| | | pmunderView.btnText.X = Application.GetRealWidth(16); |
| | | pmunderView.btnLine.X = Application.GetRealWidth(16); |
| | | pmunderView.btnLine.Width = Application.GetRealWidth(375 - 16 - 16); |
| | | pmunderView.btnText.TextID = StringId.pmdiyu; |
| | | viewLayout.AddChidren(pmunderView.FLayoutView()); |
| | | |
| | | |
| | | #endregion |
| | | |
| | |
| | | //温度高于 |
| | | temperaturehigherView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | InputBoxAction(StringId.wendugaoyu); |
| | | |
| | | }; |
| | | //温度低于 |
| | | temperatureunderView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | InputBoxAction(StringId.wendudiyu); |
| | | }; |
| | | |
| | | //湿度高于 |
| | | humidityhigherView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | |
| | | InputBoxAction(StringId.shidugaoyu); |
| | | }; |
| | | //湿度低于 |
| | | humidityunderView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | InputBoxAction(StringId.shidudiyu); |
| | | }; |
| | | |
| | | //PM2.5高于 |
| | | //PM2.5 |
| | | pmhigherView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | PmAction(this); |
| | | |
| | | }; |
| | | //PM2.5低于 |
| | | pmunderView.btnClick.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | |
| | | }; |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | /// <summary> |
| | | /// 温度,湿度弹框设置值 |
| | | /// </summary> |
| | | /// <param name="textInt">文本</param> |
| | | /// <param name="stateValue">编辑之前的状态值,默认为20</param> |
| | | public void InputBoxAction(int textInt, string stateValue = "20") |
| | | { |
| | | new LogicView.TipPopView { }.InputBox(textInt, stateValue, (value) => |
| | | { |
| | | string keyValue = ""; |
| | | string comparator = "="; |
| | | switch (textInt) |
| | | { |
| | | case StringId.wendugaoyu: |
| | | { |
| | | keyValue = "outdoor_temp"; |
| | | comparator = ">"; |
| | | } |
| | | break; |
| | | case StringId.wendudiyu: |
| | | { |
| | | keyValue = "outdoor_temp"; |
| | | comparator = "<"; |
| | | } |
| | | break; |
| | | case StringId.shidugaoyu: |
| | | { |
| | | keyValue = "outdoor_humity"; |
| | | comparator = ">"; |
| | | } |
| | | break; |
| | | case StringId.shidudiyu: |
| | | { |
| | | keyValue = "outdoor_humity"; |
| | | comparator = "<"; |
| | | } |
| | | break; |
| | | } |
| | | |
| | | AddDic(keyValue, comparator, value); |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// PM2.5设置值 |
| | | /// </summary> |
| | | /// <param name="frame">当前界面</param> |
| | | /// <param name="stateValue">编辑之前的状态值,默认为""</param> |
| | | public void PmAction(FrameLayout frame, string stateValue = "") |
| | | { |
| | | PublicInterface pmView = new PublicInterface(); |
| | | var pmListStr = pmView.GetViewList("pm25"); |
| | | pmView.SingleSelectionShow(frame, pmListStr, Language.StringByID(StringId.PM25), pmView.GetString("pm25", stateValue) |
| | | , (text) => |
| | | { |
| | | var value= pmView.GetValue("pm25", text); |
| | | AddDic("pm2.5", "in", value); |
| | | }); |
| | | } |
| | | /// <summary> |
| | | /// 封装数据 |
| | | /// </summary> |
| | | /// <param name="keyValue">类型值(pm2.5;outdoor_temp;outdoor_humity)</param> |
| | | /// <param name="comparator">比较关系</param> |
| | | /// <param name="value">值</param> |
| | | private void AddDic(string keyValue, string comparator, string value) |
| | | { |
| | | Input input = new Input(); |
| | | input.sid = LogicMethod.CurrLogicMethod.NewSid(); |
| | | input.condition_type = "4"; |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "key", keyValue); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", comparator); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "float"); |
| | | LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); |
| | | input.condition.Add(dic); |
| | | AddCondition(input, keyValue, comparator); |
| | | } |
| | | /// <summary> |
| | | /// 添加条件 |
| | | /// </summary> |
| | | /// <param name="input"></param> |
| | | /// <param name="keyValue"></param> |
| | | /// <param name="comparator">比较关系</param> |
| | | private void AddCondition(Input input, string keyValue, string comparator) |
| | | { |
| | | ///记录索引值 |
| | | 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 == "4") |
| | | { |
| | | var dicList = Logic.currlogic.input[i].condition; |
| | | if (ExistKey(dicList, keyValue, comparator)) |
| | | { |
| | | ///找到标记索引,退出循环体 |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (index != -1) |
| | | { |
| | | //移除旧数据 |
| | | Logic.currlogic.input.RemoveAt(index); |
| | | //新数据插入旧数据的位置 |
| | | Logic.currlogic.input.Insert(index, input); |
| | | } |
| | | else |
| | | { |
| | | Logic.currlogic.input.Add(input); |
| | | } |
| | | |
| | | LogicMethod.CurrLogicMethod.RemoveAllView(); |
| | | AddLogic addLogic = new AddLogic(); |
| | | MainPage.BasePageView.AddChidren(addLogic); |
| | | addLogic.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 判断是否存在Key |
| | | /// </summary> |
| | | /// <param name="dicList"></param> |
| | | /// <param name="keyValue"></param> |
| | | /// <param name="comparator">比较关系</param> |
| | | /// <returns></returns> |
| | | private bool ExistKey(List<Dictionary<string, string>> dicList, string keyValue, string comparator) |
| | | { |
| | | for (int i = 0; i < dicList.Count; i++) |
| | | { |
| | | var dic = dicList[i]; |
| | | string key = dic["key"]; |
| | | string comparatorValue = dic["comparator"]; |
| | | if (key == keyValue && comparatorValue == comparator) |
| | | { |
| | | //判断是否存在 |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |