陈嘉乐
2020-09-02 652243206427f35a256400a149a1734085824cb9
ZigbeeApp/Shared/Phone/Category/SelectFloorForm.cs
@@ -9,10 +9,6 @@
        public Action<string> FloorAction;
        /// <summary>
        /// 是否切换为当前楼层
        /// </summary>
        public bool changeFloor = true;
        /// <summary>
        /// 当前传过来的floorid
        /// </summary>
        public string CurFloorId = string.Empty;
@@ -80,7 +76,8 @@
            };
            backgroundFL.AddChidren(floorLayout);
            var floorCount = Config.Instance.Home.FloorDics.Count;
            var dicFloor = UserCenter.HdlRoomLogic.Current.GetFloorSortList();
            int floorCount = dicFloor.Count;
            if (floorCount > 0)
            {
@@ -109,9 +106,9 @@
                    floorLayout.Height = this.GetPictrueRealSize(150 * floorCount);
                }
                foreach (var floor in Config.Instance.Home.FloorDics)
                foreach (var floor in dicFloor.Keys)
                {
                    AddFloor(floorLayout, floor);
                    AddFloor(floorLayout, floor, dicFloor[floor]);
                }
            }
        }
@@ -120,50 +117,20 @@
        /// AddFloor
        /// </summary>
        /// <param name="verticalScrolView"></param>
        private void AddFloor(VerticalScrolViewLayout verticalScrolView, KeyValuePair<string, string> floor,bool isLast=false)
        private void AddFloor(VerticalScrolViewLayout verticalScrolView, string floorId, string floorName)
        {
            var frow = new Device.CommonForm.LeftIconButtonRow(449, 150);
            frow.Width = this.GetPictrueRealSize(449);
            frow.Height = this.GetPictrueRealSize(150);
            frow.Tag = floor.Key;
            frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floor.Value);
            verticalScrolView.AddChidren(frow);
            frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floorName);
            verticalScrolView.AddChidren(frow);
            frow.IsSelected = floorId == this.CurFloorId;
            if (string.IsNullOrEmpty(CurFloorId))
            frow.ButtonClickEvent += (sender, e) =>
            {
                if (Config.Instance.Home.CurrentFloorId == floor.Key)
                {
                    frow.IsSelected = true;
                }
            }
            else
            {
                if (CurFloorId == floor.Key)
                {
                    frow.IsSelected = true;
                }
            }
            frow.ButtonClickEvent += SelectFloor_MouseUpEvent;
        }
        /// <summary>
        /// SelectFloor_MouseUpEvent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void SelectFloor_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
        {
            (sender as Device.CommonForm.LeftIconButtonRow).IsSelected = true;
            if (changeFloor)
            {
                Config.Instance.Home.CurrentFloorId = (sender as Device.CommonForm.LeftIconButtonRow).Tag.ToString();
                Config.Instance.Home.Save(false);
                UserCenter.HdlRoomLogic.Current.RefreshRoomListView();
            }
            RemoveView();
            FloorAction?.Invoke((sender as Device.CommonForm.LeftIconButtonRow).Tag.ToString());
                RemoveView();
                FloorAction?.Invoke(floorId);
            };
        }
        /// <summary>