From fd3c74df4d30a88d490d0c5b469df821f1bb2d78 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 04 八月 2020 14:53:25 +0800
Subject: [PATCH] 更换新接口之前的备份

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs |   99 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 86 insertions(+), 13 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs
index 85edc36..602e1b1 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Direction/AddDeviceTypeListForm.cs
@@ -16,6 +16,14 @@
         /// 鍒楄〃鎺т欢
         /// </summary>
         private VerticalListControl listView = null;
+        /// <summary>
+        /// 褰撳墠缃戝叧瀵硅薄
+        /// </summary>
+        private ZbGateway zbGateway = null;
+        /// <summary>
+        /// mini缃戝叧鏄惁鑳藉娣诲姞璁惧
+        /// </summary>
+        private bool MiniGatewayCanAddDevice = true;
 
         #endregion
 
@@ -27,10 +35,19 @@
         public void ShowForm()
         {
             //璁惧畾鏍囬
-            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType));
-
-            //鍒濆鍖栦腑閮ㄦ帶浠�
-            this.InitMiddleFrame();
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType));
+
+            this.zbGateway = HdlGatewayLogic.Current.GetLocalGateway(GatewayResourse.AppOldSelectGatewayId);
+            if (zbGateway != null && zbGateway.LinuxImageType == 11)
+            {
+                //鍒濆鍖朚ini缃戝叧鐨勭晫闈�
+                this.InitControlByMiniGateway();
+            }
+            else
+            {
+                //鍒濆鍖栦腑閮ㄦ帶浠�
+                this.InitMiddleFrame();
+            }
         }
 
         /// <summary>
@@ -55,21 +72,15 @@
             //2鎸夐敭瑙︽懜闈㈡澘
             var objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName1);
             var unSelectPic = "Device/ButtonPanelTwo.png";
-            var arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
-            objectText = arry[0].Trim();
             this.AddMenuRow(objectText, unSelectPic, "PanelTwoButtonDirectionForm");
 
             //3鎸夐敭瑙︽懜闈㈡澘
             objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName2);
-            arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
-            objectText = arry[0].Trim();
             unSelectPic = "Device/ButtonPanelThree.png";
             this.AddMenuRow(objectText, unSelectPic, "PanelThreeButtonDirectionForm");
 
             //4鎸夐敭瑙︽懜闈㈡澘
             objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDirectionName3);
-            arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
-            objectText = arry[0].Trim();
             unSelectPic = "Device/ButtonPanelFour.png";
             this.AddMenuRow(objectText, unSelectPic, "PanelFourButtonDirectionForm");
 
@@ -209,19 +220,75 @@
             unSelectPic = "Device/ThirdPartyDevice.png";
             var rowThrid = this.AddMenuRow(objectText, unSelectPic, string.Empty, false);
             rowThrid.ButtonClickEvent += (sender, e) =>
-            {
+            {
+                if (this.MiniGatewayCanAddDevice == false)
+                {
+                    //Mini缃戝叧鏈�澶у彧鑳芥坊鍔�16涓澶�
+                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg));
+                    return;
+                }
                 var form = new Device.DeviceSearchForm();
                 form.AddForm(string.Empty);
             };
 
             //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
             listView.AdjustRealHeight(Application.GetRealHeight(23));
+        }
+
+        #endregion
+
+        #region 鈻� mini缃戝叧___________________________
+
+        /// <summary>
+        /// 鍒濆鍖朚ini缃戝叧鐨勭晫闈�
+        /// </summary>
+        private void InitControlByMiniGateway()
+        {
+            //mini澶滅伅鍙兘闄愬埗鍔犲叆16鍜岃澶�
+            this.ShowProgressBar();
+
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                int statu = 0;
+                //閲嶆柊鑾峰彇璁惧鍒楄〃
+                var listDevice = Common.LocalDevice.Current.GetDeviceListFromGateway(zbGateway, ref statu, true, ShowErrorMode.NO);
+                this.CloseProgressBar();
+
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    if (statu != 1)
+                    {
+                        listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(zbGateway.GwId);
+                    }
+                    //妫�娴媘ini缃戝叧鐨勮澶囨暟
+                    this.CheckMiniGatewayDeviceCount(listDevice);
+                    //鍒濆鍖栫晫闈�
+                    this.InitMiddleFrame();
+                });
+            });
+        }
+
+        /// <summary>
+        /// 妫�娴媘ini缃戝叧鐨勮澶囨暟
+        /// </summary>
+        /// <param name="listDevice"></param>
+        private void CheckMiniGatewayDeviceCount(List<CommonDevice> listDevice)
+        {
+            var listMac = new HashSet<string>();
+            foreach (var device in listDevice)
+            {
+                if (listMac.Contains(device.DeviceAddr) == false)
+                {
+                    listMac.Add(device.DeviceAddr);
+                }
+            }
+            MiniGatewayCanAddDevice = listMac.Count < 16;
         }
 
         #endregion
-
+
         #region 鈻� 娣诲姞鑿滃崟鏍廮________________________
-
+
         /// <summary>
         /// 娣诲姞鑿滃崟鏍�
         /// </summary>
@@ -249,6 +316,12 @@
             {
                 rowLayout.ButtonClickEvent += (sender, e) =>
                 {
+                    if (this.MiniGatewayCanAddDevice == false)
+                    {
+                        //Mini缃戝叧鏈�澶у彧鑳芥坊鍔�16涓澶�
+                        this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uMiniGatewayMaxDeviceCountMsg));
+                        return;
+                    }
                     //鍙嶅皠鐩爣鐣岄潰
                     this.LoadFormByFullName("Shared.Phone.UserCenter.DeviceDirection." + formName);
                 };

--
Gitblit v1.8.0