From 6d73bf6e816570291865674bef8bce8972e4de3f Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期三, 01 十二月 2021 16:32:57 +0800 Subject: [PATCH] 2021-12-01-01 --- HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs | 78 ++++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 37 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs index c8a71b6..f4e8760 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs @@ -16,29 +16,7 @@ topView.frameLayout.Height = Application.GetRealHeight(64 + 20); this.AddChidren(topView.FLayoutView()); topView.topNameBtn.TextID = StringId.selectionCondition; - //鑾峰彇瀹藉害 - int widthValue = topView.topNameBtn.GetTextWidth(); - int textWidth = (Application.GetRealWidth(255) - widthValue) / 2; - Button locationBtn = new Button - { - Width = Application.GetRealWidth(18), - Height = Application.GetRealWidth(18), - X = Application.GetRealWidth(60 + 4) + textWidth + widthValue, - Y = Application.GetRealHeight(34 + 1), - UnSelectedImagePath = "LogicIcon/location.png", - - }; - topView.frameLayout.AddChidren(locationBtn); - - Button textBtn = new Button - { - Height = Application.GetRealHeight(14), - Y = Application.GetRealHeight(57), - TextSize = LogicView.TextSize.text10, - TextColor = CSS.CSS_Color.textCancelColor, - Text = "骞夸笢骞垮窞甯傜暘绂哄尯鐭虫ゼ闀�", - }; - topView.frameLayout.AddChidren(textBtn); + topView.Location(); topView.clickBackBtn.MouseUpEventHandler += (e, sen) => { RemoveFromParent(); @@ -78,15 +56,15 @@ string text = view.btnClick.Tag.ToString(); if (text == Language.StringByID(StringId.clearday)) { - value = "sunny"; + value = "Sunny"; } else if (text == Language.StringByID(StringId.cloudy)) { - value = "cloudy"; + value = "Cloudy"; } else if (text == Language.StringByID(StringId.rain)) { - value = "rainy"; + value = "Rain"; } AddDic(value); }; @@ -100,21 +78,21 @@ private void AddDic(string value) { Input input = new Input(); - input.sid = LogicMethod.NewSid(); + input.sid = LogicMethod.CurrLogicMethod.NewSid(); input.condition_type = "6"; Dictionary<string, string> dic = new Dictionary<string, string>(); - LogicMethod.dictionary(dic, "key", "weather"); - LogicMethod.dictionary(dic, "comparator", "="); - LogicMethod.dictionary(dic, "data_type", "string"); - LogicMethod.dictionary(dic, "value", value); + LogicMethod.CurrLogicMethod.dictionary(dic, "key", "weather"); + LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); + LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); + LogicMethod.CurrLogicMethod.dictionary(dic, "value", value); input.condition.Add(dic); - AddCondition(input); + AddCondition(input, "weather", "="); } /// <summary> /// 娣诲姞鏉′欢 /// </summary> /// <param name="input"></param> - private void AddCondition(Input input) + private void AddCondition(Input input, string keyValue, string comparator) { ///璁板綍绱㈠紩鍊� int index = -1; @@ -123,9 +101,13 @@ var condition_type = Logic.currlogic.input[i].condition_type; if (condition_type == "6") { - ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋 - index = i; - break; + var dicList = Logic.currlogic.input[i].condition; + if (ExistKey(dicList, keyValue, comparator)) + { + ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋 + index = i; + break; + } } } if (index != -1) @@ -140,12 +122,34 @@ Logic.currlogic.input.Add(input); } - LogicMethod.RemoveAllView(); + 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; + } } } -- Gitblit v1.8.0