From eda3fb873e59544ff36301b51e05aef64f87b0f9 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期五, 27 八月 2021 13:21:21 +0800
Subject: [PATCH] Merge branch 'newBranch1' of http://172.16.1.23:6688/r/~wxr/HDL_APP_Project into newBranch1

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs |  243 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 241 insertions(+), 2 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs
index 680d108..ba94b4d 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddTarget.cs
@@ -1,8 +1,9 @@
 锘縰sing System;
+using System.Collections.Generic;
 using Shared;
 namespace HDL_ON.UI.UI2.Intelligence.Automation
 {
-    public class AddTarget:FrameLayout
+    public class AddTarget : FrameLayout
     {
         public AddTarget()
         {
@@ -33,18 +34,256 @@
             functionView.btnText.TextID = StringId.funLogic;
             functionView.btnIcon.UnSelectedImagePath = "LogicIcon/functionicon.png";
             viewLayout.AddChidren(functionView.FLayoutView());
+
+            //鍦烘櫙
+            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 securityView = new LogicView.SelectTypeView();
+            securityView.frameLayout.Y = sceneView.frameLayout.Bottom;
+            securityView.btnText.TextID = StringId.anfang;
+            securityView.btnIcon.UnSelectedImagePath = "LogicIcon/security.png";
+            viewLayout.AddChidren(securityView.FLayoutView());
+
+            //寤舵椂
+            LogicView.SelectTypeView delayView = new LogicView.SelectTypeView();
+            delayView.frameLayout.Y = sceneView.frameLayout.Bottom;
+            delayView.btnText.TextID = StringId.delayLogic;
+            delayView.btnIcon.UnSelectedImagePath = "LogicIcon/time.png";
+            //viewLayout.AddChidren(delayView.FLayoutView());
             #endregion
 
             #region  鎵�鏈夌偣鍑讳簨浠�
-            functionView.btnClick.MouseUpEventHandler += (sen, e) => {
+            //鍔熻兘鐐瑰嚮浜嬩欢
+            functionView.btnClick.MouseUpEventHandler += (sen, e) =>
+            {
                 FunTpye funTpye = new FunTpye();
                 MainPage.BasePageView.AddChidren(funTpye);
                 funTpye.Show(LogicMethod.target_if);
                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
 
             };
+            //鍦烘櫙鐐瑰嚮浜嬩欢
+            sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
+            {
+                SceneMethod();
+            };
+            //瀹夐槻鐐瑰嚮浜嬩欢
+            securityView.btnClick.MouseUpEventHandler += (sen, e) =>
+            {
+                Security security = new Security();
+                MainPage.BasePageView.AddChidren(security);
+                security.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+                //SecurityMethod(this);
+            };
+            //寤舵椂鐐瑰嚮浜嬩欢
+            delayView.btnClick.MouseUpEventHandler += (sen, e) =>
+            {
+
+                FrameLayout fLayout = new FrameLayout
+                {
+                    BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
+                };
+                this.AddChidren(fLayout);
+                Delayed(fLayout,false,1000);
+            };
             #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];
+                Output outputDevice = new Output();
+                outputDevice.target_type = "2";
+                outputDevice.sid = sceneSelecetd.sid;
+                //娌″暐浣滅敤锛屼负浜嗗彂閫佹暟鎹牸寮忕粺涓�;
+                outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "scene" }, { "value", "0" } } };
+                AddOutput(outputDevice);
+                LogicMethod.CurrLogicMethod.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            });
+        }
+        /// <summary>
+        /// 娣诲姞瀹夐槻
+        /// </summary>
+        public void SecurityMethod(FrameLayout frameLayout, bool edit=false, int index1=-1)
+        {
+            List<string> stateList = new List<string>();
+            if (edit&& index1 != -1) {
+                Output output = Logic.currlogic.output[index1];
+                var security = LogicMethod.CurrLogicMethod.GetSecurity(output.sid);
+                stateList.Add(security.name);
+            }
+            var securityList = LogicMethod.CurrLogicMethod.GetSecurityList(); 
+            List<string> nameList = new List<string>();
+            for (int i = 0; i < securityList.Count; i++)
+            {
+                var security = securityList[i];
+                nameList.Add(security.name); 
+            }
+            PublicInterface publicInterface = new PublicInterface();
+            publicInterface.FrameOrVv(frameLayout, nameList, stateList, StringId.addSecurityLogic,(index) =>
+            {
+                var securitySelecetd = securityList[index];
+                Output outputDevice = new Output();
+                outputDevice.target_type = "3";
+                outputDevice.sid = securitySelecetd.sid;
+                //娌″暐浣滅敤锛屼负浜嗗彂閫佹暟鎹牸寮忕粺涓�;
+                outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "security" }, { "value", "0" } } };
+                AddOutput(outputDevice,true);
+                LogicMethod.CurrLogicMethod.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            });
+        }
+        /// <summary>
+        /// 寤舵椂鏃堕棿鏂规硶
+        /// </summary>
+        /// <param name="fLayout">鍦ㄥ摢涓晫闈㈡樉绀�</param>
+        /// <param name="edit">锛坱rue=缂栬緫锛沠alse=鏂板缓锛�</param>
+        /// <param name="index">缂栬緫鏉′欢鐨勭储寮�</param>
+        public void Delayed(FrameLayout fLayout, bool edit, int index)
+        {
+            LogicView.TimeView timePointView = new LogicView.TimeView();
+            timePointView.FLayoutView(fLayout);
+            EventHandler<MouseEventArgs> RemovefLayout = (sender, e1) =>
+            {
+                //绉婚櫎fLayout鐣岄潰
+                fLayout.RemoveFromParent();
+            };
+            //鍙栨秷鐐瑰嚮浜嬩欢
+            timePointView.btnCancel.MouseUpEventHandler += RemovefLayout;
+
+            //鍔犺浇鏁版嵁鐣岄潰鐨勮缃柟娉�(鍒楄〃浜掍笉鑱斿姩)
+            timePointView.mUIPickerView.setNPicker(timePointView.GethStringList0(), timePointView.GetmStringList(), null);
+            //榛樿鍒濆閫変腑鐘舵��
+            timePointView.mUIPickerView.setCurrentItems(0, 5, 0);
+            //瀹氫箟涓�涓眬閮ㄥ彉閲忚褰曢�変腑鏃堕棿
+            string timepoint = "00:05";
+
+            if (edit)
+            {
+                Output output = Logic.currlogic.output[index];
+                if (output.target_type == "4")
+                {
+                    List<Dictionary<string, string>> dicList = output.status as List<Dictionary<string, string>>;
+                    foreach (var dic in dicList)
+                    {
+                        string timeValue = dic["value"];
+                        int hIndex = timePointView.GetValueIndex(timeValue, 0, 1, timePointView.GethIntList());
+                        int mIndex = timePointView.GetValueIndex(timeValue, 1, 0, timePointView.GetmIntList());
+                        //鏇存柊鍒濆鐘舵��
+                        timePointView.mUIPickerView.setCurrentItems(hIndex, mIndex, 0);
+                        timepoint = timeValue;
+                    }
+                }
+            }
+
+
+            //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆�
+            timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
+            {
+                string hour = timePointView.GethStringList0()[index1].Split(' ')[0];
+                string minuet = timePointView.GetmStringList()[index2].Split(' ')[0];
+                timepoint = hour + ":" + minuet;
+            };
+            //纭畾鐐瑰嚮浜嬩欢
+            timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) =>
+            {
+                if (timepoint=="00:00") {
+                    //鎻愮ず
+                    return;
+                }
+                Output outputTime= new Output();
+                outputTime.sid = LogicMethod.CurrLogicMethod.NewSid();
+                outputTime.target_type = "4";
+                Dictionary<string, string> dic = new Dictionary<string, string>();
+                LogicMethod.CurrLogicMethod.dictionary(dic, "key", "delay");
+                LogicMethod.CurrLogicMethod.dictionary(dic, "value", timepoint);
+                outputTime.status.Add(dic);
+                if (edit)
+                {
+                    //绉婚櫎鏃ф暟鎹�
+                    Logic.currlogic.output.RemoveAt(index);
+                    //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�;
+                    Logic.currlogic.output.Insert(index, outputTime);
+                }
+                else
+                {
+                    //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢
+                    AddOutput(outputTime);
+                }
+                fLayout.RemoveFromParent();
+                LogicMethod.CurrLogicMethod.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+            };
+        }
+        /// <summary>
+        /// 娣诲姞鐩爣
+        /// </summary>
+        /// <param name="target"></param>
+        /// <param name="bool_if">琛ㄧず鍚敤涓嶅悓鏉′欢</param>
+        private void AddOutput(Output target,bool bool_if=false)
+        {
+            int indexValue = -1;
+            for (int i = 0; i < Logic.currlogic.output.Count; i++)
+            {
+                if (bool_if)
+                {
+                    ///瀹夐槻鍏佽涓�绉�
+                    if (Logic.currlogic.output[i].target_type == target.target_type)
+                    {
+                        indexValue = i;
+                        break;
+                    }
+                }
+                else
+                {
+                    if (Logic.currlogic.output[i].sid == target.sid)
+                    {
+                        indexValue = i;
+                        break;
+                    }
+                }
+            }
+            if (indexValue != -1)
+            {
+                Logic.currlogic.output.RemoveAt(indexValue);
+                Logic.currlogic.output.Insert(indexValue, target);
+            }
+            else
+            {
+                Logic.currlogic.output.Add(target);
+            }
+
+        }
     }
 }

--
Gitblit v1.8.0