黄学彪
2020-07-21 a41a96b555f3aabf243741352bded5f28cd0ced5
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();
                    });
                }
@@ -1394,7 +1265,7 @@
                        new Tip()
                        {
                            MaxWidth = 150,
                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5001_1" + ")",
                            Direction = AMPopTipDirection.Up,
                            CloseTime = 1
                        }.Show(btnFinifh);
@@ -1411,7 +1282,7 @@
                        new Tip()
                        {
                            MaxWidth = 150,
                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5001_2" + ")",
                            Direction = AMPopTipDirection.Up,
                            CloseTime = 1
                        }.Show(btnFinifh);