From 3dcbd186c42c598c0c08d1cd37034cf2baa09e54 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 30 十二月 2019 15:47:51 +0800 Subject: [PATCH] 合并了代码 --- ZigbeeApp/Shared/Common/Device.cs | 106 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 68 insertions(+), 38 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Device.cs b/ZigbeeApp/Shared/Common/Device.cs index 1a25f6f..bd14933 100755 --- a/ZigbeeApp/Shared/Common/Device.cs +++ b/ZigbeeApp/Shared/Common/Device.cs @@ -1046,10 +1046,21 @@ /// <param name="listdevice">璁惧瀵硅薄</param> public void SetRealDeviceIconToControl(Button btnIcon, List<CommonDevice> listdevice) { + //鑾峰彇璁惧鐨勭湡瀹炲浘鐗� + string imagePath = this.GetRealDeviceIcon(listdevice); + btnIcon.UnSelectedImagePath = imagePath; + } + + /// <summary> + /// 鑾峰彇璁惧鐨勭湡瀹炲浘鐗� + /// </summary> + /// <param name="listdevice">璁惧瀵硅薄</param> + public string GetRealDeviceIcon(List<CommonDevice> listdevice) + { //鑾峰彇瀹冨睘浜庝粈涔堢被鍨嬬殑璁惧 var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); string strConcrete = Enum.GetName(typeof(DeviceConcreteType), myDeviceType.ConcreteType); - + //鍥剧墖鍏辨湁 if (this.dicPictrueShard.ContainsKey(strConcrete) == true) { @@ -1067,7 +1078,7 @@ if (arry.Length == 1) { //濡傛灉瀹冭嚜宸卞氨鏄叡閫氬浘鐗囩殑璇濓紝涓嶅啀澶勭悊 - return; + return "RealDevice/CommonDevice.png"; } imageFilePath = "RealDevice/" + arry[0] + ".png"; //濡傛灉瀹冭嚜宸辩殑鍏遍�氬浘鐗囪繕鏄笉瀛樺湪鐨勮瘽,鍒欑洿鎺ヤ娇鐢ㄦ墍鏈夎澶囩殑鍏遍�氬浘鐗� @@ -1076,16 +1087,16 @@ imageFilePath = "RealDevice/CommonDevice.png"; } } - btnIcon.UnSelectedImagePath = imageFilePath; + return imageFilePath; } /// <summary> - /// 璁剧疆銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢 + /// 璁剧疆銆愯澶囩被鍨嬨�戠殑鍥炬爣鍒版寚瀹氱殑鎺т欢 /// </summary> /// <param name="btnIcon">鎺т欢瀵硅薄</param> /// <param name="listdevice">璁惧瀵硅薄</param> /// <returns></returns> - public void SetDeviceBeloneIconToControl(Button btnIcon, List<CommonDevice> listdevice) + public void SetDeviceObjectIconToControl(Button btnIcon, List<CommonDevice> listdevice) { //鑾峰彇鑷畾涔夎澶囩被鍨� var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); @@ -1093,8 +1104,8 @@ string imageUnSelectFilePath = string.Empty; string imageSelectFilePath = string.Empty; - //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 - this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath); + //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 + this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref imageUnSelectFilePath, ref imageSelectFilePath); //璁剧疆鍥剧墖 btnIcon.UnSelectedImagePath = imageUnSelectFilePath; @@ -1102,29 +1113,29 @@ } /// <summary> - /// 鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 + /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 /// </summary> /// <param name="listdevice">璁惧瀵硅薄</param> /// <param name="unSelectPath">鍥剧墖鍦板潃</param> /// <param name="selectPath">鍥剧墖鍦板潃</param> /// <returns></returns> - public void GetDeviceBeloneIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath) + public void GetDeviceObjectIcon(List<CommonDevice> listdevice, ref string unSelectPath, ref string selectPath) { //鑾峰彇鑷畾涔夎澶囩被鍨� var myDeviceType = this.GetMyDeviceEnumInfo(listdevice); - //鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 - this.GetDeviceBeloneIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath); + //鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 + this.GetDeviceObjectIcon(myDeviceType.ConcreteType, ref unSelectPath, ref selectPath); } /// <summary> - /// 鑾峰彇銆愯澶囨墍灞炵被鍨嬨�戠殑鍥炬爣 + /// 鑾峰彇銆愯澶囩被鍨嬨�戠殑鍥炬爣 /// </summary> /// <param name="specificType">鑷畾涔夎澶囩被鍨�</param> /// <param name="unSelectPath">鍥剧墖鍦板潃</param> /// <param name="selectPath">鍥剧墖鍦板潃</param> /// <returns></returns> - public void GetDeviceBeloneIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) + public void GetDeviceObjectIcon(DeviceConcreteType specificType, ref string unSelectPath, ref string selectPath) { //灏嗗叿浣撶被鍨嬭浆瀛楃涓� string strSpecific = Enum.GetName(typeof(DeviceConcreteType), specificType); @@ -1222,7 +1233,7 @@ return info; } //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - return this.GetNotHdlMyDeviceEnumInfo(listdevice, false); + return this.GetNotHdlMyDeviceEnumInfo(listdevice); } /// <summary> @@ -1252,7 +1263,7 @@ else { //鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� - var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice, false); + var myDeviceType = this.GetNotHdlMyDeviceEnumInfo(listDevice); strName = Language.StringByID(myDeviceType.ConcreteTextId); } if (ApendFalge == true && listDevice[0].DriveCode > 0) @@ -1318,31 +1329,53 @@ #region 鈻� 鑾峰彇绗笁鏂硅澶囩殑璁惧绫诲瀷___________ /// <summary> - /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨�� + /// 鑾峰彇璁惧鐨勩�愭墍灞炵被鍨嬩俊鎭��,姝ゆ柟娉曚細鎶婃墍鏈夌殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�(鍖呮嫭娓╂箍搴︿紶鎰熷櫒) /// </summary> /// <param name="device">璁惧鍥炶矾</param> - /// <param name="margeSensor"> - /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para> - /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para> - /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para> - /// </param> /// <returns></returns> - public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(CommonDevice device, bool margeSensor = true) + public DeviceEnumInfo GetDeviceBelongEnumInfo(CommonDevice device) { - return this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device }, margeSensor); + var info = this.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice>() { device }); + if (info.BeloneType == DeviceBeloneType.A璋冨厜鍣� + || info.BeloneType == DeviceBeloneType.A褰╃伅) + { + //褰掍负鐏厜 + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId15; + info.BeloneType = DeviceBeloneType.A鐏厜; + info.ConcreteType = DeviceConcreteType.Light; + + int value = (int)info.BeloneType; + if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true) + { + //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧 + info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value]; + } + } + else if (info.BeloneType == DeviceBeloneType.A浼犳劅鍣� + || device.Type == DeviceType.TemperatureSensor) + { + //浼犳劅鍣ㄥ悎骞� + info.BeloneType = DeviceBeloneType.A浼犳劅鍣�; + info.ConcreteType = DeviceConcreteType.Sensor; + info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200; + + int value = (int)info.BeloneType; + if (dicDeviceDefultNameID.ContainsKey("uDeviceBelongId" + value) == true) + { + //璁惧鎵�灞炵被鍨嬬殑缈昏瘧鍚嶅瓧 + info.BeloneTextId = dicDeviceDefultNameID["uDeviceBelongId" + value]; + } + } + + return info; } /// <summary> /// 鑾峰彇绗笁鏂硅澶囩殑銆愯澶囩被鍨嬨��(涓嶅缓璁娇鐢�) /// </summary> /// <param name="listdevice">Mac閮戒竴鏍风殑璁惧鍒楄〃</param> - /// <param name="margeSensor"> - /// <para>鏄惁灏嗘墍鏈夌被鍨嬬殑浼犳劅鍣ㄩ兘褰掍负銆愪紶鎰熷櫒銆�,</para> - /// <para>false鐨勬椂鍊欙細銆怌oncreteType銆戝拰銆怌oncreteTextId銆戝彲鑳戒細鏈変笉鍚岀殑鍊�</para> - /// <para>true鐨勬椂鍊欙細銆怌oncreteType銆戠粺涓�涓篠ensor,銆怌oncreteTextId銆戠粺涓�涓轰紶鎰熷櫒</para> - /// </param> /// <returns></returns> - public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice, bool margeSensor = true) + public DeviceEnumInfo GetNotHdlMyDeviceEnumInfo(List<CommonDevice> listdevice) { var dicType = new Dictionary<DeviceType, CommonDevice>(); foreach (CommonDevice device in listdevice) @@ -1479,11 +1512,8 @@ info.BeloneType = DeviceBeloneType.A浼犳劅鍣�; info.ConcreteType = DeviceConcreteType.Sensor; info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId1200; - if (margeSensor == false) - { - //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 - this.SetSensorDeviceSpecificType(ref info, listdevice); - } + //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 + this.SetSensorDeviceSpecificType(ref info, listdevice); } //13鍖呭惈娓╁害浼犳劅鍣ㄧ殑璇� else if (dicType.ContainsKey(DeviceType.TemperatureSensor) == true) @@ -1513,14 +1543,14 @@ //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 info.BeloneType = DeviceBeloneType.A娓╂箍搴︿紶鎰熷櫒; info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId10; - info.ConcreteType = DeviceConcreteType.Sensor_TemperatrueHumidity; + info.ConcreteType = DeviceConcreteType.Sensor_TemperatureHumidity; } else if (temperatrue == true && humidity == false) { //璁剧疆浼犳劅鍣ㄥ叿浣撶殑绫诲瀷 info.BeloneType = DeviceBeloneType.A娓╁害浼犳劅鍣�; info.ConcreteTextId = R.MyInternationalizationString.uDeviceBelongId11; - info.ConcreteType = DeviceConcreteType.Sensor_Temperatrue; + info.ConcreteType = DeviceConcreteType.Sensor_Temperature; } else if (temperatrue == false && humidity == true) { @@ -2324,11 +2354,11 @@ /// <summary> /// 娓╂箍搴︿紶鎰熷櫒 /// </summary> - Sensor_TemperatrueHumidity = -1308, + Sensor_TemperatureHumidity = -1308, /// <summary> /// 娓╁害浼犳劅鍣� /// </summary> - Sensor_Temperatrue = -1309, + Sensor_Temperature = -1309, /// <summary> /// 婀垮害浼犳劅鍣� /// </summary> -- Gitblit v1.8.0