From 0f2e0147e8990e913d16d99bc1b94fb6bc53abd7 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期四, 03 十二月 2020 15:35:42 +0800
Subject: [PATCH] 2020-12-03-1

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs |  191 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 186 insertions(+), 5 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
index ca1b27b..87a0886 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs
@@ -10,14 +10,14 @@
         /// </summary>
         /// <param name="thisView">褰撳墠鐣岄潰</param>
         /// <param name="viewLayout">涓婁笅婊戝姩鎺т欢</param>
-        public static void InputCondition(FrameLayout thisView,VerticalScrolViewLayout viewLayout)
+        public static void InputCondition(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
         {
             for (int i = 0; i < Logic.currlogic.input.Count; i++)
             {
                 Input inputCondition = Logic.currlogic.input[i];
                 ///鍚勭鏉′欢鐨刅iew
                 LogicView.AddOutputInputView inputView = new LogicView.AddOutputInputView();
-                viewLayout.AddChidren(inputView.FLayoutView());
+                inputView.FLayoutView(viewLayout);
                 ///璁板綍鏉′欢绫诲瀷
                 inputView.btnClick.Name = inputCondition.condition_type;
                 ///璁板綍鏉′欢绱㈠紩
@@ -36,7 +36,6 @@
                                 inputView.btnText.Text = Language.StringByID(StringId.hour) + ": " + value;
                                 inputView.btnClick.AddTag("timepoint", value);
                             }
-
                         }
                         break;
                     case "2":
@@ -51,12 +50,63 @@
 
                         }
                         break;
+                    case "3":
+                        {
+                            //鐢╯id鎵惧埌璁惧锛�
+                            var device = LogicMethod.GetDevice(inputCondition.sid);
+                            //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
+                            inputView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.functionType);
+                            //鏄剧ず璁惧鍚嶇О
+                            inputView.btnText.Text = device.name;
+                            //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
+                            inputView.btnText.Width = Application.GetRealWidth(80);
+                            //鍖哄埆涓嶅悓璁惧锛屾樉绀轰笉鍚岃澶囩姸鎬�
+                            switch (device.functionType)
+                            {
+                                //寮�鍏崇伅鍏� 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")
+                                            {
+                                                inputView.btnState.Text = Language.StringByID(StringId.onLogic);
+
+                                            }
+                                            else
+                                            {
+                                                inputView.btnState.Text = Language.StringByID(StringId.offLogic);
+                                            }
+                                        }
+                                    }
+                                    break;
+                            }
+                        }
+                        break;
 
                 }
                 //鍐嶆缂栬緫鏉′欢鐘舵�佺偣鍑讳簨浠�
                 inputView.btnClick.MouseUpEventHandler += (sen, e) =>
                 {
                     Button button = (Button)sen;
+                    //鎵惧埌褰撳墠缂栬緫鐨勭储寮�
+                    int indexVulae = int.Parse(inputView.btnClick.Tag.ToString());
+                    //鏍囪缂栬緫鐘舵��
+                    bool edit = true;
                     switch (button.Name)
                     {
                         case "1":
@@ -67,7 +117,7 @@
                                 };
                                 thisView.AddChidren(fLayout);
                                 TimeTpye timeTpye = new TimeTpye();
-                                timeTpye.TimePoint(fLayout, true, int.Parse(inputView.btnClick.Tag.ToString()));
+                                timeTpye.TimePoint(fLayout, edit, indexVulae);
                             }
                             break;
                         case "2":
@@ -78,10 +128,29 @@
                                 };
                                 thisView.AddChidren(fLayout);
                                 TimeTpye timeTpye = new TimeTpye();
-                                timeTpye.TimeHorizon(fLayout, true, int.Parse(inputView.btnClick.Tag.ToString()));
+                                timeTpye.TimeHorizon(fLayout, edit, indexVulae);
                             }
                             break;
+
+                        case "3":
+                            {
+                                //鐢╯id鎵惧埌璁惧锛�
+                                var device = LogicMethod.GetDevice(inputCondition.sid);
+                                ConditionDeviceFunList deviceFunList = new ConditionDeviceFunList();
+                                MainPage.BasePageView.AddChidren(deviceFunList);
+                                deviceFunList.Show(device, indexVulae, edit);
+                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                            }
+                            break;
+
+
                     }
+                };
+                ///鍒犻櫎鎺т欢
+                inputView.btnDel.MouseUpEventHandler += (sender, e) =>
+                {
+                    Logic.currlogic.input.Remove(inputCondition);
+                    inputView.frameLayout.RemoveFromParent();
                 };
             }
 
@@ -94,7 +163,119 @@
         public static void OutputTarget(FrameLayout thisView, VerticalScrolViewLayout viewLayout)
         {
 
+            for (int i = 0; i < Logic.currlogic.output.Count; i++)  
+            {
+                Output outputTarget = Logic.currlogic.output[i];
+                ///鍚勭鏉′欢鐨刅iew
+                LogicView.AddOutputInputView targetView = new LogicView.AddOutputInputView();
+                targetView.FLayoutView(viewLayout);
+                ///璁板綍鏉′欢绫诲瀷
+                targetView.btnClick.Name = outputTarget.target_type;
+                ///璁板綍鏉′欢绱㈠紩
+                targetView.btnClick.Tag = i;
+                ///鏉′欢鐘舵�佹暟缁�
+                List<Dictionary<string, string>> dicList = outputTarget.status as List<Dictionary<string, string>>;
+                //鏄剧ず鏉′欢鍚勭绫诲瀷鐘舵��
+                switch (outputTarget.target_type)
+                {
+                    case "1":
+                        {
+                            //鐢╯id鎵惧埌璁惧锛�
+                            var device = LogicMethod.GetDevice(outputTarget.sid);
+                            //鐢ㄨ澶囩殑functionType绫诲瀷鎵惧埌瀵瑰簲鍥炬爣锛�
+                            targetView.btnIcon.UnSelectedImagePath = LogicMethod.GetIconPath(device.functionType);
+                            //鏄剧ず璁惧鍚嶇О
+                            targetView.btnText.Text = device.name;
+                            //鏀瑰彉璁惧鍚嶇О鏄剧ず鎺т欢瀹藉害
+                            targetView.btnText.Width = Application.GetRealWidth(80);
+                            //鍖哄埆涓嶅悓璁惧锛屾樉绀轰笉鍚岃澶囩姸鎬�
+                            switch (device.functionType)
+                            {
+                                case FunctionType.Relay:
+                                    {//寮�鍏崇伅
+                                        foreach (var dic in dicList)
+                                        {
 
+                                            string value = dic["value"];
+                                            if (value == "on")
+                                            {
+                                                targetView.btnState.Text = Language.StringByID(StringId.onLogic);
+
+                                            }
+                                            else
+                                            {
+                                                targetView.btnState.Text = Language.StringByID(StringId.offLogic);
+                                            }
+                                        }
+                                    }
+                                    break;
+                            }
+                        }
+                        break;
+                    case "2":
+                        {
+                            //鐢╯id鎵惧埌鍦烘櫙锛�
+                            var scene = LogicMethod.GetSecne(outputTarget.sid);
+                            targetView.btnIcon.UnSelectedImagePath = "LogicIcon/scene.png";
+                            targetView.btnNextIcon.Visible = false;
+                            //鏄剧ず鍦烘櫙鍚嶇О
+                            targetView.btnText.Text = scene.name;
+                        }
+                        break;
+                    case "3":
+                        {
+                            targetView.btnIcon.UnSelectedImagePath = "LogicIcon/delayed.png";
+                            foreach (var dic in dicList)
+                            {
+                                string value = dic["value"];
+                                targetView.btnText.Text =value;
+                            }
+                        }
+                        break;
+                }
+                //鍐嶆缂栬緫鏉′欢鐘舵�佺偣鍑讳簨浠�
+                targetView.btnClick.MouseUpEventHandler += (sen, e) =>
+                {
+                    Button button = (Button)sen;
+                    //鎵惧埌褰撳墠缂栬緫鐨勭储寮�
+                    int indexVulae = int.Parse(targetView.btnClick.Tag.ToString());
+                    //鏍囪缂栬緫鐘舵��
+                    bool edit = true;
+                    switch (button.Name)
+                    {
+                        case "1":
+                            {
+                                //鐢╯id鎵惧埌璁惧锛�
+                                var device = LogicMethod.GetDevice(outputTarget.sid);
+                                TargetDeviceFunList deviceFunList = new TargetDeviceFunList();
+                                MainPage.BasePageView.AddChidren(deviceFunList);
+                                deviceFunList.Show(device, indexVulae, edit);
+                                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                            }
+                            break;
+                        case "3":
+                            {
+
+                                FrameLayout fLayout = new FrameLayout
+                                {
+                                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
+                                };
+                                thisView.AddChidren(fLayout);
+                                AddTarget addTarget = new AddTarget();
+                                addTarget.Delayed(fLayout, edit, indexVulae);
+
+                               
+                            }
+                            break;
+                    }
+                };
+                ///鍒犻櫎鎺т欢
+                targetView.btnDel.MouseUpEventHandler += (sender, e) =>
+                {
+                    Logic.currlogic.output.Remove(outputTarget);
+                    targetView.frameLayout.RemoveFromParent();
+                };
+            }
         }
 
     }

--
Gitblit v1.8.0