gxc
2020-01-10 b9cb076fe6127160c96c35bf9c8cebcffe1d5ccd
ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs
old mode 100755 new mode 100644
@@ -8,22 +8,35 @@
    {
        public Action<string> FloorAction;
        /// <summary>
        /// 是否切换为当前楼层
        /// </summary>
        public bool changeFloor = true;
        /// <summary>
        /// 当前传过来的floorid
        /// </summary>
        public string CurFloorId = string.Empty;
        Dialog dialogBackground;
        /// <summary>
      /// Init
      /// </summary>
      public void Init(int x,int y,CommonForm.Direction direction=CommonForm.Direction.Left)
        {
            var dialog = new FrameLayout()
            dialogBackground = new Dialog
            {
                BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
            };
            AddChidren(dialog);
            dialogBackground.Show();
            var dialog = new FrameLayout()
            {
            };
            dialogBackground.AddChidren(dialog);
            dialog.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
                RemoveView();
            };
            var bg = new Button
@@ -35,9 +48,9 @@
                UnSelectedImagePath="Item/SelectFloor_Left.png"
            };
            dialog.AddChidren(bg);
            if(direction==CommonForm.Direction.Right)
            if (direction == CommonForm.Direction.Right)
            {
                bg.UnSelectedImagePath = "";
                bg.UnSelectedImagePath = "Item/SelectFloor_Right.png";
            }
            var backgroundFL = new FrameLayout
@@ -57,13 +70,11 @@
                Height = Application.GetRealHeight(150),
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = R.MyInternationalizationString.SelectFloor
                TextID = R.MyInternationalizationString.SelectFloor,
                TextSize=16,
                IsBold=true
            };
            backgroundFL.AddChidren(tip);
            tip.MouseUpEventHandler += (sender, e) =>
            {
                BackgroundColor = ZigbeeColor.Current.GXCRedColor;
            };
            var floorLayout = new VerticalScrolViewLayout
            {
@@ -92,20 +103,50 @@
            frow.Tag = floor.Key;
            frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floor.Value);
            verticalScrolView.AddChidren(frow);
            if (Config.Instance.Home.CurrentFloorId == floor.Key)
            if(string.IsNullOrEmpty(CurFloorId))
            {
                frow.IsSelected = true;
                if (Config.Instance.Home.CurrentFloorId == floor.Key)
                {
                    frow.IsSelected = true;
                }
            }
            else
            {
                if (CurFloorId == floor.Key)
                {
                    frow.IsSelected = true;
                }
            }
            frow.IconButton.MouseUpEventHandler += SelectFloor_MouseUpEvent;
            frow.TitleButton.MouseUpEventHandler += SelectFloor_MouseUpEvent;
            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 Button).Parent as CommonForm.LeftIconButtonRow).IsSelected = true;
            Config.Instance.Home.CurrentFloorId = (sender as Button).Tag.ToString();
            FloorAction?.Invoke(Config.Instance.Home.GetCurrentFloorName);
            (sender as CommonForm.LeftIconButtonRow).IsSelected = true;
            if(changeFloor)
            {
                Config.Instance.Home.CurrentFloorId = (sender as CommonForm.LeftIconButtonRow).Tag.ToString();
                Config.Instance.Home.Save(false);
                Common.Room.CurrentRoom.RefreshRoomListView();
            }
            RemoveView();
            FloorAction?.Invoke((sender as CommonForm.LeftIconButtonRow).Tag.ToString());
        }
        /// <summary>
        /// RemoveView
        /// </summary>
        private void RemoveView()
        {
            dialogBackground.Close();
            RemoveFromParent();
        }
    }