From 944b87b6bcccb095cd73f13f4410fb20faf48f74 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期三, 25 十二月 2019 11:21:06 +0800
Subject: [PATCH] 2019.12.25

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs |   72 ++++++++++++++++--------------------
 1 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs
index d4c903f..5e7e106 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs
@@ -29,17 +29,13 @@
         /// </summary>
         private FrameCaptionInputControl btnDeviceName = null;
         /// <summary>
-        /// 璁惧Mac鍦板潃
+        /// 璁惧鐨勬煇涓�鍥炶矾
         /// </summary>
-        private string deviceMac = string.Empty;
+        private CommonDevice deviceObj = null;
         /// <summary>
         /// 璁惧闇�瑕佷繚瀛樼殑璁惧鍚嶅瓧
         /// </summary>
         private Dictionary<int, string> dicDeviceSaveName = new Dictionary<int, string>();
-        /// <summary>
-        /// 璁惧鍏蜂綋绫诲瀷鐨勪俊鎭�
-        /// </summary>
-        private DeviceEnumInfo deviceEnumInfo = null;
 
         #endregion
 
@@ -48,13 +44,10 @@
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
         /// </summary>
-        /// <param name="i_deviceMac">璁惧Mac鍦板潃</param>
-        public void ShowForm(string i_deviceMac)
+        /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param>
+        public void ShowForm(CommonDevice i_device)
         {
-            this.deviceMac = i_deviceMac;
-            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
-            //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑
-            this.deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
+            this.deviceObj = i_device;
 
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion));
@@ -97,7 +90,7 @@
                 this.ShowProgressBar();
                 foreach (var epoint in dicDeviceSaveName.Keys)
                 {
-                    var device = Common.LocalDevice.Current.GetDevice(deviceMac, epoint);
+                    var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
                     if (device == null || dicDeviceSaveName[epoint] == string.Empty)
                     {
                         //涓嶈兘鍏佽绌虹櫧鍚嶅瓧
@@ -180,18 +173,6 @@
             this.AddBindRow();
             //娣诲姞鑳屽厜鐏
             this.AddBackLightRow();
-
-            //鍊熺敤Y杞村潗鏍�
-            var btnTemp = new BottomClickButton();
-            var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount;
-            if (bodyFrameLayout.Height - btnTemp.Yaxis + realHeight > listview.Height)
-            {
-                //淇冧娇琚尅浣忕殑鑿滃崟鑳藉鍚戜笂婊戝姩
-                var frameTemp = new FrameLayout();
-                frameTemp.Height = bodyFrameLayout.Height - btnTemp.Yaxis + Application.GetRealHeight(115);
-                listview.AddChidren(frameTemp);
-            }
-            btnTemp = null;
         }
 
         #endregion
@@ -227,7 +208,7 @@
             {
                 menuCount = 2;
             }
-            var frame = new TopRightMenuControl(this, menuCount);
+            var frame = new TopRightMenuControl(menuCount);
             if (canTest == true)
             {
                 //瀹氫綅
@@ -314,7 +295,8 @@
         /// </summary>
         private void InitDeviceEpointIcon()
         {
-            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
+            bool hadDevice = false;
+            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
             var listOffSwitch = new List<CommonDevice>();
             foreach (var device in listDevice)
             {
@@ -322,6 +304,11 @@
                 {
                     //鍙骞叉帴鐐�
                     listOffSwitch.Add(device);
+                    if (device.DeviceEpoint == deviceObj.DeviceEpoint)
+                    {
+                        //鑳藉鍖归厤寰楀埌杩欎釜鍥炶矾
+                        hadDevice = true;
+                    }
                 }
             }
             //鎺掑簭
@@ -333,6 +320,11 @@
                 }
                 return -1;
             });
+            if (hadDevice == false)
+            {
+                //濡傛灉鍖归厤涓嶅埌杩欎釜鍥炶矾,鍒欓粯璁ょ涓�涓�
+                this.deviceObj = listOffSwitch[0];
+            }
 
             var frameBorder = new FrameLayout();
             frameBorder.Y = Application.GetRealHeight(150);
@@ -369,7 +361,7 @@
         /// <param name="device">璁惧瀵硅薄</param>
         /// <param name="isFirst">鏄惁鏄涓�涓�</param>
         /// <returns></returns>
-        private void InitDeviceIcon(FrameLayoutControl frame, CommonDevice device,bool isFirst)
+        private void InitDeviceIcon(FrameLayoutControl frame, CommonDevice device)
         {
             //涓嶄娇鐢ㄧ偣鍑荤壒鏁�
             frame.UseClickStatu = false;
@@ -377,7 +369,7 @@
             var btnIcon = new NormalViewControl(Application.GetMinRealAverage(52), Application.GetMinRealAverage(52), false);
             btnIcon.Name = "btn" + device.DeviceEpoint;
             btnIcon.Gravity = Gravity.Center;
-            btnIcon.Radius = (uint)Application.GetMinRealAverage(6);
+            btnIcon.Radius = 6;
             btnIcon.BorderWidth = 2;
             btnIcon.BorderColor = 0xff979797;
             frame.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);
@@ -388,7 +380,7 @@
                 this.DeviceEpointSelectEvent(btnIcon, null);
             };
 
-            if (isFirst == true)
+            if (device.DeviceEpoint == deviceObj.DeviceEpoint)
             {
                 //鍒濆鍖栬彍鍗曡
                 this.DeviceEpointSelectEvent(btnIcon, null);
@@ -414,7 +406,7 @@
             frame1.Gravity = Gravity.CenterHorizontal;
             frameBack.AddChidren(frame1);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame1, listDevice[0], true);
+            this.InitDeviceIcon(frame1, listDevice[0]);
 
             //鎸夐敭2
             var frame2 = new FrameLayoutControl();
@@ -424,7 +416,7 @@
             frame2.Gravity = Gravity.CenterHorizontal;
             frameBack.AddChidren(frame2);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame2, listDevice[1], false);
+            this.InitDeviceIcon(frame2, listDevice[1]);
         }
 
         #endregion
@@ -446,7 +438,7 @@
             frame1.Gravity = Gravity.CenterHorizontal;
             frameBack.AddChidren(frame1);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame1, listDevice[0], true);
+            this.InitDeviceIcon(frame1, listDevice[0]);
 
             //鎸夐敭2
             var frame2 = new FrameLayoutControl();
@@ -456,7 +448,7 @@
             frame2.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame2);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame2, listDevice[1], false);
+            this.InitDeviceIcon(frame2, listDevice[1]);
 
             //鎸夐敭3
             var frame3 = new FrameLayoutControl();
@@ -466,7 +458,7 @@
             frame3.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame3);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame3, listDevice[2], false);
+            this.InitDeviceIcon(frame3, listDevice[2]);
         }
 
         #endregion
@@ -488,7 +480,7 @@
             frame1.Y = Application.GetMinRealAverage(63);
             frameBack.AddChidren(frame1);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame1, listDevice[0], true);
+            this.InitDeviceIcon(frame1, listDevice[0]);
 
             //鎸夐敭2
             var frame2 = new FrameLayoutControl();
@@ -498,7 +490,7 @@
             frame2.Y = Application.GetMinRealAverage(63);
             frameBack.AddChidren(frame2);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame2, listDevice[1], false);
+            this.InitDeviceIcon(frame2, listDevice[1]);
 
             //鎸夐敭3
             var frame3 = new FrameLayoutControl();
@@ -508,7 +500,7 @@
             frame3.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame3);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame3, listDevice[2], false);
+            this.InitDeviceIcon(frame3, listDevice[2]);
 
             //鎸夐敭4
             var frame4 = new FrameLayoutControl();
@@ -518,7 +510,7 @@
             frame4.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame4);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame4, listDevice[3], false);
+            this.InitDeviceIcon(frame4, listDevice[3]);
         }
 
         #endregion
@@ -549,7 +541,7 @@
             nowContr.BorderColor = 0xfffb744a;
 
             nowSelectControl = nowContr;
-            nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceMac, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
+            nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
 
             //閲嶆柊鍒濆鍖栬彍鍗曡
             this.InitMenuRow();

--
Gitblit v1.8.0