From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs | 1428 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,428 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
new file mode 100755
index 0000000..9e85870
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleMutilfunctionAddTargetsForm.cs
@@ -0,0 +1,1428 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared.Common;
+using Shared.Phone.UserCenter.Device.Bind;
+using ZigBee.Device;
+using static ZigBee.Device.BindObj;
+namespace Shared.Phone.UserCenter.DeviceBind
+{
+    public class PanelSimpleMutilfunctionAddTargetsForm : BindCommonLayout
+    {
+        #region  鏋勯�犲嚱鏁�
+        /// <summary>
+        /// 鏋勯�犲嚱鏁�
+        /// </summary>
+        /// <param name="device"></param>
+        /// <param name="deviceBindType">0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        public PanelSimpleMutilfunctionAddTargetsForm(Panel controlDev, int deviceBindType)
+        {
+            this.curControlDev = controlDev;
+            this.curBindType = deviceBindType;
+        }
+        #endregion
+
+        #region  鍙橀噺鐢虫槑 
+        /// <summary>
+        /// 鎺у埗璁惧
+        /// </summary>
+        Panel curControlDev;
+        /// <summary>
+        /// 褰撳墠琚粦璁惧
+        /// </summary>
+        CommonDevice curBindDevice;
+        /// <summary>
+        /// 鏄剧ず琚粦瀹氳澶囨垨鍦烘櫙鐨剉iew
+        /// </summary>
+        VerticalFrameRefreshControl midVerticalScrolViewLayout;
+        /// <summary>
+        /// 鏄剧ず鎴块棿鐨剉iew
+        /// </summary>
+        HorizontalScrolViewLayout btnHorizontalScrolViewLayout;
+        /// <summary>
+        /// 褰撳墠璁惧缁戝畾绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴
+        /// </summary>
+        int curBindType = 0;
+        /// <summary>
+        /// 鏈湴鎴块棿鍒楄〃
+        /// </summary>
+        List<Room> supportRoomList = new List<Room>();
+        /// <summary>
+        /// 淇濆瓨瀹屾垚鎸夐挳
+        /// </summary>
+        Button btnFinifh;
+        /// <summary>
+        /// 缁戝畾绫诲瀷鎻愮ず鏂囨湰
+        /// </summary>
+        Button btnTipText;
+        /// <summary>
+        /// 妤煎眰鏂囨湰
+        /// </summary>
+        Button btnFloorText;
+        /// <summary>
+        /// 妤煎眰鍒楄〃
+        /// </summary>
+        Dictionary<string, string> dicFloorList = new Dictionary<string, string>();
+        /// <summary>
+        /// 鎸夐敭閰嶇疆鐨勭洰鏍囧垪琛�
+        /// </summary>
+        List<CommonDevice> targetList = new List<CommonDevice>();
+        /// <summary>
+        /// 鎸夐敭閰嶇疆鐨勭洰鏍囧垪琛�
+        /// </summary>
+        List<SceneUI> targetScList = new List<SceneUI>();
+        /// <summary>
+        /// 鎵�鏈夋埧闂翠腑鏀寔琚粦瀹氱殑璁惧鍒楄〃
+        /// </summary>
+        List<CommonDevice> currentPanelSupportBindDeviceList = new List<CommonDevice>();
+        /// <summary>
+        /// 鎵�鏈夋埧闂翠腑鏀寔琚粦瀹氱殑鍦烘櫙鍒楄〃
+        /// </summary>
+        List<SceneUI> currentPanelSupportBindSceneList = new List<SceneUI>();
+        /// <summary>
+        /// 褰撳墠绫诲瀷鐨勭粦瀹氳〃
+        /// </summary>
+        List<BindListAllInfo> curBindTypeList = new List<BindListAllInfo>();
+        /// <summary>
+        /// 鏈垎閰嶇殑璁惧鍒楄〃
+        /// </summary>
+        List<CommonDevice> undistributeDevList = new List<CommonDevice>();
+        /// <summary>
+        /// 鏈垎閰嶇殑璁惧鍒楄〃
+        /// </summary>
+        List<SceneUI> undistributeScList = new List<SceneUI>();
+        /// <summary>
+        /// 褰撳墠鎴块棿涓敮鎸佽缁戝畾鐨勮澶囧垪琛�
+        /// </summary>
+        List<CommonDevice> currentRoomSupportBindDeviceList = new List<CommonDevice>();
+        /// <summary>
+        /// 褰撳墠鎴块棿涓敮鎸佽缁戝畾鐨勮澶囧垪琛�
+        /// </summary>
+        List<SceneUI> currentRoomSupportBindSceneList = new List<SceneUI>();
+        /// <summary>
+        /// 褰撳墠鏀寔鐨勭鐐圭粦瀹氳〃
+        /// </summary>
+        List<int> curSupportBindEpointList = new List<int>();
+        /// <summary>
+        /// 褰撳墠琚�夋嫨鐩爣鍗冲皢缁戝畾鐨勭鐐�
+        /// </summary>
+        List<int> curSendEpointList = new List<int>();
+        /// <summary>
+        /// 褰撳墠鏀寔鐨勮皟鍏変釜鏁癧瀛樿皟鍏夌伅鍏夌殑璁惧]
+        /// </summary>
+        List<int> curSupportDimmerEpointList = new List<int>();
+        /// <summary>
+        /// 褰撳墠鏀寔鐨勮皟鍏夊紑鍏充釜鏁癧瀛樼户鐢靛櫒鐨勫姛鑳界被鍨嬫槸鐏厜鐨勮澶嘳
+        /// </summary>
+        List<int> curSupportLightEpointList = new List<int>();
+        /// <summary>
+        /// 闈㈡澘涓瓨鍦ㄧ殑閿��
+        /// </summary>
+        List<String> panelBindListKey = null;
+        /// <summary>
+        /// 聽鍒锋柊缁戝畾琛ㄩ〉闈⒙犅�
+        /// </summary>
+        public Action actionRefreshBindList;
+        /// <summary>
+        /// 鏄惁鑳藉埛鏂�
+        /// </summary>
+        private bool canFresh = false;
+        #endregion
+
+        #region UI璁捐
+        /// <summary>
+        /// 鐩爣椤垫樉绀�
+        /// </summary>
+        public void Show()
+        {
+            TitleUI();
+            MidFrameLayouUI();
+            //棣栨鍒濆鍖栨暟鎹�
+            CommonPage.Loading.Start("");
+            InitData();
+
+            //澶囨敞寮圭獥鎻愮ず
+            string msg = Language.StringByID(R.MyInternationalizationString.BindRemarkTip1).Replace("{0}", "\r\n");
+            var alert = new Shared.Phone.UserCenter.ShowMsgControl(ShowMsgType.Confirm, msg, Language.StringByID(R.MyInternationalizationString.Iknown));
+            alert.Show();
+        }
+
+        /// <summary>
+        /// 鏍囬鏍�
+        /// </summary>
+        void TitleUI()
+        {
+            string titleText = Language.StringByID(R.MyInternationalizationString.Bind);
+            switch (curBindType)
+            {
+                case 0:
+                    titleText += Language.StringByID(R.MyInternationalizationString.scene);
+                    break;
+                case 1:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId13);
+                    break;
+                case 2:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId14);
+                    break;
+                case 3:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId15);
+                    break;
+                case 4:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId200);
+                    break;
+                case 5:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId3600);
+                    break;
+                case 6:
+                    titleText += Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2310);
+                    break;
+            }
+            this.TopFrameLayout(this, titleText);
+            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
+            {
+                RemoveFromParent();
+            };
+            this.btnTitle.Width = Application.GetRealWidth(1080 - 161 - 300);
+            this.btnBack.MouseUpEventHandler += eHandlerBack;
+            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
+            this.MidFrameLayout(this);
+        }
+
+        /// <summary>
+        /// 涓儴UI銆愭爣棰樻爮涓嬬殑UI銆�
+        /// </summary>
+        void MidFrameLayouUI()
+        {
+            var btnMidTopLayout = new FrameLayout
+            {
+                Height = Application.GetRealHeight(389 - 184),
+            };
+            this.midFrameLayout.AddChidren(btnMidTopLayout);
+
+            //鎴块棿鏍�
+            btnHorizontalScrolViewLayout = new HorizontalScrolViewLayout
+            {
+                X = Application.GetRealWidth(58),
+            };
+            btnMidTopLayout.AddChidren(btnHorizontalScrolViewLayout);
+
+            //璁惧鏍�
+            midVerticalScrolViewLayout = new VerticalFrameRefreshControl()
+            {
+                Y = btnMidTopLayout.Bottom,
+                Height = Application.GetRealHeight(1145),
+            };
+            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
+            midVerticalScrolViewLayout.BeginHeaderRefreshingAction += () =>
+            {
+                midVerticalScrolViewLayout.BeginHeaderRefreshing();
+                canFresh = true;
+                InitData();
+            };
+
+            //搴曢儴淇濆瓨鏍�
+            var bottomFrameLayout = new FrameLayout()
+            {
+                Width = LayoutParams.MatchParent,
+                Height = Application.GetRealHeight(84 * 2 + 127),
+                Y = Application.GetRealHeight(1388),
+            };
+            this.midFrameLayout.AddChidren(bottomFrameLayout);
+
+            btnTipText = new Button()
+            {
+                Height = Application.GetRealHeight(84),
+                TextID = R.MyInternationalizationString.Tip,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+                TextSize = 12,
+                TextAlignment = TextAlignment.Center,
+            };
+            bottomFrameLayout.AddChidren(btnTipText);
+
+            btnFinifh = new Button()
+            {
+                Width = Application.GetRealWidth(907),
+                Height = Application.GetRealHeight(127),
+                Y = Application.GetRealHeight(49 + 35),
+                Gravity = Gravity.CenterHorizontal,
+                Radius = (uint)Application.GetRealHeight(127) / 2,
+                TextID = R.MyInternationalizationString.Save,
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                IsBold = true,
+                TextSize = 16,
+            };
+            bottomFrameLayout.AddChidren(btnFinifh);
+            btnFinifh.MouseUpEventHandler += (sender, e) =>
+            {
+                curSendEpointList.Clear();
+                SaveTarget();
+            };
+        }
+
+        /// <summary>
+        /// 闈㈡澘缁戝畾鐩爣琛ㄦ樉绀�
+        /// </summary>
+        /// <param name="gateway">Gateway.</param>
+        /// <param name="key">Key.</param>
+        void RefreshRoomList()
+        {
+            btnHorizontalScrolViewLayout.RemoveAll();
+            Room curRoom = null;
+            Button curentOldRoom = null;
+            FrameLayout curentOldRoomFrameLayout = null;
+            int index = 0;
+            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)
+                {
+                    roomTempList.Add(roomUn);
+                }
+            }
+            else
+            {
+                if (undistributeDevList.Count != 0)
+                {
+                    roomTempList.Add(roomUn);
+                }
+            }
+
+            for (int i = 0; i < roomTempList.Count; i++)
+            {
+                var room = roomTempList[i];
+                bool canSelect = false;
+                if (curControlDev.currentSelectRoomId == room.Id)
+                {
+                    slectedRoom = room;
+                    canSelect = true;
+                }
+                //鎴块棿
+                var btnRoomFrameLayout = new FrameLayout
+                {
+                    Height = Application.GetMinReal(159),
+                    Width = Application.GetMinReal(255),
+                    Y = Application.GetRealHeight(23),
+                    X = Application.GetRealWidth(5),
+                    BackgroundImagePath = "Item/RoomIconBackground.png",
+                    BorderWidth = 1,
+                };
+                btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayout);
+
+                var btnRoom = new Button
+                {
+                    Height = Application.GetRealHeight(66),
+                    Width = Application.GetRealWidth(250),
+                    Y = Application.GetRealHeight(58),
+                    X = Application.GetRealWidth(14),
+                    Text = room.Name,
+                    TextSize = 12,
+                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
+                    Gravity = Gravity.Center,
+                };
+                btnRoomFrameLayout.AddChidren(btnRoom);
+
+                btnRoom.IsSelected = false;
+                if (canSelect)
+                {
+                    btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+                    btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+                    curentOldRoom = btnRoom;
+                    curentOldRoomFrameLayout = btnRoomFrameLayout;
+                }
+
+                //琚粦瀹氱殑鐩爣杩樻湭鍒嗛厤鍖哄煙锛岄粯璁ゆ槸鏈�鍚庝竴涓紝鏈垎閰嶆埧闂�
+                if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId))
+                {
+                    if (index == roomTempList.Count - 1)
+                    {
+                        btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+                        btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+                        curentOldRoom = btnRoom;
+                        curentOldRoomFrameLayout = btnRoomFrameLayout;
+                    }
+                }
+
+                if (index == roomTempList.Count - 1 && index > 2)
+                {
+                    var btnRoomFrameLayoutEmpty = new FrameLayout
+                    {
+                        Height = Application.GetMinReal(159),
+                        Width = Application.GetMinReal(50),
+                        Y = Application.GetRealHeight(23),
+                        X = Application.GetRealWidth(5),
+                        //BorderWidth = 1,
+                    };
+                    btnHorizontalScrolViewLayout.AddChidren(btnRoomFrameLayoutEmpty);
+                }
+
+                EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) =>
+                {
+                    if (!btnRoom.IsSelected)
+                    {
+                        if (curentOldRoom != null)
+                        {
+                            curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
+                        }
+                        curentOldRoom = btnRoom;
+                        curentOldRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+                    }
+
+                    if (btnRoomFrameLayout.BorderWidth == 1)
+                    {
+                        if (curentOldRoomFrameLayout != null)
+                        {
+                            curentOldRoomFrameLayout.BorderWidth = 1;
+                            curentOldRoomFrameLayout.BorderColor = Shared.Common.ZigbeeColor.Current.XMOrange;
+                            curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackground.png";
+                        }
+                        curentOldRoomFrameLayout = btnRoomFrameLayout;
+                        curentOldRoomFrameLayout.BorderWidth = 0;
+                        curentOldRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+                    }
+                    curRoom = room;
+
+                    //鏂伴闈㈡澘淇濆瓨浣胯兘
+                    btnFinifh.Enable = true;
+                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                    if (curBindType == 0)
+                    {
+                        RefreshSceneList(curRoom);
+                    }
+                    else
+                    {
+                        RefreshDeviceList(curRoom);
+                    }
+                };
+                btnRoom.MouseUpEventHandler += eHandlerRoom;
+                btnRoomFrameLayout.MouseUpEventHandler += eHandlerRoom;
+                index++;
+            }
+            BindInfo.FinishDisplay(roomTempList, btnFinifh);
+
+            if (roomTempList.Count == 0)
+            {
+                curRoom = new Shared.Common.Room();
+            }
+            else
+            {
+                if (slectedRoom == null)
+                {
+                    //鏈�変腑榛樿鏈�鍚庝竴涓�滄湭鍒嗛厤閫変腑鈥�
+                    curRoom = roomTempList[index - 1];
+                    var view = btnHorizontalScrolViewLayout.GetChildren(index - 1);
+                    var frame = (FrameLayout)view;
+                    var btn = (Button)frame.GetChildren(0);
+                    frame.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+                    btn.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+                    curentOldRoom = btn;
+                    curentOldRoomFrameLayout = frame;
+                }
+                else
+                {
+                    curRoom = slectedRoom;
+                }
+            }
+
+            if (curBindType == 0)
+            {
+                RefreshSceneList(curRoom);
+            }
+            else
+            {
+                RefreshDeviceList(curRoom);
+            }
+
+            switch (curBindType)
+            {
+                case 1:
+                    btnTipText.Text = MutilfunctionPanelMethod.MatchTypeBindTextTip(curBindType, MutilfunctionPanelMethod.curSwitchCount + MutilfunctionPanelMethod.curSocketCount + MutilfunctionPanelMethod.curLightFromRelayCount);
+                    break;
+                case 2:
+                    btnTipText.Text = MutilfunctionPanelMethod.MatchTypeBindTextTip(curBindType, MutilfunctionPanelMethod.curSwitchCount + MutilfunctionPanelMethod.curSocketCount + MutilfunctionPanelMethod.curLightFromRelayCount);
+                    break;
+                case 3:
+                    btnTipText.Text = MutilfunctionPanelMethod.MatchTypeBindTextTip(curBindType, MutilfunctionPanelMethod.curSwitchCount + MutilfunctionPanelMethod.curSocketCount + MutilfunctionPanelMethod.curLightFromRelayCount + MutilfunctionPanelMethod.curLightCount);
+                    break;
+                default:
+                    btnTipText.Text = MutilfunctionPanelMethod.MatchTypeBindTextTip(curBindType, curBindTypeList.Count);
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 鎸夐敭缁戠洰鏍囪〃鏄剧ず
+        /// </summary>
+        /// <param name="curRoom"></param>
+        void RefreshDeviceList(Room curRoom)
+        {
+            midVerticalScrolViewLayout.RemoveAll();
+            Button oldDevice = null;
+            int curIndex = 0;
+
+            if (curRoom.Id == "UndistributedId")
+            {
+                currentRoomSupportBindDeviceList = MutilfunctionPanelMethod.GetUndistributeDeviceList(undistributeDevList, curBindTypeList, curBindType);
+            }
+            else
+            {
+                currentRoomSupportBindDeviceList = MutilfunctionPanelMethod.GetCurRoomSupportDeviceList(curRoom, currentRoomSupportBindDeviceList, curBindTypeList, curBindType);
+            }
+
+            if (currentRoomSupportBindDeviceList.Count == 0)
+            {
+                btnFinifh.Enable = false;
+                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+                return;
+            }
+            foreach (var device in currentRoomSupportBindDeviceList)
+            {
+                #region 缁戝畾琛║I鏄撅紙鏃犳暟鎹鐞嗭級
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                midVerticalScrolViewLayout.AddChidren(rowLayout);
+
+                var devicePic = new Button()
+                {
+                    X = Application.GetMinRealAverage(58),
+                    Y = Application.GetMinRealAverage(46),
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
+                    UnSelectedImagePath = device.IconPath,
+                };
+                rowLayout.AddChidren(devicePic);
+
+                var btnBindName = new Button()
+                {
+                    Width = Application.GetRealWidth(790),
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 15,
+                    Text = Common.LocalDevice.Current.GetDeviceEpointName(device),
+                };
+                rowLayout.AddChidren(btnBindName);
+
+                var btnChoose = new Button()
+                {
+                    Width = Application.GetMinReal(60),
+                    Height = Application.GetMinReal(60),
+                    X = Application.GetRealWidth(861 + 81),
+                    Y = Application.GetRealHeight(35),
+                    SelectedImagePath = "DoorLock/SelectedIcon.png",
+                    Visible = false,
+                };
+                rowLayout.AddChidren(btnChoose);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    Width = Application.GetRealWidth(965 - 116),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+
+                if (curIndex == currentRoomSupportBindDeviceList.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+                if (Common.LocalDevice.Current.CheckDeviceIsOnline(device) == true)
+                {
+                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.TextBlack;
+                }
+                else
+                {
+                    btnBindName.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
+                }
+                switch (curBindType)
+                {
+                    case 1:
+                        devicePic.UnSelectedImagePath = "BindPic/Switch.png";
+                        break;
+                    case 2:
+                        devicePic.UnSelectedImagePath = "Device/Socket1.png";
+                        break;
+                    case 3:
+                        if (device.Type == DeviceType.DimmableLight)
+                        {
+                            devicePic.UnSelectedImagePath = "Device/Light.png";
+                        }
+                        if (device.Type == DeviceType.OnOffOutput)
+                        {
+                            devicePic.UnSelectedImagePath = "Device/RelayEpoint.png";
+                        }
+                        break;
+                    case 4:
+                        devicePic.UnSelectedImagePath = "Device/AirQualitySensorEpoint.png";
+                        if (device.Type == DeviceType.WindowCoveringDevice)
+                        {
+                            var tempDev = device as Rollershade;
+                            if (tempDev.WcdType == 4)
+                            {
+                                devicePic.UnSelectedImagePath = "BindPic/Curtain.png";
+                            }
+                            else
+                            {
+                                devicePic.UnSelectedImagePath = "BindPic/Roller.png";
+                            }
+                        }
+                        break;
+                    case 5:
+                        devicePic.UnSelectedImagePath = "Device/AirConditionerEpoint.png";
+                        break;
+                    case 6:
+                        devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png";
+                        break;
+                }
+                #endregion
+
+                string mianKey = device.DeviceAddr + device.DeviceEpoint;
+                if (targetList.Count != 0)
+                {
+                    foreach (var bindedDev in targetList)
+                    {
+                        if (bindedDev.DeviceAddr + bindedDev.DeviceEpoint == mianKey)
+                        {
+                            btnChoose.IsSelected = true;
+                            btnChoose.Visible = true;
+                            oldDevice = btnChoose;
+                        }
+                    }
+                }
+
+                EventHandler<MouseEventArgs> hander = (sender, e) =>
+                {
+                    //鐩爣澶囨敞澶勭悊
+                    var localName = System.Text.Encoding.UTF8.GetBytes(Common.LocalDevice.Current.GetDeviceEpointName(device));
+                    if (localName.Length > 20)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindRemarkTip2), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        return;
+                    }
+                    btnChoose.IsSelected = !btnChoose.IsSelected;
+                    if (curBindType != 6)
+                    {
+                        if (curSupportBindEpointList.Count == 0)
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            return;
+                        }
+                        if (curBindType == 3)
+                        {
+                            if (device.Type == DeviceType.DimmableLight)
+                            {
+                                if (curSupportDimmerEpointList.Count == 0)
+                                {
+                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CanSelectRelay), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                                    return;
+                                }
+                            }
+                            if (device.Type == DeviceType.OnOffOutput)
+                            {
+                                if (curSupportLightEpointList.Count == 0)
+                                {
+                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.CanSelectDimmer), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                                    return;
+                                }
+                            }
+                        }
+                        if (!btnChoose.IsSelected)
+                        {
+                            targetList.Remove(device);
+                            btnChoose.IsSelected = false;
+                            btnChoose.Visible = false;
+                        }
+                        else
+                        {
+                            if (targetList.Count >= curSupportBindEpointList.Count)
+                            {
+                                new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            }
+                            else
+                            {
+                                if (curBindType == 3)
+                                {
+                                    //涓存椂璁板綍鐏厜绫诲瀷涓皟鍏変釜鏁板拰寮�鍏充釜鏁�
+                                    var tList1 = new List<CommonDevice> { };
+                                    var tList2 = new List<CommonDevice> { };
+                                    foreach (var tD in targetList)
+                                    {
+                                        if (tD.Type == DeviceType.DimmableLight)
+                                        {
+                                            tList1.Add(tD);
+                                        }
+                                        if (tD.Type == DeviceType.OnOffOutput)
+                                        {
+                                            tList2.Add(tD);
+                                        }
+                                    }
+                                    if (device.Type == DeviceType.DimmableLight)
+                                    {
+                                        if (tList1.Count >= curSupportDimmerEpointList.Count)
+                                        {
+                                            new Tip() { MaxWidth = 310, Text = Language.StringByID(R.MyInternationalizationString.CanSelectRelay), Direction = AMPopTipDirection.None, CloseTime = 2 }.Show(Common.CommonPage.Instance);
+                                            return;
+                                        }
+                                    }
+                                    if (device.Type == DeviceType.OnOffOutput)
+                                    {
+                                        if (tList2.Count >= curSupportLightEpointList.Count)
+                                        {
+                                            new Tip() { MaxWidth = 310, Text = Language.StringByID(R.MyInternationalizationString.CanSelectDimmer), Direction = AMPopTipDirection.None, CloseTime = 2 }.Show(Common.CommonPage.Instance);
+                                            return;
+                                        }
+                                    }
+                                }
+
+                                targetList.Add(device);
+                                btnChoose.IsSelected = true;
+                                btnChoose.Visible = true;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        if (curSupportBindEpointList.Count == 0)
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            return;
+                        }
+                        if (!btnChoose.IsSelected)
+                        {
+                            if (oldDevice != null)
+                            {
+                                oldDevice.IsSelected = false;
+                                oldDevice.Visible = false;
+                            }
+                            oldDevice = btnChoose;
+                            oldDevice.IsSelected = false;
+                            oldDevice.Visible = false;
+                            targetList.Clear();
+                        }
+                        else
+                        {
+                            if (oldDevice != null)
+                            {
+                                oldDevice.IsSelected = false;
+                                oldDevice.Visible = false;
+                            }
+                            oldDevice = btnChoose;
+                            oldDevice.IsSelected = true;
+                            oldDevice.Visible = true;
+                            targetList.Clear();
+                            targetList.Add(device);
+                        }
+                    }
+                    if (targetList.Count == 0)
+                    {
+                        btnFinifh.Enable = false;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+                    }
+                    else
+                    {
+                        btnFinifh.Enable = true;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                    }
+                };
+                rowLayout.MouseUpEventHandler += hander;
+                devicePic.MouseUpEventHandler += hander;
+                btnBindName.MouseUpEventHandler += hander;
+                btnChoose.MouseUpEventHandler += hander;
+                curIndex++;
+            }
+        }
+
+        /// <summary>
+        /// 鎸夐敭缁戠洰鏍囪〃鏄剧ず
+        /// </summary>
+        /// <param name="curRoom"></param>
+        void RefreshSceneList(Room curRoom)
+        {
+            midVerticalScrolViewLayout.RemoveAll();
+            Button oldScene = null;
+            int curIndex = 0;
+
+            if (curRoom.Id == "UndistributedId")
+            {
+                currentRoomSupportBindSceneList = HdlSceneLogic.Current.GetUnalloctedScenes();
+            }
+            else
+            {
+                currentRoomSupportBindSceneList = MutilfunctionPanelMethod.GetCurRoomSupportSceneList(curRoom, currentRoomSupportBindSceneList, curBindTypeList);
+            }
+
+            if (currentRoomSupportBindSceneList.Count == 0)
+            {
+                btnFinifh.Enable = false;
+                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+                return;
+            }
+            foreach (var scene in currentRoomSupportBindSceneList)
+            {
+                #region 缁戝畾琛║I鏄撅紙鏃犳暟鎹鐞嗭級
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                midVerticalScrolViewLayout.AddChidren(rowLayout);
+
+                var devicePic = new Button()
+                {
+                    X = Application.GetMinRealAverage(58),
+                    Y = Application.GetMinRealAverage(46),
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
+                    UnSelectedImagePath = "Scene/SceneIcon.png",
+                };
+                rowLayout.AddChidren(devicePic);
+
+                var btnBindName = new Button()
+                {
+                    Width = Application.GetRealWidth(790),
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 15,
+                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
+                    Text = scene.Name,
+                };
+                rowLayout.AddChidren(btnBindName);
+
+                var btnChoose = new Button()
+                {
+                    Width = Application.GetMinReal(60),
+                    Height = Application.GetMinReal(60),
+                    X = Application.GetRealWidth(861 + 81),
+                    Y = Application.GetRealHeight(35),
+                    SelectedImagePath = "DoorLock/SelectedIcon.png",
+                    Visible = false,
+                };
+                rowLayout.AddChidren(btnChoose);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = devicePic.Right + Application.GetRealWidth(20),
+                    Width = Application.GetRealWidth(965 - 116),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+
+                if (curIndex == currentRoomSupportBindDeviceList.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+                #endregion
+
+                if (targetScList.Count != 0)
+                {
+                    foreach (var bindedDev in targetScList)
+                    {
+                        if (bindedDev.Id == scene.Id)
+                        {
+                            btnChoose.IsSelected = true;
+                            btnChoose.Visible = true;
+                            oldScene = btnChoose;
+                        }
+                    }
+                }
+
+                EventHandler<MouseEventArgs> hander = (sender, e) =>
+                {
+
+                    //鐩爣澶囨敞澶勭悊
+                    if (!string.IsNullOrEmpty(scene.Name))
+                    {
+                        var localName = System.Text.Encoding.UTF8.GetBytes(scene.Name);
+                        if (localName.Length > 20)
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindRemarkTip2), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                            return;
+                        }
+                    }
+
+                    btnChoose.IsSelected = !btnChoose.IsSelected;
+
+                    if (curSupportBindEpointList.Count == 0)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        return;
+                    }
+
+                    if (!btnChoose.IsSelected)
+                    {
+                        targetScList.Remove(scene);
+                        btnChoose.IsSelected = false;
+                        btnChoose.Visible = false;
+                    }
+                    else
+                    {
+                        if (targetScList.Count >= curSupportBindEpointList.Count)
+                        {
+                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                        }
+                        else
+                        {
+                            targetScList.Add(scene);
+                            btnChoose.IsSelected = true;
+                            btnChoose.Visible = true;
+                        }
+                    }
+
+                    if (targetScList.Count == 0)
+                    {
+                        btnFinifh.Enable = false;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+                    }
+                    else
+                    {
+                        btnFinifh.Enable = true;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                    }
+                };
+                rowLayout.MouseUpEventHandler += hander;
+                devicePic.MouseUpEventHandler += hander;
+                btnBindName.MouseUpEventHandler += hander;
+                btnChoose.MouseUpEventHandler += hander;
+                curIndex++;
+            }
+        }
+        #endregion
+
+        #region 鏁版嵁澶勭悊 
+        /// <summary>
+        /// 鍒濆鍖栬澶囨暟鎹�
+        /// </summary>
+        void InitData()
+        {
+            System.Threading.Tasks.Task.Run(async () =>
+            {
+                try
+                {
+                    //鑾峰彇妤煎眰
+                    dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
+                    curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
+
+                    //鑾峰彇鎴块棿鍒楄〃
+                    supportRoomList = BindInfo.GetSupportRoomList();
+
+                    //鑾峰彇闈㈡澘宸茬粡缁戝畾鐨勫尮閰嶇被鍨嬬殑鍒楄〃
+                    curBindTypeList = MutilfunctionPanelMethod.GetMatchBindList(curControlDev, curBindType);
+
+                    if (curBindType == 0)
+                    {
+                        currentPanelSupportBindSceneList = MutilfunctionPanelMethod.GetAllRoomSupportSceneList(currentPanelSupportBindSceneList, supportRoomList, curBindTypeList);
+                        // 鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氬満鏅垪琛�
+                        undistributeScList = HdlSceneLogic.Current.GetUnalloctedScenes();
+                    }
+                    else
+                    {
+                        //鑾峰彇鎵�鏈夋埧闂翠腑鍖归厤鐨勮兘缁戠殑鐩�
+                        currentPanelSupportBindDeviceList = MutilfunctionPanelMethod.GetAllRoomSupportDeviceList(currentPanelSupportBindDeviceList, supportRoomList, curBindTypeList, curBindType);
+                        //鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氳澶囧垪琛�
+                        undistributeDevList = MutilfunctionPanelMethod.GetUndistributeDeviceList(undistributeDevList, curBindTypeList, curBindType);
+                    }
+                    //鑾峰彇褰撳墠鏀寔鐨勭鐐圭粦瀹氳〃
+                    curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curControlDev, curBindType);
+                    if (curBindType == 3)
+                    {
+                        foreach (var ep in curSupportBindEpointList)
+                        {
+                            if (ep >= 22 && ep <= 28)
+                            {
+                                curSupportDimmerEpointList.Add(ep);
+                            }
+                            if (ep >= 52 && ep <= 61)
+                            {
+                                curSupportLightEpointList.Add(ep);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    var mess = ex.Message;
+                }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        if (!canFresh)
+                        {
+                            BindDownFrameLayout(this.midFrameLayout, curControlDev, dicFloorList, ref btnFloorText);
+                        }
+                        ChooseFloorAction += (floorId, btnMethodText) =>
+                        {
+                            btnFloorText.Text = dicFloorList[floorId];
+
+                            //鑾峰彇鎴块棿鍒楄〃
+                            supportRoomList.Clear();
+                            supportRoomList = BindInfo.GetSupportRoomList();
+                            if (curBindType == 0)
+                            {
+                                // 鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氬満鏅垪琛�
+                                undistributeScList = HdlSceneLogic.Current.GetUnalloctedScenes();
+                            }
+                            else
+                            {
+                                //鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氳澶囧垪琛�
+                                undistributeDevList = MutilfunctionPanelMethod.GetUndistributeDeviceList(undistributeDevList, curBindTypeList, curBindType);
+                            }
+                            RefreshRoomList();
+                        };
+                        //榛樿妤煎眰鏄剧ず
+                        if (BindInfo.GetCurrentSelectFloorIdName() != null)
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                btnFloorText.Text = BindInfo.GetCurrentSelectFloorIdName();
+                            });
+                        }
+                        //鑾峰彇妤煎眰涓埧闂村垪琛�
+                        RefreshRoomList();
+                        CommonPage.Loading.Hide();
+                        canFresh = false;
+                        midVerticalScrolViewLayout.EndHeaderRefreshing();
+                    });
+                }
+            });
+        }
+
+        /// <summary>
+        /// 淇濆瓨鐩爣
+        /// </summary>
+        /// <param name="curControlDev"></param>
+        void SaveTarget()
+        {
+            btnFinifh.Enable = false;
+            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Start("");
+                    });
+                    int tempBindCluster = -1;
+                    int targetSendCount = 0;
+                    int targetRecCount = 0;
+                    if (curBindType == 0)
+                    {
+                        targetSendCount = targetScList.Count;
+                        if (targetScList.Count == 0)
+                        {
+                            //娌℃湁鐩爣鎻愮ず
+                            Application.RunOnMainThread(() =>
+                            {
+                                var myTip = new Tip();
+                                myTip.Direction = AMPopTipDirection.None;
+                                myTip.CloseTime = 2;
+                                myTip.Text = Language.StringByID(R.MyInternationalizationString.BindDeviceTargetIsEmpty);
+                                myTip.Show(Common.CommonPage.Instance);
+                                btnFinifh.Enable = true;
+                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                CommonPage.Loading.Hide();
+                            });
+                            return;
+                        }
+                        for (int i = 0; i < targetScList.Count; i++)
+                        {
+                            //缁戝畾鏂扮殑鏁版嵁
+                            var addSingleBindData = new AddSingleBindData();
+                            addSingleBindData.DeviceAddr = curControlDev.DeviceAddr;
+                            for (int j = 0; j < curSupportBindEpointList.Count; j++)
+                            {
+                                curSendEpointList.Add(curSupportBindEpointList[0]);
+                                addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
+                                break;
+                            }
+                            var de = targetScList[i];
+                            addSingleBindData.BindType = 1;
+                            addSingleBindData.BindClusterList.Add(6);
+                            addSingleBindData.BindScenesId = de.Id;
+
+                            var resT = AddDeviceBind(addSingleBindData, targetSendCount, ref targetRecCount);
+                            if (!resT)
+                            {
+                                break;
+                            }
+                        }
+                    }
+                    else
+                    {
+                        targetSendCount = targetList.Count;
+                        if (targetList.Count == 0)
+                        {
+                            //娌℃湁鐩爣鎻愮ず
+                            Application.RunOnMainThread(() =>
+                            {
+                                var myTip = new Tip();
+                                myTip.Direction = AMPopTipDirection.None;
+                                myTip.CloseTime = 2;
+                                myTip.Text = Language.StringByID(R.MyInternationalizationString.BindDeviceTargetIsEmpty);
+                                myTip.Show(Common.CommonPage.Instance);
+                                btnFinifh.Enable = true;
+                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                CommonPage.Loading.Hide();
+                            });
+                            return;
+                        }
+                        foreach (var de in targetList)
+                        {
+                            //缁戝畾鏂扮殑鏁版嵁
+                            var addSingleBindData = new AddSingleBindData();
+                            addSingleBindData.DeviceAddr = curControlDev.DeviceAddr;
+
+                            if (curBindType == 3)
+                            {
+                                if (de.Type == DeviceType.DimmableLight)
+                                {
+                                    for (int j = 0; j < curSupportDimmerEpointList.Count; j++)
+                                    {
+                                        curSendEpointList.Add(curSupportDimmerEpointList[0]);
+                                        addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportDimmerEpointList[0];
+                                        break;
+                                    }
+                                }
+
+                                if (de.Type == DeviceType.OnOffOutput)
+                                {
+                                    for (int j = 0; j < curSupportLightEpointList.Count; j++)
+                                    {
+                                        curSendEpointList.Add(curSupportLightEpointList[0]);
+                                        addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportLightEpointList[0];
+                                        break;
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                for (int j = 0; j < curSupportBindEpointList.Count; j++)
+                                {
+                                    curSendEpointList.Add(curSupportBindEpointList[0]);
+                                    addSingleBindData.Epoint = curControlDev.DeviceEpoint = curSupportBindEpointList[0];
+                                    break;
+                                }
+                            }
+
+                            addSingleBindData.BindType = 0;
+                            addSingleBindData.BindMacAddr = de.DeviceAddr;
+                            addSingleBindData.BindEpoint = de.DeviceEpoint;
+                            switch (curBindType)
+                            {
+                                case 0:
+                                case 1:
+                                case 2:
+                                    addSingleBindData.BindClusterList.Add(6);
+                                    break;
+                                case 3:
+                                    addSingleBindData.BindClusterList.Add(6);
+                                    var device = LocalDevice.Current.GetDevice(de.DeviceAddr, de.DeviceEpoint);
+                                    if (device != null)
+                                    {
+                                        if (device.Type == DeviceType.DimmableLight)
+                                        {
+                                            //鐏厜涓鸿皟鍏夋椂闇�瑕佺粦瀹�6锛�8
+                                            addSingleBindData.BindClusterList.Add(8);
+                                        }
+                                    }
+                                    break;
+                                case 4:
+                                    addSingleBindData.BindClusterList.Add(258);
+                                    break;
+                                case 5:
+                                    //瑕佺粦瀹氱┖璋冿細闇�瑕佺粦瀹�513锛�514
+                                    addSingleBindData.BindClusterList.Add(513);
+                                    addSingleBindData.BindClusterList.Add(514);
+                                    break;
+                                case 6:
+                                    addSingleBindData.BindClusterList.Add(514);
+                                    break;
+                            }
+
+
+                            var resT = AddDeviceBind(addSingleBindData, targetSendCount, ref targetRecCount);
+                            if (!resT)
+                            {
+                                break;
+                            }
+                        }
+                    }
+                }
+                catch
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        btnFinifh.Enable = true;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                        CommonPage.Loading.Hide();
+                    });
+                }
+
+            });
+        }
+
+        /// <summary>
+        /// AddDeviceBind
+        /// </summary>
+        /// <param name="addSingleBindData"></param>
+        /// <param name="targetSendCount"></param>
+        /// <param name="targetRecCount"></param>
+        /// <returns></returns>
+        private bool AddDeviceBind(AddSingleBindData addSingleBindData, int targetSendCount, ref int targetRecCount)
+        {
+            var addSuccess = false;
+            var dev = HdlDeviceBindLogic.Current.AddDeviceSingleBindAsync(addSingleBindData);
+            if (dev != null && dev.addedDeviceSingleBindResponseData != null)
+            {
+                addSuccess = true;
+                targetRecCount++;
+                if (dev.addedDeviceSingleBindResponseData.Result == 0)
+                {
+                    var countTotal = targetRecCount;
+                    var bList = new List<BindListAllInfo>();
+                    foreach (var cluster in dev.addedDeviceSingleBindResponseData.BindClusterList)
+                    {
+                        var curD = new BindListAllInfo();
+                        curD.KeyMacAddr = curControlDev.DeviceAddr;
+                        curD.KeyEpoint = curControlDev.DeviceEpoint;
+                        curD.BindCluster = cluster;
+                        curD.BindScenesId = dev.addedDeviceSingleBindResponseData.BindScenesId;
+                        curD.BindMacAddr = dev.addedDeviceSingleBindResponseData.BindMacAddr;
+                        curD.BindEpoint = dev.addedDeviceSingleBindResponseData.BindEpoint;
+                        curD.ESName = dev.addedDeviceSingleBindResponseData.ESName;
+                        curD.BindType = dev.addedDeviceSingleBindResponseData.BindType;
+                        bList.Add(curD);
+                    }
+
+                    if (curControlDev.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
+                    {
+                        curControlDev.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
+                    }
+                    else
+                    {
+                        curControlDev.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
+                    }
+
+                    if (curBindType == 3)
+                    {
+                        if (addSingleBindData.Epoint >= 22 && addSingleBindData.Epoint <= 28)
+                        {
+                            curSupportDimmerEpointList.RemoveAt(0);
+
+                        }
+                        if (addSingleBindData.Epoint >= 52 && addSingleBindData.Epoint <= 61)
+                        {
+                            curSupportLightEpointList.RemoveAt(0);
+                        }
+                    }
+                    else
+                    {
+                        curSupportBindEpointList.RemoveAt(0);
+                    }
+                    Application.RunOnMainThread(() =>
+                    {
+                        if (countTotal == targetSendCount)
+                        {
+                            if (actionRefreshBindList != null)
+                            {
+                                actionRefreshBindList();
+                            }
+                            targetList.Clear();
+                            this.RemoveFromParent();
+                            btnFinifh.Enable = true;
+                            btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                            CommonPage.Loading.Hide();
+                        }
+                    });
+                }
+                else if (dev.addedDeviceSingleBindResponseData.Result == 1)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        btnFinifh.Enable = true;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                        RefreshRoomList();
+                        CommonPage.Loading.Hide();
+                        new Tip()
+                        {
+                            MaxWidth = 150,
+                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed) + "(" + "5020_1" + ")",
+                            Direction = AMPopTipDirection.Up,
+                            CloseTime = 1
+                        }.Show(btnFinifh);
+                    });
+                }
+                else
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        btnFinifh.Enable = true;
+                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                        RefreshRoomList();
+                        CommonPage.Loading.Hide();
+                        new Tip()
+                        {
+                            MaxWidth = 150,
+                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError) + "(" + "5020_2" + ")",
+                            Direction = AMPopTipDirection.Up,
+                            CloseTime = 1
+                        }.Show(btnFinifh);
+                    });
+                }
+            }
+            else
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    btnFinifh.Enable = true;
+                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                    RefreshRoomList();
+                    new Tip()
+                    {
+                        MaxWidth = 150,
+                        Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5020" + ")",
+                        Direction = AMPopTipDirection.Up,
+                        CloseTime = 1
+                    }.Show(btnFinifh);
+                    CommonPage.Loading.Hide();
+                    GetEpointData();
+                });
+            }
+            return addSuccess;
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栬澶囨暟鎹�
+        /// </summary>
+        void GetEpointData()
+        {
+            System.Threading.Tasks.Task.Run(() =>
+            {
+                try
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Start("");
+                    });
+                    int count1 = curSendEpointList.Count;
+                    int count2 = 0;
+                    foreach (var epoint in curSendEpointList)
+                    {
+                        curControlDev.DeviceEpoint = epoint;
+                        var getBindList = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
+                        if (getBindList != null && getBindList.getAllBindResponseData != null)
+                        {
+                            count2++;
+                            var bList = new List<BindListAllInfo>();
+                            foreach (var dev in getBindList.getAllBindResponseData.BindList)
+                            {
+                                var curD = new BindListAllInfo();
+                                curD.KeyMacAddr = curControlDev.DeviceAddr;
+                                curD.KeyEpoint = epoint;
+                                curD.BindCluster = dev.BindCluster;
+                                curD.BindScenesId = dev.BindScenesId;
+                                curD.BindMacAddr = dev.BindMacAddr;
+                                curD.BindEpoint = dev.BindEpoint;
+                                curD.BindType = dev.BindType;
+                                bList.Add(curD);
+
+                                //鏇存柊targetScListj or targetList 
+                                if (curBindType == 0)
+                                {
+                                    for (int i = 0; i < targetScList.Count; i++)
+                                    {
+                                        if (targetScList[i].Id == dev.BindScenesId)
+                                        {
+                                            targetScList.RemoveAt(i);
+                                        }
+                                    }
+                                }
+                                else
+                                {
+                                    for (int i = 0; i < targetList.Count; i++)
+                                    {
+                                        if (targetList[i].DeviceAddr + targetList[i].DeviceEpoint == dev.BindMacAddr + dev.BindEpoint)
+                                        {
+                                            targetList.RemoveAt(i);
+                                        }
+                                    }
+                                }
+                            }
+
+                            //鏇存柊bindTargetsFromMutilfunctionPanelList
+                            if (curControlDev.bindTargetsFromMutilfunctionPanelList.ContainsKey(curControlDev.DeviceAddr + curControlDev.DeviceEpoint))
+                            {
+                                curControlDev.bindTargetsFromMutilfunctionPanelList[curControlDev.DeviceAddr + curControlDev.DeviceEpoint] = bList;
+                            }
+                            else
+                            {
+                                curControlDev.bindTargetsFromMutilfunctionPanelList.Add(curControlDev.DeviceAddr + curControlDev.DeviceEpoint, bList);
+                            }
+
+                            //鏇存柊褰撳墠鏀寔鐨勭鐐圭粦瀹氳〃
+                            curSupportBindEpointList = MutilfunctionPanelMethod.GetMatchEpointList(curControlDev, curBindType);
+                            if (curBindType == 3)
+                            {
+                                foreach (var ep in curSupportBindEpointList)
+                                {
+                                    if (ep >= 22 && ep <= 28)
+                                    {
+                                        curSupportDimmerEpointList.Remove(ep);
+                                    }
+                                    if (ep >= 52 && ep <= 61)
+                                    {
+                                        curSupportLightEpointList.Remove(ep);
+                                    }
+                                }
+                            }
+
+                            if (count1 == count2)
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    if (actionRefreshBindList != null)
+                                    {
+                                        actionRefreshBindList();
+                                    }
+                                    RefreshRoomList();
+                                    CommonPage.Loading.Hide();
+                                });
+                            }
+                        }
+                        else
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                targetList.Clear();
+                                new Tip() { MaxWidth = 300, Text = Language.StringByID(R.MyInternationalizationString.UpdateBindList), Direction = AMPopTipDirection.None, CloseTime = 3 }.Show(Common.CommonPage.Instance);
+                                btnFinifh.Enable = true;
+                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                CommonPage.Loading.Hide();
+                                this.RemoveFromParent();
+                            });
+                            break;
+                        }
+                    }
+                }
+                catch { }
+            });
+        }
+        #endregion
+    }
+}

--
Gitblit v1.8.0