using System;
|
using System.Collections.Generic;
|
using System.Threading;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserRoom : FrameLayout
|
{
|
Room room;
|
string roomFilePath;
|
List<string> showList;
|
VerticalScrolViewLayout RoomView;
|
static UserRoom curView = null;
|
|
|
Thread readEnergyThead;
|
bool readEnergy = false;
|
List<Common> EnergtLightList = new List<Common> ();
|
static string AirQCity = "";
|
static string AirQTemp = "";
|
static string AirQHumidityIcon = "";
|
static string AirQHumidity = "";
|
static string AirQAirIcon = "";
|
static string AirQAirPM25 = "";
|
static string AirQAirPM25Icon = "";
|
static uint AirLineNullBackgroundColor = SkinStyle.Current.Transparent;
|
|
public UserRoom ()
|
{
|
Height = Application.GetRealHeight (1136);
|
showList = new List<string> ();
|
}
|
|
/// <summary>
|
/// 更新能源设备数据
|
/// </summary>
|
/// <param name="updataType">更新类型(bit0-bit5) 2: 电压 3: 电流 10:功率 11:电能 (BIT 6-7 0:2bytes 1:1bytes 2:4bytes)</param>
|
/// <param name="updataFlag">更新的设备标记</param>
|
/// <param name="energy">更新的值</param>
|
public static void UpdataEnergy (int updataType, string updataFlag, int energy)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
if (curView.RoomView.Decelerating) {
|
return;
|
}
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var lightRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = lightRow.Tag;
|
if (o != null && o.ToString () == updataFlag) {
|
for (int j = 0; j < lightRow.ChildrenCount; j++) {
|
if (lightRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)lightRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (updataType == 10) {
|
if (btn.Tag.ToString () == DeviceType.LightEnergySocket.ToString () + "_Voltage" || btn.Tag.ToString () == DeviceType.LightEnergySwitch.ToString () + "_Voltage") {
|
btn.Text = energy.ToString () + " W";
|
}
|
}
|
//2020-07-01 客户提出隐藏kwh
|
//else if (updataType == 11) {
|
// if (btn.Tag.ToString () == DeviceType.LightEnergySocket.ToString () + "_Electric" || btn.Tag.ToString () == DeviceType.LightEnergySwitch.ToString () + "_Electric") {
|
// btn.Text = ((double)(Convert.ToDouble (energy) / 10)).ToString () + " kw.h";
|
// }
|
//}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
public static void UpdataDeviceStatus (Common common)
|
{
|
_ = System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
//Application.RunOnMainThread (() => {
|
// MainPage.Loading.Start ("Please wait...");
|
//});
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var deviceRow = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = deviceRow.Tag;
|
if (o != null && deviceRow.Tag.ToString () == common.Type + "_" + common.CommonLoopID) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (common.Type == DeviceType.LightCCT || common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightDALI || common.Type == DeviceType.LightRGBW ||
|
common.Type == DeviceType.LightLogic || common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightDimming ||
|
common.Type == DeviceType.LightMixSwitch || common.Type == DeviceType.LightMixDimming ||
|
common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySwitch || common.Type == DeviceType.LightEnergySocket || common.Type == DeviceType.FanModule) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
try {
|
if (common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightLogic) {
|
if ((common as LightLogic).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
if (btn.Tag == "Values") {
|
btn.Text = (common as LightLogic).CurrentBrightness.ToString () + "%";
|
}
|
} else if (common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightMixSwitch
|
|| common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySwitch || common.Type == DeviceType.LightEnergySocket) {
|
if ((common as LightSwitch).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
if (btn.Tag == "Values") {
|
btn.Text = (common as LightSwitch).CurrentBrightness.ToString () + "%";
|
}
|
} else if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightDALI) {
|
if ((common as LightDimming).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
if (btn.Tag == "Values") {
|
btn.Text = (common as LightDimming).CurrentBrightness.ToString () + "%";
|
}
|
} else if (common.Type == DeviceType.FanModule) {
|
if ((common as FanModule).WindSpeed == 0 || (common as FanModule).Switch == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
} catch {
|
}
|
} else if (deviceRow.GetChildren (j).GetType () == typeof (HorizontalSeekBar)) {//&& 3 < (DateTime.Now - (DateTime)deviceRow.GetChildren (j).Tag).TotalSeconds) {
|
var curTtt = 0;
|
if (common.Type == DeviceType.LightRGB || common.Type == DeviceType.LightLogic) {
|
curTtt = (common as LightLogic).CurrentBrightness;
|
} else if (common.Type == DeviceType.LightDimming || common.Type == DeviceType.LightMixDimming || common.Type == DeviceType.LightDALI) {
|
curTtt = (common as LightDimming).CurrentBrightness;
|
}
|
(deviceRow.GetChildren (j) as HorizontalSeekBar).Progress = curTtt;
|
if (curTtt > 0) {
|
(deviceRow.GetChildren (j) as HorizontalSeekBar).ThumbColor = SkinStyle.Current.SelectedColor;
|
} else {
|
(deviceRow.GetChildren (j) as HorizontalSeekBar).ThumbColor = SkinStyle.Current.ThumbColor;
|
}
|
}
|
} else if (common.Type == DeviceType.FoolHeat || common.Type == DeviceType.FoolHeatPanel) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Switch") {
|
if ((common as FoolHeat).Status == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = (common as FoolHeat).WorkingTemperature.ToString () + "°C";
|
}
|
}
|
}
|
} else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared || common.Type == DeviceType.ACPanel) {
|
AC ac = (common as AC);
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempacBLL = new ACMethod ();
|
if (btn.Tag.ToString () == "Switch") {
|
if (ac.Power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
tempacBLL.UpdataACModeTemperature (ac, ac.SetMode, btn);
|
} else if (btn.Tag.ToString () == "Mode") {
|
tempacBLL.UpdataACHostModeIcon (ac.SetMode, btn);
|
} else if (btn.Tag.ToString () == "Wind") {
|
tempacBLL.UpdataACHostWindIcon (ac.SetFanSpeed, btn);
|
}
|
}
|
} else if (common.Type == DeviceType.FreshAir) {
|
FreshAir fa = (common as FreshAir);
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag == null) {
|
continue;
|
}
|
var tempfaBLL = new FreshAirBLL ();
|
if (btn.Tag.ToString () == "Switch") {
|
if (fa.SwitchStatus == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} else if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = fa.InTemp.ToString () + "°C";
|
} else if (btn.Tag.ToString () == "Mode") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.SetPattern);
|
} else if (btn.Tag.ToString () == "Wind") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.WindSpeed);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
} catch (Exception ex) {
|
Utlis.WriteLine (ex.Message);
|
} finally {
|
//Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
//});
|
}
|
});
|
|
}
|
|
public static Action ReadAirAction;
|
|
public override void RemoveFromParent ()
|
{
|
foreach (var thread in UserMiddle.updateSensorhreadList) {
|
thread.Abort ();
|
Utlis.WriteLine ("abortThread");
|
}
|
UserMiddle.updateSensorhreadList.Clear ();
|
EnergtLightList.Clear ();
|
readEnergy = false;
|
if (readEnergyThead != null) {
|
readEnergyThead.Abort ();
|
readEnergyThead = null;
|
}
|
curView = null;
|
UserMiddle.FavoritePageView.ScrollEnabled = true;
|
UserMiddle.RoomPageView.ScrollEnabled = true;
|
base.RemoveFromParent ();
|
}
|
|
|
|
public void InitRoomView (string RoomFilePath)
|
{
|
try {
|
|
curView = this;
|
RemoveAll ();
|
showList.Clear ();
|
|
#if __IOS__
|
UserMiddle.FavoritePageView.ScrollEnabled = false;
|
UserMiddle.RoomPageView.ScrollEnabled = false;
|
#endif
|
roomFilePath = RoomFilePath;
|
|
room = Room.GetRoomByFilePath (roomFilePath);
|
if (room == null) {
|
if (roomFilePath == Room.FavoriteRoom) {
|
new Room ().Save (Room.FavoriteRoom);
|
room = Room.GetRoomByFilePath (roomFilePath);
|
} else {
|
(Parent as PageLayout).PageIndex -= 1;
|
curView = null;
|
return;
|
}
|
}
|
showList.AddRange (room.DeviceFilePathList);
|
showList.AddRange (room.SceneFilePathList);
|
#region ---TopView---
|
FrameLayout topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topView);
|
|
if (roomFilePath == Room.FavoriteRoom) {
|
//Button LogoButton = new Button () {
|
// Y = Application.GetRealHeight(10),
|
// Width = Application.GetRealWidth (154),
|
// Height = Application.GetRealHeight (90),
|
// UnSelectedImagePath = MainPage.WiFiStatus,
|
//};
|
topView.AddChidren (UserMiddle.btnLinkStatus);
|
//LogoButton.MouseUpEventHandler += (dd, ff) => {
|
// EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus,LogoButton);
|
//};
|
} else {
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
topView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
this.RemoveFromParent ();
|
};
|
}
|
|
Button NameButton = new Button () {
|
Width = Application.GetRealWidth (400),
|
Height = Application.GetMinReal (90),
|
Text = MainPage.SoftTitle,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Gravity = Gravity.CenterHorizontal,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 20,
|
};
|
topView.AddChidren (NameButton);
|
|
Button ItemButton = new Button () {
|
Width = Application.GetRealWidth (55),
|
Height = Application.GetRealHeight (55),
|
UnSelectedImagePath = "Item/+.png",
|
SelectedImagePath = "Item/+.png",
|
X = Application.GetRealWidth (640 - 80),
|
Y = Application.GetRealHeight (17),
|
};
|
topView.AddChidren (ItemButton);
|
ItemButton.MouseUpEventHandler += (sender, e) => {
|
var userDeviceListPage = new UserDeviceListPage (room, showList, roomFilePath);
|
userDeviceListPage.Show ();
|
Action action = () => {
|
InitRoomView (roomFilePath);
|
UserMiddle.ReadAllDeviceStatus ();
|
};
|
|
Action<List<string>, List<string>> saveAction = (roomSceneFilePathList, roomDeviceFilePathList) => {
|
room.SceneFilePathList.Clear ();
|
room.SceneFilePathList.AddRange (roomSceneFilePathList);
|
room.DeviceFilePathList.Clear ();
|
room.DeviceFilePathList.AddRange (roomDeviceFilePathList);
|
room.Save (room.RoomFilePath);
|
Room.UpdateMemorry (room.RoomFilePath);
|
Room.InitAllRoom ();
|
};
|
|
userDeviceListPage.ShowPage (action, saveAction);
|
};
|
#endregion
|
RoomView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (126),
|
Height = Application.GetRealHeight (1136 - 126),
|
Width = Application.GetRealWidth (640),
|
};
|
AddChidren (RoomView);
|
RoomView.Height = Application.GetRealHeight (1136 - 126 - 90);
|
|
Button btnGoDownTip = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (90 - 26),
|
Width = Application.GetRealWidth (53),
|
Height = Application.GetRealHeight (26),
|
UnSelectedImagePath = "Room/godown.png",
|
};
|
NameButton.Text = UserConfig.Instance.CurrentRegion.Name;
|
topView.AddChidren (btnGoDownTip);
|
|
//顶部标题按钮切换住宅区域
|
NameButton.MouseUpEventHandler += (sdf, asf) => {
|
MainPage.Loading.Start ();
|
System.Threading.Tasks.Task.Run (() => {
|
if (UserConfig.Instance.HomeLists.Count == 0) {
|
//var requestObj2 = new GetHomePagerObj ();
|
//requestObj2.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
|
////var requestObj2 = new HomeListObj ();
|
//var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
|
//var revertObj2 = MainPage.RequestHttps (API.GetHomePager, requestJson2);
|
//if (revertObj2.StateCode.ToUpper() == StateCode.SUCCESS) {
|
// var mResidenceRes = Newtonsoft.Json.JsonConvert.DeserializeObject<ResidenceRes> (revertObj2.ResponseData.ToString ());
|
|
// if (mResidenceRes.PageData != null && mResidenceRes.PageData.Count > 0) {
|
// UserConfig.Instance.HomeLists = mResidenceRes.PageData;
|
// UserConfig.Instance.SaveUserConfig ();
|
// }
|
//} else {
|
// ShowGetHomePagerErrorInfo (revertObj2.StateCode);
|
//}
|
|
//获取住宅列表
|
var revertObjCode = HttpServerRequest.Current.GetHomePager ();
|
if (revertObjCode == StateCode.SUCCESS) {
|
|
} else {
|
IMessageCommon.Current.ShowErrorInfoAlter (revertObjCode);
|
}
|
}
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
Dialog dialog = new Dialog ();
|
FrameLayout bodyView = new FrameLayout ();
|
dialog.AddChidren (bodyView);
|
bodyView.MouseUpEventHandler += (lkj, oiu) => {
|
dialog.Close ();
|
};
|
|
VerticalScrolViewLayout dialogBodyView = new VerticalScrolViewLayout () {
|
Y = Application.GetRealHeight (126),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (360),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0
|
};
|
bodyView.AddChidren (dialogBodyView);
|
|
foreach (var homeTemp in UserConfig.Instance.HomeLists) {
|
var rowView = new RowLayout () {
|
Height = Application.GetRealHeight (110),
|
};
|
dialogBodyView.AddChidren (rowView);
|
|
Button btnRowLine = new Button () {
|
Y = Application.GetRealHeight (107),
|
Height = Application.GetRealHeight (3),
|
BackgroundColor = SkinStyle.Current.Black50Transparent
|
};
|
rowView.AddChidren (btnRowLine);
|
|
var btnPoint = new Button () {
|
Width = Application.GetRealWidth (10),
|
Height = Application.GetRealHeight (10),
|
X = Application.GetRealWidth (50),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Point.png",
|
SelectedImagePath = "Item/Point.png",
|
Visible = homeTemp.Id != UserConfig.Instance.CurrentRegion.Id
|
};
|
rowView.AddChidren (btnPoint);
|
|
var btnName = new Button () {
|
Width = Application.GetRealWidth (300),
|
Text = homeTemp.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (90),
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
rowView.AddChidren (btnName);
|
|
btnName.MouseUpEventHandler += (ss, ee) => {
|
if (UserConfig.Instance.CurrentRegion.Id == homeTemp.Id) {
|
return;
|
}
|
MainPage.Loading.Start ("Please wait...");
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
var backuplist = IO.FileUtils.ReadFiles ();
|
int index = 0;
|
string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.Id);
|
IO.FileUtils.DeleteRegionFiles (oldRegionRootPath);
|
foreach (var fileName in backuplist) {
|
System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName);
|
if (fileInfo.Exists) {
|
fileInfo.MoveTo (oldRegionRootPath + fileName);
|
Utlis.WriteLine ("move file : " + fileName);
|
}
|
index++;
|
Application.RunOnMainThread (() => {
|
int pro = (int)(index * 1.0 / backuplist.Count * 50);
|
MainPage.Loading.Text = pro.ToString () + "%";
|
});
|
}
|
IO.FileUtils.DeleteAllFile ();
|
string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.Id);
|
IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
|
UserConfig.Instance.RefreshUserConfig ();
|
UserConfig.Instance.CurrentRegion = homeTemp;
|
UserConfig.Instance.SaveUserConfig ();
|
|
MainPage.LoginUser.SaveUserInfo ();
|
Room.InitAllRoom ();
|
//UserConfig.Instance.RefreshUserConfig ();
|
//MainPage.LoginUser.SaveUserInfo ();
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
this.InitRoomView (roomFilePath);
|
EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus);
|
});
|
} catch (Exception ex) {
|
Application.RunOnMainThread (() => {
|
new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
Utlis.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
}
|
});
|
};
|
if (homeTemp.Id == UserConfig.Instance.CurrentRegion.Id) {
|
Button btnCheck = new Button () {
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (25),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
UnSelectedImagePath = "Skin/Check.png",
|
};
|
rowView.AddChidren (btnCheck);
|
|
Button btnBackupIcon = new Button () {
|
X = Application.GetRealWidth (400),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth (75),
|
Height = Application.GetRealHeight (75),
|
UnSelectedImagePath = "AccountSettings/Backup.png"
|
};
|
rowView.AddChidren (btnBackupIcon);
|
|
btnBackupIcon.MouseUpEventHandler += (lkj2, oiua) => {
|
Databackup dataBackupView = new Databackup ();
|
UserMiddle.FavoritePageView.AddChidren (dataBackupView);
|
dataBackupView.DatabackupShow ();
|
UserMiddle.FavoritePageView.PageIndex = UserMiddle.FavoritePageView.ChildrenCount - 1;
|
dialog.Close ();
|
};
|
}
|
}
|
|
dialog.Show ();
|
});
|
});
|
};
|
//----------=-----
|
|
FrameLayout airQualityBackgroundView = new FrameLayout () {
|
Height = Application.GetRealHeight (360),
|
BackgroundImagePath = room.BackGroundImage,//"Room/FavoriteRoom.png"
|
//BackGroundImage
|
};
|
RoomView.AddChidren (airQualityBackgroundView);
|
if (roomFilePath == Room.FavoriteRoom) {
|
airQualityBackgroundView.BackgroundImagePath = "Room/FavoriteRoom.png";
|
|
FrameLayout airQualityView = new FrameLayout () {
|
//BackgroundColor = SkinStyle.Current.Black50Transparent,
|
};
|
airQualityBackgroundView.AddChidren (airQualityView);
|
|
airQualityView.MouseLongEventHandler += (asdf, fas) => {
|
Action action = () => {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
};
|
UserRooms.UpdateFavoriteRoom (action, roomFilePath);
|
};
|
|
Button btnCity = new Button () {
|
X = Application.GetRealWidth (30),
|
Width = Application.GetRealWidth (600),
|
Height = Application.GetRealHeight (70),
|
//TextID = R.MyInternational,
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = AirQCity,
|
TextSize = 16
|
};
|
airQualityView.AddChidren (btnCity);
|
|
btnCity.MouseLongEventHandler += (asdf, fas) => {
|
Action action = () => {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
};
|
UserRooms.UpdateFavoriteRoom (action, roomFilePath);
|
};
|
|
Button btnAirIcon = new Button () {
|
X = Application.GetRealWidth (390),
|
Y = Application.GetRealHeight (230),
|
Width = Application.GetRealWidth (91),
|
Height = Application.GetRealHeight (69),
|
UnSelectedImagePath = AirQAirIcon,
|
};
|
airQualityView.AddChidren (btnAirIcon);
|
|
Button btnTemp = new Button () {
|
X = btnAirIcon.Right,
|
Y = btnAirIcon.Y,
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (70),
|
Text = AirQTemp,
|
TextSize = Application.DeviceType == Device.Ios ? 40 : 34,
|
TextAlignment = TextAlignment.Center,
|
FontName = "TitilliumText25L"
|
};
|
airQualityView.AddChidren (btnTemp);
|
Button btnHumidityIcon = new Button () {
|
X = btnAirIcon.X + Application.GetRealWidth (10),
|
Y = btnAirIcon.Bottom + Application.GetRealHeight (20),
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (25),
|
UnSelectedImagePath = AirQHumidityIcon,
|
};
|
airQualityView.AddChidren (btnHumidityIcon);
|
Button btnHumidity = new Button () {
|
X = btnHumidityIcon.Right,
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (40),
|
Height = Application.GetRealHeight (27),
|
Text = AirQHumidity,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 12
|
};
|
airQualityView.AddChidren (btnHumidity);
|
|
Button btnAirLineNull = new Button () {
|
X = btnHumidity.Right + Application.GetRealWidth (15),
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (5),
|
Height = btnHumidityIcon.Height,
|
BackgroundColor = AirLineNullBackgroundColor,
|
};
|
airQualityView.AddChidren (btnAirLineNull);
|
|
Button btnPM25Icon = new Button () {
|
X = btnAirLineNull.Right + Application.GetRealWidth (5),
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (25),
|
UnSelectedImagePath = AirQAirPM25Icon,
|
};
|
airQualityView.AddChidren (btnPM25Icon);
|
|
Button btnPM25 = new Button () {
|
X = btnPM25Icon.Right + Application.GetRealWidth (5),
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (27),
|
Text = AirQAirPM25,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12
|
};
|
airQualityView.AddChidren (btnPM25);
|
|
CommonPage.RefreshAir = () => {
|
var airQualityR = CommonPage.AirQuality;
|
if (airQualityR != null) {
|
AirQCity = btnCity.Text = airQualityR.city;
|
AirQTemp = btnTemp.Text = airQualityR.airQTemp + "°";
|
if (airQualityR.airQAirPM25 != null) {
|
AirQAirPM25 = btnPM25.Text = "PM2.5 " + airQualityR.airQAirPM25;
|
} else {
|
if (string.IsNullOrEmpty (airQualityR.airQAirWeather))
|
btnPM25.Text = airQualityR.airQAirWeather;
|
}
|
AirQHumidity = btnHumidity.Text = airQualityR.airQHumidity;
|
AirQHumidityIcon = btnHumidityIcon.UnSelectedImagePath = "AirQuality/HumidityIcon.png";
|
AirQAirPM25Icon = btnPM25Icon.UnSelectedImagePath = "AirQuality/PM25Icon.png";
|
btnAirLineNull.BackgroundColor = SkinStyle.Current.White20Transparent;
|
#region
|
switch (airQualityR.airQAirWeather) {
|
case "晴":
|
case "Sunny":
|
case "晴天":
|
case "天晴":
|
case "Clear":
|
case "大部晴朗":
|
case "Mostly Sunny":
|
case "晴時多雲":
|
case "陽光充沛":
|
case "Mostly Clear":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/0.png";
|
break;
|
case "多云":
|
case "Cloudy":
|
case "多雲":
|
case "少云":
|
case "Partly Cloudy":
|
case "少雲":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/1.png";
|
break;
|
case "阴":
|
case "Overcast":
|
case "陰天":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/2.png";
|
break;
|
case "阵雨":
|
case "Showers":
|
case "陣雨":
|
case "驟雨":
|
case "局部阵雨":
|
case "Scattered Showers":
|
case "局地陣雨":
|
case "局部地區性驟雨":
|
case "小阵雨":
|
case "Light Showers":
|
case "小陣雨":
|
case "零散驟雨":
|
case "强阵雨":
|
case "Heavy Showers":
|
case "強陣雨":
|
case "間中有驟雨":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/3.png";
|
break;
|
case "阵雪":
|
case "Snow Showers":
|
case "陣雪":
|
case "驟雪":
|
case "小阵雪":
|
case "Light Snow Showers":
|
case "小陣雪":
|
case "零散驟雪":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/13.png";
|
break;
|
case "雾":
|
case "Fog":
|
case "霧":
|
case "薄霧":
|
case "冻雾":
|
case "Freezing Fog":
|
case "凍霧":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/18.png";
|
break;
|
case "沙尘暴":
|
case "Sandstorm":
|
case "沙塵暴":
|
case "强沙尘暴":
|
case "Heavy Sandstorm":
|
case "強沙塵暴":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/20.png";
|
break;
|
case "浮尘":
|
case "Dust":
|
case "浮塵":
|
case "尘卷风":
|
case "Dust Storm":
|
case "塵捲風":
|
case "扬沙":
|
case "Sand":
|
case "揚沙":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/29.png";
|
break;
|
case "霾":
|
case "Haze":
|
case "煙霞":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/45.png";
|
break;
|
case "雷阵雨":
|
case "Thundershower":
|
case "雷陣雨":
|
case "雷雨":
|
case "雷电":
|
case "Lightning":
|
case "雷電":
|
case "雷暴":
|
case "Thunderstorm":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/4.png";
|
break;
|
case "雷阵雨伴有冰雹":
|
case "Thundershower with Hail":
|
case "雷陣雨伴有冰雹":
|
case "雷雨伴有冰雹":
|
case "冰雹":
|
case "Hail":
|
case "冰针":
|
case "Needle Ice":
|
case "冰針":
|
case "冰粒":
|
case "Icy":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/5.png";
|
break;
|
case "雨夹雪":
|
case "Sleet":
|
case "雨夾雪":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/6.png";
|
break;
|
case "小雨":
|
case "Light Rain":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/7.png";
|
break;
|
case "中雨":
|
case "Rain":
|
case "小到中雨":
|
case "雨":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/8.png";
|
break;
|
case "大雨":
|
case "Heavy Rain":
|
case "中到大雨":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/9.png";
|
break;
|
case "暴雨":
|
case "Rainstorm":
|
case "豪雨":
|
case "大暴雨":
|
case "Heavy Rainstorm":
|
case "大豪雨":
|
case "特大暴雨":
|
case "Extreme Rainstorm":
|
case "超大豪雨":
|
case "大到暴雨":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/10.png";
|
break;
|
case "小雪":
|
case "Light Snow":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/14.png";
|
break;
|
case "雪":
|
case "中雪":
|
case "小到中雪":
|
case "Snow":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/15.png";
|
break;
|
case "大雪":
|
case "Heavy Snow":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/16.png";
|
break;
|
case "暴雪":
|
case "Blizzard":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/17.png";
|
break;
|
case "冻雨":
|
case "Freezing Rain":
|
case "凍雨":
|
AirQAirIcon = btnAirIcon.UnSelectedImagePath = "AirQuality/19.png";
|
break;
|
}
|
#endregion
|
}
|
};
|
|
CommonPage.RefreshAir ();
|
|
} else {
|
NameButton.Text = room.Name;
|
RoomView.Height = Application.GetRealHeight (1136 - 126);
|
}
|
if (room.BackGroundImage != "Room/r1.png") {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
}
|
var dirDevice = new Dictionary<string, string> ();
|
if (room.RoomFilePath == Room.FavoriteRoom) {
|
foreach (var r in Room.Lists) {
|
if (r.RoomFilePath == room.RoomFilePath) {
|
continue;
|
}
|
if (r != null) {
|
foreach (var de in r.DeviceFilePathList) {
|
if (!dirDevice.ContainsKey (de))
|
dirDevice.Add (de, r.Name);
|
}
|
}
|
}
|
}
|
|
var acList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.HVAC || obj.Type == DeviceType.ACInfrared || obj.Type == DeviceType.ACPanel);
|
foreach (var devcieCommon in acList) {
|
if (devcieCommon == null)
|
continue;
|
|
var tempDeviceNameText = "";
|
dirDevice.TryGetValue (devcieCommon.SavePath, out tempDeviceNameText);
|
if (!string.IsNullOrEmpty (tempDeviceNameText)) {
|
tempDeviceNameText = tempDeviceNameText + "-" + devcieCommon.Name;
|
} else {
|
tempDeviceNameText = devcieCommon.Name;
|
}
|
#region AC
|
var ac = devcieCommon as AC;
|
EventHandler<MouseEventArgs> openACControlPageEvent = (button, mouseEventArgs) => {
|
UserACPage acView = new UserACPage (ac, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (acView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (acView);
|
}
|
acView.showRoomAC ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
var acRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (140),
|
Tag = devcieCommon.Type + "_" + ac.CommonLoopID
|
};
|
RoomView.AddChidren (acRowView);
|
acRowView.MouseUpEventHandler += openACControlPageEvent;
|
|
var tempDeviceName = new Button () {
|
X = Application.GetRealWidth (30),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = tempDeviceNameText,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
acRowView.AddChidren (tempDeviceName);
|
//2020-08-28 增加长按修改设备备注
|
ButtonNameAddMouseLongEventHandler (tempDeviceName, devcieCommon);
|
|
tempDeviceName.MouseUpEventHandler += openACControlPageEvent;
|
|
Button btnMode = new Button () {
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Mode"
|
};
|
acRowView.AddChidren (btnMode);
|
new ACMethod ().UpdataACHostModeIcon (ac.SetMode, btnMode);
|
btnMode.MouseUpEventHandler += openACControlPageEvent;
|
|
Button btnWind = new Button () {
|
X = btnMode.Right + Application.GetRealWidth (0),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Wind"
|
};
|
acRowView.AddChidren (btnWind);
|
new ACMethod ().UpdataACHostWindIcon (ac.SetFanSpeed, btnWind);
|
btnWind.MouseUpEventHandler += openACControlPageEvent;
|
|
var btnSetTemperature = new Button () {
|
Width = Application.GetRealWidth (310),
|
X = Application.GetRealWidth (280),
|
Y = Application.GetRealHeight (20),
|
TextSize = 26,
|
TextAlignment = TextAlignment.Center,
|
Tag = "Temperature",
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
acRowView.AddChidren (btnSetTemperature);
|
new ACMethod ().UpdataACModeTemperature (ac, ac.SetMode, btnSetTemperature);
|
btnSetTemperature.MouseUpEventHandler += openACControlPageEvent;
|
|
var tempSiwtch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Y = Application.GetRealHeight (67),
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = "Switch"
|
};
|
acRowView.AddChidren (tempSiwtch);
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
|
//ac.Power = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
|
|
SendControlAc (ac, tempSiwtch.IsSelected ? (byte)0 : (byte)1);
|
//if (ac.Type == DeviceType.ACPanel) {
|
// //2020-02-10 待修改
|
// Control.ControlBytesSend (Command.InstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.Power, ac.LoopID });
|
//} else if (ac.Type == DeviceType.ACDevice || ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) {
|
// //2020-02-10 待修改
|
// Control.ControlBytesSend (Command.SetACMode, ac.SubnetID, ac.DeviceID, new [] { ac.LoopID, ac.TemperatureMode, ac.IndoorTemperature, ac.CoolTemperature, ac.HeatTemperature, ac.AutoTemperature, ac.ChuShiTemperature, ac.RealModeAndFanSpeed, ac.Power, ac.SetMode, ac.SetFanSpeed, ac.SetTemperature, ac.ShaoFanMode });
|
//}
|
};
|
|
if (0 < ac.Power) {
|
tempSiwtch.IsSelected = true;
|
}
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
var fhList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.FoolHeat || obj.Type == DeviceType.FoolHeatPanel);
|
foreach (var devcieCommon in fhList) {
|
if (devcieCommon == null)
|
continue;
|
|
var tempDeviceNameText = "";
|
dirDevice.TryGetValue (devcieCommon.SavePath, out tempDeviceNameText);
|
if (!string.IsNullOrEmpty (tempDeviceNameText)) {
|
tempDeviceNameText = tempDeviceNameText + "-" + devcieCommon.Name;
|
} else {
|
tempDeviceNameText = devcieCommon.Name;
|
}
|
#region 地热模块
|
var fh = devcieCommon as FoolHeat;
|
var fhRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (130),
|
Tag = devcieCommon.Type + "_" + devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (fhRowView);
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = "Item/FloorHeating.png",
|
SelectedImagePath = "Item/FloorHeating.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
fhRowView.AddChidren (btnIcon);
|
|
var tempDeviceName = new Button () {
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
Width = Application.GetRealWidth (300),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = tempDeviceNameText,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
IsMoreLines = true
|
};
|
fhRowView.AddChidren (tempDeviceName);
|
|
//2020-08-28 增加长按修改设备备注
|
ButtonNameAddMouseLongEventHandler (tempDeviceName, devcieCommon);
|
|
tempDeviceName.MouseUpEventHandler += (sender2, e2) => {
|
UserFHPage fhView = new UserFHPage (fh, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fhView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fhView);
|
}
|
fhView.ShowRoomFH ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
|
var btnSetTemperature = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (200),
|
X = Application.GetRealWidth (280),
|
Gravity = Gravity.CenterVertical,
|
Text = fh.WorkingTemperature.ToString () + "°C",
|
TextSize = 26,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = "Temperature"
|
};
|
fhRowView.AddChidren (btnSetTemperature);
|
|
var tempSiwtch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = "Switch"
|
};
|
fhRowView.AddChidren (tempSiwtch);
|
|
if (fh.Status == 1) {
|
tempSiwtch.IsSelected = true;
|
} else {
|
tempSiwtch.IsSelected = false;
|
}
|
|
//UpdateStatus (roomFH);
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
|
fh.Status = tempSiwtch.IsSelected ? (byte)1 : (byte)0;
|
System.Threading.Tasks.Task.Run (() => {
|
if (fh.Type == DeviceType.FoolHeatPanel) {
|
//2020-02-10 待修改
|
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 20, fh.Status, fh.LoopID });
|
} else if (fh.Type == DeviceType.FoolHeat) {
|
//2020-02-10 待修改
|
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch);
|
}
|
});
|
};
|
|
if (0 < fh.Status) {
|
tempSiwtch.IsSelected = true;
|
}
|
|
Button btnFHNull = new Button () {
|
Y = Application.GetRealHeight (127),
|
Height = Application.GetRealHeight (3),
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
fhRowView.AddChidren (btnFHNull);
|
#endregion
|
}
|
foreach (var devcieCommon in room.DeviceList) {
|
if (devcieCommon == null)
|
continue;
|
|
if (devcieCommon.Type == DeviceType.FoolHeat || devcieCommon.Type == DeviceType.FoolHeatPanel ||
|
devcieCommon.Type == DeviceType.HVAC || devcieCommon.Type == DeviceType.ACInfrared || devcieCommon.Type == DeviceType.ACPanel ||
|
devcieCommon.Type == DeviceType.FreshAir) {
|
continue;
|
} else {
|
|
var tempDeviceNameText = "";
|
dirDevice.TryGetValue (devcieCommon.SavePath, out tempDeviceNameText);
|
if (!string.IsNullOrEmpty (tempDeviceNameText)) {
|
tempDeviceNameText = tempDeviceNameText + "-" + devcieCommon.Name;
|
} else {
|
tempDeviceNameText = devcieCommon.Name;
|
}
|
var DeviceRowView = new FrameLayout () {
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Height = Application.GetRealHeight (110),
|
Tag = devcieCommon.Type + "_" + devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (DeviceRowView);
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
DeviceRowView.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = tempDeviceNameText,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.Right + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
IsMoreLines = true
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
//2020-08-28 增加长按修改设备备注
|
ButtonNameAddMouseLongEventHandler (btnName, devcieCommon);
|
|
//btnName.MouseLongEventHandler += (sender, e)=>{
|
// RemarkDeviceName (devcieCommon, SimpleControl.CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (devcieCommon)), btnName);
|
//};
|
|
Button tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (530),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = devcieCommon.CommonLoopID
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
//==============================
|
if (devcieCommon.Type == DeviceType.FanModule) {
|
#region 风扇
|
FanModule fanModule = devcieCommon as FanModule;
|
|
btnIcon.UnSelectedImagePath = "Fan/Fan.png";
|
btnIcon.SelectedImagePath = "Fan/Fan.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserFan fanView = new UserFan (fanModule);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fanView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fanView);
|
}
|
fanView.ShowRoomFan ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.IsSelected = fanModule.Switch == 0 ? false : true;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
//if (tempSwitch.IsSelected) {
|
// fanModule.Switch = fanModule.WindSpeed;
|
//} else {
|
// fanModule.Switch = 0;
|
//}
|
//Control.ControlBytesSend (Command.SetSingleLight, fanModule.SubnetID, fanModule.DeviceID, new byte [] { fanModule.LoopID, fanModule.Switch });
|
|
int mSetSwitch = 0;
|
if (!tempSwitch.IsSelected) {
|
//2021-03-02 修复开0档问题
|
if (fanModule.WindSpeed == 0) {
|
mSetSwitch = 1;
|
} else {
|
mSetSwitch = fanModule.WindSpeed;
|
}
|
} else {
|
mSetSwitch = 0;
|
}
|
|
SendControl.SendControlSetSingleLight (fanModule, new byte [] { fanModule.LoopID, (byte)mSetSwitch });
|
//IO.FileUtils.SaveEquipmentMessage (fanModule, fanModule.LoopID.ToString ());
|
};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.LightDimming || devcieCommon.Type == DeviceType.LightDALI) {
|
#region 调光器A
|
|
btnIcon.UnSelectedImagePath = "CrabtreeAdd/Dimmer.png";
|
btnIcon.SelectedImagePath = "CrabtreeAdd/Dimmer.png";
|
LightDimming dimming = devcieCommon as LightDimming;// (LightDimming)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
|
DeviceRowView.Height = Application.GetRealHeight (130);
|
|
//btnName.Y = Application.GetRealHeight (10);
|
btnName.Padding = new Padding (0, 0, 10, 0);
|
|
var btnValues = new Button () {
|
X = Application.GetRealHeight (30),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetRealWidth (55),
|
Height = Application.GetRealHeight (130 - 20),
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = dimming.CurrentBrightness + "%",
|
TextSize = 10,
|
Tag = "Values",
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center
|
};
|
DeviceRowView.AddChidren (btnValues);
|
|
//进度条
|
var tempLightSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (440 - 20),
|
Height = Application.GetRealHeight (130 - 20),
|
X = btnValues.Right + Application.GetRealWidth (5),
|
Y = Application.GetRealHeight (40),
|
Visible = dimming.DimmingFunction,
|
Progress = dimming.CurrentBrightness,
|
Tag = DateTime.MinValue,
|
ThumbColor = dimming.CurrentBrightness > 0 ? SkinStyle.Current.SelectedColor : SkinStyle.Current.ThumbColor,
|
//Tag = devcieCommon.Type + "_" + devcieCommon.CommonLoopID,
|
ThumbRadius = 8,
|
};
|
DeviceRowView.AddChidren (tempLightSeekBar);
|
//开关按键
|
tempSwitch.X = Application.GetRealWidth (640 - 90 - 20);
|
tempSwitch.Y = Application.GetRealHeight (50);
|
|
tempLightSeekBar.ProgressChanged += (sender2, e4) => {
|
btnValues.Text = e4 + "%";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(tempLightSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
tempLightSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
});
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)tempLightSeekBar.Progress;
|
if (e4 == 0) {
|
tempLightSeekBar.ThumbColor = SkinStyle.Current.ThumbColor;
|
tempSwitch.IsSelected = false;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 });
|
} else if (e4 == 100) {
|
tempLightSeekBar.ThumbColor = SkinStyle.Current.SelectedColor;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 });
|
} else {
|
tempLightSeekBar.ThumbColor = SkinStyle.Current.SelectedColor;
|
tempSwitch.IsSelected = true;
|
}
|
};
|
tempLightSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
tempLightSeekBar.Tag = DateTime.Now;
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)tempLightSeekBar.Progress;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)tempLightSeekBar.Progress, 0, 0 });
|
dimming.CurrentBrightness = (byte)tempLightSeekBar.Progress;
|
btnValues.Text = tempLightSeekBar.Progress + "%";
|
tempSwitch.IsSelected = tempLightSeekBar.Progress > 0;
|
};
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (!tempSwitch.IsSelected) {
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.LoopID, dimming.LastOpenBrightness, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.LastOpenBrightness, 0, 0 });
|
//tempLightSeekBar.Progress = dimming.CurrentBrightness = dimming.LastOpenBrightness;
|
//tempLightSeekBar.ThumbColor = SkinStyle.Current.SelectedColor;
|
//dimming.CurrentBrightness = dimming.LastOpenBrightness;
|
} else {
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.LoopID, 0, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, 0, 0, 0 });
|
//tempLightSeekBar.Progress = 0;
|
//tempLightSeekBar.ThumbColor = SkinStyle.Current.ThumbColor;
|
//dimming.CurrentBrightness = 0;
|
}
|
//btnValues.Text = dimming.CurrentBrightness + "%";
|
};
|
if (dimming.CurrentBrightness > 0) {
|
tempSwitch.IsSelected = true;
|
}
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.LightMixDimming) {
|
#region 调光器
|
LightMixDimming comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (devcieCommon.SavePath)));
|
LightMixDimming dimming = devcieCommon as LightMixDimming;
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
if (dimming == null) {
|
dimming = comm;
|
}
|
btnName.MouseUpEventHandler += (sender, e) => {
|
if (UserConfig.Instance.UnEnableDimmingLight.Contains (dimming.CommonLoopID)) {
|
return;
|
}
|
Dialog dialogDimming = new Dialog ();
|
FrameLayout dialogBodyView = new FrameLayout ();
|
dialogDimming.AddChidren (dialogBodyView);
|
dialogBodyView.MouseUpEventHandler += (sender1, e2) => {
|
dialogDimming.Close ();
|
};
|
|
FrameLayout dimmingView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (240),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
};
|
dialogBodyView.AddChidren (dimmingView);
|
|
Button btnDialogTitle = new Button () {
|
Height = Application.GetRealHeight (90),
|
Text = dimming.Name,
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dimmingView.AddChidren (btnDialogTitle);
|
|
FrameLayout proessView = new FrameLayout () {
|
Y = btnDialogTitle.Bottom,
|
Height = Application.GetRealHeight (150),
|
};
|
dimmingView.AddChidren (proessView);
|
|
var tempSeekBarFrame = new FrameLayout () {
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
proessView.AddChidren (tempSeekBarFrame);
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
ThumbRadius = 6,
|
Progress = dimming.CurrentBrightness
|
};
|
tempSeekBarFrame.AddChidren (horizontalSeekBar);
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = tempSeekBarFrame.Right + Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
Text = dimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
proessView.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
Utlis.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
});
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
};
|
dialogDimming.Show ();
|
};
|
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (!tempSwitch.IsSelected) {
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
} else {
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
}
|
};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.LightMixSwitch) {
|
#region
|
//LightMixSwitch dimming = deviceCommon as LightMixSwitch;// (LightMixSwitch)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
LightMixSwitch comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixSwitch> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (devcieCommon.SavePath)));
|
LightMixSwitch dimming = devcieCommon as LightMixSwitch;//(LightMixDimming)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
if (dimming == null) {
|
dimming = comm;
|
}
|
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (!tempSwitch.IsSelected) {
|
//dimming.CurrentBrightness = 100;
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
} else {
|
//dimming.CurrentBrightness = 0;
|
SendControl.SendControlSetSingleLight (dimming, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
//Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
}
|
};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.LightRGB) {
|
#region RGB
|
//LightLogic comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
LightLogic rgbLight = devcieCommon as LightLogic;//(LightLogic)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
|
btnName.MouseUpEventHandler += (sender, e) => {
|
byte [] lightLigicBytes = new byte [11];
|
System.Threading.Tasks.Task.Run (() => {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Please wait...");
|
});
|
lightLigicBytes = Control.ControlBytesSendHasReturn (Command.ReadLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID });
|
if (lightLigicBytes == null) {
|
lightLigicBytes = new byte [11];
|
}
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
Dialog dialog = new Dialog () {
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
Button btnTopNull = new Button () {
|
Height = Application.GetRealHeight (36),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
dialog.AddChidren (btnTopNull);
|
Button btnTitle = new Button () {
|
Y = btnTopNull.Bottom,
|
Height = Application.GetRealHeight (90),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
Text = rgbLight.Name,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextSize = 19
|
};
|
dialog.AddChidren (btnTitle);
|
|
Button btnColor = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = Application.GetRealWidth (20),
|
Y = btnTitle.Bottom + Application.GetRealHeight (50),
|
Radius = 5,
|
BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8])
|
};
|
dialog.AddChidren (btnColor);
|
Button btnColorText = new Button () {
|
Width = Application.GetRealWidth (100),
|
Height = Application.GetRealHeight (40),
|
X = btnColor.X,
|
Y = btnColor.Bottom,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = "Color"
|
};
|
dialog.AddChidren (btnColorText);
|
ColorPicker c = new ColorPicker () {
|
X = Application.GetRealWidth (140),
|
Y = btnTitle.Bottom + Application.GetRealHeight (30),
|
Width = Application.GetMinRealAverage (440),
|
Height = Application.GetMinRealAverage (440),
|
ColorImagePath = "Item/PickerColorWheel.png",
|
};
|
dialog.AddChidren (c);
|
|
DateTime colorChangeTime = DateTime.MinValue;
|
c.ColorChaged += (sender2, e2) => {
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 500) {
|
lightLigicBytes [6] = e2 [0];
|
lightLigicBytes [7] = e2 [1];
|
lightLigicBytes [8] = e2 [2];
|
//2020-02-10 待修改
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnColor.BackgroundColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]);
|
|
}
|
};
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = c.Bottom,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialog.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (170),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOnReduce);
|
|
Button btnDelayTimeOnText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnReduce.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = rgbLight.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialog.AddChidren (btnDelayTimeOnText);
|
|
Button btnDelayTimeOnAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOnText.Right,
|
Y = btnDelayTimeOnReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = rgbLight.CustomDelayTimeOpen;
|
btnDelayTimeOnAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = true;
|
if (delayTimeOn > 59)
|
return;
|
delayTimeOn++;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn > 59)
|
break;
|
delayTimeOn++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOnReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = true;
|
if (delayTimeOn == 0)
|
return;
|
delayTimeOn--;
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOn == 0)
|
break;
|
delayTimeOn--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOnText.Text = delayTimeOn.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOnReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOnReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
|
#region ---延时关---
|
Button btnDelayTimeOFFTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnDelayTimeOnReduce.Bottom + Application.GetRealHeight (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialog.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (170),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOffReduce);
|
|
Button btnDelayTimeOffText = new Button () {
|
Width = Application.GetRealWidth (180),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffReduce.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
BackgroundColor = SkinStyle.Current.LightDialogTextColor,
|
Text = rgbLight.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
dialog.AddChidren (btnDelayTimeOffText);
|
|
Button btnDelayTimeOffAdd = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = btnDelayTimeOffText.Right,
|
Y = btnDelayTimeOffReduce.Y,
|
UnSelectedImagePath = "Light/Light+.png",
|
SelectedImagePath = "Light/Light+On.png",
|
};
|
dialog.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = rgbLight.CustomDelayTimeClose;
|
btnDelayTimeOffAdd.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = true;
|
if (delayTimeOff > 59)
|
return;
|
delayTimeOff++;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff > 59)
|
break;
|
delayTimeOff++;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffAdd.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffAdd.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
|
btnDelayTimeOffReduce.MouseDownEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = true;
|
if (delayTimeOff == 0)
|
return;
|
delayTimeOff--;
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
newTime = DateTime.Now;
|
|
System.Threading.Tasks.Task.Run (() => {
|
while (newTime != DateTime.MaxValue) {
|
System.Threading.Thread.Sleep (100);
|
if ((DateTime.Now - newTime).TotalSeconds > 1) {
|
if (delayTimeOff == 0)
|
break;
|
delayTimeOff--;
|
Application.RunOnMainThread (() => {
|
btnDelayTimeOffText.Text = delayTimeOff.ToString () + "s";
|
});
|
}
|
}
|
});
|
};
|
btnDelayTimeOffReduce.MouseUpEventHandler += (sender2, e2) => {
|
btnDelayTimeOffReduce.IsSelected = false;
|
newTime = DateTime.MaxValue;
|
};
|
#endregion
|
HorizontalSeekBar seekBarLighting = new HorizontalSeekBar () {
|
X = Application.GetRealWidth (50),
|
Y = btnDelayTimeOffReduce.Bottom + Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (50),
|
Progress = lightLigicBytes [1],
|
ThumbColor = (uint)(0xFF000000 + lightLigicBytes [6] * 256 * 256 + lightLigicBytes [7] * 256 + lightLigicBytes [8]),
|
Max = 100,
|
};
|
dialog.AddChidren (seekBarLighting); Button btnLightingText = new Button () {
|
X = seekBarLighting.Right + Application.GetRealWidth (5),
|
Y = seekBarLighting.Y,
|
Width = Application.GetRealWidth (80),
|
Height = Application.GetRealHeight (50),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = lightLigicBytes [1].ToString () + "%"
|
};
|
dialog.AddChidren (btnLightingText);
|
seekBarLighting.ProgressChanged += (sender3, e3) => {
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 50) {
|
lightLigicBytes [1] = (byte)e3;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
colorChangeTime = DateTime.Now;
|
btnLightingText.Text = e3.ToString () + "%";
|
rgbLight.LastOpenBrightness = (byte)e3;
|
}
|
};
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = dialog.Height - Application.GetRealHeight (100),
|
Height = Application.GetRealHeight (100),
|
};
|
dialog.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (322),
|
TextID = R.MyInternationalizationString.Close,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = Application.GetRealWidth (3),
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (322),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
if (rgbLight.CustomDelayTimeOpen != delayTimeOn || rgbLight.CustomDelayTimeClose != delayTimeOff) {
|
string keyString = rgbLight.SubnetID.ToString () + "_" + rgbLight.DeviceID.ToString () + "_" + rgbLight.LoopID.ToString ();
|
rgbLight.CustomDelayTimeOpen = delayTimeOn;
|
rgbLight.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (keyString + "Open")) {
|
room.DelayTime [keyString + "Open"] = delayTimeOn;
|
} else {
|
room.DelayTime.Add (keyString + "Open", delayTimeOn);
|
}
|
if (room.DelayTime.ContainsKey (keyString + "Close")) {
|
room.DelayTime [keyString + "Close"] = delayTimeOff;
|
} else {
|
room.DelayTime.Add (keyString + "Close", delayTimeOff);
|
}
|
room.Save (typeof (Room).Name + "_" + room.Name);
|
}
|
if (lightLigicBytes [6] != rgbLight.RStatus || lightLigicBytes [7] != rgbLight.GStatus || lightLigicBytes [8] != rgbLight.BStatus) {
|
rgbLight.RStatus = lightLigicBytes [6];
|
rgbLight.GStatus = lightLigicBytes [7];
|
rgbLight.BStatus = lightLigicBytes [8];
|
IO.FileUtils.SaveEquipmentMessage (rgbLight, rgbLight.LoopID.ToString ());
|
}
|
dialog.Close ();
|
};
|
dialog.Show ();
|
});
|
});
|
};
|
|
tempSwitch.IsSelected = rgbLight.CurrentBrightness > 0 ? true : false;
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (!tempSwitch.IsSelected) {
|
//rgbLight.CurrentBrightness = 100;
|
SendControl.SendControlSetSingleLight (rgbLight, new byte [] { rgbLight.LoopID, 100, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 100, 0, 0 });
|
} else {
|
//rgbLight.CurrentBrightness = 0;
|
SendControl.SendControlSetSingleLight (rgbLight, new byte [] { rgbLight.LoopID, 0, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID, 0, 0, 0 });
|
}
|
};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.LightSwitch
|
|| devcieCommon.Type == DeviceType.LightEnergySocket
|
|| devcieCommon.Type == DeviceType.LightEnergySwitch
|
|| devcieCommon.Type == DeviceType.LightSwitchSocket) {
|
#region 继电器
|
LightSwitch switchLight = devcieCommon as LightSwitch;
|
tempSwitch.IsSelected = switchLight.CurrentBrightness == 100 ? true : false;
|
//DeviceRowView.HHeight = Application.geh
|
if (devcieCommon.Type == DeviceType.LightSwitchSocket || devcieCommon.Type == DeviceType.LightEnergySocket) {
|
btnIcon.UnSelectedImagePath = "Light/Socket.png";
|
btnIcon.SelectedImagePath = "Light/Socket.png";
|
DeviceRowView.Height = Application.GetRealHeight (120);
|
} else {
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
}
|
|
if (devcieCommon.Type == DeviceType.LightEnergySocket || devcieCommon.Type == DeviceType.LightEnergySwitch) {
|
Button btnEnergy = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (35),
|
X = tempSwitch.X,
|
Y = tempSwitch.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
Tag = devcieCommon.Type.ToString () + "_Voltage",
|
Text = "0 W"
|
};
|
DeviceRowView.AddChidren (btnEnergy);
|
EnergtLightList.Add (devcieCommon);
|
//2020-07-01 客户提出隐藏kwh
|
//Button btnElectric = new Button () {
|
// Width = Application.GetRealWidth (200),
|
// Height = Application.GetRealHeight (35),
|
// X = Application.GetRealWidth (320),
|
// Y = tempSwitch.Bottom,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// TextAlignment = TextAlignment.CenterRight,
|
// SelectedTextColor = SkinStyle.Current.TextColor1,
|
// Tag = devcieCommon.Type.ToString () + "_Electric",
|
// Text = "0 kw.h"
|
//};
|
//DeviceRowView.AddChidren (btnElectric);
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
//tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (!tempSwitch.IsSelected) {
|
//switchLight.CurrentBrightness = 100;
|
SendControl.SendControlSetSingleLight (switchLight, new byte [] { switchLight.LoopID, 100, 0, 0 });
|
|
//Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 });
|
} else {
|
//switchLight.CurrentBrightness = 0;
|
SendControl.SendControlSetSingleLight (switchLight, new byte [] { switchLight.LoopID, 0, 0, 0 });
|
//Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 });
|
}
|
|
if (devcieCommon.Type == DeviceType.LightEnergySocket || devcieCommon.Type == DeviceType.LightEnergySwitch) {
|
new System.Threading.Thread (() => {
|
Control.ControlBytesSend (Command.ReadAnalogValue, switchLight.SubnetID, switchLight.DeviceID, new byte [] { 10, switchLight.LoopID }, SendCount.Zero);
|
//2020-07-01 客户提出隐藏kwh
|
//Control.ControlBytesSend (Command.ReadAnalogValue, switchLight.SubnetID, switchLight.DeviceID, new byte [] { 11, switchLight.LoopID }, SendCount.Zero);
|
}) { IsBackground = true }.Start ();
|
}
|
};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.CurtainModel) {
|
#region 窗帘
|
//CurtainModel comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainModel curtain = devcieCommon as CurtainModel;//(CurtainModel)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.CurtainTrietex) {
|
#region 开合帘窗帘
|
//CurtainTrietex comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainTrietex curtain = devcieCommon as CurtainTrietex;//(CurtainTrietex)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.CurtainRoller) {
|
#region 卷帘
|
//CurtainRoller comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainRoller curtain = devcieCommon as CurtainRoller;//(CurtainRoller)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserCurtainPage curtainView = new UserCurtainPage (curtain, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (curtainView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (curtainView);
|
}
|
curtainView.showCurtainsRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.MusicModel) {
|
#region 音乐模块
|
//MusicModel comm = Newtonsoft.Json.JsonConvert.DeserializeObject<MusicModel> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
//MusicModel musicMode = (MusicModel)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (musicMode == null) {
|
// musicMode = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Item/Music.png";
|
btnIcon.SelectedImagePath = "Item/Music.png";
|
tempSwitch.Visible = false;
|
//tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
// tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
// if (tempSwitch.IsSelected) {
|
// //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 1 });
|
// } else {
|
// //Control.ControlBytesSend (Command.UpdataCurtainModelStutas, curtain.SubnetID, curtain.DeviceID, new byte [] { curtain.LoopID, 2 });
|
// }
|
//};
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.DryContact) {
|
#region 干接点
|
DryContact dc = devcieCommon as DryContact;// Newtonsoft.Json.JsonConvert.DeserializeObject<DryContact> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
btnIcon.UnSelectedImagePath = "Item/DryContact.png";
|
btnIcon.SelectedImagePath = "Item/DryContact.png";
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.InfraredMode) {
|
#region 红外电视
|
try {
|
InfraredMode infraredTV = devcieCommon as InfraredMode;// Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (infraredTV != null)
|
Utlis.WriteLine (infraredTV.InfraredType);
|
if (infraredTV.InfraredType == InfraredType.TV) {
|
btnIcon.UnSelectedImagePath = "Item/InfraredTV.png";
|
btnIcon.SelectedImagePath = "Item/InfraredTV.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
UserTVFrameLayout fhView = new UserTVFrameLayout (infraredTV);
|
UserMiddle.RoomPageView.AddChidren (fhView);
|
//fhView.Show ();
|
fhView.ShowUserTV (tempSwitch);
|
UserMiddle.RoomPageView.PageIndex = 2;
|
};
|
tempSwitch.IsSelected = infraredTV.isOpen;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
infraredTV.isOpen = tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
int RandKey = new Random ().Next (0, 255);
|
//2020-02-10 待修改
|
Control.ControlBytesSend (Command.InfraredControl, infraredTV.SubnetID, infraredTV.DeviceID, new byte [] { Convert.ToByte (infraredTV.Port), infraredTV.LoopID, (byte)InfraredCode_TV.Power, 0, 0, (byte)RandKey });
|
IO.FileUtils.SaveEquipmentMessage (infraredTV, infraredTV.LoopID.ToString ());
|
};
|
}
|
} catch (Exception ex) {
|
Utlis.WriteLine (ex.ToString ());
|
continue;
|
}
|
#endregion
|
} else if (devcieCommon.Type == DeviceType.UniversalDevice) {
|
#region UniversalDevice
|
UniversalDevice udDevice = devcieCommon as UniversalDevice;
|
switch (udDevice.TargetType) {
|
case 0:
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
break;
|
case 1:
|
btnIcon.UnSelectedImagePath = "Curtain/Curtain.png";
|
btnIcon.SelectedImagePath = "Curtain/Curtain.png";
|
break;
|
case 2:
|
btnIcon.UnSelectedImagePath = "AC/AC.png";
|
btnIcon.SelectedImagePath = "AC/AC.png";
|
break;
|
default:
|
btnIcon.UnSelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
btnIcon.SelectedImagePath = "UniversalDevice/UniversalDevice.png";
|
break;
|
}
|
tempSwitch.RemoveFromParent ();
|
tempSwitch = new Button () {
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (640 - 110 - 20),
|
Gravity = Gravity.CenterVertical,
|
Radius = 2,
|
BorderColor = SkinStyle.Current.BorderColor,
|
BorderWidth = 2,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
if (udDevice.ActionType == 0) {
|
//tempSwitch.Text = udDevice.ON_Text;
|
tempSwitch.TextID = R.MyInternationalizationString.ON;
|
} else if (udDevice.ActionType == 1) {
|
//tempSwitch.Text = udDevice.OFF_Text;
|
tempSwitch.TextID = R.MyInternationalizationString.OFF;
|
} else if (udDevice.ActionType == 2) {
|
//tempSwitch.Text = udDevice.OFF_Text;
|
tempSwitch.TextID = R.MyInternationalizationString.OFF;
|
|
Button tempON = new Button () {
|
Width = Application.GetRealWidth (110),
|
Height = Application.GetRealHeight (70),
|
X = Application.GetRealWidth (640 - 250 - 20),
|
Gravity = Gravity.CenterVertical,
|
Radius = 2,
|
BorderColor = SkinStyle.Current.BorderColor,
|
TextColor = SkinStyle.Current.TextColor1,
|
BorderWidth = 2,
|
Text = udDevice.ON_Text
|
};
|
DeviceRowView.AddChidren (tempON);
|
tempON.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
//2020-02-10 待修改
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
}
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempON.BorderColor = SkinStyle.Current.BorderColor;
|
};
|
tempON.MouseDownEventHandler += (sende3r, e3) => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempON.BorderColor = SkinStyle.Current.SelectedColor;
|
};
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.ActionType == 0) {
|
//2020-02-10 待修改
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
} else if (udDevice.ActionType == 1) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
} else if (udDevice.ActionType == 2) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 0 }, SendCount.Zero);
|
}
|
}
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempSwitch.BorderColor = SkinStyle.Current.BorderColor;
|
};
|
tempSwitch.MouseDownEventHandler += (sende3r, e3) => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempSwitch.BorderColor = SkinStyle.Current.SelectedColor;
|
};
|
|
#endregion
|
} else if (devcieCommon.Type.ToString ().Contains ("Sensor")) {
|
#region 传感器
|
btnIcon.UnSelectedImagePath = "Sensor/Sensor.png";
|
btnIcon.SelectedImagePath = "Sensor/Sensor.png";
|
tempSwitch.RemoveFromParent ();
|
Button btnValues = new Button () {
|
X = Application.GetRealWidth (320),
|
Width = Application.GetRealWidth (300),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnValues);
|
if (devcieCommon.Type == DeviceType.SensorCO2) {
|
SensorCO2 udDevice = devcieCommon as SensorCO2;
|
btnValues.Text = udDevice.CurrentCO2.ToString () + " ppm";
|
|
System.Threading.Thread thread = new System.Threading.Thread (() => {
|
while (true) {
|
var ssbytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.BigClass, udDevice.MinClass, udDevice.LoopID });
|
Application.RunOnMainThread (() => {
|
btnValues.Text = udDevice.CurrentCO2.ToString () + " ppm";
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
} else if (devcieCommon.Type == DeviceType.SensorHumidity) {
|
SensorHumidity shDevice = devcieCommon as SensorHumidity;
|
btnValues.Text = shDevice.CurrentHumidity.ToString () + "%";
|
System.Threading.Thread thread = new System.Threading.Thread (() => {
|
while (true) {
|
var ssbytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, shDevice.SubnetID, shDevice.DeviceID, new byte [] { shDevice.BigClass, shDevice.MinClass, shDevice.LoopID });
|
Application.RunOnMainThread (() => {
|
btnValues.Text = shDevice.CurrentHumidity.ToString () + "%";
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
} else if (devcieCommon.Type == DeviceType.SensorTVOC) {
|
SensorTVOC shDevice = devcieCommon as SensorTVOC;
|
btnValues.Text = shDevice.CurrentTVOC.ToString () + " ppm";
|
System.Threading.Thread thread = new System.Threading.Thread (() => {
|
while (true) {
|
var ssbytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, shDevice.SubnetID, shDevice.DeviceID, new byte [] { shDevice.BigClass, shDevice.MinClass, shDevice.LoopID });
|
Application.RunOnMainThread (() => {
|
btnValues.Text = shDevice.CurrentTVOC.ToString () + " ppm";
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
} else if (devcieCommon.Type == DeviceType.SensorTemperature) {
|
SensorTemperature shDevice = devcieCommon as SensorTemperature;
|
btnValues.Text = shDevice.CurrentTemperature.ToString () + "°";
|
System.Threading.Thread thread = new System.Threading.Thread (() => {
|
while (true) {
|
var ssbytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, shDevice.SubnetID, shDevice.DeviceID, new byte [] { shDevice.BigClass, shDevice.MinClass, shDevice.LoopID });
|
Application.RunOnMainThread (() => {
|
btnValues.Text = shDevice.CurrentTemperature.ToString () + "°";
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
} else if (devcieCommon.Type == DeviceType.SensorPM25) {
|
SensorPM25 shDevice = devcieCommon as SensorPM25;
|
btnValues.Text = shDevice.CurrentPM25.ToString ();
|
System.Threading.Thread thread = new System.Threading.Thread (() => {
|
while (true) {
|
var ssbytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, shDevice.SubnetID, shDevice.DeviceID, new byte [] { shDevice.BigClass, shDevice.MinClass, shDevice.LoopID });
|
Application.RunOnMainThread (() => {
|
btnValues.Text = shDevice.CurrentPM25.ToString ();
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
}
|
#endregion
|
}
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
}
|
|
foreach (var scenFilePath in room.SceneFilePathList) {
|
Common devcieCommon = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (scenFilePath)));
|
if (devcieCommon == null)
|
continue;
|
RowLayout DeviceRowView = new RowLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
Tag = devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (DeviceRowView);
|
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical
|
};
|
DeviceRowView.AddChidren (btnIcon);
|
Button btnName = new Button () {
|
Width = Application.GetRealWidth (342),
|
Height = LayoutParams.MatchParent,
|
Text = devcieCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = scenFilePath
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
Button tempSwitch = new Button () {
|
Width = Application.GetMinRealAverage (90),
|
Height = Application.GetMinRealAverage (53),
|
X = Application.GetRealWidth (640 - 90 - 20),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/SwitchClose.png",
|
SelectedImagePath = "Item/SwitchOpen.png",
|
Tag = devcieCommon.CommonLoopID
|
};
|
DeviceRowView.AddChidren (tempSwitch);
|
|
Button btnDelFile = new Button () {
|
TextID = R.MyInternationalizationString.Del,
|
BackgroundColor = SkinStyle.Current.DelColor,
|
};
|
DeviceRowView.AddRightView (btnDelFile);
|
btnDelFile.MouseUpEventHandler += (sender, e) => {
|
if (room.SceneFilePathList.Contains (scenFilePath)) {
|
room.SceneFilePathList.Remove (scenFilePath);
|
}
|
room.Save (roomFilePath);
|
|
this.InitRoomView (roomFilePath);
|
};
|
|
if (scenFilePath.Split ('_') [0].Contains ("Scene")) {
|
#region 场景
|
var scene = Scene.GetSceneByFilePath (scenFilePath);
|
btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
btnIcon.SelectedImagePath = "Scene/Scene.png";
|
tempSwitch.UnSelectedImagePath = "Item/UserSceneEditIcon.png";
|
tempSwitch.SelectedImagePath = "Item/UserSceneEditIcon.png";
|
tempSwitch.Y = Application.GetRealHeight (10);
|
|
tempSwitch.Width = Application.GetRealWidth (70);
|
tempSwitch.Height = Application.GetRealHeight (76);
|
btnName.MouseDownEventHandler += (sender2, e2) => {
|
btnIcon.IsSelected = btnName.IsSelected = true;
|
};
|
btnName.MouseUpEventHandler += (sender3, e3) => {
|
btnIcon.IsSelected = btnName.IsSelected = false;
|
new ScenePhoneMethod ().ControlScene (btnName.Tag.ToString ());
|
};
|
tempSwitch.MouseDownEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = true;
|
};
|
tempSwitch.MouseUpEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = false;
|
var sceneView = new UserAddSceneDevice (typeof (Room).Name + "_" + room.Name, btnName.Tag.ToString());
|
UserMiddle.RoomPageView.AddChidren (sceneView);
|
sceneView.ShowScene ((newSceneFilePath) => {
|
try {
|
btnName.Tag = newSceneFilePath;
|
btnName.Text = newSceneFilePath.Split ('_') [2];
|
} catch { }
|
});
|
UserMiddle.RoomPageView.PageIndex = 2;
|
};
|
if (roomFilePath == Room.FavoriteRoom) {
|
tempSwitch.RemoveFromParent ();
|
}
|
#endregion
|
}
|
}
|
} catch (Exception ex) {
|
Utlis.WriteLine ("exddd :" + ex.ToString ());
|
} finally {
|
//2020-02-14 增加读状态操作
|
UserMiddle.ReadAllDeviceStatus (false, true);
|
|
readEnergyThead = new Thread ((obj) => {
|
while (readEnergy && !Control.IsEnterBackground) {
|
|
try {
|
for(int i=0;i<EnergtLightList.Count;i++){
|
|
var c = EnergtLightList [i];
|
Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 10, c.LoopID }, SendCount.Zero);
|
//2020-07-01 客户提出隐藏kwh
|
//Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 11, c.LoopID }, SendCount.Zero);
|
#if DEBUG
|
Application.RunOnMainThread (() => {
|
Utlis.WriteLine ($"读取 { c.Name } 电能");
|
});
|
#endif
|
System.Threading.Thread.Sleep (500);
|
}
|
System.Threading.Thread.Sleep (10000);
|
} catch {
|
EnergtLightList = new List<Common> ();
|
}
|
}
|
});
|
if (EnergtLightList.Count > 0) {
|
readEnergyThead.IsBackground = true;
|
readEnergyThead.Start ();
|
readEnergy = true;
|
//#if DEBUG
|
// Application.RunOnMainThread (() => {
|
// new Alert("","读取 电能","Close").Show();
|
// });
|
//#endif
|
}
|
}
|
}
|
|
/// <summary>
|
/// 空调控制,带返回结果
|
/// </summary>
|
/// <param name="mAcData"></param>
|
/// <param name="bPower"></param>
|
void SendControlAc (AC mAcData, byte bPower)
|
{
|
MainPage.Loading.Start ("Sending...");
|
System.Threading.Tasks.Task.Run (() => {
|
byte [] returnBytes = null;
|
if (mAcData.Type == DeviceType.ACPanel) {
|
returnBytes = Control.ControlBytesSendHasReturn (Command.InstructionPanelKey, mAcData.SubnetID, mAcData.DeviceID, new byte [] { 3, bPower, mAcData.LoopID });
|
} else if (mAcData.Type == DeviceType.ACDevice || mAcData.Type == DeviceType.HVAC || mAcData.Type == DeviceType.ACInfrared) {
|
|
returnBytes = Control.ControlBytesSendHasReturn (Command.SetACMode, mAcData.SubnetID, mAcData.DeviceID, new [] { mAcData.LoopID, mAcData.TemperatureMode, mAcData.IndoorTemperature, mAcData.CoolTemperature, mAcData.HeatTemperature, mAcData.AutoTemperature, mAcData.ChuShiTemperature, mAcData.RealModeAndFanSpeed, bPower, mAcData.SetMode, mAcData.SetFanSpeed, mAcData.SetTemperature, mAcData.ShaoFanMode });
|
}
|
|
Application.RunOnMainThread (() => {
|
if (returnBytes == null) {
|
new Alert ("", mAcData.Name + ErrorCode.ControlFailure, "Close").Show ();
|
}
|
MainPage.Loading.Hide ();
|
});
|
});
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="btnName"></param>
|
/// <param name="devcieCommon"></param>
|
void ButtonNameAddMouseLongEventHandler (Button btnName,Common devcieCommon)
|
{
|
//2020-08-28 增加长按修改设备备注
|
btnName.MouseLongEventHandler += (sender, e) => {
|
RemarkDeviceName (devcieCommon, SimpleControl.CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (devcieCommon)), btnName);
|
};
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="commonDevice"></param>
|
/// <param name="commonBytes"></param>
|
/// <param name="btnEquipment"></param>
|
void RemarkDeviceName (Common commonDevice, byte[] commonBytes, Button btnEquipment)
|
{
|
Action successAction = () => {
|
GenericDialog.Current.RefreshRemark (commonDevice);
|
//if (!roomDeviceFilePathList.Contains (filePath)) {
|
// roomDeviceFilePathList.Add (filePath);
|
//}
|
};
|
GenericDialog.Current.ShowModifyRemarksDialog (commonDevice, commonBytes, btnEquipment, successAction);
|
}
|
}
|
}
|