From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/NewGateWayMenuSelectForm.cs |  281 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 186 insertions(+), 95 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/NewGateWayMenuSelectForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/NewGateWayMenuSelectForm.cs
index b9c9a7f..7c9024b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/NewGateWayMenuSelectForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Gateway/Add/NewGateWayMenuSelectForm.cs
@@ -5,7 +5,22 @@
     /// 娣诲姞缃戝叧鐨勯�夋嫨鐢婚潰
     /// </summary>
     public class NewGateWayMenuSelectForm : EditorCommonForm
-    {
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鏄惁鏄剧ず鎻愮ず璁剧疆浣忓畢鍦扮悊浣嶇疆
+        /// </summary>
+        private bool showSettion = true;
+        /// <summary>
+        /// 鎻愮ず鐨凢rameLayout
+        /// </summary>
+        private FrameLayout frameTip = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
         /// </summary>
@@ -27,7 +42,7 @@
             this.ClearBodyFrame();
 
             var listView = new VerticalListControl(29);
-            listView.Height = Application.GetRealHeight(340);
+            listView.Height = bodyFrameLayout.Height;
             listView.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(listView);
 
@@ -42,8 +57,8 @@
             row1.AddBottomLine();
             row1.ButtonClickEvent += (sender, e) =>
             {
-                var form = new WiredGatewayDirectionForm();
-                form.AddForm();
+                //鑿滃崟鎸夐挳鐨勭偣鍑讳簨浠�
+                this.MenuButtonClickEvent(1);
             };
 
             //鏃犵嚎缃戝叧
@@ -54,106 +69,182 @@
             var btntext2 = row2.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uWirelessGateway), 500);
             btntext2.TextSize = 15;
             row2.AddRightArrow();
+            row2.AddBottomLine();
             row2.ButtonClickEvent += (sender, e) =>
             {
-                var menuContr = new BottomMenuSelectForm();
-                menuContr.AddForm(2);
-                //UDP妯″紡(鎺ㄨ崘)
-                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uUdpModeRecommend), () =>
-                {
-                    var form = new WirelessUdpDirectionForm();
-                    form.AddForm();
-                });
-                //AP妯″紡
-                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uApMode), () =>
-                {
-                    var form = new WirelessApDirection1Form();
-                    form.AddForm();
-                });
+                //鑿滃崟鎸夐挳鐨勭偣鍑讳簨浠�
+                this.MenuButtonClickEvent(2);
             };
+
+            //Mini缃戝叧
+            var row3 = new FrameRowControl(listView.rowSpace / 2);
+            listView.AddChidren(row3);
+            var btnIcon3 = row3.AddLeftIcon(81);
+            btnIcon3.UnSelectedImagePath = "Gateway/MiniGateway.png";
+            var btntext3 = row3.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uMiniGateway), 500);
+            btntext3.TextSize = 15;
+            row3.AddRightArrow();
+            row3.ButtonClickEvent += (sender, e) =>
+            {
+                //鑿滃崟鎸夐挳鐨勭偣鍑讳簨浠�
+                this.MenuButtonClickEvent(3);
+            };
+            listView.AdjustRealHeight(Application.GetRealHeight(23));
+
+            //濡傛灉杩樻病鏈夎缃湴鐞嗕綅缃�
+            if (Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
+            {
+                this.frameTip = new FrameLayout();
+                frameTip.X = Application.GetRealWidth(179);
+                frameTip.Y = Application.GetRealHeight(1426);
+                frameTip.Height = Application.GetRealHeight(100);
+                frameTip.Width = Application.GetRealWidth(714);
+                bodyFrameLayout.AddChidren(frameTip);
+
+                var btnIcon = new IconViewControl(58);
+                btnIcon.UnSelectedImagePath = "Item/Tips.png";
+                frameTip.AddChidren(btnIcon);
+
+                //濡傛灉涓嶈缃綇瀹呯殑鍦扮悊浣嶇疆,鍒欎細褰卞搷鑷姩鍖栧湴鐞嗗洿鏍忓姛鑳界殑璁剧疆
+                var btnTip = new NormalViewControl(Application.GetRealWidth(636), Application.GetRealHeight(100), false);
+                btnTip.X = btnIcon.Right + Application.GetRealWidth(20);
+                btnTip.TextAlignment = TextAlignment.Center;
+                btnTip.TextColor = UserCenterColor.Current.TextGrayColor1;
+                btnTip.TextSize = 12;
+                btnTip.IsMoreLines = true;
+                btnTip.Text = Language.StringByID(R.MyInternationalizationString.uNotSetLocationWillAffectTheAutomaticGeofencingFunction);
+                frameTip.AddChidren(btnTip);
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鎸夐敭鐐瑰嚮___________________________
+
+        /// <summary>
+        /// 鑿滃崟鎸夐挳鐨勭偣鍑讳簨浠�
+        /// </summary>
+        /// <param name="menuDiv">1:鏈夌嚎缃戝叧 2:鏃犵嚎缃戝叧 3:mini缃戝叧</param>
+        private void MenuButtonClickEvent(int menuDiv)
+        {
+            //鍙脊涓�娆�
+            if (this.showSettion == true && Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
+            {
+                this.showSettion = false;
+                //璇峰墠寰�浣忓畢绠$悊{0}璁剧疆浣忓畢鐨勫湴鐞嗕綅缃�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGotoResidenceAndSetLocation).Replace("{0}", "\r\n");
+                var alert = new ShowMsgControl(ShowMsgType.Confirm, msg,
+                    Language.StringByID(R.MyInternationalizationString.uGotoSettion),
+                    Language.StringByID(R.MyInternationalizationString.uNeglect));
+                alert.Show();
+
+                //蹇界暐
+                alert.CancelClickEvent += () =>
+                {
+                    //鏄剧ず鎸囧畾鐨勭晫闈�
+                    this.ShowFormByMenuDiv(menuDiv);
+                };
+                //鍘昏缃�
+                alert.ConfirmClickEvent += () =>
+                {
+                    var form = new Residence.ResidenceManagementForm();
+                    form.AddForm(false);
+                };
+                return;
+            }
+            //鏄剧ず鎸囧畾鐨勭晫闈�
+            this.ShowFormByMenuDiv(menuDiv);
+        }
+
+        /// <summary>
+        /// 鏄剧ず鎸囧畾鐨勭晫闈�
+        /// </summary>
+        /// <param name="menuDiv">1:鏈夌嚎缃戝叧 2:鏃犵嚎缃戝叧 3:mini缃戝叧</param>
+        private void ShowFormByMenuDiv(int menuDiv)
+        {
+            if (menuDiv == 1)
+            {
+                var form = new WiredGatewayDirectionForm();
+                form.AddForm();
+            }
+            else if (menuDiv == 2)
+            {
+                var menuContr = new BottomMenuSelectForm();
+                menuContr.AddForm(2);
+                //UDP妯″紡(鎺ㄨ崘)
+                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uUdpModeRecommend), () =>
+                {
+                    var form = new WirelessUdpDirectionForm();
+                    form.AddForm();
+                });
+                //AP妯″紡
+                menuContr.AddMenu(Language.StringByID(R.MyInternationalizationString.uApMode), () =>
+                {
+                    var form = new WirelessApDirection1Form();
+                    form.AddForm();
+                });
+            }
+            else if (menuDiv == 3)
+            {
+                var form = new MiniGatewayDirection1Form();
+                form.AddForm();
+            }
         }
 
+        #endregion
+
+        #region 鈻� 涓�鑸柟娉昣__________________________
+
         /// <summary>
-        /// 鑿滃崟鎺т欢
+        /// 妫�娴嬩綇瀹呯粡绾害
         /// </summary>
-        private class SearchWirelessMenuControl : DialogCommonForm
+        /// <returns></returns>
+        private bool CheckResidencePoint()
         {
-            /// <summary>
-            /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
-            /// </summary>
-            public void ShowForm()
+            //鍙脊涓�娆�
+            if (this.showSettion == false)
             {
-                var frameBack1 = new FrameLayoutControl();
-                frameBack1.UseClickStatu = false;
-                frameBack1.Y = Application.GetRealHeight(1420);
-                frameBack1.Gravity = Gravity.CenterHorizontal;
-                frameBack1.RadiusEx = 12;
-                frameBack1.Width = Application.GetRealWidth(1034);
-                frameBack1.Height = Application.GetRealHeight(300);
-                frameBack1.BackgroundColor = UserCenterColor.Current.White;
-                bodyFrameLayout.AddChidren(frameBack1);
-
-                //UDP妯″紡(鎺ㄨ崘)
-                var btnUdp = new NormalViewControl(900, 156, true);
-                btnUdp.Gravity = Gravity.CenterHorizontal;
-                btnUdp.TextAlignment = TextAlignment.Center;
-                btnUdp.TextColor = 0xff0075ff;
-                btnUdp.TextSize = 17;
-                btnUdp.TextID = R.MyInternationalizationString.uUdpModeRecommend;
-                frameBack1.AddChidren(btnUdp, ChidrenBindMode.NotBind);
-                btnUdp.ButtonClickEvent += (sender, e) =>
-                {
-                    //鍏抽棴鐣岄潰
-                    this.CloseForm();
-                    var form = new WirelessUdpDirectionForm();
-                    form.AddForm();
-                };
-
-                //绾�
-                var btnLine = new NormalViewControl(frameBack1.Width, ControlCommonResourse.BottomLineHeight, false);
-                btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
-                btnLine.Y = btnUdp.Bottom;
-                frameBack1.AddChidren(btnLine, ChidrenBindMode.NotBind);
-                //AP妯″紡
-                var btnAp = new NormalViewControl(900, 144, true);
-                btnAp.Y = btnLine.Bottom;
-                btnAp.Gravity = Gravity.CenterHorizontal;
-                btnAp.TextAlignment = TextAlignment.Center;
-                btnAp.TextColor = 0xff0075ff;
-                btnAp.TextSize = 17;
-                btnAp.TextID = R.MyInternationalizationString.uApMode;
-                frameBack1.AddChidren(btnAp, ChidrenBindMode.NotBind);
-                btnAp.ButtonClickEvent += (sender, e) =>
-                {
-                    //鍏抽棴鐣岄潰
-                    this.CloseForm();
-                    var form = new WirelessApDirection1Form();
-                    form.AddForm();
-                };
-
-                var frameBack2 = new FrameLayoutControl();
-                frameBack2.UseClickStatu = false;
-                frameBack2.Y = frameBack1.Bottom + Application.GetRealHeight(23);
-                frameBack2.Gravity = Gravity.CenterHorizontal;
-                frameBack2.RadiusEx = 12;
-                frameBack2.Width = Application.GetRealWidth(1034);
-                frameBack2.Height = Application.GetRealHeight(156);
-                frameBack2.BackgroundColor = UserCenterColor.Current.White;
-                bodyFrameLayout.AddChidren(frameBack2);
-                //鍙栨秷
-                var btnCancel = new NormalViewControl(900, 156, true);
-                btnCancel.Gravity = Gravity.CenterHorizontal;
-                btnCancel.TextAlignment = TextAlignment.Center;
-                btnCancel.TextColor = 0xff0075ff;
-                btnCancel.TextSize = 17;
-                btnCancel.TextID = R.MyInternationalizationString.uCancel;
-                frameBack2.AddChidren(btnCancel, ChidrenBindMode.NotBind);
-                btnCancel.ButtonClickEvent += (sender, e) =>
-                {
-                    //鍏抽棴鐣岄潰
-                    this.CloseForm();
-                };
+                return true;
             }
-        }
+            this.showSettion = false;
+
+            if (Common.Config.Instance.Home.Latitude == 0 && Common.Config.Instance.Home.Longitude == 0)
+            {
+                //璇峰墠寰�浣忓畢绠$悊{0}璁剧疆浣忓畢鐨勫湴鐞嗕綅缃�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGotoResidenceAndSetLocation).Replace("{0}", "\r\n");
+                this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                {
+                    var form = new Residence.ResidenceManagementForm();
+                    form.AddForm(false);
+
+                }, Language.StringByID(R.MyInternationalizationString.uGotoSettion));
+                return false;
+            }
+            return true;
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
+
+        /// <summary>
+        /// 鑷韩鐨勪笂灞傜晫闈㈠叧闂悗,瀹冭嚜韬浜庢渶涓婂眰鏃�,瑙﹀彂鐨勪簨浠�
+        /// </summary>
+        public override int FormActionAgainEvent()
+        {
+            if (frameTip == null)
+            {
+                return 0;
+            }
+            if (Common.Config.Instance.Home.Latitude != 0 || Common.Config.Instance.Home.Longitude != 0)
+            {
+                //绉婚櫎鎺夋彁绀�
+                frameTip.RemoveFromParent();
+                return 1;
+            }
+            return 1;
+        }
+
+        #endregion
     }
 }

--
Gitblit v1.8.0