黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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)
        {
@@ -74,6 +82,7 @@
                        SmartSound.getInstantiate().LayerList = dataInfo.ResponseData.LayerList;
                        SmartSound.getInstantiate().TokenID = mSoundInfo.Id;
                        SmartSound.getInstantiate().UserID = mSoundInfo.UserID;
                        SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID;
                    }
                }
@@ -82,6 +91,7 @@
                    if (SmartSound.getInstantiate().LayerList == null || SmartSound.getInstantiate().LayerList.Count < 1)
                    {
                        this.CloseProgressBar();
                        this.ShowNotDataImage(this.bodyFrameLayout, new string[] { "还没有控制内容哦,", "点击\"+\"添加" });
                        return;
                    }
@@ -89,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>
@@ -147,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)
                {
@@ -169,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)
@@ -222,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);
        }
@@ -233,7 +250,7 @@
            // 提交数据至服务器
            string url = "https://developer.hdlcontrol.com/zigbeespeakerservice/BatchEdit";
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(SmartSound.getInstantiate());
            string response_str = await MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8);
            string response_str = MyHttpWebResponse.PostWebRequest(url, json, Encoding.UTF8);
            return response_str;
        }
@@ -290,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)
@@ -320,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();
                    });
                }