From 0e4ad9a4de5b95f58daf1a6c5072c6a57cf223f9 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期一, 30 十二月 2019 10:02:10 +0800 Subject: [PATCH] 2019.12.30 --- ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 53 ++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 36 insertions(+), 17 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs index 7ed1c76..0d012e2 100644 --- a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs +++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs @@ -16,10 +16,16 @@ /// </summary> public Action action; + FrameLayout roomNameBackground; + + FrameLayout roomTemperatureBackground; + + Button roomListBtn; + public override void RemoveFromParent() { - HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); - HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice" + room.Id); + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice" + room.Id); base.RemoveFromParent(); } @@ -58,7 +64,7 @@ }; roomBackView.AddChidren(roomImg); - var roomNameBackground = new FrameLayout + roomNameBackground = new FrameLayout { X = Application.GetRealWidth(29), Y = Application.GetRealHeight(282), @@ -79,11 +85,11 @@ roomNameBackground.AddChidren(roomName); - var roomTemperatureBackground = new FrameLayout + roomTemperatureBackground = new FrameLayout { X = Application.GetRealWidth(29), Y = Application.GetRealHeight(374), - Width = Application.GetRealWidth(340), + Width = Application.GetRealWidth(400), Height = Application.GetRealHeight(80), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor2 }; @@ -103,16 +109,16 @@ var temperatureText = new Button { X = Application.GetRealWidth(69), - Width = Application.GetRealWidth(86), + Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(58), Gravity = Gravity.CenterVertical, - Text = "26鈩�" + Text = $"{room.Temperatrue}鈩�" }; roomTemperatureBackground.AddChidren(temperatureText); var humidityIcon = new Button { - X = Application.GetRealWidth(179), + X = Application.GetRealWidth(200), Width = Application.GetMinRealAverage(58), Height = Application.GetMinRealAverage(58), Gravity = Gravity.CenterVertical, @@ -122,19 +128,19 @@ var humidityText = new Button { - X = Application.GetRealWidth(236), - Width = Application.GetRealWidth(86), + X = Application.GetRealWidth(260), + Width = Application.GetRealWidth(120), Height = Application.GetRealHeight(58), Gravity = Gravity.CenterVertical, - Text = "13%" + Text = $"{room.Humidity}%" }; roomTemperatureBackground.AddChidren(humidityText); if (string.IsNullOrEmpty(room.TemperatrueDevice) == false) { - HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice"); - HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (Action<ZigBee.Device.CommonDevice>)((report) => + HdlGatewayReceiveLogic.Current.RemoveEvent("TemperatrueDevice" + room.Id); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("TemperatrueDevice" + room.Id, ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.TemperatrueDevice != mainKeys) @@ -152,6 +158,7 @@ { //0鈩� temperatureText.Text = "0.0鈩�"; + room.Temperatrue = 0; } else if (data.AttriButeData > 32767) { @@ -160,6 +167,7 @@ //灏忔暟鐐归渶瑕佷竴浣� strValue = strValue.Substring(0, strValue.Length - 1); temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) * 0.1; } else { @@ -167,10 +175,11 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); temperatureText.Text = strValue.Insert(strValue.Length - 1, ".") + "鈩�"; + room.Temperatrue = int.Parse(strValue) * 0.1; } } } - })); + }); //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护 var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice); if (dev != null) @@ -181,8 +190,8 @@ if (string.IsNullOrEmpty(room.HumidityDevice) == false) { - HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"); - HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice", ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => + HdlGatewayReceiveLogic.Current.RemoveEvent("HumidityDevice"+room.Id); + HdlGatewayReceiveLogic.Current.AddAttributeEvent("HumidityDevice" + room.Id, ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) => { string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report); if (room.HumidityDevice != mainKeys) @@ -199,6 +208,7 @@ { //0 humidityText.Text = "0.0%"; + room.Humidity = 0; } else { @@ -206,6 +216,7 @@ string strValue = data.AttriButeData.ToString(); strValue = strValue.Substring(0, strValue.Length - 1); humidityText.Text = strValue.Insert(strValue.Length - 1, ".") + "%"; + room.Humidity = int.Parse(strValue) * 0.1; } } } @@ -218,7 +229,8 @@ } } - var roomListBtn = new Button() + + roomListBtn = new Button() { X = roomBackView.Width - Application.GetRealWidth(100 + 20), Y = Application.GetRealHeight(20), @@ -240,7 +252,14 @@ action?.Invoke(); }; }; + } + /// <summary> + /// HideName + /// </summary> + public void HideName(bool statu) + { + roomNameBackground.Visible = roomTemperatureBackground.Visible = roomListBtn.Visible = !statu; } } } -- Gitblit v1.8.0