黄学彪
2020-02-21 bd46c57c77c276014db3192a4e2cc96e23c93202
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddDevicePage.cs
@@ -30,27 +30,68 @@
            this.curDeviceBindType = deviceBindType;
        }
        #region ◆ 变量申明__________________________
        #region 变量申明
        /// <summary>
        /// 当前按键
        /// </summary>
        ZigBee.Device.Panel currentKey;
        //显示被绑定设备或场景的view
        /// <summary>
        /// 显示被绑定设备或场景的view
        /// </summary>
        VerticalScrolViewLayout midVerticalScrolViewLayout;
        /// <summary>
        /// 显示房间的view
        /// </summary>
        HorizontalScrolViewLayout btnHorizontalScrolViewLayout;
        /// <summary>
        /// 按键配置的目标列表
        /// </summary>
        List<CommonDevice> targetList = new List<CommonDevice>();
        /// <summary>
        /// 房间列表
        /// </summary>
        List<Room> roomList = new List<Room>();
        /// <summary>
        /// 添加设备后的回调
        /// </summary>
        public Action<List<BindListResponseObj>> actionAddDevicePage;
        /// <summary>
        /// 当前设备类型列表
        /// </summary>
        List<DeviceUI> curTypeDeviceList = new List<DeviceUI> { };
        /// <summary>
        /// 当前设备绑定类型
        /// </summary>
        string curDeviceBindType = "";
        /// <summary>
        /// 楼层文本
        /// </summary>
        Button btnFloorText;
        /// <summary>
        /// 楼层表
        /// </summary>
        Dictionary<string, string> dicFloor;
        /// <summary>
        /// 当前选择的按键模式
        /// </summary>
        Button btnChooseKeyMode;
        bool IsInitEntry = false;//是否首次进入该页
        /// <summary>
        /// 是否首次进入该页
        /// </summary>
        bool IsInitEntry = false;
        /// <summary>
        /// 当前按键的所有房间设备列表
        /// </summary>
        List<DeviceUI> currentKeyAllRoomDeviceList = new List<DeviceUI>();
        /// <summary>
        /// 临时存储的目标列表
        /// </summary>
        Dictionary<string, CommonDevice> oldTargetList = new Dictionary<string, CommonDevice> { };
        #endregion
        /// <summary>
        /// 添加设备显示
        /// </summary>
        public void Show()
        {
            targetList.Clear();
@@ -81,7 +122,6 @@
            var btnAddFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(830),
                Width = Application.GetRealWidth(200),
            };
            this.titleFrameLayout.AddChidren(btnAddFrameLayout);
@@ -91,7 +131,8 @@
                X = Application.GetRealWidth(15),
                Text = Language.StringByID(R.MyInternationalizationString.FirstFloor),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 15,
                TextSize = 14,
                IsBold = true,
                TextAlignment = TextAlignment.CenterRight,
            };
            btnAddFrameLayout.AddChidren(btnFloorText);
@@ -115,9 +156,20 @@
            {
                SideslipFramelayout();
            };
            if (Common.Config.Instance.Home.FloorDics.Count == 0)
            {
                btnAddFrameLayout.Width = 0;
            }
            else
            {
                btnAddFrameLayout.Width = Application.GetRealWidth(200);
            }
            MidFrameLayoutContent(btnFloorText);
        }
        /// <summary>
        /// 中部布局
        /// </summary>
        async void MidFrameLayoutContent(Button btnFloorText)
        {
            #region UI
@@ -162,6 +214,7 @@
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                TextSize = 16,
                IsBold = true,
            };
            bottomFrameLayout.AddChidren(btnChooseKeyMode);
            #endregion
@@ -396,7 +449,10 @@
            RefreshDeviceList(curRoom);
        }
        //当前按键所有显示房间的所有设备处理
        /// <summary>
        /// 当前按键所有显示房间的所有设备处理
        /// </summary>
        /// <returns></returns>
        List<DeviceUI> GetALlDispalyRoomDeviceList()
        {
            currentKeyAllRoomDeviceList.Clear();
@@ -532,6 +588,7 @@
            int curIndex = 0;
            foreach (var device in curTypeDeviceList)
            {
                curIndex++;
                if (device.CommonDevice != null && device.CommonDevice.IsOnline == 0)
                {
                    continue;
@@ -558,11 +615,12 @@
                var btnBindName = new Button()
                {
                    Width = Application.GetRealWidth(500 - 120),
                    Width = Application.GetRealWidth(790),
                    X = devicePic.Right + Application.GetRealWidth(20),
                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
                    TextAlignment = TextAlignment.CenterLeft,
                    Tag = device.CommonDevice?.DeviceEpointName,
                    TextSize = 15,
                };
                rowLayout.AddChidren(btnBindName);
@@ -589,7 +647,7 @@
                };
                rowLayout.AddChidren(line2);
                if (curIndex == curRoom.DeviceUIList.Count - 1)
                if (curIndex == curTypeDeviceList.Count)
                {
                    line2.Visible = false;
                }
@@ -634,7 +692,7 @@
                btnBindName.MouseUpEventHandler += hander;
                btnChoose.MouseUpEventHandler += hander;
                if (device.CommonDevice?.DeviceEpointName == "")
                if (string.IsNullOrEmpty(device.CommonDevice?.DeviceEpointName))
                {
                    btnBindName.Text = device.CommonDevice?.DeviceAddr + "_" + device.CommonDevice?.DeviceEpoint;
                }
@@ -651,8 +709,6 @@
                        btnChoose.Visible = true;
                    }
                }
                curIndex++;
            }
            if (targetList.Count == 0)
            {
@@ -666,7 +722,9 @@
            }
        }
        // 侧边导航栏
        /// <summary>
        /// 选择楼层的侧边栏
        /// </summary>
        void SideslipFramelayout()
        {
            var dialog = new Dialog
@@ -697,10 +755,11 @@
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(81),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = R.MyInternationalizationString.SelectFloor,
                IsBold = true,
            };
            sidelipFrameLayout.AddChidren(btnSelectFloor);
@@ -749,6 +808,7 @@
                if (currentKey.currentSelectFloorId == floorId)
                {
                    btnAllMethod.IsSelected = true;
                    btnAllMethod.IsBold = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                }
@@ -777,6 +837,7 @@
                        oldbuttonText = btnMethodText;
                        btnMethodText.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                    }
                    //获取楼层对应的房间