From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 07 五月 2020 10:40:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm
---
ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 268 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
new file mode 100755
index 0000000..9a5f16c
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/RoomView.cs
@@ -0,0 +1,268 @@
+锘縰sing System;
+using Shared.Common;
+using Shared.Phone.UserCenter;
+using ZigBee.Device;
+
+namespace Shared.Phone.Device.CommonForm
+{
+ public class RoomView : FrameLayoutBase
+ {
+ /// <summary>
+ /// Room
+ /// </summary>
+ private Common.Room room;
+
+ FrameLayout roomNameBackground;
+
+ FrameLayout roomTemperatureBackground;
+
+ Button roomListBtn;
+
+ Button temperatureText;
+
+ Button humidityText;
+ /// <summary>
+ /// 娓╁害璁惧
+ /// </summary>
+ private CommonDevice temperDevice = null;
+ /// <summary>
+ /// 婀垮害璁惧
+ /// </summary>
+ private CommonDevice humidDevice = null;
+
+ /// <summary>
+ /// RoomView
+ /// </summary>
+ /// <param name="x"></param>
+ /// <param name="y"></param>
+ public RoomView(int x, int y)
+ {
+ X = Application.GetRealWidth(x);
+ Y = Application.GetRealHeight(y);
+ Width = Application.GetRealWidth(717);
+ Height = Application.GetRealHeight(478);
+ }
+
+ /// <summary>
+ /// Init
+ /// </summary>
+ /// <param name="r"></param>
+ public void Init(Common.Room r)
+ {
+ this.RemoveAll();
+
+ this.room = r;
+
+ this.temperDevice = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
+
+ this.humidDevice = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
+
+ var roomBackView = new FrameLayout()
+ {
+ Width = Application.GetRealWidth(717),
+ Height = Application.GetRealHeight(478),
+ Radius = (uint)Application.GetRealHeight(17),
+ Tag = "R"
+ };
+ AddChidren(roomBackView);
+
+ var roomImg = new ImageView()
+ {
+ ImagePath = room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage),
+ Radius = (uint)Application.GetRealHeight(17),
+ Tag = "R"
+ };
+ roomBackView.AddChidren(roomImg);
+
+ //鍔犱釜鐗规畩鐨勯伄缃�
+ var frameBackGroudTemp = new FrameLayout();
+ frameBackGroudTemp.Width = roomBackView.Width;
+ frameBackGroudTemp.Height = roomBackView.Height;
+ frameBackGroudTemp.Radius = (uint)Application.GetRealHeight(17);
+ frameBackGroudTemp.BackgroundColor = UserCenterColor.Current.PictrueZhezhaoColor;
+ roomBackView.AddChidren(frameBackGroudTemp);
+
+ roomNameBackground = new FrameLayout
+ {
+ X = Application.GetRealWidth(29),
+ Y = Application.GetRealHeight(282),
+ Width = Application.GetRealWidth(200),
+ Height = Application.GetRealHeight(80),
+ BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor2
+ };
+ roomBackView.AddChidren(roomNameBackground);
+ roomNameBackground.SetCornerWithSameRadius(Application.GetRealHeight(40), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
+
+ var roomName = new Button()
+ {
+ X = Application.GetRealWidth(29),
+ Width = Application.GetRealWidth(190),
+ Text = room.Name,
+ TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
+ TextSize = 10,
+ TextAlignment = TextAlignment.CenterLeft,
+ IsBold = true
+ };
+ roomNameBackground.AddChidren(roomName);
+ roomNameBackground.Width = (roomName.GetTextWidth() + Application.GetRealWidth(100)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : roomName.GetTextWidth() + Application.GetRealWidth(100);
+ roomName.Width = roomNameBackground.Width - Application.GetRealWidth(40);
+
+ roomTemperatureBackground = new FrameLayout
+ {
+ X = Application.GetRealWidth(29),
+ Y = Application.GetRealHeight(374),
+ Width = Application.GetRealWidth(400),
+ Height = Application.GetRealHeight(80),
+ BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor2
+ };
+ roomBackView.AddChidren(roomTemperatureBackground);
+ roomTemperatureBackground.SetCornerWithSameRadius(Application.GetRealHeight(40), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
+
+ var temperatureIcon = new Button
+ {
+ X = Application.GetRealWidth(12),
+ Width = this.GetPictrueRealSize(58),
+ Height = this.GetPictrueRealSize(58),
+ Gravity = Gravity.CenterVertical,
+ UnSelectedImagePath = "Room/Temperature.png"
+ };
+ roomTemperatureBackground.AddChidren(temperatureIcon);
+
+ temperatureText = new Button
+ {
+ X = Application.GetRealWidth(69),
+ Width = Application.GetRealWidth(120),
+ Text = "--鈩�",
+ TextSize = 14,
+ TextAlignment = TextAlignment.CenterLeft
+ };
+ if (LocalDevice.Current.GetDevice(room.TemperatrueDevice) != null)
+ {
+ //杩欎釜璁惧瑕佸瓨鍦ㄦ湰鍦版墠琛�
+ temperatureText.Text = room.Temperatrue == 0 ? "0.0鈩�" : room.Temperatrue.ToString() + "鈩�";
+ }
+ roomTemperatureBackground.AddChidren(temperatureText);
+ temperatureText.Width = temperatureText.GetTextWidth() + Application.GetRealWidth(60);
+
+ var humidityIcon = new Button
+ {
+ X = temperatureText.Right,
+ Width = this.GetPictrueRealSize(58),
+ Height = this.GetPictrueRealSize(58),
+ Gravity = Gravity.CenterVertical,
+ UnSelectedImagePath = "Room/Humidity.png"
+ };
+ roomTemperatureBackground.AddChidren(humidityIcon);
+
+ humidityText = new Button
+ {
+ X = humidityIcon.Right,
+ Width = Application.GetRealWidth(120),
+ Text = "--%",
+ TextSize = 14,
+ TextAlignment = TextAlignment.CenterLeft
+ };
+ if (LocalDevice.Current.GetDevice(room.HumidityDevice) != null)
+ {
+ //杩欎釜璁惧瑕佸瓨鍦ㄦ湰鍦版墠琛�
+ humidityText.Text = room.Humidity == 0 ? "0.0%" : room.Humidity.ToString() + "%";
+ }
+ roomTemperatureBackground.AddChidren(humidityText);
+ humidityText.Width = humidityText.GetTextWidth() + Application.GetRealWidth(60);
+ roomTemperatureBackground.Width = (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150)) > Application.GetRealWidth(600) ? Application.GetRealWidth(600) : (humidityText.Width + temperatureText.Width + Application.GetRealWidth(150));
+
+ if (string.IsNullOrEmpty(room.TemperatrueDevice) == false)
+ {
+ //鍙戦�佽幏鍙栨俯搴︾殑鍛戒护
+ var dev = Common.LocalDevice.Current.GetDevice(room.TemperatrueDevice);
+ HdlDeviceAttributeLogic.Current.SendTemperatureStatuComand(dev);
+ }
+
+ if (string.IsNullOrEmpty(room.HumidityDevice) == false)
+ {
+ var dev = Common.LocalDevice.Current.GetDevice(room.HumidityDevice);
+ HdlDeviceAttributeLogic.Current.SendHumidityStatuComand(dev);
+ }
+
+ roomListBtn = new Button()
+ {
+ X = roomBackView.Width - Application.GetRealWidth(100 + 20),
+ Y = Application.GetRealHeight(20),
+ Width = this.GetPictrueRealSize(100),
+ Height = this.GetPictrueRealSize(100),
+ UnSelectedImagePath = "Room/List.png",
+ };
+ roomBackView.AddChidren(roomListBtn);
+
+ roomListBtn.MouseUpEventHandler += (send, e) =>
+ {
+ CommonPage.Instance.IsDrawerLockMode = true;
+
+ var form = new UserCenter.Residence.EditorRoomInforForm();
+ form.AddForm(room);
+ form.FinishEditorEvent += (roomName2) =>
+ {
+ //閲嶆柊鍒锋柊鎺т欢
+ this.Init(this.room);
+ };
+ };
+ //璁惧灞炴�т笂鎶�
+ HdlGatewayReceiveLogic.Current.AddAttributeEvent("RoomView" + this.room.Id, ReceiveComandDiv.A璁惧灞炴�т笂鎶�, (report) =>
+ {
+ if (this.temperDevice != null)
+ {
+ //娓╁害璁惧
+ if (report.DeviceAddr == temperDevice.DeviceAddr && report.DeviceEpoint == temperDevice.DeviceEpoint)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ if (((TemperatureSensor)temperDevice).Temperatrue == 0)
+ {
+ temperatureText.Text = "0.0鈩�";
+ }
+ else
+ {
+ temperatureText.Text = ((TemperatureSensor)temperDevice).Temperatrue + "鈩�";
+ }
+ }, ShowErrorMode.NO);
+ }
+ }
+ if (this.humidDevice != null)
+ {
+ //婀垮害璁惧
+ if (report.DeviceAddr == humidDevice.DeviceAddr && report.DeviceEpoint == humidDevice.DeviceEpoint)
+ {
+ HdlThreadLogic.Current.RunMain(() =>
+ {
+ if (((TemperatureSensor)temperDevice).Humidity == 0)
+ {
+ humidityText.Text = "--%";
+ }
+ else
+ {
+ humidityText.Text = ((TemperatureSensor)temperDevice).Humidity + "%";
+ }
+ }, ShowErrorMode.NO);
+ }
+ }
+ });
+ }
+
+ /// <summary>
+ /// HideName
+ /// </summary>
+ public void HideName(bool statu)
+ {
+ roomNameBackground.Visible = roomTemperatureBackground.Visible = roomListBtn.Visible = !statu;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public override void RemoveFromParent()
+ {
+ HdlGatewayReceiveLogic.Current.RemoveEvent("RoomView" + this.room.Id);
+ base.RemoveFromParent();
+ }
+ }
+}
--
Gitblit v1.8.0