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/Bind/MutilfunctionPanelMethod.cs |  955 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 955 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
new file mode 100755
index 0000000..e7f0c06
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/MutilfunctionPanelMethod.cs
@@ -0,0 +1,955 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Shared.Common;
+using Shared.Phone.UserCenter.Device;
+using Shared.Phone.UserCenter.DeviceBind;
+using ZigBee.Device;
+using static ZigBee.Device.BindObj;
+using static ZigBee.Device.Panel;
+
+namespace Shared.Phone.UserCenter.Device.Bind
+{
+    /// <summary>
+    /// 鍙娇鐢ㄤ簬绠�绾﹀鍔熻兘闈㈡澘鐨勬柟娉�
+    /// 銆愪竴涓寜閿彧鑳戒竴涓洰鏍囷紝涓�瀵逛竴缁戝畾銆備絾鏄鍔熻兘闈㈡澘60鎸夐敭锛屾渶澶氱粦瀹�60涓洰鏍囥��
+    /// 缁戝畾涓暟 鏈�澶�20涓満鏅紙鎸夐敭31锝�52锛�  鏈�澶�10涓紑鍏筹紙鎸夐敭52锝�61锛�  鏈�澶�10涓彃搴э紙鎸夐敭52锝�61锛�  鏈�澶�17涓伅鍏夛紙鎸夐敭52锝�61鎴栬��22锝�28锛�  鏈�澶�8涓伄闃筹紙鎸夐敭14锝�21锛� 鏈�澶�3涓┖璋冿紙鎸夐敭2锝�4锛� 鏈�澶�1涓柊椋庯紙鎸夐敭13锛�</param>
+    /// </summary>
+    public class MutilfunctionPanelMethod
+    {
+        #region  鍙橀噺鐢虫槑 
+        /// <summary>
+        /// 寮�鍏崇殑涓暟聽[姣忔杩涘叆鍒板鍔熻兘缁戝畾鐣岄潰锛岄兘瑕佽閲嶆柊鍙栧�糫
+        /// </summary>
+        public static int curSwitchCount = 0;
+        /// <summary>
+        /// 鎻掑骇鐨勪釜鏁奥燵姣忔杩涘叆鍒板鍔熻兘缁戝畾鐣岄潰锛岄兘瑕佽閲嶆柊鍙栧�糫
+        /// </summary>
+        public static int curSocketCount = 0;
+        /// <summary>
+        /// 鐏厜涓暟聽[浠庣户鐢靛櫒涓垎閰嶇殑鍔熻兘绫诲瀷鏄伅鍏塢[姣忔杩涘叆鍒板鍔熻兘缁戝畾鐣岄潰锛岄兘瑕佽閲嶆柊鍙栧�糫
+        /// </summary>
+        public static int curLightFromRelayCount = 0;
+        /// <summary>
+        /// 璋冨厜涓暟聽[姣忔杩涘叆鍒板鍔熻兘缁戝畾鐣岄潰锛岄兘瑕佽閲嶆柊鍙栧�糫
+        /// </summary>
+        public static int curLightCount = 0;
+        #endregion
+
+        /// <summary>
+        /// 鑾峰彇闈㈡澘宸茬粡缁戝畾鐨勫尮閰嶇被鍨嬬殑鍒楄〃
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�   2:鎻掑骇   3:鐏厜  4:閬槼  5:绌鸿皟  6:鏂伴 </param>
+        /// </summary>
+        /// <returns></returns>
+        public static List<BindListAllInfo> GetMatchBindList(Panel curControlDev, int curBindType)
+        {
+            var tempList = new List<BindListAllInfo>();
+            int count1 = 0;
+            int count2 = 0;
+
+            switch (curBindType)
+            {
+                case 1:
+                    curSwitchCount = 0;
+                    break;
+                case 2:
+                    curSocketCount = 0;
+                    break;
+                case 3:
+                    curLightFromRelayCount = 0;
+                    curLightCount = 0;
+                    break;
+            }
+
+            foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys)
+            {
+                var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key];
+                foreach (var bDev in bList)
+                {
+                    if (curBindType == 0)
+                    {
+                        if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51)
+                        {
+                            tempList.Add(bDev);
+                        }
+                    }
+
+                    var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
+                    if (device == null)
+                    {
+                        continue;
+                    }
+                    switch (curBindType)
+                    {
+                        case 1:
+                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                    {
+                                        tempList.Add(bDev);
+                                    }
+                                }
+                            }
+                            curSwitchCount = tempList.Count;
+                            break;
+                        case 2:
+                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                    {
+                                        tempList.Add(bDev);
+                                    }
+                                }
+                            }
+                            curSocketCount = tempList.Count;
+                            break;
+                        case 3:
+                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                    {
+                                        tempList.Add(bDev);
+                                        count1++;
+                                    }
+                                }
+                            }
+                            curLightFromRelayCount = count1;
+                            if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8)
+                                    {
+                                        tempList.Add(bDev);
+                                        count2++;
+                                    }
+                                }
+                            }
+                            curLightCount = count2;
+                            break;
+                        case 4:
+                            if (bDev.KeyEpoint >= 14 && bDev.KeyEpoint <= 21 && bDev.BindCluster == 258)
+                            {
+                                tempList.Add(bDev);
+                            }
+                            break;
+                        case 5:
+                            if (bDev.KeyEpoint >= 2 && bDev.KeyEpoint <= 4)
+                            {
+                                if (device != null)
+                                {
+                                    //绌鸿皟缁戝畾绫诲瀷
+                                    if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
+                                    {
+                                        tempList.Add(bDev);
+                                    }
+                                }
+                            }
+                            break;
+                        case 6:
+                            if (bDev.KeyEpoint == 13)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.Type == DeviceType.FreshAir && bDev.BindCluster == 514)
+                                    {
+                                        tempList.Add(bDev);
+                                    }
+                                }
+                            }
+                            break;
+                    }
+                }
+            }
+            return tempList;
+        }
+
+        /// <summary>
+        /// 璋冨厜鐏拰缁х數鍣ㄧ壒娈婂鐞嗘柟娉�
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// </summary>
+        /// <returns></returns>
+        public static void UpdateLightCount(Panel curControlDev, int curBindType)
+        {
+
+            if (curBindType == 1 || curBindType == 2 || curBindType == 3)
+            {
+                curSwitchCount = 0;
+                curSocketCount = 0;
+                curLightFromRelayCount = 0;
+                curLightCount = 0;
+
+                foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys)
+                {
+                    var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key];
+                    foreach (var bDev in bList)
+                    {
+                        var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
+                        if (device == null)
+                        {
+                            continue;
+                        }
+                        if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                        {
+                            if (device != null)
+                            {
+                                if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                {
+                                    curSwitchCount++;
+                                }
+                                else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                {
+                                    curSocketCount++;
+                                }
+                                else if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                {
+                                    curLightFromRelayCount++;
+                                }
+                            }
+                        }
+
+                        if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28)
+                        {
+                            if (device != null)
+                            {
+                                if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8)
+                                {
+                                    curLightCount++;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// 鏀寔鍖归厤鐨勭鐐逛釜鏁�
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// </summary>
+        /// <returns></returns>
+        private static List<int> MatchEpointList(int curBindType)
+        {
+            var tempList = new List<int>();
+            switch (curBindType)
+            {
+                case 0:
+                    for (int i = 32; i < 52; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                case 1:
+                case 2:
+                    for (int i = 52; i < 62; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                case 3:
+                    //鏈�澶ф湁10涓户鐢靛櫒鐨勭伅鍏夛紝7涓皟鍏�
+                    for (int i = 52; i < 62; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    for (int i = MutilfunctionPanelMethod.curLightCount + 22; i < 29; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                case 4:
+                    for (int i = 14; i < 22; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                case 5:
+                    for (int i = 2; i < 5; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                case 6:
+                    for (int i = 13; i < 14; i++)
+                    {
+                        tempList.Add(i);
+                    }
+                    break;
+                    //5~12鍦扮儹 绨� 0x0201
+            }
+            return tempList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇闈㈡澘鏀寔缁戝畾鐨勭鐐瑰垪琛�
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// </summary>
+        /// <returns></returns>
+        public static List<int> GetMatchEpointList(Panel curControlDev, int curBindType)
+        {
+            var tempList = MatchEpointList(curBindType);
+            foreach (var key in curControlDev.bindTargetsFromMutilfunctionPanelList.Keys)
+            {
+                var bList = curControlDev.bindTargetsFromMutilfunctionPanelList[key];
+                foreach (var bDev in bList)
+                {
+                    if (curBindType == 0)
+                    {
+                        if (bDev.KeyEpoint >= 32 && bDev.KeyEpoint <= 51)
+                        {
+                            tempList.Remove(bDev.KeyEpoint);
+                        }
+                    }
+
+                    var device = LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
+                    if (device == null)
+                    {
+                        continue;
+                    }
+                    switch (curBindType)
+                    {
+                        case 1:
+                        case 2:
+                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                    if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                    if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                }
+                            }
+                            break;
+                        case 3:
+                            if (bDev.KeyEpoint >= 52 && bDev.KeyEpoint <= 61)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                    if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                    if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                }
+                            }
+                            if (bDev.KeyEpoint >= 22 && bDev.KeyEpoint <= 28)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.Type == DeviceType.DimmableLight && bDev.BindCluster == 8)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                }
+                            }
+                            break;
+                        case 4:
+                            if (bDev.KeyEpoint >= 14 && bDev.KeyEpoint <= 21 && bDev.BindCluster == 258)
+                            {
+                                tempList.Remove(bDev.KeyEpoint);
+                            }
+                            break;
+                        case 5:
+                            if (bDev.KeyEpoint >= 2 && bDev.KeyEpoint <= 4)
+                            {
+                                if (device != null)
+                                {
+                                    //绌鸿皟缁戝畾绫诲瀷
+                                    if (device.Type == DeviceType.Thermostat && bDev.BindCluster == 513)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                }
+                            }
+                            break;
+                        case 6:
+                            if (bDev.KeyEpoint == 13)
+                            {
+                                if (device != null)
+                                {
+                                    if (device.Type == DeviceType.FreshAir && bDev.BindCluster == 514)
+                                    {
+                                        tempList.Remove(bDev.KeyEpoint);
+                                    }
+                                }
+                            }
+                            break;
+                    }
+                }
+            }
+            return tempList;
+        }
+
+
+        /// <summary>
+        /// 鑳芥樉绀虹殑鎴块棿鍒楄〃
+        /// </summary>
+        public static List<Room> GetSupportRoomList(Panel curControlDev, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType)
+        {
+            var roomTempList = new List<Room>();
+            for (int i = 0; i < supportRoomList.Count; i++)
+            {
+                var room = supportRoomList[i];
+                //濡傛灉鎴块棿涓哄枩鐖盵鍚庢潵鏀瑰悕涓哄父鐢ㄦ埧闂碷锛屽垯涓嶆樉绀�
+                if (room.IsLove == true)
+                {
+                    continue;
+                }
+
+                List<CommonDevice> roomIncludeMatchDevice = new List<CommonDevice>();
+                List<SceneUI> roomIncludeMatchScene = new List<SceneUI>();
+                if (curDeviceBindType == 0)
+                {
+                    foreach (var sceneId in room.ListSceneId)
+                    {
+                        var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                        if (scene == null)
+                        {
+                            continue;
+                        }
+                        var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId);
+                        if (tempSc == null)
+                        {
+                            //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                            roomIncludeMatchScene.Add(scene);
+                        }
+                    }
+                }
+                else
+                {
+                    foreach (var de in room.ListDevice)
+                    {
+                        var device = LocalDevice.Current.GetDevice(de);
+                        if (device != null)
+                        {
+                            var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint);
+                            if (tempDev == null)
+                            {
+                                switch (curDeviceBindType)
+                                {
+                                    case 1:
+                                        if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                        {
+                                            if (device.Type != DeviceType.AirSwitch)
+                                            {
+                                                roomIncludeMatchDevice.Add(device);
+                                            }
+                                        }
+                                        break;
+                                    case 2:
+                                        if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                        {
+                                            if (device.Type != DeviceType.AirSwitch)
+                                            {
+                                                roomIncludeMatchDevice.Add(device);
+                                            }
+                                        }
+                                        break;
+                                    case 3:
+                                        if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                        {
+                                            if (device.Type != DeviceType.AirSwitch)
+                                            {
+                                                roomIncludeMatchDevice.Add(device);
+                                            }
+                                        }
+                                        //if (device.Type == DeviceType.DimmableLight)
+                                        //{
+                                        //    roomIncludeMatchDevice.Add(device);
+                                        //}
+                                        break;
+                                    case 4:
+                                        if (device.Type == DeviceType.WindowCoveringDevice)
+                                        {
+                                            roomIncludeMatchDevice.Add(device);
+                                        }
+                                        break;
+                                    case 5:
+                                        if (device.Type == DeviceType.Thermostat)
+                                        {
+                                            if (BindInfo.checkRealAcDevice(device) == false)
+                                            {
+                                                continue;
+                                            }
+                                            roomIncludeMatchDevice.Add(device);
+                                        }
+                                        break;
+                                    case 6:
+                                        if (device.Type == DeviceType.FreshAir)
+                                        {
+                                            if (BindInfo.checkRealFreshAirDevice(device) == false)
+                                            {
+                                                continue;
+                                            }
+                                            roomIncludeMatchDevice.Add(device);
+                                        }
+                                        break;
+                                }
+                            }
+                        }
+                    }
+                }
+
+                if (curDeviceBindType == 0)
+                {
+                    if (room.ListSceneId.Count == 0)
+                    {
+                        continue;
+                    }
+                    if (roomIncludeMatchScene.Count == 0)
+                    {
+                        continue;
+                    }
+                }
+                else
+                {
+                    if (room.ListDevice.Count == 0)
+                    {
+                        continue;
+                    }
+                    if (roomIncludeMatchDevice.Count == 0)
+                    {
+                        continue;
+                    }
+                }
+
+
+                if (!string.IsNullOrEmpty(room.FloorId))
+                {
+                    //鏈夋ゼ灞�
+                    if (room.FloorId == curControlDev.currentSelectFloorId)
+                    {
+                        roomTempList.Add(room);
+                    }
+                }
+                else
+                {
+                    //娌℃湁妤煎眰
+                    roomTempList.Add(room);
+                }
+            }
+            return roomTempList;
+        }
+
+
+        /// <summary>
+        /// 鍖归厤鐨勭被鍨嬬粦瀹氭枃鏈釜鏁版彁绀�
+        /// </summary>
+        /// <param name="curBindType">褰撳墠绫诲瀷 0:鍦烘櫙  1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// <param name="countTemp">寮�鍏冲拰鐏厜鍔ㄦ�佷釜鏁�</param>
+        /// <returns></returns>
+        public static string MatchTypeBindTextTip(int curBindType, int countDynamic = 0)
+        {
+            string[] msgArry = Language.StringByID(R.MyInternationalizationString.AddMoreTip).Split(new string[] { "{0}" }, StringSplitOptions.RemoveEmptyEntries);
+            var tipText = msgArry[0];
+
+            switch (curBindType)
+            {
+                case 0:
+                    //鍦烘櫙鍏�20涓�
+                    var temp0 = 20 - countDynamic;
+                    tipText += temp0 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.scene);
+                    break;
+                case 1:
+                    //寮�鍏冲叡10涓�
+                    var temp1 = 10 - countDynamic;
+                    tipText += temp1 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId13);
+                    break;
+                case 2:
+                    //寮�鍏冲叡10涓�
+                    var temp2 = 10 - countDynamic;
+                    tipText += temp2 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId14);
+                    break;
+                case 3:
+                    //寮�鍏充腑鍙垎閰嶇伅鍏夊姛鑳藉叡10涓紝璋冨厜鍗�7涓�
+                    var temp3 = 17 - countDynamic;
+                    tipText += temp3 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId15);
+                    break;
+                case 4:
+                    //閬槼鍏�8涓�
+                    var temp4 = 8 - countDynamic;
+                    tipText += temp4 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100);
+                    break;
+                case 5:
+                    //绌鸿皟鍏�3涓�
+                    var temp5 = 3 - countDynamic;
+                    tipText += temp5 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId3600);
+                    break;
+                case 6:
+                    //鏂伴鍏�1涓�
+                    var temp6 = 1 - countDynamic;
+                    tipText += temp6 + msgArry[1] + Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2310);
+                    break;
+            }
+            return tipText;
+        }
+
+        /// <summary>
+        /// 鎵�鏈夋埧闂翠腑鍖归厤鐨勬敮鎸佺粦瀹氱殑鎵�鏈夌洰鏍囧垪琛�
+        /// </summary>
+        /// <param name="currentPanelSupportBindDeviceList"></param>
+        /// <param name="supportRoomList"></param>
+        /// <param name="curDeviceBindType">褰撳墠璁惧缁戝畾绫诲瀷 1:寮�鍏�  2:鎻掑骇  3:鐏厜  4:閬槼 5:绌鸿皟 6:鏂伴</param>
+        /// <param name="curBindTypeList">褰撳墠绫诲瀷鐨勭粦瀹氳〃</param> 
+        /// <returns></returns>
+        public static List<CommonDevice> GetAllRoomSupportDeviceList(List<CommonDevice> currentPanelSupportBindDeviceList, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType)
+        {
+            currentPanelSupportBindDeviceList.Clear();
+            List<CommonDevice> currentPanelBindSupportDeviceListTemp = new List<CommonDevice>();
+            foreach (var r in supportRoomList)
+            {
+                if (r.ListDevice.Count == 0)
+                {
+                    continue;
+                }
+                foreach (var deviceKeys in r.ListDevice)
+                {
+                    var device = LocalDevice.Current.GetDevice(deviceKeys);
+                    if (device == null)
+                    {
+                        continue;
+                    }
+                    var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == deviceKeys);
+                    if (tempDev == null)
+                    {
+                        //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                        switch (curDeviceBindType)
+                        {
+                            case 1:
+                                if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                                {
+                                    if (device.Type != DeviceType.AirSwitch)
+                                    {
+                                        currentPanelBindSupportDeviceListTemp.Add(device);
+                                    }
+                                }
+                                break;
+                            case 2:
+                                if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                                {
+                                    if (device.Type != DeviceType.AirSwitch)
+                                    {
+                                        if (device.Type != DeviceType.AirSwitch)
+                                        {
+                                            currentPanelBindSupportDeviceListTemp.Add(device);
+                                        }
+                                    }
+                                }
+
+                                break;
+                            case 3:
+                                if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                                {
+                                    currentPanelBindSupportDeviceListTemp.Add(device);
+                                }
+                                //if (device.Type == DeviceType.DimmableLight)
+                                //{
+                                //    currentPanelBindSupportDeviceListTemp.Add(device);
+                                //}
+                                break;
+                            case 4:
+                                if (device.Type == DeviceType.WindowCoveringDevice)
+                                {
+                                    currentPanelBindSupportDeviceListTemp.Add(device);
+                                }
+                                break;
+                            case 5:
+                                if (device.Type == DeviceType.Thermostat)
+                                {
+                                    if (BindInfo.checkRealAcDevice(device) == false)
+                                    {
+                                        continue;
+                                    }
+                                    currentPanelBindSupportDeviceListTemp.Add(device);
+                                }
+                                break;
+                            case 6:
+                                if (device.Type == DeviceType.FreshAir)
+                                {
+                                    if (BindInfo.checkRealFreshAirDevice(device) == false)
+                                    {
+                                        continue;
+                                    }
+                                    currentPanelBindSupportDeviceListTemp.Add(device);
+                                }
+                                break;
+
+                        }
+                    }
+                }
+            }
+            return currentPanelBindSupportDeviceListTemp;
+        }
+
+        /// <summary>
+        /// 鎵�鏈夋埧闂翠腑鍖归厤鐨勬敮鎸佺粦瀹氱殑鎵�鏈夌洰鏍囧垪琛�
+        /// </summary>
+        /// <param name="currentPanelSupportBindSceneList"></param>
+        /// <param name="supportRoomList"></param>
+        /// <param name="curBindTypeList">褰撳墠绫诲瀷鐨勭粦瀹氳〃</param> 
+        /// <param name="curDeviceBindType">褰撳墠璁惧缁戝畾绫诲瀷 0:鍦烘櫙</param>
+        /// <returns></returns>
+        public static List<SceneUI> GetAllRoomSupportSceneList(List<SceneUI> currentPanelSupportBindSceneList, List<Room> supportRoomList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType = 0)
+        {
+            currentPanelSupportBindSceneList.Clear();
+            List<SceneUI> currentPanelBindSupportSceneListTemp = new List<SceneUI>();
+            foreach (var room in supportRoomList)
+            {
+                //濡傛灉鎴块棿涓哄枩鐖憋紝鍒欎笉鏄剧ず
+                if (room.IsLove == true)
+                {
+                    continue;
+                }
+                //濡傛灉鎴块棿涓病鏈夊満鏅紝鍒欎笉鏄剧ず
+                if (room.ListSceneId.Count == 0)
+                {
+                    continue;
+                }
+                foreach (var sceneId in room.ListSceneId)
+                {
+                    var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                    if (scene == null)
+                    {
+                        continue;
+                    }
+                    var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId);
+                    if (tempSc == null)
+                    {
+                        //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                        currentPanelSupportBindSceneList.Add(scene);
+                    }
+                }
+            }
+            return currentPanelSupportBindSceneList;
+        }
+
+
+        /// <summary>
+        /// 鑾峰彇鏈湴鏈垎閰嶇殑鏀寔褰撳墠绫诲瀷鐨勭粦瀹氳澶囧垪琛�
+        /// </summary>
+        /// <param name="undistruibuteDevList"></param>
+        /// <param name="curBindTypeList"></param>
+        /// <param name="curDeviceBindType">褰撳墠绫诲瀷鐨勭粦瀹氳〃</param>
+        /// <returns></returns>
+        public static List<CommonDevice> GetUndistributeDeviceList(List<CommonDevice> undistruibuteDevList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType)
+        {
+            undistruibuteDevList.Clear();
+            List<CommonDevice> UndistributeCommonDeviceListTemp = new List<CommonDevice>();
+
+            //鑾峰彇鏈湴璁惧鍒楄〃
+            foreach (var tempDev in Shared.Common.LocalDevice.Current.listAllDevice)
+            {
+                //鑾峰彇璁惧鎵�灞炴埧闂�
+                var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
+                if (tempDevRoom == null)
+                {
+                    UndistributeCommonDeviceListTemp.Add(tempDev);
+                }
+            }
+            foreach (var device in UndistributeCommonDeviceListTemp)
+            {
+                var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint);
+                if (tempDev == null)
+                {
+                    //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                    switch (curDeviceBindType)
+                    {
+                        case 1:
+                            if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    undistruibuteDevList.Add(device);
+                                }
+                            }
+                            break;
+                        case 2:
+                            if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    undistruibuteDevList.Add(device);
+                                }
+                            }
+
+                            break;
+                        case 3:
+                            if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    undistruibuteDevList.Add(device);
+                                }
+                            }
+                            break;
+                        case 4:
+                            if (device.Type == DeviceType.WindowCoveringDevice)
+                            {
+                                undistruibuteDevList.Add(device);
+                            }
+                            break;
+                        case 5:
+                            if (device.Type == DeviceType.Thermostat)
+                            {
+                                if (BindInfo.checkRealAcDevice(device) == false)
+                                {
+                                    continue;
+                                }
+                                undistruibuteDevList.Add(device);
+                            }
+                            break;
+                        case 6:
+                            if (device.Type == DeviceType.FreshAir)
+                            {
+                                if (BindInfo.checkRealFreshAirDevice(device) == false)
+                                {
+                                    continue;
+                                }
+                                undistruibuteDevList.Add(device);
+                            }
+                            break;
+
+                    }
+                }
+            }
+
+            return undistruibuteDevList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠鎴块棿涓尮閰嶇殑鏀寔缁戝畾鐨勫満鏅垪琛�
+        /// </summary>
+        /// <returns></returns>
+        public static List<SceneUI> GetCurRoomSupportSceneList(Room curRoom, List<SceneUI> currentRoomSupportBindSceneList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType = 0)
+        {
+            currentRoomSupportBindSceneList.Clear();
+            List<SceneUI> curRoomDeviceListTemp = new List<SceneUI>();
+            foreach (var sceneId in curRoom.ListSceneId)
+            {
+                var tempSc = curBindTypeList.Find(obj => obj.BindScenesId == sceneId);
+                if (tempSc != null)
+                {
+                    //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                    continue;
+                }
+                var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                if (scene != null)
+                {
+                    curRoomDeviceListTemp.Add(scene);
+                }
+            }
+            return curRoomDeviceListTemp;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠鎴块棿涓尮閰嶇殑鏀寔缁戝畾鐨勮澶囧垪琛�
+        /// </summary>
+        /// <returns></returns>
+        public static List<CommonDevice> GetCurRoomSupportDeviceList(Room curRoom, List<CommonDevice> currentRoomSupportBindDeviceList, List<BindListAllInfo> curBindTypeList, int curDeviceBindType)
+        {
+            currentRoomSupportBindDeviceList.Clear();
+            List<CommonDevice> curRoomDeviceListTemp = new List<CommonDevice>();
+            foreach (var deviceKeys in curRoom.ListDevice)
+            {
+                var device = LocalDevice.Current.GetDevice(deviceKeys);
+                if (device != null)
+                {
+                    //鑾峰彇璁惧绫诲瀷鐨�
+                    var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
+                    var tempDev = curBindTypeList.Find(obj => obj.BindMacAddr + obj.BindEpoint == device.DeviceAddr + device.DeviceEpoint);
+                    if (tempDev != null)
+                    {
+                        //琚粦瀹氱洰鏍囦笉鑳藉啀娆″嚭鐜�
+                        continue;
+                    }
+                    switch (curDeviceBindType)
+                    {
+                        case 1:
+                            if (device.DfunctionType == DeviceFunctionType.A寮�鍏�)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    curRoomDeviceListTemp.Add(device);
+                                }
+                            }
+                            break;
+                        case 2:
+                            if (device.DfunctionType == DeviceFunctionType.A鎻掑骇)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    curRoomDeviceListTemp.Add(device);
+                                }
+                            }
+
+                            break;
+                        case 3:
+                            if (device.DfunctionType == DeviceFunctionType.A鐏厜)
+                            {
+                                if (device.Type != DeviceType.AirSwitch)
+                                {
+                                    curRoomDeviceListTemp.Add(device);
+                                }
+                            }
+                            break;
+                        case 4:
+                            if (device.Type == DeviceType.WindowCoveringDevice)
+                            {
+                                if (deviceEnumInfo.ConcreteType != Common.DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+                                {
+                                    curRoomDeviceListTemp.Add(device);
+                                }
+                            }
+                            break;
+                        case 5:
+                            if (device.Type == DeviceType.Thermostat)
+                            {
+                                if (BindInfo.checkRealAcDevice(device) == false)
+                                {
+                                    continue;
+                                }
+                                curRoomDeviceListTemp.Add(device);
+                            }
+                            break;
+                        case 6:
+                            if (device.Type == DeviceType.FreshAir)
+                            {
+                                if (BindInfo.checkRealFreshAirDevice(device) == false)
+                                {
+                                    continue;
+                                }
+                                curRoomDeviceListTemp.Add(device);
+                            }
+                            break;
+
+                    }
+                }
+            }
+            return curRoomDeviceListTemp;
+        }
+
+    }
+}

--
Gitblit v1.8.0