From 23420922845c9e77019a55c3b3e3271eb1ec261e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 13 七月 2020 11:42:18 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs |  201 +++++++++-----------------------------------------
 1 files changed, 36 insertions(+), 165 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
index 9ae205e..2083145 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
@@ -129,6 +129,10 @@
         /// 聽鍒锋柊缁戝畾琛ㄩ〉闈⒙犅�
         /// </summary>
         public Action actionRefreshBindList;
+        /// <summary>
+        /// 鏄惁鑳藉埛鏂�
+        /// </summary>
+        private bool canFresh = false;
         #endregion
 
         #region UI璁捐
@@ -139,6 +143,8 @@
         {
             TitleUI();
             MidFrameLayouUI();
+            //棣栨鍒濆鍖栨暟鎹�
+            CommonPage.Loading.Start("");
             InitData();
         }
 
@@ -211,6 +217,7 @@
             midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
             {
                 midVerticalScrolViewLayout.BeginHeaderRefreshing();
+                canFresh = true;
                 InitData();
             };
 
@@ -255,169 +262,28 @@
         }
 
         /// <summary>
-        /// 妤煎眰閫夋嫨鐨勪晶杈规爮
-        /// </summary>
-        void SideslipFramelayout()
-        {
-            var dialog = new Dialog
-            {
-            };
-            dialog.Show();
-
-            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
-            dialog.AddChidren(flMain);
-            flMain.MouseUpEventHandler += (sender11, e11) =>
-            {
-                dialog.Close();
-            };
-
-            var sidelipFrameLayout = new FrameLayout()
-            {
-                Width = Application.GetMinReal(449),
-                Y = Application.GetRealHeight(161),
-                X = Application.GetRealWidth(596),
-                BackgroundImagePath = "DoorLock/SideslipPic.png",
-            };
-            flMain.AddChidren(sidelipFrameLayout);
-
-            var btnSelectFloor = new Button()
-            {
-                Width = Application.GetRealWidth(200),
-                Height = Application.GetRealHeight(58),
-                X = Application.GetRealWidth(81),
-                Y = Application.GetRealHeight(81),
-                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
-                TextSize = 14,
-                IsBold = true,
-                TextAlignment = TextAlignment.CenterLeft,
-                TextID = R.MyInternationalizationString.SelectFloor,
-            };
-            sidelipFrameLayout.AddChidren(btnSelectFloor);
-
-            var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
-            {
-                Y = btnSelectFloor.Bottom + Application.GetRealHeight(45),
-                Height = Application.GetRealHeight(600),
-            };
-            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
-
-            Button oldbutton = null;
-            Button oldbuttonText = null;
-            int count = 0;
-            foreach (var floorId in dicFloorList.Keys)
-            {
-                var rowFrameLayout = new RowLayout()
-                {
-                    Height = Application.GetRealHeight(152),
-                    LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
-                    X = Application.GetRealWidth(81),
-                };
-                sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
-
-                var btnAllMethod = new Button()
-                {
-                    Width = Application.GetMinReal(81),
-                    Height = Application.GetMinReal(81),
-                    UnSelectedImagePath = "Floor/Floor.png",
-                    SelectedImagePath = "Floor/FloorSelected.png",
-                    Gravity = Gravity.CenterVertical,
-                };
-                rowFrameLayout.AddChidren(btnAllMethod);
-
-                var btnMethodText = new Button()
-                {
-                    Width = Application.GetRealWidth(311),
-                    Height = Application.GetRealHeight(58),
-                    X = Application.GetRealWidth(92),
-                    Gravity = Gravity.CenterVertical,
-                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
-                    TextSize = 14,
-                    TextAlignment = TextAlignment.CenterLeft,
-                    Text = dicFloorList[floorId],
-                };
-                rowFrameLayout.AddChidren(btnMethodText);
-
-                if (curControlDev.currentSelectFloorId == floorId)
-                {
-                    btnAllMethod.IsSelected = true;
-                    btnAllMethod.IsBold = true;
-                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                }
-
-                string curFloorId = floorId;
-                EventHandler<MouseEventArgs> hander = (sender, e) =>
-                {
-                    if (curControlDev.currentSelectFloorId == curFloorId)
-                    {
-                        return;
-                    }
-                    curControlDev.currentSelectFloorId = curFloorId;
-
-
-
-                    if (!btnMethodText.IsSelected)
-                    {
-                        if (oldbutton != null)
-                        {
-                            oldbutton.IsSelected = false;
-                        }
-                        if (oldbuttonText != null)
-                        {
-                            oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
-                        }
-                        oldbutton = btnMethodText;
-                        oldbuttonText = btnMethodText;
-                        btnMethodText.IsSelected = true;
-                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
-                        oldbuttonText.IsBold = true;
-                    }
-
-                    int index = 0;
-                    RefreshRoomList();
-                    dialog.Close();
-                };
-                btnAllMethod.MouseUpEventHandler += hander;
-                rowFrameLayout.MouseUpEventHandler += hander;
-                btnMethodText.MouseUpEventHandler += hander;
-                count++;
-            }
-
-            if (count == 0)
-            {
-                sidelipFrameLayout.Height = 0;
-            }
-            else if (count <= 4 && count > 0)
-            {
-                sidelipFrameLayout.Height = Application.GetRealHeight(180) + count * Application.GetRealHeight(150);
-            }
-            else
-            {
-                sidelipFrameLayout.Height = Application.GetMinReal(780);
-            }
-        }
-
-        /// <summary>
         /// 闈㈡澘缁戝畾鐩爣琛ㄦ樉绀�
         /// </summary>
         /// <param name="gateway">Gateway.</param>
         /// <param name="key">Key.</param>
         void RefreshRoomList()
         {
-            Room curRoom = null;
-            if (supportRoomList.Count == 0)
-            {
-                return;
-            }
             btnHorizontalScrolViewLayout.RemoveAll();
+            Room curRoom = null;
             Button curentOldRoom = null;
             FrameLayout curentOldRoomFrameLayout = null;
             int index = 0;
-            curBindTypeList = MutilfunctionPanelMethod.GetMatchBindList(curBindType);
-            var roomTempList = MutilfunctionPanelMethod.GetSupportRoomList(curControlDev, supportRoomList, curBindTypeList, curBindType);
+            List<Room> roomTempList = new List<Room> { };
             Room slectedRoom = null;
             var roomUn = new Room();
             roomUn.Name = Language.StringByID(R.MyInternationalizationString.Undistributed);
             roomUn.Id = "UndistributedId";
+
+            if (supportRoomList.Count != 0)
+            {
+                roomTempList = MutilfunctionPanelMethod.GetSupportRoomList(curControlDev, supportRoomList, curBindTypeList, curBindType);
+            }
+
             if (curBindType == 0)
             {
                 if (undistributeScList != null && undistributeScList.Count != 0)
@@ -560,6 +426,8 @@
                     var btn = (Button)frame.GetChildren(0);
                     frame.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
                     btn.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+                    curentOldRoom = btn;
+                    curentOldRoomFrameLayout = frame;
                 }
                 else
                 {
@@ -1027,17 +895,14 @@
             {
                 try
                 {
-                    Application.RunOnMainThread(() =>
-                    {
-                        CommonPage.Loading.Start("");
-                    });
-
                     //鑾峰彇妤煎眰
                     dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
                     curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
 
-                    //鑾峰彇妤煎眰涓埧闂村垪琛�
-                    supportRoomList = BindInfo.GetFloorRoomList();
+                    //鑾峰彇鎴块棿鍒楄〃
+                    supportRoomList = BindInfo.GetSupportRoomList();
+                    //鑾峰彇闈㈡澘宸茬粡缁戝畾鐨勫尮閰嶇被鍨嬬殑鍒楄〃
+                    curBindTypeList = MutilfunctionPanelMethod.GetMatchBindList(curBindType);
 
                     if (curBindType == 0)
                     {
@@ -1077,14 +942,17 @@
                 {
                     Application.RunOnMainThread(() =>
                     {
-                        BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
+                        if (!canFresh)
+                        {
+                            BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
+                        }
                         ChooseFloorAction += (floorId, btnMethodText) =>
                         {
                             btnFloorText.Text = dicFloorList[floorId];
 
-                            //鑾峰彇妤煎眰涓埧闂村垪琛�
+                            //鑾峰彇鎴块棿鍒楄〃
                             supportRoomList.Clear();
-                            supportRoomList = BindInfo.GetFloorRoomList();
+                            supportRoomList = BindInfo.GetSupportRoomList();
                             if (curBindType == 0)
                             {
                                 // 鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氬満鏅垪琛�
@@ -1097,15 +965,18 @@
                             }
                             RefreshRoomList();
                         };
-
-                        btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
-                        //鑾峰彇妤煎眰涓埧闂村垪琛�
-                        if (supportRoomList.Count != 0)
+                        //榛樿妤煎眰鏄剧ず
+                        if (BindInfo.GetCurrentSelectFloorIdName() != null)
                         {
-                            RefreshRoomList();
+                            Application.RunOnMainThread(() =>
+                            {
+                                btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
+                            });
                         }
-
+                        //鑾峰彇妤煎眰涓埧闂村垪琛�
+                        RefreshRoomList();
                         CommonPage.Loading.Hide();
+                        canFresh = false;
                         midVerticalScrolViewLayout.EndHeaderRefreshing();
                     });
                 }

--
Gitblit v1.8.0