gxc
2019-12-13 eb424d24e39bab4a245725f35deab3f234ea0f13
ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
@@ -72,8 +72,8 @@
        public override void RemoveFromParent()
        {
            HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
            HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
            HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
            CommonPage.Instance.IsDrawerLockMode = false;
            base.RemoveFromParent();
@@ -162,31 +162,32 @@
            var floorRow = new DeviceInfoRow(308);
            floorRow.Init();
            floorRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongFloor)} :");
            infoFL.AddChidren(floorRow);
            if (!room.IsLove)
            if (Config.Instance.Home.FloorDics.Count > 0 && room.IsLove == false)
            {
                floorRow.SetTitle(room.FloorName);
                floorRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
                {
                    if (Config.Instance.Home.FloorDics != null)
                    {
                        List<string> floorIds = new List<string> { };
                        List<string> floorNames = new List<string> { };
                        foreach (var floor in Config.Instance.Home.FloorDics)
                        {
                            floorIds.Add(floor.Key);
                            floorNames.Add(floor.Value);
                        }
                        PickerView.Show(floorNames, (index) =>
                        {
                            room.FloorId = floorIds[index];
                            floorRow.SetTitle(room.FloorName);
                        }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
                    }
                };
                infoFL.AddChidren(floorRow);
            }
            floorRow.SetTitle(room.FloorName);
            floorRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (Config.Instance.Home.FloorDics != null)
                {
                    List<string> floorIds = new List<string> { };
                    List<string> floorNames = new List<string> { };
                    foreach (var floor in Config.Instance.Home.FloorDics)
                    {
                        floorIds.Add(floor.Key);
                        floorNames.Add(floor.Value);
                    }
                    PickerView.Show(floorNames, (index) =>
                    {
                        room.FloorId = floorIds[index];
                        floorRow.SetTitle(room.FloorName);
                    }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
                }
            };
            var temperatureRow = new DeviceInfoRow(446);
            temperatureRow.Init();
            temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature);
@@ -207,8 +208,8 @@
                    }
                    room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
                    HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                    HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) =>
                    HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
                    HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice",  ReceiveComandDiv.A设备属性上报, (Action<ZigBee.Device.CommonDevice>)((report) =>
                    {
                        string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                        if (room.TemperatrueDevice != mainKeys)
@@ -216,7 +217,7 @@
                            return;
                        }
                        //移除掉事件
                        HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                        HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
                        foreach (var data in report.DeviceStatusReport.AttriBute)
                        {
@@ -249,11 +250,10 @@
                    (selectTemp as ZigBee.Device.TemperatureSensor).ReadTemperatureOrHumidity();
                };
            };
            if (string.IsNullOrEmpty(room.TemperatrueDevice) == false)
            {
                HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) =>
                HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
                HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice",  ReceiveComandDiv.A设备属性上报, (Action<ZigBee.Device.CommonDevice>)((report) =>
                {
                    string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                    if (room.TemperatrueDevice != mainKeys)
@@ -261,7 +261,7 @@
                        return;
                    }
                    //移除掉事件
                    HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                    HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice");
                    foreach (var data in report.DeviceStatusReport.AttriBute)
                    {
@@ -298,6 +298,7 @@
                }
            }
            var humidityRow = new DeviceInfoRow(585);
            humidityRow.Init();
            humidityRow.SetTipTitle(R.MyInternationalizationString.Humidity);
@@ -318,8 +319,8 @@
                    }
                    room.HumidityDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
                    HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
                    HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) =>
                    HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
                    HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice",  ReceiveComandDiv.A设备属性上报, (report) =>
                    {
                        string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                        if (room.HumidityDevice != mainKeys)
@@ -327,7 +328,7 @@
                            return;
                        }
                        //移除掉事件
                        HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
                        HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
                        foreach (var data in report.DeviceStatusReport.AttriBute)
                        {
                            if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
@@ -353,8 +354,8 @@
            };
            if (string.IsNullOrEmpty(room.HumidityDevice) == false)
            {
                HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
                HdlDeviceAttributeLogic.Current.AddAttributeEvent("HumidityDevice", "DeviceStatusReport", (report) =>
                HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
                HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice",  ReceiveComandDiv.A设备属性上报, (report) =>
                {
                    string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                    if (room.HumidityDevice != mainKeys)
@@ -362,7 +363,7 @@
                        return;
                    }
                    //移除掉事件
                    HdlDeviceAttributeLogic.Current.RemoveEvent("HumidityDevice");
                    HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice");
                    foreach (var data in report.DeviceStatusReport.AttriBute)
                    {
                        if (data.AttributeId == (int)ZigBee.Device.AttriButeId.MeasuredValue)
@@ -390,6 +391,11 @@
                }
            }
            if (Config.Instance.Home.FloorDics.Count == 0 || room.IsLove)
            {
                temperatureRow.Y = Application.GetRealHeight(308);
                humidityRow.Y= Application.GetRealHeight(446);
            }
            var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127);
            confirm.SetTitle(R.MyInternationalizationString.Confrim);