HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-12-30 3dcbd186c42c598c0c08d1cd37034cf2baa09e54
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的时候:【ConcreteType】和【ConcreteTextId】可能会有不同的值</para>
        /// <para>true的时候:【ConcreteType】统一为Sensor,【ConcreteTextId】统一为传感器</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的时候:【ConcreteType】和【ConcreteTextId】可能会有不同的值</para>
        /// <para>true的时候:【ConcreteType】统一为Sensor,【ConcreteTextId】统一为传感器</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>