黄学彪
2020-07-01 304dca51c28183a9dfc192c6b93ea1c00bdd5d97
ZigbeeApp/Shared/Phone/SmartSound/Forms/SmartSoundControlContentForm.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Shared.Common;
using Shared.Phone.UserCenter.SmartSound.Util;
using Shared.Phone.UserCenter.SmartSound.Widget;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.SmartSound.Forms
@@ -22,8 +23,15 @@
        private VerticalListControl listView = null;
        
        private FrameLayout contentLayout = null;
        public int CurrentIndex = 0;
        /// <summary>
        /// 当前楼层的索引
        /// </summary>
        public int CurrentIndex = 0;
        private BottomClickButton bottomClickButton = null;
        /// <summary>
        /// 当前楼层的名称
        /// </summary>
        private static NormalViewControl pullLayoutText = null;
        public SmartSoundControlContentForm(SmartSoundInfo.SoundInfo soundInfo)            
        {
@@ -64,31 +72,57 @@
            bottomClickButton.Text = "确认";
            bottomClickButton.ButtonClickEvent += (sender, e) =>
            {
                HdlThreadLogic.Current.RunThread(async () =>
                if (SmartSound.getInstantiate().LayerList != null && SmartSound.getInstantiate().LayerList.Count > 0)
                {
                    this.ShowProgressBar();
                    //保存数据
                    if (SmartSound.getInstantiate().LayerList == null)
                        SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>();
                    //生成一个弹窗画面
                    var dialogForm = new TextDialog("确认删除现有房间列表的所有控制内容,添加全新的场景和功能?", "确认");
                    dialogForm.SetTitleText("提示");
                    SmartSound.getInstantiate().LayerList.Clear();
                    SmartSound.getInstantiate().LayerList = CollateData();
                    SmartSound.getInstantiate().TokenID = mSoundInfo.Id;
                    SmartSound.getInstantiate().UserID = mSoundInfo.UserID;
                    SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID;
                    //上传数据到服务器
                    string str = await postBatchEdit();
                    CloseProgressBar();
                    HdlThreadLogic.Current.RunMainInThread(() =>
                    //按下确认按钮
                    dialogForm.ComfirmClickEvent += () =>
                    {
                        CloseForm();
                    });
                });
                        //画面关闭
                        dialogForm.CloseDialog();
                        uploadData();
                    };
                }
                else
                {
                    uploadData();
                }
            };
            bottomClickButton.Visible = false;
        }
        /// <summary>
        /// 提交数据到服务器
        /// </summary>
        private void uploadData()
        {
            HdlThreadLogic.Current.RunThread(async () =>
            {
                this.ShowProgressBar();
                //保存数据
                if (SmartSound.getInstantiate().LayerList == null)
                    SmartSound.getInstantiate().LayerList = new List<SmartSound.Layer>();
                SmartSound.getInstantiate().LayerList.Clear();
                SmartSound.getInstantiate().LayerList = CollateData();
                SmartSound.getInstantiate().TokenID = mSoundInfo.Id;
                SmartSound.getInstantiate().UserID = mSoundInfo.UserID;
                SmartSound.getInstantiate().HomeID = mSoundInfo.HomeID;
                //上传数据到服务器
                string str = await postBatchEdit();
                CloseProgressBar();
                HdlThreadLogic.Current.RunMainInThread(() =>
                {
                    CloseForm();
                });
            });
        }
        private void LoadAllRoomListView()
@@ -109,6 +143,7 @@
                    listView.Height = bodyFrameLayout.Height- Application.GetRealHeight(173);                    
                }
                pullLayoutText.Text = layer.LayerName;
                listView.RemoveAll();
                foreach(SmartSound.Room room in layer.RoomList)
@@ -332,7 +367,6 @@
            if (tempLayer == null) return;
          
            #region 添加楼层
            bool floor_exists = false;
@@ -536,21 +570,21 @@
                right_icon.ButtonClickEvent += (sender, e) =>
                {
                    ShowPullList();
                };
                var layout = this.AddMostRightView(Layers[smartSoundDataAdd.CurrentIndex].LayerName, 300, false);
                layout.Name = "pullLayout";
                layout.ButtonClickEvent += (sender, e) =>
                };
                pullLayoutText = this.AddMostRightView(Layers[smartSoundDataAdd.CurrentIndex].LayerName, 300, false);
                pullLayoutText.Name = "pullLayout";
                pullLayoutText.ButtonClickEvent += (sender, e) =>
                {
                    ShowPullList();
                };
                pullLayoutText.Text = Layers[smartSoundDataAdd.CurrentIndex].LayerName;
                if (Layers.Count == 1)
                {
                    right_icon.Visible = false;
                    layout.Visible = false;
                }
                    pullLayoutText.Visible = false;
                }
            }
            private void ShowPullList()
@@ -558,14 +592,16 @@
                //房间列表行{房间列表 textView,楼层下拉窗}
                //显示房间{带选择框的;当选中了房间后需要在底部弹出确认按钮,点击确认跳转到新的界面}
                var pull_frame = new TopRightMenuControl(Layers.Count, 2);
                pull_frame.Y = this.Height;
                for (int i = 0; i < Layers.Count; i++)
                {
                    int index = i;
                    //创建楼层
                    pull_frame.AddRowMenu(Layers[i].LayerName, "Item/CreatFloor.png", "Item/CreatFloorSelected.png", () =>
                    {
                        smartSoundDataAdd.CurrentIndex = i;
                        smartSoundDataAdd.CurrentIndex = index;
                        smartSoundDataAdd.LoadAllRoomListView();
                    });
                }