From d7ad5a3953a8cd001659092ebde204b881f94b9d Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 31 十月 2019 10:47:13 +0800
Subject: [PATCH] 2019-10-31-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs |  209 +++++++++++++++++++---------------------------------
 1 files changed, 77 insertions(+), 132 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs
index 55f2b36..efbac27 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,47 +44,44 @@
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
         /// </summary>
-        /// <param name="i_deviceMac">璁惧Mac鍦板潃</param>
-        public void ShowForm(string i_deviceMac)
-        {
-            this.deviceMac = i_deviceMac;
-            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
-            //鑾峰彇杩欎竴鍫嗚澶囨椂灞炰簬浠�涔堢被鍨嬬殑
-            this.deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
-
-            //璁剧疆澶撮儴淇℃伅
-            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion));
-
-            //鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// <param name="i_device">璁惧鐨勬煇涓�鍥炶矾</param>
+        public void ShowForm(CommonDevice i_device)
+        {
+            this.deviceObj = i_device;
+
+            //璁剧疆澶撮儴淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion));
+
+            //鍒濆鍖栦腑閮ㄤ俊鎭�
             this.InitMiddleFrame();
 
             //鍒濆鍖栧彸涓婅鑿滃崟
-            this.InitTopRightMenu();
-        }
-
-        /// <summary>
-        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
-        /// </summary>
-        private void InitMiddleFrame()
+            this.InitTopRightMenu();
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄤ俊鎭�
+        /// </summary>
+        private void InitMiddleFrame()
         {
             //娓呯┖bodyFrame
-            this.ClearBodyFrame();
-
-            //鍒濆鍖栨甯�
-            this.InitFrameTable();
+            this.ClearBodyFrame();
+
+            //鍒濆鍖栨甯�
+            var tableContr = new InformationEditorControl();
+            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 708, 1028);
+
             //鍒濆鍖栬澶囧洖璺浘鏍�
             this.InitDeviceEpointIcon();
 
+            //鍒濆鍖栨甯冨畬鎴�
+            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
+            tableContr = null;
+
             //淇濆瓨
             var btnFinish = new BottomClickButton();
-            //鍊熺敤Y杞村潗鏍�(璁╄繖涓尯鍩熶笉鑳界偣鍑昏彍鍗�)
-            var frameBack = new FrameLayout();
-            frameBack.Y = btnFinish.Yaxis;
-            frameBack.Height = bodyFrameLayout.Height - btnFinish.Yaxis;
-            bodyFrameLayout.AddChidren(frameBack);
-
-            btnFinish.TextID = R.MyInternationalizationString.uSave;
-            bodyFrameLayout.AddChidren(btnFinish);
+            btnFinish.TextID = R.MyInternationalizationString.uSave;
+            bodyFrameLayout.AddChidren(btnFinish);
             btnFinish.ButtonClickEvent += async (sender, e) =>
             {
                 //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧
@@ -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)
                     {
                         //涓嶈兘鍏佽绌虹櫧鍚嶅瓧
@@ -120,7 +113,7 @@
                 this.CloseProgressBar();
                 //鍏抽棴鑷韩
                 this.CloseForm();
-            };
+            };
         }
 
         /// <summary>
@@ -165,56 +158,30 @@
             };
 
             //鎵�灞炲尯鍩�
-            List<string> listRoomName = Common.Room.CurrentRoom.GetRoomListNameByDevice(nowSelectDevice);
-            caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
-            nameValue = Common.Room.CurrentRoom.GetRoomName(listRoomName);
-            var btnBeloneArea = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
-            listview.AddChidren(btnBeloneArea);
-            btnBeloneArea.InitControl();
+            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
+            listview.AddChidren(rowBeloneArea);
+            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), nowSelectDevice);
             //搴曠嚎
-            btnBeloneArea.AddBottomLine();
-            //鍙崇澶�
-            btnBeloneArea.AddRightIconControl();
-            btnBeloneArea.ButtonClickEvent += (sender, e) =>
+            rowBeloneArea.AddBottomLine();
+            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
             {
-                var form = new SelectRoomForm();
-                form.AddForm(listRoomName);
-                form.ActionSelectRoom = (list) =>
-                {
-                    //鍙樻洿鎴块棿
-                    Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, list);
-
-                    btnBeloneArea.Text = Common.Room.CurrentRoom.GetRoomName(list);
-                    listRoomName.Clear();
-                    listRoomName.AddRange(list);
-                };
-            };
+                //鍙樻洿鎴块棿
+                Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys);
+            };
 
             //娣诲姞缁戝畾鐩爣琛�
             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
 
-        #region 鈻� 鍙充笂瑙掕彍鍗昣________________________
+        #region 鈻� 鍙充笂瑙掕彍鍗昣________________________
 
         /// <summary>
         /// 鍒濆鍖栧彸涓婅鑿滃崟
-        /// </summary>
+        /// </summary>
         private void InitTopRightMenu()
         {
             var btnIcon = new MostRightIconControl(69, 69);
@@ -226,11 +193,11 @@
                 //鏄剧ず鍙充笂瑙掕彍鍗曠晫闈�
                 this.ShowTopRightMenu();
             });
-        }
-
+        }
+
         /// <summary>
         /// 鏄剧ず鍙充笂瑙掕彍鍗曠晫闈�
-        /// </summary>
+        /// </summary>
         private void ShowTopRightMenu()
         {
             int menuCount = 1;
@@ -241,7 +208,7 @@
             {
                 menuCount = 2;
             }
-            var frame = new TopRightMenuControl(this, menuCount);
+            var frame = new TopRightMenuControl(menuCount);
             if (canTest == true)
             {
                 //瀹氫綅
@@ -278,9 +245,14 @@
                 //搴曠嚎
                 btnBind.AddBottomLine();
                 //鍙崇澶�
-                btnBind.AddRightIconControl();
+                btnBind.AddRightArrow();
                 btnBind.ButtonClickEvent += (sender, e) =>
                 {
+                    var panel = nowSelectDevice as ZigBee.Device.Panel;
+                    var bindTargetsPage = new Shared.Phone.UserCenter.DeviceBind.BindTargetsPage(panel);
+                    Shared.Phone.UserView.HomePage.Instance.AddChidren(bindTargetsPage);
+                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+                    bindTargetsPage.Show();
                 };
             }
         }
@@ -305,7 +277,7 @@
                 //搴曠嚎
                 btnLight.AddBottomLine();
                 //鍙崇澶�
-                btnLight.AddRightIconControl();
+                btnLight.AddRightArrow();
                 btnLight.ButtonClickEvent += (sender, e) =>
                 {
                     var form = new PanelBackLightSettionForm();
@@ -323,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)
             {
@@ -331,6 +304,11 @@
                 {
                     //鍙骞叉帴鐐�
                     listOffSwitch.Add(device);
+                    if (device.DeviceEpoint == deviceObj.DeviceEpoint)
+                    {
+                        //鑳藉鍖归厤寰楀埌杩欎釜鍥炶矾
+                        hadDevice = true;
+                    }
                 }
             }
             //鎺掑簭
@@ -342,6 +320,11 @@
                 }
                 return -1;
             });
+            if (hadDevice == false)
+            {
+                //濡傛灉鍖归厤涓嶅埌杩欎釜鍥炶矾,鍒欓粯璁ょ涓�涓�
+                this.deviceObj = listOffSwitch[0];
+            }
 
             var frameBorder = new FrameLayout();
             frameBorder.Y = Application.GetRealHeight(150);
@@ -378,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;
@@ -397,7 +380,7 @@
                 this.DeviceEpointSelectEvent(btnIcon, null);
             };
 
-            if (isFirst == true)
+            if (device.DeviceEpoint == deviceObj.DeviceEpoint)
             {
                 //鍒濆鍖栬彍鍗曡
                 this.DeviceEpointSelectEvent(btnIcon, null);
@@ -423,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();
@@ -433,7 +416,7 @@
             frame2.Gravity = Gravity.CenterHorizontal;
             frameBack.AddChidren(frame2);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame2, listDevice[1], false);
+            this.InitDeviceIcon(frame2, listDevice[1]);
         }
 
         #endregion
@@ -455,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();
@@ -465,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();
@@ -475,7 +458,7 @@
             frame3.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame3);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame3, listDevice[2], false);
+            this.InitDeviceIcon(frame3, listDevice[2]);
         }
 
         #endregion
@@ -497,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();
@@ -507,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();
@@ -517,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();
@@ -527,45 +510,7 @@
             frame4.Y = Application.GetMinRealAverage(245);
             frameBack.AddChidren(frame4);
             //鍒濆鍖栬澶囧浘鏍�
-            this.InitDeviceIcon(frame4, listDevice[3], false);
-        }
-
-        #endregion
-
-        #region 鈻� 鍒濆鍖栨甯僟________________________
-
-        /// <summary>
-        /// 鍒濆鍖栨甯�
-        /// </summary>
-        private void InitFrameTable()
-        {
-            //寮у害鐨勫渾鐨勪竴鍗婄殑楂樺害(鍥哄畾)
-            int halfRoundHeigth = Application.GetRealHeight(116) / 2;
-            //寮у害鐨勫渾
-            var btnRound = new NormalViewControl(bodyFrameLayout.Width, halfRoundHeigth * 2, false);
-            btnRound.Y = Application.GetRealHeight(708);
-            btnRound.BackgroundColor = UserCenterColor.Current.White;
-            btnRound.Radius = (uint)halfRoundHeigth;
-            bodyFrameLayout.AddChidren(btnRound);
-            //鏄庣粏鍒楄〃鐨勬甯冿紝鐧借壊鑳屾櫙(瑕嗙洊寮у害鐨勫渾鐨勫崐杈�)
-            var detailBackFrame = new FrameLayout();
-            detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2;
-            detailBackFrame.Height = Application.GetRealHeight(1028);//楂樺害灏辨槸瑕佸畠瓒呰繃
-            detailBackFrame.BackgroundColor = UserCenterColor.Current.White;
-            bodyFrameLayout.AddChidren(detailBackFrame);
-
-            //璁惧缂栬緫
-            var btnTile = new NormalViewControl(800, 60, true);
-            btnTile.X = ControlCommonResourse.XXLeft;
-            btnTile.TextSize = 15;
-            btnTile.TextColor = UserCenterColor.Current.TextColor2;
-            btnTile.TextID = R.MyInternationalizationString.uDeviceEditor;
-            detailBackFrame.AddChidren(btnTile);
-
-            this.listview = new VerticalListControl(12);
-            listview.Y = btnTile.Bottom + Application.GetRealHeight(17);
-            listview.Height = Application.GetRealHeight(1028) - halfRoundHeigth - btnTile.Bottom - Application.GetRealHeight(17);
-            detailBackFrame.AddChidren(listview);
+            this.InitDeviceIcon(frame4, listDevice[3]);
         }
 
         #endregion
@@ -596,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