From dc6b96a219645c1125de6d6bb5e94d61cf167be1 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期六, 21 八月 2021 17:37:53 +0800 Subject: [PATCH] 2021-8-21-1 --- HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs | 79 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 78 insertions(+), 1 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs index 3f835d8..65f2bec 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs @@ -49,9 +49,16 @@ functionView.frameLayout.Y = Application.GetRealHeight(0); } + //鍦烘櫙 + LogicView.SelectTypeView sceneView = new LogicView.SelectTypeView(); + sceneView.frameLayout.Y = functionView.frameLayout.Bottom; + sceneView.btnText.TextID = StringId.Scenes; + sceneView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png"; + viewLayout.AddChidren(sceneView.FLayoutView()); + //瀹ゅ鍙樺寲 LogicView.SelectTypeView shiwaiView = new LogicView.SelectTypeView(); - shiwaiView.frameLayout.Y = functionView.frameLayout.Bottom; + shiwaiView.frameLayout.Y = sceneView.frameLayout.Bottom; shiwaiView.btnText.TextID = StringId.shiwaibainhua; shiwaiView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; @@ -78,6 +85,11 @@ funTpye.Show(LogicMethod.condition_if); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; }; + //鍦烘櫙鐐瑰嚮浜嬩欢 + sceneView.btnClick.MouseUpEventHandler += (sen, e) => + { + SceneMethod(); + }; //瀹ゅ鍙樺寲 shiwaiView.btnClick.MouseUpEventHandler += (sen, e) => { Weather weather = new Weather(); @@ -88,5 +100,70 @@ #endregion } + + /// <summary> + /// 娣诲姞鍦烘櫙 + /// </summary> + public void SceneMethod() + { + var sceneList = LogicMethod.CurrLogicMethod.GetSceneList(); + List<string> nameList = new List<string>(); + for (int i = 0; i < sceneList.Count; i++) + { + var scene = sceneList[i]; + nameList.Add(scene.name); + } + PublicInterface publicInterface = new PublicInterface(); + publicInterface.FrameOrVv(this, nameList, new List<string> { }, StringId.addSceneLogic, (index) => + { + var sceneSelecetd = sceneList[index]; + Input input = new Input(); + input.sid = sceneSelecetd.sid; + input.condition_type = "10"; + Dictionary<string, string> dic = new Dictionary<string, string>(); + LogicMethod.CurrLogicMethod.dictionary(dic, "key", "scene"); + LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); + LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); + LogicMethod.CurrLogicMethod.dictionary(dic, "value", "on"); + input.condition.Add(dic); + AddCondition(input); + LogicMethod.CurrLogicMethod.RemoveAllView(); + AddLogic addLogic = new AddLogic(); + MainPage.BasePageView.AddChidren(addLogic); + addLogic.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }); + } + + /// <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 == "10") + { + ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋 + index = i; + break; + } + } + if (index != -1) + { + //绉婚櫎鏃ф暟鎹� + Logic.currlogic.input.RemoveAt(index); + //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃� + Logic.currlogic.input.Insert(index, input); + } + else + { + Logic.currlogic.input.Add(input); + } + } } } -- Gitblit v1.8.0