From 1410e38e50687272a162123552de122661d981ee Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 25 十一月 2020 17:53:04 +0800 Subject: [PATCH] 2020-11-25-2 --- HDL_ON/UI/UI2/3-Intelligence/Automation/DeviceFunList.cs | 129 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 102 insertions(+), 27 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/DeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/DeviceFunList.cs index 929669b..cb35527 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/DeviceFunList.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/DeviceFunList.cs @@ -10,8 +10,9 @@ Tag = "Logic"; } - public void Show(Entity.Function device) + public void Show(Entity.Function device, int index, bool edit) { + #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; LogicView.TopView topView = new LogicView.TopView(); this.AddChidren(topView.FLayoutView()); @@ -27,17 +28,24 @@ Height = Application.GetRealHeight(667 - 64), }; this.AddChidren(fLayout); - - Input inputdevice = new Input(); - inputdevice.condition_type = "3"; - inputdevice.sid = device.sid; - + #endregion + + //瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵�� + string selectedState = "unknown"; + + Input inputdevice = new Input(); + inputdevice.condition_type = "3"; + inputdevice.sid = device.sid; + switch (device.functionType) { //寮�鍏崇伅鍏� case FunctionType.Relay: { + + + //for (int i = 0; i < device.function.Count; i++) //{ //} @@ -46,9 +54,9 @@ relayView.btnState.Visible = true; relayView.btnText.TextSize = LogicView.TextSize.text16; relayView.btnText.Height = Application.GetRealHeight(22); - relayView.btnText.TextID =StringId.switchLogic; + relayView.btnText.TextID = StringId.switchLogic; relayView.btnText.X = Application.GetRealWidth(16); - relayView.btnText.Width= Application.GetRealWidth(130); + relayView.btnText.Width = Application.GetRealWidth(130); relayView.btnLine.X = Application.GetRealWidth(16); relayView.btnLine.Width = Application.GetRealWidth(343); fLayout.AddChidren(relayView.FLayoutView()); @@ -61,7 +69,7 @@ this.AddChidren(relayFunView); LogicView.SwitchView switchView = new LogicView.SwitchView(); switchView.FLayoutView(relayFunView, 2); - + Button btnOn = new Button { TextAlignment = TextAlignment.Center, @@ -96,18 +104,43 @@ LogicMethod.dictionary(dic, "comparator", "="); LogicMethod.dictionary(dic, "data_type", "string"); inputdevice.condition.Add(dic); - btnOn.MouseUpEventHandler += (sender2, e2) => { + btnOn.MouseUpEventHandler += (sender2, e2) => + { LogicMethod.dictionary(dic, "value", "on"); RemView(relayFunView); relayView.btnState.TextID = StringId.onLogic; + selectedState = device.functionType + "_on"; }; - btnOff.MouseUpEventHandler += (sender3, e3) => { + btnOff.MouseUpEventHandler += (sender3, e3) => + { LogicMethod.dictionary(dic, "value", "off"); RemView(relayFunView); relayView.btnState.TextID = StringId.offLogic; + selectedState = device.functionType + "_off"; }; }; + if (edit) + { + Input inputs = Logic.currlogic.input[index]; + if (inputs.condition_type == "3") + { + List<Dictionary<string, string>> dicList = inputs.condition as List<Dictionary<string, string>>; + foreach (var dic in dicList) + { + string value = dic["value"]; + if (value == "on") + { + relayView.btnState.Text = Language.StringByID(StringId.onLogic); + + } + else + { + relayView.btnState.Text = Language.StringByID(StringId.offLogic); + } + } + } + } } break; @@ -124,21 +157,31 @@ this.AddChidren(saveView.FLayoutView()); saveView.btnClick.MouseUpEventHandler += (sen, e) => { - //if (edit) - //{ - // //绉婚櫎鏃ф暟鎹� - // Logic.currlogic.input.RemoveAt(index); - // //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�; - // Logic.currlogic.input.Insert(index, inputdevice); - //} - //else - //{ - // //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢 - // Logic.currlogic.input.Add(inputdevice); - //} - - //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢 - Logic.currlogic.input.Add(inputdevice); + if (selectedState != "unknown") + { + if (edit) + { + //绉婚櫎鏃ф暟鎹� + Logic.currlogic.input.RemoveAt(index); + //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�; + Logic.currlogic.input.Insert(index, inputdevice); + } + else + { + //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢 + Logic.currlogic.input.Add(inputdevice); + } + } + else + { + if (!edit) + { + //鎻愮ず鐢ㄦ埛 + return; + } + this.RemoveFromParent(); + return; + } RemoveViewByTag("Logic"); AddLogic addLogic = new AddLogic(); MainPage.BasePageView.AddChidren(addLogic); @@ -153,8 +196,40 @@ /// 绉婚櫎鎺т欢 /// </summary> /// <param name="frame"></param> - public void RemView(FrameLayout frame) { + public void RemView(FrameLayout frame) + { frame.RemoveFromParent(); } + + public void GetState(Entity.Function device, bool edit, int index,Button button1,Button button2,Button button3,Button button4) + { + if (edit) + { + Input inputs = Logic.currlogic.input[index]; + var dicList = inputs.condition as List<Dictionary<string, string>>; + switch (device.functionType) + { + //寮�鍏崇伅鍏� + case FunctionType.Relay: + { + foreach (var dic in dicList) + { + string value = dic["value"]; + //if (value == "on") + //{ + // relayView.btnState.Text = Language.StringByID(StringId.onLogic); + + //} + //else + //{ + // relayView.btnState.Text = Language.StringByID(StringId.offLogic); + //} + } + } + break; + + } + } + } } } -- Gitblit v1.8.0