From f8f87a4fe67a1539b6fb85a54e4c178474792285 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 20 九月 2022 13:22:22 +0800
Subject: [PATCH] 完善后退功能

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs |  161 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 151 insertions(+), 10 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
index 1c9b2bc..3c52457 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/ConditionDeviceFunList.cs
@@ -24,10 +24,20 @@
         /// 瀹氫箟涓�涓彉閲忥紝璁板綍閫変腑鐘舵��
         /// </summary>
         private string selectedState = "unknown";
+        /// <summary>
+        /// 鏄笉鏄啀娆$紪杈�
+        /// </summary>
+        private bool mEdit;
+        /// <summary>
+        /// 杈撳叆鏉′欢鍒楄〃绱㈠紩鍊�
+        /// </summary>
+        private int mIndex;
 
         public void Show(Entity.Function device, int index, bool edit)
         {
             this.function = device;
+            this.mEdit = edit;
+            this.mIndex = index;
             #region 鐣岄潰甯冨眬
             this.BackgroundColor = CSS.CSS_Color.viewMiddle;
             LogicView.TopView topView = new LogicView.TopView();
@@ -61,7 +71,6 @@
                 //绌鸿皟
                 case SPK.AcStandard:
                 case SPK.HvacAC:
-                case SPK.HvacCac://姣涚粏绌鸿皟
                 //鍦扮儹
                 case SPK.FloorHeatStandard:
                 case SPK.HvacFloorHeat:
@@ -201,8 +210,64 @@
                         }
                     }
                     break;
-                //姣背娉紶鎰熷櫒
+                //姣背娉紶鎰熷櫒(鑷爺鍖楅偖)
                 case SPK.SenesorMegahealth:
+                    {
+                        int intValue =0;
+                        if (edit)
+                        {
+                            Input inputs = Logic.currlogic.input[index];
+                            var dicList = inputs.condition;
+                            foreach (var dic in dicList)
+                            {
+                                if (dic["key"] == "target_status")
+                                {
+                                    intValue = 1;
+                                }
+                                else
+                                {
+                                    intValue = 2;
+                                }
+                                break;
+
+                            }
+                        }
+                        LogicView.FunTypeView view1= new LogicView.FunTypeView(); 
+                        view1.btnText.TextID = StringId.diedaobaojing;
+                        view1.btnState.Name = Language.StringByID(StringId.diedaobaojing);
+                        fLayout.AddChidren(view1.FLayoutView());
+                        view1.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view1.btnState, StringId.shi, StringId.offLogic, 1);
+                        };
+                        
+                        LogicView.FunTypeView view2 = new LogicView.FunTypeView();
+                        view2.frameLayout.Y = view1.frameLayout.Bottom;
+                        view2.btnText.TextID = StringId.yourenbaojing;
+                        view2.btnState.Name = Language.StringByID(StringId.yourenbaojing);
+                        fLayout.AddChidren(view2.FLayoutView());
+
+                        if (intValue==1) {
+                            view2.frameLayout.Visible = false;
+                           
+                        }
+                        if (intValue == 2)
+                        {
+                            view2.frameLayout.Y = Application.GetRealHeight(0);
+                        }
+
+                        view2.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view2.btnState, StringId.youren, StringId.wuren, 2);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view1.btnState, view2.btnState, null, null);
+                        }
+
+                    }
+                    break;
+                //姣背娉紶鎰熷櫒(鍏嗚涓撶敤浜戜簯瀵规帴)
                 case SPK.SenesorMegahealth2:
                     {
                         LogicView.FunTypeView view = new LogicView.FunTypeView();
@@ -361,6 +426,7 @@
                 //tvoc
                 case SPK.SensorTVOC:
                     {
+                        
                         ///tvoc
                         LogicView.FunTypeView tvocView = new LogicView.FunTypeView();
                         tvocView.btnText.TextID = StringId.tvoc;
@@ -387,6 +453,23 @@
                             PmCo2TvocAction(this, device, "hcho", StringId.Formaldehyde, index, edit);
 
                         };
+                    }
+                    break;
+                //闂ㄩ攣
+                case SPK.DoorLock:
+                    {
+
+                        LogicView.FunTypeView view = new LogicView.FunTypeView();
+                        view.btnText.TextID = StringId.shifoukaisuoshi;
+                        fLayout.AddChidren(view.FLayoutView());
+                        view.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            DeviceView(device, view.btnState, StringId.shi, StringId.offLogic,1);
+                        };
+                        if (edit)
+                        {
+                            GetEditState(device, index, view.btnState, null, null, null);
+                        }
                     }
                     break;
             }
@@ -466,12 +549,13 @@
         /// <param name="button">閫変腑鐘舵�佹樉绀烘枃鏈珺tn鎺т欢</param>
         /// <param name="btnText1">灞炴�х姸鎬佸�兼枃鏈�1</param>
         /// <param name="btnText2">灞炴�х姸鎬佸�兼枃鏈�2</param>
-        private void DeviceView(Entity.Function device, Button button, int btnText1, int btnText2)
+        /// <param name="viewCount">view鏁伴噺</param>
+        private void DeviceView(Entity.Function device, Button button, int btnText1, int btnText2,int viewCount=2)
         {
             FrameLayout frame = new FrameLayout { BackgroundColor = CSS.CSS_Color.viewTrans60lucence };
             this.AddChidren(frame);
             LogicView.SwitchView switchView = new LogicView.SwitchView();
-            switchView.FLayoutView(frame, btnText1, btnText2, button.Text, (intValue) =>
+            switchView.FLayoutView(frame, btnText1, btnText2, button.Text, viewCount,(intValue) =>
             {
                 //璁惧灞炴�у�硷紝浜戦泙涓婂畾涔夊ソ鐨�;
                 string keyVlaue = "on_off";
@@ -514,6 +598,23 @@
                         }
                         break;
                     case SPK.SenesorMegahealth:
+                        {
+                            if (button != null)
+                            {
+                                
+                                if (button.Name == Language.StringByID(StringId.yourenbaojing))
+                                {
+                                    keyVlaue = "people_status";
+                                   
+                                }
+                                else
+                                {
+                                    keyVlaue = "target_status";
+                                }
+                            }
+
+                        }
+                        break;
                     case SPK.SenesorMegahealth2:
                         {
                             keyVlaue = "action_state";
@@ -521,6 +622,11 @@
                             {
                                 keyVlaue = "megahealth_state";
                             }
+                        }
+                        break;
+                    case SPK.DoorLock:
+                        {
+                            keyVlaue = "door_status";
                         }
                         break;
 
@@ -556,13 +662,33 @@
                         break;
                     case StringId.wuren:
                         {
-                            if (device.spk == SPK.SenesorMegahealth || device.spk == SPK.SenesorMegahealth2)
+                            if (device.spk == SPK.SenesorMegahealth2)
                             {
                                 value = "uninhabited";
                             }
                             else
                             {
                                 value = "false";
+                            }
+                        }
+                        break;
+                    case StringId.shi:
+                        {
+                            value = "open";
+                            if (button != null)
+                            {
+
+                                if (button.Name == Language.StringByID(StringId.yourenbaojing))
+                                {
+                                    //鐘舵��(鏈変汉)
+                                    value = "true";
+
+                                }
+                                else if(button.Name == Language.StringByID(StringId.diedaobaojing))
+                                {
+                                    //璺屽��
+                                    value = "4";
+                                }
                             }
                         }
                         break;
@@ -590,11 +716,24 @@
                         {
                             value = "fall";
                         }; break;
+                   
+
                 }
                 //鏄剧ず鏂囨湰
                 button.TextID = intValue;
                 selectedState = device.spk + "_" + value;
                 AddDictionary(keyVlaue, value, "string");
+                if (button != null)
+                {
+
+                    if (button.Name == Language.StringByID(StringId.yourenbaojing)
+                    || (button.Name == Language.StringByID(StringId.diedaobaojing)))
+                    {
+                        //鍙湁姣背娉紶鎰熷櫒(鑷爺)
+                        Save(device, mIndex, mEdit);
+                    }
+                }
+            
 
             });
 
@@ -666,7 +805,7 @@
         /// <param name="stateValue">缂栬緫涔嬪墠鐨勭姸鎬佸��,榛樿涓�""</param>
         public void PmCo2TvocAction(FrameLayout frame, Entity.Function device, string key, int title, int index, bool edit, string stateValue = "")
         {
-            if (edit)
+            if (edit) 
             {
                 ///
                 this.function = device;
@@ -680,12 +819,14 @@
                 }
             }
             PublicInterface view = new PublicInterface();
-            var listStr = view.GetViewList(key);
-            view.SingleSelectionShow(frame, listStr, Language.StringByID(title), view.GetString(key, stateValue)
+            //var listStr = view.GetViewList(key);
+            var listStr = view.GetSensorLevelList(device);//2022骞�05鏈�25鏃�10:01:33 浜у搧缁忕悊鍚涚厡瑕佹眰鏀规垚鍔ㄦ��
+            view.SingleSelectionShow(frame, listStr, Language.StringByID(title), view.GetSensorLevelText(device, stateValue,true)
                , (text) =>
                {
                   
-                   var value = view.GetValue(key, text);
+                   //var value = view.GetValue(key, text);
+                   var values = view.GetSensorLevelText(device,text,false);
                    selectedState = device.spk + "_" + key;
                    switch (device.spk)
                    {
@@ -703,7 +844,7 @@
                            }
                            break;
                    }
-                   AddDictionary(key, value, "integer", "in");
+                   AddDictionary(key, values, "integer", "in");
                    Save(device, index, edit);
                });
         }

--
Gitblit v1.8.0