From 6bca8fcd37a48808a0b9c9342fc1be0adddfece6 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期五, 08 五月 2020 17:46:44 +0800
Subject: [PATCH] 请合并最新代码,优化绑定信息
---
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs | 212 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 155 insertions(+), 57 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
index 427baf6..e52c72f 100644
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirTargetsForm.cs
@@ -16,23 +16,25 @@
/// 鏋勯�犲嚱鏁�
/// </summary>
/// <param name="device"></param>
- /// <param name="deviceBindType">1:鏂伴;2:娓╁害浼犳劅鍣�;3:婀垮害浼犳劅鍣�</param>
- public PanelFangyueFreshAirTargetsForm(CommonDevice device, int deviceBindType)
+ /// <param name="deviceBindType">1:鏂伴;2:娓╁害浼犳劅鍣�;3:婀垮害浼犳劅鍣�;4:PM2.5浼犳劅鍣�</param>
+ /// <param name="bindDev">缁戝畾鐩爣 </param>
+ public PanelFangyueFreshAirTargetsForm(CommonDevice device, CommonDevice bindDev, int deviceBindType)
{
this.curControlDev = device as FreshAir;
+ this.curBindDevice = bindDev;
this.curDeviceBindType = deviceBindType;
}
#endregion
- #region 鍙橀噺鐢虫槑
- /// <summary>
- /// 褰撳墠鎺у埗璁惧
- /// </summary>
- //CommonDevice currentControlDevice;
+ #region 鍙橀噺鐢虫槑
/// <summary>
/// 褰撳墠鏂伴闈㈡澘銆愭帶鍒惰澶囥��
/// </summary>
FreshAir curControlDev;
+ /// <summary>
+ /// 褰撳墠琚粦璁惧
+ /// </summary>
+ CommonDevice curBindDevice;
/// <summary>
/// 鏄剧ず琚粦瀹氳澶囨垨鍦烘櫙鐨剉iew
/// </summary>
@@ -318,6 +320,19 @@
curentOldRoom = btnRoom;
curentOldRoomFrameLayout = btnRoomFrameLayout;
}
+
+ //琚粦瀹氱殑鐩爣杩樻湭鍒嗛厤鍖哄煙锛岄粯璁ゆ槸绗竴涓�
+ if (string.IsNullOrEmpty(curControlDev.currentSelectRoomId))
+ {
+ if (index == 0)
+ {
+ btnRoomFrameLayout.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
+ btnRoom.TextColor = Shared.Common.ZigbeeColor.Current.XMWhite;
+ curentOldRoom = btnRoom;
+ curentOldRoomFrameLayout = btnRoomFrameLayout;
+ }
+ }
+
EventHandler<MouseEventArgs> eHandlerRoom = (sender, e) =>
{
if (!btnRoom.IsSelected)
@@ -450,6 +465,21 @@
line2.Visible = false;
}
+ switch (curDeviceBindType)
+ {
+ case 1:
+ devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png";
+ break;
+ case 2:
+ devicePic.UnSelectedImagePath = "Device/SensorTemperature.png";
+ break;
+ case 3:
+ devicePic.UnSelectedImagePath = "Device/SensorHumidity.png";
+ break;
+ case 4:
+ devicePic.UnSelectedImagePath = "Device/FreshAirEpoint.png";
+ break;
+ }
#endregion
string mianKey = device.DeviceAddr + device.DeviceEpoint;
@@ -608,7 +638,7 @@
btnFloorText.Text = dicFloorList[floorId];
//鑾峰彇妤煎眰涓埧闂村垪琛�
- supportRoomList = GetFloorRoomList(curFloorId);
+ supportRoomList = GetFloorRoomList();
if (!btnMethodText.IsSelected)
{
if (oldbutton != null)
@@ -665,11 +695,13 @@
{
CommonPage.Loading.Start("");
});
+ //鑾峰彇琚粦鐩爣绛変俊鎭�
+ BindDevInfo(curBindDevice);
//鑾峰彇妤煎眰
dicFloorList = HdlRoomLogic.Current.GetFloorSortList();
//鑾峰彇妤煎眰涓埧闂村垪琛�
- supportRoomList = GetFloorRoomList(curControlDev.currentSelectFloorId);
+ supportRoomList = GetFloorRoomList();
//鑾峰彇鎵�鏈夋埧闂翠腑鍖归厤鐨勮兘缁戠殑鐩爣
currentPanelSupportBindDeviceList = GetAllRoomSupportDeviceList();
@@ -725,11 +757,24 @@
case 2:
if (device.Type == DeviceType.TemperatureSensor)
{
- targetList.Add(device);
- oldTargetList.Add(device);
+ var bDev = device as TemperatureSensor;
+ if (bDev.SensorDiv == 1)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
}
break;
case 3:
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var bDev = device as TemperatureSensor;
+ if (bDev.SensorDiv == 2)
+ {
+ targetList.Add(device);
+ oldTargetList.Add(device);
+ }
+ }
if (device.Type == DeviceType.FreshAirHumiditySensor)
{
targetList.Add(device);
@@ -759,6 +804,7 @@
if (targetList.Count == 0)
{
curControlDev.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
+ curControlDev.currentSelectRoomId = null;
if (BindInfo.GetCurrentSelectFloorIdName() != null)
{
Application.RunOnMainThread(() =>
@@ -1141,6 +1187,31 @@
}
/// <summary>
+ /// 褰撳墠琚粦瀹氳澶囨墍灞炴ゼ灞傚拰鎴块棿
+ /// </summary>
+ /// <param name="bindDev"></param>
+ void BindDevInfo(CommonDevice bindDev)
+ {
+ if (bindDev == null)
+ {
+ return;
+ }
+ //鑾峰彇鏈湴璁惧鍒楄〃
+ var localDeviceList = Shared.Common.LocalDevice.Current.listAllDevice;
+ var tempDev = localDeviceList.Find(obj => obj.DeviceAddr == bindDev.DeviceAddr && obj.DeviceEpoint == bindDev.DeviceEpoint);
+ if (tempDev != null)
+ {
+ //鑾峰彇璁惧鎵�灞炴埧闂�
+ var tempDevRoom = HdlRoomLogic.Current.GetRoomByDevice(tempDev);
+ if (tempDevRoom != null)
+ {
+ curControlDev.currentSelectRoomId = tempDevRoom.Id;
+ curControlDev.currentSelectFloorId = tempDevRoom.FloorId;
+ }
+ }
+ }
+
+ /// <summary>
/// 妫�娴嬬洰鏍囨槸鍚﹁缁戝畾杩�
/// </summary>
/// <returns></returns>
@@ -1211,19 +1282,10 @@
}
break;
case 2:
- foreach (var de in room.ListDevice)
- {
- var device = LocalDevice.Current.GetDevice(de);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- roomIncludeMatchDevice.Add(device);
- }
- }
- }
+ roomIncludeMatchDevice = GetMatchTemperatureSensorDevice(room);
break;
case 3:
+ roomIncludeMatchDevice = GetMatchHumiditySensorDevice(room);
foreach (var de in room.ListDevice)
{
var device = LocalDevice.Current.GetDevice(de);
@@ -1244,30 +1306,80 @@
{
continue;
}
- }
- if (!string.IsNullOrEmpty(room.FloorId))
- {
- //鏈夋ゼ灞�
- if (room.FloorId == curControlDev.currentSelectFloorId)
+ if (!string.IsNullOrEmpty(room.FloorId))
{
+ //鏈夋ゼ灞�
+ if (room.FloorId == curControlDev.currentSelectFloorId)
+ {
+ roomTempList.Add(room);
+ }
+ }
+ else
+ {
+ //娌℃湁妤煎眰
roomTempList.Add(room);
}
- }
- else
- {
- //娌℃湁妤煎眰
- roomTempList.Add(room);
}
}
return roomTempList;
}
/// <summary>
+ /// 鍖归厤娓╁害浼犳劅鍣�
+ /// </summary>
+ /// <param name="room"></param>
+ List<CommonDevice> GetMatchTemperatureSensorDevice(Room room)
+ {
+ List<CommonDevice> roomIncludeMatchTempDevice = new List<CommonDevice>();
+ foreach (var de in room.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(de);
+ if (device != null)
+ {
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var dev = device as TemperatureSensor;
+ if (dev.SensorDiv == 1)
+ {
+ roomIncludeMatchTempDevice.Add(device);
+ }
+ }
+ }
+ }
+ return roomIncludeMatchTempDevice;
+ }
+
+ /// <summary>
+ /// 鍖归厤婀垮害浼犳劅鍣�
+ /// </summary>
+ /// <param name="room"></param>
+ List<CommonDevice> GetMatchHumiditySensorDevice(Room room)
+ {
+ List<CommonDevice> roomIncludeMatchHumpDevice = new List<CommonDevice>();
+ foreach (var de in room.ListDevice)
+ {
+ var device = LocalDevice.Current.GetDevice(de);
+ if (device != null)
+ {
+ if (device.Type == DeviceType.TemperatureSensor)
+ {
+ var dev = device as TemperatureSensor;
+ if (dev.SensorDiv == 2)
+ {
+ roomIncludeMatchHumpDevice.Add(device);
+ }
+ }
+ }
+ }
+ return roomIncludeMatchHumpDevice;
+ }
+
+ /// <summary>
/// 鑾峰彇妤煎眰瀵瑰簲鐨勬埧闂村垪琛�
/// </summary>
/// <returns></returns>
- private List<Room> GetFloorRoomList(string floorId)
+ private List<Room> GetFloorRoomList()
{
supportRoomList.Clear();
var supportRoomListTemp = new List<Room>();
@@ -1279,10 +1391,6 @@
{
if (string.IsNullOrEmpty(room.FloorId))
{
- if (room.FloorId != floorId)
- {
- continue;
- }
if (room.IsLove)
{
continue;
@@ -1350,16 +1458,10 @@
{
continue;
}
- foreach (var deviceKeys in r.ListDevice)
+ var deviceListTemp = GetMatchTemperatureSensorDevice(r);
+ foreach (var dev in deviceListTemp)
{
- var device = LocalDevice.Current.GetDevice(deviceKeys);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- currentPanelBindSupportDeviceListTemp.Add(device);
- }
- }
+ currentPanelBindSupportDeviceListTemp.Add(dev);
}
}
break;
@@ -1369,6 +1471,11 @@
if (r.ListDevice.Count == 0)
{
continue;
+ }
+ var deviceListTemp = GetMatchHumiditySensorDevice(r);
+ foreach (var dev in deviceListTemp)
+ {
+ currentPanelBindSupportDeviceListTemp.Add(dev);
}
foreach (var deviceKeys in r.ListDevice)
{
@@ -1420,19 +1527,10 @@
}
break;
case 2:
- foreach (var deviceKeys in curRoom.ListDevice)
- {
- var device = LocalDevice.Current.GetDevice(deviceKeys);
- if (device != null)
- {
- if (device.Type == DeviceType.TemperatureSensor)
- {
- curRoomDeviceListTemp.Add(device);
- }
- }
- }
+ curRoomDeviceListTemp = GetMatchTemperatureSensorDevice(curRoom);
break;
case 3:
+ curRoomDeviceListTemp = GetMatchHumiditySensorDevice(curRoom);
foreach (var deviceKeys in curRoom.ListDevice)
{
var device = LocalDevice.Current.GetDevice(deviceKeys);
--
Gitblit v1.8.0