From 3dcbd186c42c598c0c08d1cd37034cf2baa09e54 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 30 十二月 2019 15:47:51 +0800
Subject: [PATCH] 合并了代码

---
 ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs |  170 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 129 insertions(+), 41 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs
index b44fd18..7751fe6 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddLogicPage.cs
@@ -388,8 +388,8 @@
             var securityfra = new FrameLayout
             {
                 Width = Application.GetRealWidth(1080),
-                Height = Application.GetRealHeight(690),
-                Y = Application.GetRealHeight(1920 - 690),
+                Height = Application.GetRealHeight(690+160),
+                Y = Application.GetRealHeight(1920 - 690-160),
                 BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                 //Radius = (uint)Application.GetRealHeight(60),
             };
@@ -445,7 +445,7 @@
             #endregion
 
 
-            #region  ----鍦ㄥ甯冮槻 绂诲甯冮槻  鎾ら槻
+            #region  ----鍦ㄥ甯冮槻 绂诲甯冮槻  鎾ら槻 鑳佽揩鎾ら槻
 
             #region  鍦ㄥ甯冮槻
 
@@ -528,7 +528,7 @@
                 Width = Application.GetRealWidth(920),
                 Height = Application.GetRealHeight(130),
                 X = Application.GetRealWidth(80),
-                LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
+                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
             };
             withdrawalFrameLayout.AddChidren(withdrawalRowLayout);
 
@@ -545,17 +545,50 @@
             var withdrawalSelected = new SelectedButton();
             withdrawalRowLayout.AddChidren(withdrawalSelected);
             #endregion
+            #region  鑳佽揩鎾ら槻
+            var urgentwithdFrameLayout = new FrameLayout
+            {
+                Height = Application.GetRealHeight(160),
+                Y = withdrawalFrameLayout.Bottom,
+            };
+            securityfra.AddChidren(urgentwithdFrameLayout);
 
-            #region  ----鍦ㄥ甯冮槻 绂诲甯冮槻  鎾ら槻鐐瑰嚮浜嬩欢
+
+            var urgentwithdrawalRowLayout = new RowLayout
+            {
+                Y = Application.GetRealHeight(30),
+                Width = Application.GetRealWidth(920),
+                Height = Application.GetRealHeight(130),
+                X = Application.GetRealWidth(80),
+                LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
+            };
+            urgentwithdFrameLayout.AddChidren(urgentwithdrawalRowLayout);
+
+            var btnurgentwithdrawal = new Button
+            {
+                TextID = MyInternationalizationString.urgentwithdrawal,
+                Width = Application.GetRealWidth(600),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
+                TextSize = 14,
+            };
+            urgentwithdrawalRowLayout.AddChidren(btnurgentwithdrawal);
+
+            var urgentwithdrawalSelected = new SelectedButton();
+            urgentwithdrawalRowLayout.AddChidren(urgentwithdrawalSelected);
+            #endregion
+            #region  ----鍦ㄥ甯冮槻 绂诲甯冮槻  鎾ら槻 鑳佽揩鎾ら槻鐐瑰嚮浜嬩欢
             ///鍦ㄥ甯冮槻鐐瑰嚮浜嬩欢
             EventHandler<MouseEventArgs> athomeclick = (sedner14, e14) =>
             {
                 btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                 leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                btnurgentwithdrawal.TextColor= ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 athomedefenceSelected.Visible = true;
                 leavehomedefenceSelected.Visible = false;
                 withdrawalSelected.Visible = false;
+                urgentwithdrawalSelected.Visible = false;
             };
             athomedefenceRowLayout.MouseUpEventHandler += athomeclick;
             btnathomedefence.MouseUpEventHandler += athomeclick;
@@ -568,9 +601,11 @@
                 btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                 btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 athomedefenceSelected.Visible = false;
                 leavehomedefenceSelected.Visible = true;
                 withdrawalSelected.Visible = false;
+                urgentwithdrawalSelected.Visible = false;
             };
             leavehomedefenceRowLayout.MouseUpEventHandler += leavehomeclick;
             leavehomebtndefence.MouseUpEventHandler += leavehomeclick;
@@ -582,14 +617,33 @@
                 btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                 athomedefenceSelected.Visible = false;
                 leavehomedefenceSelected.Visible = false;
                 withdrawalSelected.Visible = true;
+                urgentwithdrawalSelected.Visible = false;
             };
             withdrawalRowLayout.MouseUpEventHandler += disableclick;
             btnwithdrawal.MouseUpEventHandler += disableclick;
             withdrawalSelected.MouseUpEventHandler += disableclick;
             withdrawalFrameLayout.MouseUpEventHandler += disableclick;
+
+            ///鑳佽揩鎾ら槻鐐瑰嚮浜嬩欢
+            EventHandler<MouseEventArgs> urgentwithdrawalclick = (seder, e) =>
+            {
+                btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                athomedefenceSelected.Visible = false;
+                leavehomedefenceSelected.Visible = false;
+                withdrawalSelected.Visible = false;
+                urgentwithdrawalSelected.Visible = true;
+            };
+            urgentwithdrawalRowLayout.MouseUpEventHandler += urgentwithdrawalclick;
+            btnurgentwithdrawal.MouseUpEventHandler += urgentwithdrawalclick;
+            urgentwithdrawalSelected.MouseUpEventHandler += urgentwithdrawalclick;
+            urgentwithdFrameLayout.MouseUpEventHandler += urgentwithdrawalclick;
             #endregion
             #endregion
 
@@ -608,30 +662,47 @@
                                 btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                 leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                 btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                                btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                 athomedefenceSelected.Visible = true;
                                 leavehomedefenceSelected.Visible = false;
                                 withdrawalSelected.Visible = false;
+                                urgentwithdrawalSelected.Visible = false;
                             }
                             else
                             {
                                 btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                 leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                 btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                                btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                 athomedefenceSelected.Visible = false;
                                 leavehomedefenceSelected.Visible = true;
                                 withdrawalSelected.Visible = false;
+                                urgentwithdrawalSelected.Visible = false;
                             }
 
 
                         }
-                        else
+                        else if (securityifon["EnOrWithdrawMode"] == "1")
                         {
                             btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                             leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                             btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                             athomedefenceSelected.Visible = false;
                             leavehomedefenceSelected.Visible = false;
                             withdrawalSelected.Visible = true;
+                            urgentwithdrawalSelected.Visible = false;
+                        }
+                        else if (securityifon["EnOrWithdrawMode"] == "2")
+                        {
+                            btnathomedefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            leavehomebtndefence.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            btnwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
+                            btnurgentwithdrawal.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
+                            athomedefenceSelected.Visible = false;
+                            leavehomedefenceSelected.Visible = false;
+                            withdrawalSelected.Visible = false;
+                            urgentwithdrawalSelected.Visible = true;
                         }
                         break;
                     }
@@ -639,7 +710,7 @@
             }
             Btncomplete.MouseUpEventHandler += (sender, e) =>
             {
-                if (!athomedefenceSelected.Visible && !leavehomedefenceSelected.Visible && !withdrawalSelected.Visible)
+                if (!athomedefenceSelected.Visible && !leavehomedefenceSelected.Visible && !withdrawalSelected.Visible&&!urgentwithdrawalSelected.Visible)
                 {
                     return;
                 }
@@ -656,46 +727,43 @@
                 {
                     SecurityConditionsInfo.Remove("ModeId");
                 }
-
                 SecurityConditionsInfo.Add("Type", "6");
                 SecurityConditionsInfo.Add("IsValid", "1");
-                SecurityConditionsInfo.Add("ModeId", "0");
+                if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode"))
+                {
+                    SecurityConditionsInfo.Remove("EnOrWithdrawMode");
+                }
+                if (SecurityConditionsInfo.ContainsKey("ModeId"))
+                {
+                    SecurityConditionsInfo.Remove("ModeId");
+                }
                 //鍦ㄥ甯冮槻
                 if (athomedefenceSelected.Visible)
                 {
-                    if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode"))
-                    {
-                        SecurityConditionsInfo.Remove("EnOrWithdrawMode");
-                    }
-                    if (SecurityConditionsInfo.ContainsKey("ModeId"))
-                    {
-                        SecurityConditionsInfo.Remove("ModeId");
-                    }
+                    
                     SecurityConditionsInfo.Add("EnOrWithdrawMode", "0");
                     SecurityConditionsInfo.Add("ModeId", "1");
                 }
                 //绂诲甯冮槻
                 if (leavehomedefenceSelected.Visible)
                 {
-                    if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode"))
-                    {
-                        SecurityConditionsInfo.Remove("EnOrWithdrawMode");
-                    }
-                    if (SecurityConditionsInfo.ContainsKey("ModeId"))
-                    {
-                        SecurityConditionsInfo.Remove("ModeId");
-                    }
+                  
                     SecurityConditionsInfo.Add("EnOrWithdrawMode", "0");
                     SecurityConditionsInfo.Add("ModeId", "2");
                 }
                 //鎾ら槻
                 if (withdrawalSelected.Visible)
                 {
-                    if (SecurityConditionsInfo.ContainsKey("EnOrWithdrawMode"))
-                    {
-                        SecurityConditionsInfo.Remove("EnOrWithdrawMode");
-                    }
+                    
                     SecurityConditionsInfo.Add("EnOrWithdrawMode", "1");
+                    SecurityConditionsInfo.Add("ModeId", "0");
+                }
+                //鑳佽揩鎾ら槻
+                if (urgentwithdrawalSelected.Visible)
+                {
+
+                    SecurityConditionsInfo.Add("EnOrWithdrawMode", "2");
+                    SecurityConditionsInfo.Add("ModeId", "0");
                 }
                 LogicIfon.AddSecurityconditions(SecurityConditionsInfo);
                 var logicCommunalPage = new LogicCommunalPage();
@@ -782,8 +850,8 @@
             typeRow.AddChidren(Btncomplete);
             #endregion
 
-            #region  ------鍦ㄥ   绂诲  
-            #region ------鍦ㄥ
+            #region  ------鍒拌揪鍦扮偣   绂诲紑鍦扮偣  
+            #region ------鍒拌揪鍦扮偣
 
             var athomeFrameLayout = new FrameLayout
             {
@@ -817,7 +885,7 @@
             athomeRowLayout.AddChidren(athomeSelected);
             #endregion
 
-            #region -------绂诲 
+            #region -------绂诲紑鍦扮偣 
             var leavehomeFrameLayout = new FrameLayout
             {
                 Height = Application.GetRealHeight(160),
@@ -850,7 +918,7 @@
 
             #endregion
             string strname = "";
-            ///鍦ㄥ鐐瑰嚮浜嬩欢
+            ///鍒拌揪鍦扮偣鐐瑰嚮浜嬩欢
             EventHandler<MouseEventArgs> athomeclick = (sedner15, e15) =>
             {
                 strname = btnathome.Text;
@@ -866,7 +934,7 @@
             athomeRowLayout.MouseUpEventHandler += athomeclick;
             athomeFrameLayout.MouseUpEventHandler += athomeclick;
 
-            ///绂诲鐐瑰嚮浜嬩欢
+            ///绂诲紑鍦扮偣鐐瑰嚮浜嬩欢
             EventHandler<MouseEventArgs> leavehomeclick = (sedner14, e14) =>
             {
                 strname = btnleavehome.Text;
@@ -879,14 +947,18 @@
             leavehomeSelected.MouseUpEventHandler += leavehomeclick;
             leavehomeRowLayout.MouseUpEventHandler += leavehomeclick;
             leavehomeFrameLayout.MouseUpEventHandler += leavehomeclick;
-
+            double latitude = Config.Instance.Home.Latitude;//绾害
+            double longitude = Config.Instance.Home.Longitude;//缁忓害
+            int r = 500;//鍗婂緞
             if (edit)
             {
+                string guid = "";
                 foreach (var Locationifon in Common.Logic.CurrentLogic.Conditions)
                 {
 
                     if (Locationifon["Type"] == "7")
                     {
+                        guid = Locationifon["WhoSiteUId"];
                         if (Locationifon["AtHome"] == "0")
                         {
                             strname = btnleavehome.Text;
@@ -903,6 +975,20 @@
                             btnleavehome.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                             btnathome.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                         }
+                        break;
+                    }
+                }
+
+                foreach (var accounts in Common.Logic.CurrentLogic.Accounts)
+                {
+
+                    if (accounts["Type"] == "7" && accounts["Account"] == guid)
+                    {
+
+                        ///杞崲涓篸ouble绫诲瀷锛�
+                        latitude = Convert.ToDouble(accounts["Latitude"])/1000000.0;
+                        longitude = Convert.ToDouble(accounts["Longitude"]) / 1000000.0;
+                        r = int.Parse(accounts["Radius"]);
                         break;
                     }
                 }
@@ -948,14 +1034,16 @@
                     }
                     LocationConditionsInfo.Add("AtHome", "1");
                 }
-                double a1 = Config.Instance.Home.Latitude, a2 = Config.Instance.Home.Longitude;
+
                 //璋冪敤鏂规硶锛岃烦杞〉闈�
                 GDMapKit.Show((mLatitude, mLongitude, mRadius, name) =>
                 {
+                    //鎴彇瀛楃涓插悗绗�6浣嶏紱
+                    //var len = name.Substring(name.Length - 6, 6);
 
                     //鐐瑰嚮淇濆瓨鎸夐挳锛屽洖璋冨綋鍓嶉�夋嫨鐨勭含搴︼紝缁忓害锛屽崐寰勮寖鍥�
-                    var latitud = (int)Math.Truncate(mLatitude * 1000000);
-                    var longitude = (int)Math.Truncate(mLongitude * 1000000);
+                    var latitudW = (int)Math.Truncate(mLatitude * 1000000);
+                    var longitudeH = (int)Math.Truncate(mLongitude * 1000000);
                     Dictionary<string, string> accounts = new Dictionary<string, string>();
                     if (accounts.ContainsKey("Account"))
                     {
@@ -979,8 +1067,8 @@
                     }
                     accounts.Add("Account", Config.Instance.Guid);
                     accounts.Add("Type", "7");
-                    accounts.Add("Latitude", latitud.ToString());
-                    accounts.Add("Longitude", longitude.ToString());
+                    accounts.Add("Latitude", latitudW.ToString());
+                    accounts.Add("Longitude", longitudeH.ToString());
                     accounts.Add("Radius", mRadius.ToString());
                     LogicIfon.Addaccounts(accounts);
                     LogicIfon.AddLocationconditions(LocationConditionsInfo);
@@ -988,7 +1076,7 @@
                     UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                     UserView.HomePage.Instance.PageIndex += 1;
                     logicCommunalPage.Show(() => { });
-                }, strname, true, a1, a2, 500);
+                }, strname, true, latitude, longitude, r);
             };
         }
 

--
Gitblit v1.8.0