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/Device/PirSensor/PirSensorTargetSelectForm.cs |  171 +++++++++++++++++++++++---------------------------------
 1 files changed, 70 insertions(+), 101 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs
index e7de8fc..ac74863 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/PirSensor/PirSensorTargetSelectForm.cs
@@ -22,7 +22,7 @@
         /// <summary>
         /// 妗屽竷鎺т欢
         /// </summary>
-        private FrameLayout frameTable = null;
+        private NormalFrameLayout frameTable = null;
         /// <summary>
         /// 鎴块棿瀵硅薄
         /// </summary>
@@ -66,23 +66,51 @@
             var frameBack = new FrameLayout();
             frameBack.Height = Application.GetRealHeight(204);
             bodyFrameLayout.AddChidren(frameBack);
-            var scrolContr = new HorizontalScrolViewLayout();
-            scrolContr.Gravity = Gravity.CenterVertical;
-            scrolContr.Height = frameBack.Height;
-            frameBack.AddChidren(scrolContr);
 
             //妗屽竷鎺т欢
-            this.frameTable = new FrameLayout();
+            this.frameTable = new NormalFrameLayout();
             frameTable.Y = frameBack.Bottom;
             frameTable.Height = bodyFrameLayout.Height - frameBack.Height;
             bodyFrameLayout.AddChidren(frameTable);
+
+            //鍏朵粬
+            var tempRoom = new Common.Room();
+            tempRoom.Name = Language.StringByID(R.MyInternationalizationString.uOther);
+            foreach (var mainKeys in this.listEsixtDevice)
+            {
+                var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys);
+                if (device == null)
+                {
+                    continue;
+                }
+                //杩欎釜鎵嬫満寮勫紕,閭d釜鎵嬫満寮勫紕鐨勬儏鍐典笅,
+                //閲囩敤鍚庡鎿嶄綔 -> 鏂板缓涓�涓复鏃舵埧闂村璞″嚭鏉�
+                if (HdlRoomLogic.Current.GetRoomByDevice(device) == null)
+                {
+                    tempRoom.ListDevice.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
+                }
+            }
 
             HdlThreadLogic.Current.RunMainInThread(() =>
             {
                 if (dicRoom.ContainsKey(nowSelectFloorId) == true && dicRoom[nowSelectFloorId].Count > 0)
                 {
                     //鍒濆鍖栨埧闂存帶浠�
-                    this.InitRoomControl(scrolContr, dicRoom[nowSelectFloorId]);
+                    var listRoom = new List<Common.Room>();
+                    listRoom.AddRange(dicRoom[nowSelectFloorId]);
+                    if (tempRoom.ListDevice.Count > 0)
+                    {
+                        //鏄剧ず鏂板缓鐨勪复鏃舵埧闂村璞�
+                        listRoom.Add(tempRoom);
+                    }
+                    var roomContr = new RoomDeviceGroupMenuControl(listRoom);
+                    frameBack.AddChidren(roomContr);
+                    roomContr.SelectRoomEvent += (myRoom) =>
+                    {
+                        //鍒濆鍖栬澶囪
+                        this.InitDeviceControl(myRoom);
+                    };
+                    roomContr.InitControl();
 
                     //纭畾鎸夐挳
                     var btnOk = new BottomClickButton();
@@ -95,6 +123,11 @@
                         //鐣岄潰鍏抽棴
                         this.CloseForm();
                     };
+                    //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                    if (Common.Config.Instance.Home.IsShowTemplate == true)
+                    {
+                        btnOk.CanClick = false;
+                    }
                 }
                 else
                 {
@@ -114,7 +147,8 @@
         private void InitTopRightMenuControl()
         {
             //鎴块棿鍒嗙粍
-            foreach (var room in Common.Room.Lists)
+            var listRoom = HdlRoomLogic.Current.GetAllListRooms();
+            foreach (var room in listRoom)
             {
                 //妫�娴嬭鎴块棿鑳藉惁鏄剧ず
                 if (this.CheckCanShowRow(room) == false)
@@ -134,11 +168,22 @@
             }
 
             //鑾峰彇妤煎眰
-            var dicFloor = Common.Room.CurrentRoom.GetFloorSortList();
+            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
             if (dicFloor.Count == 0)
             {
                 return;
             }
+            int indexTemp = 1;
+            foreach (var floorId in dicRoom.Keys)
+            {
+                if (dicFloor.ContainsKey(floorId) == false)
+                {
+                    //杩欐槸澶氬彴鎵嬫満鐬庢悶涔嬪悗鍑虹幇鐨勫悗澶囪ˉ鏁戞帾鏂�
+                    dicFloor[floorId] = Language.StringByID(R.MyInternationalizationString.uOther) + indexTemp;
+                    indexTemp++;
+                }
+            }
+
             var btnIconContr = new MostRightIconControl(69, 69);
             btnIconContr.UnSelectedImagePath = "Item/Drop_Down.png";
             topFrameLayout.AddChidren(btnIconContr);
@@ -161,7 +206,7 @@
             btnIconContr.ButtonClickEvent += (sender, e) =>
             {
                 //妤煎眰鑿滃崟
-                var contr = new TopRightMenuControl(dicFloor.Count, 449, Language.StringByID(R.MyInternationalizationString.SelectFloor));
+                var contr = new TopRightMenuControl(dicFloor.Count, 2, Language.StringByID(R.MyInternationalizationString.SelectFloor));
                 foreach (var floorId in dicFloor.Keys)
                 {
                     contr.AddRowMenu(dicFloor[floorId], "Floor/Floor.png", "Floor/FloorSelected.png", () =>
@@ -175,88 +220,6 @@
                 }
             };
         }
-        #endregion
-
-        #region 鈻� 鍒濆鍖栨埧闂存帶浠禵____________________
-
-        /// <summary>
-        /// 鍒濆鍖栨埧闂存帶浠�
-        /// </summary>
-        /// <param name="scrolContr">瀹瑰櫒</param>
-        /// <param name="listRoom">鎴块棿鍒楄〃</param>
-        private void InitRoomControl(HorizontalScrolViewLayout scrolContr, List<Common.Room> listRoom)
-        {
-            string oldRoomId = listRoom[0].Id;
-            FrameLayoutControl oldFrameBack = null;
-            NormalViewControl oldBtnText = null;
-
-            //寮勪釜绌虹殑杩涘幓鍗犱綅缃�
-            var frameTemp = new FrameLayout();
-            frameTemp.Height = scrolContr.Height;
-            frameTemp.Width = ControlCommonResourse.XXLeft / 2;
-            scrolContr.AddChidren(frameTemp);
-
-            for (int i = 0; i < listRoom.Count; i++)
-            {
-                var room = listRoom[i];
-                //甯﹀浘鐗囩殑
-                var frameBack = new FrameLayoutControl();
-                frameBack.UseClickStatu = false;
-                frameBack.Gravity = Gravity.Center;
-                frameBack.Height = Application.GetRealHeight(159);
-                frameBack.Width = Application.GetRealWidth(255);
-                if (i == 0)
-                {
-                    frameBack.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
-                    oldFrameBack = frameBack;
-                }
-                else
-                {
-                    frameBack.BackgroundImagePath = "Item/RoomIconBackground.png";
-                }
-                scrolContr.AddChidren(frameBack);
-                //鏂囧瓧
-                var btnText = new NormalViewControl(frameBack.Width - (int)(frameBack.Height * 0.47), frameBack.Height, false);
-                btnText.Gravity = Gravity.CenterHorizontal;
-                btnText.Text = room.Name;
-                btnText.TextSize = 12;
-                btnText.TextAlignment = TextAlignment.Center;
-                if (i == 0)
-                {
-                    btnText.TextColor = UserCenterColor.Current.White;
-                    oldBtnText = btnText;
-                }
-                else
-                {
-                    btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
-                }
-                frameBack.AddChidren(btnText, ChidrenBindMode.BindEventOnly);
-
-                frameBack.ButtonClickEvent += (sender, e) =>
-                {
-                    if (oldRoomId == room.Id)
-                    {
-                        //鍚屼竴涓笢瑗�
-                        return;
-                    }
-                    oldRoomId = room.Id;
-
-                    //鐘舵�佸彉鏇�
-                    frameBack.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
-                    btnText.TextColor = UserCenterColor.Current.White;
-
-                    oldFrameBack.BackgroundImagePath = "Item/RoomIconBackground.png";
-                    oldBtnText.TextColor = UserCenterColor.Current.TextGrayColor1;
-                    oldFrameBack = frameBack;
-                    oldBtnText = btnText;
-                    //鍒濆鍖栬澶囪
-                    this.InitDeviceControl(room);
-                };
-            }
-            //鍒濆鍖栬澶囪
-            this.InitDeviceControl(listRoom[0]);
-        }
-
         #endregion
 
         #region 鈻� 鍒濆鍖栬澶囨帶浠禵____________________
@@ -282,9 +245,9 @@
             frameTable.AddChidren(listView);
 
             var listDevice = new List<ZigBee.Device.CommonDevice>();
-            foreach (var deviceUi in room.DeviceUIList)
+            foreach (var deviceKeys in room.ListDevice)
             {
-                var device = deviceUi.CommonDevice;
+                var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKeys);
                 //妫�娴嬭澶�
                 if (this.CheckCanShowDevice(device) == true)
                 {
@@ -295,15 +258,15 @@
             for (int i = 0; i < listDevice.Count; i++)
             {
                 var device = listDevice[i];
-                string mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+                string mainKey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
 
                 var rowDevice = new FrameRowControl(listView.rowSpace / 2);
                 listView.AddChidren(rowDevice);
                 //鍥炬爣
                 var btnIcon = rowDevice.AddLeftIcon(81);
-                Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
+                HdlDeviceCommonLogic.Current.SetDeviceIconToControl(btnIcon, device);
                 //璁惧鍚嶇О
-                var btnName = rowDevice.AddLeftCaption(Common.LocalDevice.Current.GetDeviceEpointName(device), 600);
+                var btnName = rowDevice.AddLeftCaption(HdlDeviceCommonLogic.Current.GetDeviceEpointName(device), 700);
                 btnName.TextSize = 15;
                 //閫夋嫨
                 var btnSelect = rowDevice.AddMostRightEmptyIcon(58, 58);
@@ -330,6 +293,11 @@
                         listEsixtDevice.Remove(mainKey);
                     }
                 };
+                //鏌ョ湅妯℃澘鏃�,涓嶅厑璁哥紪杈�
+                if (Common.Config.Instance.Home.IsShowTemplate == true)
+                {
+                    rowDevice.CanClick = false;
+                }
             }
             listDevice = null;
             //璋冩暣鎺т欢鐪熷疄楂樺害
@@ -357,7 +325,7 @@
         /// <returns></returns>
         private bool CheckCanShowRow(Common.Room room)
         {
-            if (room.DeviceUIList.Count == 0)
+            if (room.ListDevice.Count == 0)
             {
                 return false;
             }
@@ -365,10 +333,11 @@
             {
                 return false;
             }
-            foreach (var deviceUi in room.DeviceUIList)
+            foreach (var deviceKeys in room.ListDevice)
             {
                 //妫�娴嬭璁惧鑳藉惁鏄剧ず
-                if (this.CheckCanShowDevice(deviceUi.CommonDevice) == false)
+                var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKeys);
+                if (this.CheckCanShowDevice(device) == false)
                 {
                     continue;
                 }
@@ -391,7 +360,7 @@
                 return false;
             }
             //濡傛灉鏄紶鎰熷櫒锛屾垨鑰呮槸娌℃湁寮�鍏崇皣鐨勮瘽(杩欓噷鍒ゆ柇鐨勬槸杈撳叆绨�)
-            if ((device.Type == ZigBee.Device.DeviceType.IASZone) || Common.LocalDevice.Current.InDeviceIsCanOnOff(device) == false)
+            if ((device.Type == ZigBee.Device.DeviceType.IASZone) || HdlDeviceCommonLogic.Current.InDeviceIsCanOnOff(device) == false)
             {
                 return false;
             }

--
Gitblit v1.8.0