From 631f94758c3cb42abcdda8094e77895f376eff16 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 11 一月 2021 14:53:43 +0800 Subject: [PATCH] 2021-1-12-3 --- HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs | 178 +++++++++++++++++++++------------------------------------- 1 files changed, 65 insertions(+), 113 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs index 1db4522..140875b 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs @@ -1,6 +1,8 @@ -锘縰sing System; +using System; using Shared; using System.Collections.Generic; +using HDL_ON.Entity; + namespace HDL_ON.UI.UI2.Intelligence.Automation { public class ConditionDeviceFunList : FrameLayout @@ -17,10 +19,6 @@ /// 瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵�� /// </summary> private string selectedState = "unknown"; - /// <summary> - /// 瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵�佽褰曞睘鎬� - /// </summary> - private string keyVlaue = ""; public void Show(Entity.Function device, int index, bool edit) { #region 鐣岄潰甯冨眬 @@ -40,22 +38,22 @@ }; this.AddChidren(fLayout); #endregion - switch (device.functionType) + switch (device.spk) { //寮�鍏崇伅鍏� light.Switch - case FunctionType.Dimmer: - case FunctionType.RGB: - case FunctionType.RGBW: - case FunctionType.CCT: - case FunctionType.Relay: + case SPK.LightDimming: + case SPK.LightRGB: + case SPK.LightRGBW: + case SPK.LightCCT: + case SPK.LightSwitch: //绐楀笜 - case FunctionType.Curtain: - case FunctionType.RollerCurtain: - case FunctionType.TrietexCurtain: + case SPK.CurtainSwitch: + case SPK.CurtainRoller: + case SPK.CurtainTrietex: //绌鸿皟 - case FunctionType.AC: + case SPK.AcStandard: //鍦扮儹 - case FunctionType.FloorHeating: + case SPK.FloorHeatStandard: { LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView(); lightSwitchView.btnText.TextID = StringId.switchLogic; @@ -68,19 +66,39 @@ BackgroundColor = CSS.CSS_Color.viewTrans60lucence, }; this.AddChidren(frame); - SwitchViewMethod(frame, device, lightSwitchView.btnState, 2); + LogicView.SwitchView switchView = new LogicView.SwitchView(); + switchView.FLayoutView(frame, 2, lightSwitchView.btnState.Text, (strValue) => + { + int id = 0; + switch (strValue) + { + case "on": + { + id = StringId.onLogic; + } + break; + case "off": + { + id = StringId.offLogic; + } + break; + } + //鏄剧ず鏂囨湰 + lightSwitchView.btnState.TextID = id; + selectedState = device.spk + "_" + strValue; + //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�; + string keyVlaue = "on_off"; + AddDictionary(keyVlaue, strValue); + + }); }; if (edit) { - GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null); + GetEditState(device, index, lightSwitchView.btnState, null, null, null); } } break; - - - - } #region 淇濆瓨 @@ -91,8 +109,6 @@ this.AddChidren(saveView.FLayoutView()); saveView.btnClick.MouseUpEventHandler += (sen, e) => { - - if (selectedState != "unknown") { Input inputDevice = new Input(); @@ -133,69 +149,50 @@ } /// <summary> - /// 绉婚櫎鎺т欢 - /// </summary> - /// <param name="frame"></param> - private void RemView(FrameLayout frame) - { - frame.RemoveFromParent(); - } - /// <summary> /// 鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬� /// </summary> /// <param name="device">缂栬緫璁惧</param> - /// <param name="edit">缂栬緫鐘舵��</param> /// <param name="index">缂栬緫鏁版嵁鐨勭储寮�</param> /// <param name="button1">鏄剧ずBtn</param> /// <param name="button2">鏄剧ずBtn</param> /// <param name="button3">鏄剧ずBtn</param> /// <param name="button4">鏄剧ずBtn</param> - private void GetEditState(Entity.Function device, bool edit, int index, Button button1, Button button2, Button button3, Button button4) + private void GetEditState(Entity.Function device, int index, Button button1, Button button2, Button button3, Button button4) { Input inputs = Logic.currlogic.input[index]; var dicList = inputs.condition as List<Dictionary<string, string>>; - switch (device.functionType) + //娓呴櫎涔嬪墠鏃ф暟鎹� + dicSateteList.Clear(); + if (dicList.Count != 0) { - //寮�鍏崇伅鍏� light.Switch - case FunctionType.Dimmer: - case FunctionType.RGB: - case FunctionType.RGBW: - case FunctionType.CCT: - case FunctionType.Relay: - //绐楀笜 - case FunctionType.Curtain: - case FunctionType.RollerCurtain: - case FunctionType.TrietexCurtain: - //绌鸿皟 - case FunctionType.AC: - //鍦扮儹 - case FunctionType.FloorHeating: - { - foreach (var dic in dicList) - { - string value = dic["value"]; - if (value == "on") - { - button1.Text = Language.StringByID(StringId.onLogic); - } - else - { - button1.Text = Language.StringByID(StringId.offLogic); - } - } - } - break; - + //鏈夋暟鎹噸鏂拌祴鍊� + dicSateteList = dicList; } + InpOrOutLogicMethod.EditState(device, dicList, button1, button2, button3, button4); } /// <summary> /// 娣诲姞閫変腑鏁版嵁 /// </summary> - /// <param name="dicList">瀛樺偍鏁版嵁鍒楄〃</param> - /// <param name="keyValue">璇嗗埆璁惧</param> + /// <param name="KeyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param> + /// <param name="selectedValue">鐘舵�佸��</param> + private void AddDictionary(string KeyValue, string selectedValue) + { + //鏁版嵁灏佽 + Dictionary<string, string> dic = new Dictionary<string, string>(); + LogicMethod.dictionary(dic, "key", KeyValue); + LogicMethod.dictionary(dic, "comparator", "="); + LogicMethod.dictionary(dic, "data_type", "string"); + LogicMethod.dictionary(dic, "value", selectedValue); + AddDictionaryList(KeyValue, dic, dicSateteList); + } + /// <summary> + /// 鏇存柊鏁版嵁鍒楄〃 + /// </summary> + /// <param name="keyValue">璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�</param> /// <param name="dictionary">閫変腑鏁版嵁</param> + /// <param name="dicList">瀛樺偍鏁版嵁鍒楄〃</param> /// <returns></returns> - private void AddDictionaryData(List<Dictionary<string, string>> dicList, string keyValue, Dictionary<string, string> dictionary) + private void AddDictionaryList(string keyValue, Dictionary<string, string> dictionary, List<Dictionary<string, string>> dicList) { int indexValue = -1; for (int i = 0; i < dicList.Count; i++) @@ -249,51 +246,6 @@ Logic.currlogic.input.Add(input); } - } - /// <summary> - /// 寮�鍏冲姛鑳藉睍寮�鐣岄潰 - /// </summary> - /// <param name="frame"></param> - /// <param name="device"></param> - /// <param name="button"></param> - /// <param name="len"></param> - public void SwitchViewMethod(FrameLayout frame, Entity.Function device, Button button, int len) - { - - LogicView.SwitchView switchView = new LogicView.SwitchView(); - switchView.FLayoutView(frame, len); - Dictionary<string, string> dic = new Dictionary<string, string>(); - LogicMethod.dictionary(dic, "key", "on_off"); - LogicMethod.dictionary(dic, "comparator", "="); - LogicMethod.dictionary(dic, "data_type", "string"); - keyVlaue = "on_off"; - switchView.btnOn.MouseUpEventHandler += (sender2, e2) => - { - LogicMethod.dictionary(dic, "value", "on"); - RemView(frame); - button.TextID = StringId.onLogic; - selectedState = device.functionType + "_on"; - AddDictionaryData(dicSateteList, keyVlaue, dic); - }; - switchView.btnOff.MouseUpEventHandler += (sender3, e3) => - { - LogicMethod.dictionary(dic, "value", "off"); - RemView(frame); - button.TextID = StringId.offLogic; - selectedState = device.functionType + "_off"; - AddDictionaryData(dicSateteList, keyVlaue, dic); - }; - if (button.Text != "") - { - if (button.Text == switchView.btnOn.Text) - { - switchView.btnOn.TextColor = CSS.CSS_Color.textConfirmColor; - } - else if (button.Text == switchView.btnOff.Text) - { - switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor; - } - } } } } -- Gitblit v1.8.0