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/SmartSound/Forms/SmartSoundControlForm.cs |   89 ++++++++++++++++++++++++++------------------
 1 files changed, 53 insertions(+), 36 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs
index f85422e..f156c91 100755
--- a/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs
+++ b/ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlForm.cs
@@ -22,9 +22,17 @@
         public int CurrentIndex = 0;
         private MostRightIconControl btnAddDeviceIcon = null;
         /// <summary>
+        /// 褰撳墠妤煎眰鐨勫悕绉�
+        /// </summary>
+        private static NormalViewControl pullLayoutText = null;
+        /// <summary>
         ///  鏅鸿兘闊崇鏁版嵁
         /// </summary>
         private static SmartSoundInfo.SoundInfo mSoundInfo = null;
+        /// <summary>
+        /// 妤煎眰鎺т欢
+        /// </summary>
+        private MyPullControl myPullControl;
 
         public SmartSoundControlForm(SmartSoundInfo.SoundInfo soundInfo)
         {
@@ -83,6 +91,7 @@
                     if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.Count < 1)
                     {
                         this.CloseProgressBar();
+                        this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "杩樻病鏈夋帶鍒跺唴瀹瑰摝锛�", "鐐瑰嚮\"+\"娣诲姞" });
                         return;
                     }
 
@@ -90,35 +99,35 @@
                     this.bodyFrameLayout.AddChidren(contentLayout);
                     contentLayout.RemoveAll();
 
-                    var pullLayout = new MyPullControl(this, SmartSound.getInstantiate().LayerList);
-                    contentLayout.AddChidren(pullLayout);
-                    pullLayout.InitControl();
+                    myPullControl = new MyPullControl(this, SmartSound.getInstantiate().LayerList);
+                    contentLayout.AddChidren(myPullControl);
+                    myPullControl.InitControl();
 
                     LoadAllRoomListView();
-
-                    //鏃犳暟鎹殑鏃跺�欒鍋氫竴涓彁绀�
-                    {
-                        bool bol = false;
-                        for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++)
-                        {
-                            if (SmartSound.getInstantiate().LayerList[i].RoomList.Count > 0)
-                            {
-                                bol = true;
-                                break;
-                            }
-                        }
-
-                        if (!bol)
-                        {
-                            pullLayout.Visible = false;
-                            this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "杩樻病鏈夋帶鍒跺唴瀹瑰摝锛�", "鐐瑰嚮\"+\"娣诲姞" });
-                        }
-                    }
-
+                    
                     this.CloseProgressBar();
 
                 });
             });
+        }
+
+
+        /// <summary>
+        /// 鍒ゆ柇鏄惁鏈夋暟鎹�
+        /// </summary>
+        /// <returns></returns>
+        private bool HaveData()
+        {
+            bool bol = false;
+            for (int i = 0; i < SmartSound.getInstantiate().LayerList.Count; i++)
+            {
+                if (SmartSound.getInstantiate().LayerList[i].RoomList.Count > 0)
+                {
+                    bol = true;
+                    break;
+                }
+            }
+            return bol;
         }
 
         /// <summary>
@@ -148,9 +157,9 @@
                     listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(173);
                 }
 
-                listView.RemoveAll();
-
                 SmartSound.Layer layer = SmartSound.getInstantiate().LayerList[CurrentIndex];
+                pullLayoutText.Text = layer.LayerName;
+                listView.RemoveAll();                               
 
                 foreach (SmartSound.Room room in layer.RoomList)
                 {
@@ -170,6 +179,13 @@
                         var delBtn = sender as NormalViewControl;
                         DelectRoom(delBtn);
                     };
+                }
+
+                if (!HaveData())
+                {
+                    SmartSound.getInstantiate().LayerList.Clear();
+                    myPullControl.Visible = false;
+                    this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "杩樻病鏈夋帶鍒跺唴瀹瑰摝锛�", "鐐瑰嚮\"+\"娣诲姞" });
                 }
             }
             catch (Exception e)
@@ -223,9 +239,9 @@
         }
 
         private async Task<string> GetData()
-        {
-            // 浠庢湇鍔″櫒鑾峰彇鏁版嵁
-            string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit?Platform&UserID={0}&TokenID={1}", mSoundInfo.UserID, mSoundInfo.Id);
+        {
+            // 浠庢湇鍔″櫒鑾峰彇鏁版嵁
+            string url = string.Format("https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit?Platform&UserID={0}&TokenID={1}&HomeID={2}", mSoundInfo.UserID, mSoundInfo.Id,mSoundInfo.HomeID);
             return await MyHttpWebResponse.GetWebRequest(url);
         }
 
@@ -291,19 +307,19 @@
                     right_icon.ButtonClickEvent += (sender, e) =>
                     {
                         ShowPullList();
-                    };
-                   
-                    var layout = this.AddMostRightView(Layers[smartSoundControlData.CurrentIndex].LayerName, 300, false);
-                    layout.Name = "pullLayout";
-                    layout.ButtonClickEvent += (sender, e) =>
+                    };
+
+                    pullLayoutText = this.AddMostRightView(Layers[smartSoundControlData.CurrentIndex].LayerName, 300, false);
+                    pullLayoutText.Name = "pullLayout";
+                    pullLayoutText.ButtonClickEvent += (sender, e) =>
                     {
                         ShowPullList();
                     };
-
+                    pullLayoutText.Text = Layers[smartSoundControlData.CurrentIndex].LayerName;
                     if (SmartSound.getInstantiate().LayerList.Count < 2)
                     {
                         right_icon.Visible = false;
-                        layout.Visible = false;
+                        pullLayoutText.Visible = false;
                     }
                 }
                 catch(Exception e)
@@ -321,10 +337,11 @@
 
                 for (int i = 0; i < Layers.Count; i++)
                 {
+                    int index = i;
                     //鍒涘缓妤煎眰
                     pull_frame.AddRowMenu(Layers[i].LayerName, "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () =>
                     {
-                        smartSoundControlData.CurrentIndex = i;
+                        smartSoundControlData.CurrentIndex = index;
                         smartSoundControlData.LoadAllRoomListView();
                     });
                 }

--
Gitblit v1.8.0