From 0039220054537c28443625b5becc5355e74e6cf8 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 11 一月 2021 17:51:15 +0800 Subject: [PATCH] 2021-1-11-5 --- HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs | 75 ++++++++++++++++++++++++++++++++----- 1 files changed, 64 insertions(+), 11 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs index 67c8638..34870f5 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/WeatherCondition.cs @@ -9,7 +9,7 @@ { Tag = "Logic"; } - public void Show(bool edit = false, int index=-1) + public void Show() { #region 鐣岄潰甯冨眬 LogicView.TopView topView = new LogicView.TopView(); @@ -17,14 +17,14 @@ this.AddChidren(topView.FLayoutView()); topView.topNameBtn.TextID = StringId.selectionCondition; //鑾峰彇瀹藉害 - int widthValue= topView.topNameBtn.GetTextWidth(); - int textWidth =(Application.GetRealWidth(255)- widthValue) / 2; + 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), + X = Application.GetRealWidth(60 + 4) + textWidth + widthValue, + Y = Application.GetRealHeight(34 + 1), UnSelectedImagePath = "LogicIcon/location.png", }; @@ -46,9 +46,9 @@ FrameLayout viewLayout = new FrameLayout { - Y = Application.GetRealHeight(64+20), + Y = Application.GetRealHeight(64 + 20), Width = Application.GetRealWidth(LogicView.TextSize.view375), - Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64-20), + Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64 - 20), BackgroundColor = CSS.CSS_Color.viewMiddle, }; this.AddChidren(viewLayout); @@ -74,25 +74,78 @@ view.btnClick.MouseUpEventHandler += (sen, e) => { + string value = ""; string text = view.btnClick.Tag.ToString(); if (text == Language.StringByID(StringId.clearday)) { - + value = "sunny"; } else if (text == Language.StringByID(StringId.cloudy)) { - + value = "cloudy"; } else if (text == Language.StringByID(StringId.rain)) { - + value = "rainy"; } + AddDic(value); }; } } + /// <summary> + /// 灏佽鏁版嵁 + /// </summary> + /// <param name="value"></param> + private void AddDic(string value) + { + Input inputTime = new Input(); + inputTime.sid = LogicMethod.NewSid(); + inputTime.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); + inputTime.condition.Add(dic); + AddCondition(inputTime); + } + /// <summary> + /// 娣诲姞鏉′欢 + /// </summary> + /// <param name="input"></param> + 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 == "6") + { + ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋 + 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; - + } } } -- Gitblit v1.8.0