From a9d1161b1df96e7ddad566335989a1444e433ef5 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 28 三月 2023 11:54:45 +0800
Subject: [PATCH] 2023年03月28日11:52:02

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs |  209 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 180 insertions(+), 29 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
index 2072723..3545a8c 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs
@@ -1,6 +1,7 @@
 锘縰sing System;
 using System.Collections.Generic;
 using Shared;
+
 namespace HDL_ON.UI.UI2.Intelligence.Automation
 {
     public class AddInputType : FrameLayout
@@ -11,6 +12,7 @@
         }
         public void Show()
         {
+
             LogicView.TopView topView = new LogicView.TopView();
             this.AddChidren(topView.FLayoutView());
             topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
@@ -63,14 +65,14 @@
             likiadaodaView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png";
             int count = 3;//杈撳叆绫诲瀷涓暟
             //2022骞�05鏈�24鏃�15:08:22 闅愯棌鎺夊湴鐞嗗洿鏍�
-            //if (MainView.IsGatewayType)
-            //{
-            //    count = 4;
-            //    viewLayout.AddChidren(likiadaodaView.FLayoutView());
-            //}
+            if (MainView.IsGatewayType)
+            {
+                count = 4;
+                viewLayout.AddChidren(likiadaodaView.FLayoutView());
+            }
             ////鍔熻兘
             ///浜у搧缁忕悊鍚涚剷瑕佹眰锛岃澶囧姛鑳界Щ鍒拌繖閲屻��<2022-3-7>
-            new FunTpye(LogicMethod.condition_if).FunTypeView(viewLayout, shiwaiView.frameLayout.Bottom, count);
+            new FunTpye(LogicMethod.condition_if).FunTypeView(viewLayout, likiadaodaView.frameLayout.Bottom, count);
 
             #endregion
 
@@ -79,13 +81,13 @@
             timeView.btnClick.MouseUpEventHandler += (sen, e) =>
              {
 
-          TimeTpye timeTpye = new TimeTpye();
-          MainPage.BasePageView.AddChidren(timeTpye);
-          timeTpye.Show();
-          MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                 TimeTpye timeTpye = new TimeTpye();
+                 MainPage.BasePageView.AddChidren(timeTpye);
+                 timeTpye.Show();
+                 MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
 
              };
-            
+
             //鍦烘櫙鐐瑰嚮浜嬩欢
             sceneView.btnClick.MouseUpEventHandler += (sen, e) =>
             {
@@ -112,12 +114,13 @@
             #endregion
 
         }
+
         /// <summary>
         /// 娣诲姞鍦烘櫙
         /// </summary>
         public void SceneMethod()
         {
-            var sceneList = LogicMethod.CurrLogicMethod.GetSceneList();
+            var sceneList = LogicMethod.Current.GetSceneList();
             List<string> nameList = new List<string>();
             for (int i = 0; i < sceneList.Count; i++)
             {
@@ -125,20 +128,20 @@
                 nameList.Add(scene.name);
             }
             PublicInterface publicInterface = new PublicInterface();
-            publicInterface.FrameOrVv(this, nameList, new List<string> { }, StringId.addSceneLogic, (index) =>
+            publicInterface.FrameOrVv(this, nameList, new List<string> { }, Language.StringByID(StringId.addSceneLogic), (index) =>
             {
                 var sceneSelecetd = sceneList[index];
                 Input input = new Input();
                 input.sid = sceneSelecetd.sid;
                 input.condition_type = "10";
                 Dictionary<string, string> dic = new Dictionary<string, string>();
-                LogicMethod.CurrLogicMethod.dictionary(dic, "key", "scene");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "=");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "value", "on");
+                LogicMethod.Current.dictionary(dic, "key", "scene");
+                LogicMethod.Current.dictionary(dic, "comparator", "=");
+                LogicMethod.Current.dictionary(dic, "data_type", "string");
+                LogicMethod.Current.dictionary(dic, "value", "on");
                 input.condition.Add(dic);
                 AddCondition(input);
-                LogicMethod.CurrLogicMethod.RemoveAllView();
+                LogicMethod.Current.RemoveAllView();
                 AddLogic addLogic = new AddLogic();
                 MainPage.BasePageView.AddChidren(addLogic);
                 addLogic.Show();
@@ -152,11 +155,14 @@
         /// <param name="edit">If set to <c>true</c> edit.</param>
         public void LocationView(FrameLayout flMain, bool edit)
         {
+
             string strname = "";
             ///閫氳繃璋冭瘯瀹濈粰鐨勭粡绾害<鏍囧噯GPS>
-            double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//绾害
-            double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//缁忓害
-            LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude);
+            //double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//绾害
+            //double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//缁忓害
+            /////濡傛灉鏄敤褰撳墠鎵嬫満浣嶇疆浣滀负涓績鐨勮瘽锛涘啀娆$紪杈憉i鐣岄潰鏄剧ず鏄綋鍓嶆墜鏈轰綅缃紝杩樻槸涔嬪墠鐨勭粡绾憿锛�
+            double latitude = Convert.ToDouble(MainPage.cityInfo.lat);//绾害
+            double longitude = Convert.ToDouble(MainPage.cityInfo.lon);//缁忓害
             int r = 500;//榛樿鍗婂緞
             if (edit)
             {
@@ -252,20 +258,165 @@
                 //鎸夐亾鐞嗚涓嶄細鍑虹幇
                 r = 500;
             }
+            ChooseIocate chooseIocate = new ChooseIocate();
+            MainPage.BasePageView.AddChidren(chooseIocate);
+            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+            chooseIocate.Show(latitude, longitude, r, (value) =>
+            {
+                if (value.Contains("km"))
+                {
+                    value = value.Replace("km", "");
+                }
+                else {
+                    value = value.Replace("m", "");
+                }
+                Input input = new Input();
+                input.sid = LogicMethod.Current.NewSid();
+                input.condition_type = "8";
+                Dictionary<string, string> dic = new Dictionary<string, string>();
+                LogicMethod.Current.dictionary(dic, "key", "direction");
+                LogicMethod.Current.dictionary(dic, "comparator", "=");
+                LogicMethod.Current.dictionary(dic, "data_type", "string");
+                LogicMethod.Current.dictionary(dic, "value", valueStr);
+                input.condition.Add(dic);
+                //绾害
+                input.geo_fence.latitude = latitude.ToString();
+                //缁忓害
+                input.geo_fence.longitude = longitude.ToString();
+                //鍗婂緞<鍗曚綅绫�>
+                input.geo_fence.radius = value;
+                AddCondition(input);
+                LogicMethod.Current.RemoveAllView();
+                AddLogic addLogic = new AddLogic();
+                MainPage.BasePageView.AddChidren(addLogic);
+                addLogic.Show();
+                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+            });
+
+        }
+        /// <summary>
+        /// 娣诲姞鍦扮悊鍥存爮(鏈夐珮寰峰湴鍥�,鍥犱负楂樺痉鏀惰垂鏆傛椂寮冪敤)
+        /// </summary>
+        /// <param name="flMain">Fl main.</param>
+        /// <param name="edit">If set to <c>true</c> edit.</param>
+        public void LocationView1(FrameLayout flMain, bool edit)
+        {
+            string strname = "";
+            ///閫氳繃璋冭瘯瀹濈粰鐨勭粡绾害<鏍囧噯GPS>
+            double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//绾害
+            double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//缁忓害
+            LogicMethod.Current.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude);
+            int r = 500;//榛樿鍗婂緞
+            if (edit)
+            {
+                for (var i = 0; i < Logic.currlogic.input.Count; i++)
+                {
+                    var input = Logic.currlogic.input[i];
+                    if (input.condition_type != "8")
+                    {
+                        continue;
+                    }
+                    if (input.condition[0]["value"] == "arrive")
+                    {
+                        //鍒拌揪鏌愬湴
+                        strname = Language.StringByID(StringId.daoda);
+                    }
+                    else
+                    {
+                        //绂诲紑鍦扮偣
+                        strname = Language.StringByID(StringId.likai);
+                    }
+                    //鍐嶄竴娆$紪杈戝湴鐞嗗洿鏍� <鎺т欢鏆傛椂涓嶆敮鎸佹樉绀鸿褰曚笂涓�娆$殑鐘舵��>
+                    if (!string.IsNullOrEmpty(input.geo_fence.latitude) && !string.IsNullOrEmpty(input.geo_fence.longitude))
+                    {
+                        ////绾害
+                        //var latitude1 = Convert.ToDouble(input.geo_fence.latitude);
+                        ////缁忓害
+                        //var longitude1 = Convert.ToDouble(input.geo_fence.longitude);
+                        //鍗婂緞
+                        r = int.Parse(input.geo_fence.radius);
+                        //WGS84鍧愭爣杞珮寰峰潗鏍�
+                        //LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(longitude1, latitude1, out longitude, out latitude);
+                    }
+                }
+            }
+
+            PublicInterface publicInterface = new PublicInterface();
+            var list = publicInterface.GetViewList("鍦扮悊鍥存爮");
+            publicInterface.SingleSelectionShow(flMain, list, Language.StringByID(StringId.likiadaoda), strname, (str) =>
+            {
+
+                string valueStr = "arrive";
+                if (str == Language.StringByID(StringId.daoda))
+                {
+                    //鍒拌揪鏌愬湴
+                    valueStr = "arrive";
+                }
+                else
+                {
+                    //绂诲紑
+                    valueStr = "leave";
+                }
+
+#if __Android__
+                       //鐢宠瀹氫綅鏉冮檺
+                       ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) =>
+                       {
+                           if (result1 == false) { return; }
+
+                        //鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠�
+                        ((BaseActivity)Application.Activity).SetPermission((result2) =>
+                        {
+                            if (result2 == false) { return; }
+                             //璇诲彇鐢佃瘽鐘舵�佹潈闄�
+                             ((BaseActivity)Application.Activity).SetPermission((result3) =>
+                             {
+                                 if (result3 == false) { return; }
+                                 //璋冪敤鏂规硶锛岃烦杞〉闈�
+                                 Location(valueStr, strname, latitude, longitude, r);
+                             }, "android.permission.READ_PHONE_STATE");
+
+                        }, "android.permission.WRITE_EXTERNAL_STORAGE");
+                       });
+#endif
+#if __IOS__
+               //璋冪敤鏂规硶锛岃烦杞〉闈�
+                  Location(valueStr, strname, latitude, longitude, r);
+#endif
+            });
+
+
+        }
+        /// <summary>
+        /// 鍦扮悊鍥存爮View
+        /// </summary>
+        /// <param name="valueStr">杩涘叆(arrive)鎴栬�呯寮�(leave)</param>
+        /// <param name="strname"></param>
+        /// <param name="latitude">绾害</param>
+        /// <param name="longitude">缁忓害</param>
+        /// <param name="r">鍗婂緞(榛樿500绫�)</param>
+        private void Location1(string valueStr, string strname, double latitude, double longitude, int r)
+        {
+            if (r == 0)
+            {
+                //鎸夐亾鐞嗚涓嶄細鍑虹幇
+                r = 500;
+            }
             //璋冪敤鏂规硶锛岃烦杞〉闈�
             GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
             {
                 //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS)
                 double out_lng, out_lat;
-                LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
+                LogicMethod.Current.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat);
                 Input input = new Input();
-                input.sid = LogicMethod.CurrLogicMethod.NewSid();
+                input.sid = LogicMethod.Current.NewSid();
                 input.condition_type = "8";
                 Dictionary<string, string> dic = new Dictionary<string, string>();
-                LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "=");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string");
-                LogicMethod.CurrLogicMethod.dictionary(dic, "value", valueStr);
+                LogicMethod.Current.dictionary(dic, "key", "direction");
+                LogicMethod.Current.dictionary(dic, "comparator", "=");
+                LogicMethod.Current.dictionary(dic, "data_type", "string");
+                LogicMethod.Current.dictionary(dic, "value", valueStr);
                 input.condition.Add(dic);
                 //绾害
                 input.geo_fence.latitude = out_lat.ToString();
@@ -274,7 +425,7 @@
                 //鍗婂緞<鍗曚綅绫�>
                 input.geo_fence.radius = mRadius.ToString();
                 AddCondition(input);
-                LogicMethod.CurrLogicMethod.RemoveAllView();
+                LogicMethod.Current.RemoveAllView();
                 AddLogic addLogic = new AddLogic();
                 MainPage.BasePageView.AddChidren(addLogic);
                 addLogic.Show();
@@ -313,6 +464,6 @@
                 Logic.currlogic.input.Add(input);
             }
         }
-        
+
     }
 }

--
Gitblit v1.8.0