using System;
|
using System.Collections.Generic;
|
using System.Threading;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class UserRoom : FrameLayout
|
{
|
static Room room;
|
string roomFilePath;
|
List<string> showList;
|
VerticalScrolViewLayout RoomView;
|
static UserRoom curView = null;
|
|
|
Thread readEnergyThead;
|
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 = "";
|
|
public UserRoom ()
|
{
|
showList = new List<string> ();
|
Height = Application.GetRealHeight (Application.DesignHeight);
|
}
|
#region Update data
|
|
public static void UpdateThermostatExtensionTempAndHumidityValues (Thermostat cac)
|
{
|
Application.RunOnMainThread (() => {
|
try {
|
if (curView == null)
|
return;
|
if (curView.RoomView.Decelerating) {
|
return;
|
}
|
if (room.DeviceList.Find ((obj) => obj.SubnetID == cac.SubnetID && obj.DeviceID == cac.DeviceID && obj.LoopID == cac.LoopID && obj.Type == DeviceType.Thermostat) == null)
|
return;
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var rowView = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = rowView.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (o != null && o.ToString () == cac.Type.ToString()) {
|
for (int j = 0; j < rowView.ChildrenCount; j++) {
|
if (rowView.GetChildren (j).GetType () == typeof (Button)) {
|
var btn0 = (Button)rowView.GetChildren (j);
|
if (btn0.Tag != null) {
|
if (btn0.Tag.ToString () == "CapillaryACThermometerValues") {
|
btn0.Text = Math.Round (cac.Indoor_Temperature_Values, 0) + "°C";
|
} else if (btn0.Tag.ToString () == "CapillaryACHumidityValues") {
|
btn0.Text = Math.Round (cac.Indoor_Humidity_Values, 0) + "%";
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
} catch { }
|
});
|
}
|
public static void UpdateThermostatModeStatus (Thermostat cac)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null)
|
return;
|
if (curView.RoomView.Decelerating) {
|
return;
|
}
|
if (room.DeviceList.Find ((obj) => obj.SubnetID == cac.SubnetID && obj.DeviceID == cac.DeviceID && obj.Type == DeviceType.Thermostat) == null)
|
return;
|
for (int i = 0; i < curView.RoomView.ChildrenCount; i++) {
|
if (curView.RoomView.GetChildren (i).GetType () == typeof (FrameLayout)) {
|
var rowView = (FrameLayout)curView.RoomView.GetChildren (i);
|
var o = rowView.Tag;
|
if (o == null) {
|
continue;
|
}
|
if (o != null && o.ToString () == cac.Type.ToString()) {
|
for (int j = 0; j < rowView.ChildrenCount; j++) {
|
if (rowView.GetChildren (j).GetType () == typeof (Button)) {
|
var btn0 = (Button)rowView.GetChildren (j);
|
if (btn0.Tag != null) {
|
if (btn0.Tag.ToString () == "CapillaryACCurMode") {
|
switch (cac.CurrentMode) {
|
case 5:// "HeatingAndDehumidification":
|
btn0.UnSelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png";
|
btn0.SelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png";
|
break;
|
case 1://"Cooling":
|
btn0.UnSelectedImagePath = "CapillaryAC/Cooling.png";
|
btn0.SelectedImagePath = "CapillaryAC/Cooling.png";
|
break;
|
case 2: //"Heating":
|
btn0.UnSelectedImagePath = "CapillaryAC/Heating.png";
|
btn0.SelectedImagePath = "CapillaryAC/Heating.png";
|
break;
|
case 4: //"Dehumidification":
|
btn0.UnSelectedImagePath = "CapillaryAC/Dehumidification.png";
|
btn0.SelectedImagePath = "CapillaryAC/Dehumidification.png";
|
break;
|
case 3: //"Aeration":
|
btn0.UnSelectedImagePath = "CapillaryAC/Aeration.png";
|
btn0.SelectedImagePath = "CapillaryAC/Aeration.png";
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
|
public static void UpdataEnergy (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) {
|
continue;
|
}
|
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 && btn.Tag.ToString () == DeviceType.LightEnergySwitch.ToString ()) {
|
btn.Text = energy.ToString () + " W";
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前地热开关 - 针对单一属性更新
|
/// </summary>
|
public static void Update_FoolHeatPanel_WorkingTemp (string updataFalg, byte workingTemp)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Temperature") {
|
btn.Text = workingTemp + "°";
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前地热工作温度 - 针对单一属性更新
|
/// </summary>
|
public static void Update_FoolHeatPanel_Power (string updataFalg, byte power)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
if (deviceRow.GetChildren (j).GetType () == typeof (Button)) {
|
var btn = (Button)deviceRow.GetChildren (j);
|
if (btn.Tag != null) {
|
if (btn.Tag.ToString () == "Switch") {
|
if (power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调开关 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_WorkingTemp (string updataFalg, byte workingTemp,byte temperatureMode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
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 () == "Temperature") {
|
btn.Text = workingTemp + "°";
|
//if (btn.Text.Contains("C")) {
|
// btn.Text = workingTemp + "°C";
|
//} else {
|
// btn.Text = workingTemp + "°F";
|
//}
|
}
|
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调模式图标 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_ModeIcon (string updataFalg, byte mode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
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 () == "Mode") {
|
tempacBLL.UpdataACHostModeIcon (mode, btn);
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调风速图标 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_FanIcon (string updataFalg, byte fanMode)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
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 () == "Wind") {
|
tempacBLL.UpdataACHostWindIcon (fanMode, btn);
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 更新当前空调工作温度 - 针对单一属性更新
|
/// </summary>
|
public static void Update_ACPanel_Power (string updataFalg, byte power)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (deviceRow.Tag.ToString () == updataFalg) {
|
for (int j = 0; j < deviceRow.ChildrenCount; j++) {
|
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 (power == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
public static void UpdataDeviceStatus (Common common)
|
{
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
if (curView == null || curView.RoomView == null) {
|
return;
|
}
|
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) {
|
continue;
|
}
|
if (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.LightEnergySwitch ||
|
common.Type == DeviceType.LightSwitchSocket || 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;
|
}
|
} else if (common.Type == DeviceType.LightSwitch || common.Type == DeviceType.LightMixSwitch
|
|| common.Type == DeviceType.LightSwitchSocket || common.Type == DeviceType.LightEnergySwitch) {
|
if ((common as LightSwitch).CurrentBrightness == 0) {
|
btn.IsSelected = false;
|
} else {
|
btn.IsSelected = true;
|
}
|
} 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;
|
}
|
} else if (common.Type == DeviceType.FanModule) {
|
if ((common as FanModule).WindSpeed == 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) {
|
//(lightRow.GetChildren (j) as HorizontalSeekBar).Progress = brightness;
|
}
|
} else if (common.Type == DeviceType.FoolHeat) {
|
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 () + "°";
|
}
|
}
|
}
|
} else if (common.Type == DeviceType.HVAC || common.Type == DeviceType.ACInfrared ) {
|
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 () + "°";
|
} else if (btn.Tag.ToString () == "Mode") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.SetPattern);
|
} else if (btn.Tag.ToString () == "Wind") {
|
btn.UnSelectedImagePath = tempfaBLL.GetWindIcon (fa.WindSpeed);
|
}
|
}
|
} else if(common.Type == DeviceType.CurtainModel) {
|
|
}
|
}
|
}
|
}
|
}
|
});
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
} finally {
|
//Application.RunOnMainThread (() => {
|
// MainPage.Loading.Hide ();
|
//});
|
}
|
});
|
|
}
|
#endregion
|
public static Action ReadAirAction;
|
|
public override void RemoveFromParent ()
|
{
|
base.RemoveFromParent ();
|
foreach (var thread in UserMiddle.updateSensorhreadList) {
|
thread.Abort ();
|
Console.WriteLine ("abortThread");
|
}
|
UserMiddle.updateSensorhreadList.Clear ();
|
|
if (readEnergyThead != null)
|
readEnergyThead.Abort ();
|
curView = null;
|
}
|
|
void ShowSettingHomePageSensor()
|
{
|
Dialog dialog = new Dialog () ;
|
|
var dialogView = new PageLayout () {
|
Gravity = Gravity.Center,
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (730),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
IsShowPoint = false
|
};
|
dialog.AddChidren (dialogView);
|
|
dialogView.PageChange += (sender, e) => {
|
if (e < dialogView.ChildrenCount - 1) {
|
dialogView.GetChildren (dialogView.ChildrenCount - 1).RemoveFromParent ();
|
}
|
};
|
|
var bodyView = new FrameLayout () {
|
Width = Application.GetRealWidth(500),
|
Height = Application.GetRealHeight(730),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
dialogView.AddChidren (bodyView);
|
|
var btnTitle = new Button () {
|
Height = Application.GetRealHeight(90),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Setting,
|
};
|
bodyView.AddChidren (btnTitle);
|
|
var setTargetView = new VerticalScrolViewLayout () {
|
Y = btnTitle.Bottom,
|
Height = Application.GetRealHeight(550),
|
ScrollEnabled = false,
|
};
|
bodyView.AddChidren (setTargetView);
|
|
var enableView = new FrameLayout () {
|
Height = Application.GetRealHeight(100),
|
};
|
setTargetView.AddChidren (enableView);
|
|
var btnEnable = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (380),
|
TextID = R.MyInternationalizationString.EnablingIndoorSensors,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
enableView.AddChidren (btnEnable);
|
|
var btnCheck = new Button () {
|
X = btnEnable.Right ,
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (100),
|
SelectedImagePath = "Item/CheckSelected.png",
|
UnSelectedImagePath = "Item/Check.png",
|
IsSelected = UserConfig.Instance.IsSetHomePageSensor
|
};
|
enableView.AddChidren (btnCheck);
|
btnCheck.MouseUpEventHandler += (sender, e) => {
|
btnCheck.IsSelected = !btnCheck.IsSelected;
|
};
|
|
var btnLine1 = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
setTargetView.AddChidren (btnLine1);
|
|
var tempView = new FrameLayout () {
|
Height = Application.GetRealHeight(90),
|
};
|
setTargetView.AddChidren (tempView);
|
|
var btnTempName = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (400),
|
Text = Language.StringByID (R.MyInternationalizationString.SourceOfTemp) + UserConfig.Instance.temp.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = UserConfig.Instance.temp
|
};
|
tempView.AddChidren (btnTempName);
|
|
var btnTempNameRight = new Button () {
|
X = btnTempName.Right,
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
tempView.AddChidren (btnTempNameRight);
|
|
btnTempName.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorTemperature, dialogView, btnTempName);
|
dialogView.PageIndex = 1;
|
};
|
btnTempNameRight.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorTemperature, dialogView, btnTempName);
|
dialogView.PageIndex = 1;
|
};
|
tempView.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorTemperature, dialogView, btnTempName);
|
dialogView.PageIndex = 1;
|
};
|
|
var btnLine2 = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
setTargetView.AddChidren (btnLine2);
|
|
|
var pm25View = new FrameLayout () {
|
Height = Application.GetRealHeight (90),
|
};
|
setTargetView.AddChidren (pm25View);
|
var btnPM25Name = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (400),
|
Text = Language.StringByID (R.MyInternationalizationString.SourceOfPM25) + UserConfig.Instance.pm25.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = UserConfig.Instance.pm25
|
};
|
pm25View.AddChidren (btnPM25Name);
|
|
var btnPM25NameRight = new Button () {
|
X = btnTempName.Right,
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
pm25View.AddChidren (btnPM25NameRight);
|
|
|
btnPM25Name.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorPM25, dialogView, btnPM25Name);
|
dialogView.PageIndex = 1;
|
};
|
btnPM25NameRight.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorPM25, dialogView, btnPM25Name);
|
dialogView.PageIndex = 1;
|
};
|
pm25View.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorPM25, dialogView, btnPM25Name);
|
dialogView.PageIndex = 1;
|
};
|
|
|
var btnLine3 = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
setTargetView.AddChidren (btnLine3);
|
|
|
var humidityView = new FrameLayout () {
|
Height = Application.GetRealHeight (90),
|
};
|
setTargetView.AddChidren (humidityView);
|
var btnHumidityName = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (400),
|
Text = Language.StringByID (R.MyInternationalizationString.SourceOfHumidity) + UserConfig.Instance.humidity.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = UserConfig.Instance.humidity
|
};
|
humidityView.AddChidren (btnHumidityName);
|
|
var btnHumidityNameRight = new Button () {
|
X = btnTempName.Right,
|
Width = Application.GetRealWidth (28),
|
Height = Application.GetRealHeight (40),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/Right.png",
|
SelectedImagePath = "Item/RightSelected.png",
|
};
|
humidityView.AddChidren (btnHumidityNameRight);
|
|
btnHumidityName.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorHumidity, dialogView, btnHumidityName);
|
dialogView.PageIndex = 1;
|
};
|
btnHumidityNameRight.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorHumidity, dialogView, btnHumidityName);
|
dialogView.PageIndex = 1;
|
};
|
humidityView.MouseUpEventHandler += (sender, e) => {
|
ShowSettingHomePageSensorTarget (DeviceType.SensorHumidity, dialogView, btnHumidityName);
|
dialogView.PageIndex = 1;
|
};
|
|
var btnLine4 = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
setTargetView.AddChidren (btnLine4);
|
|
//var co2View = new FrameLayout () {
|
// Height = Application.GetRealHeight (90),
|
//};
|
//setTargetView.AddChidren (co2View);
|
//var btnCO2Name = new Button () {
|
// X = Application.GetRealWidth (40),
|
// Width = Application.GetRealWidth (400),
|
// Text = Language.StringByID (R.MyInternationalizationString.SourceOfCO2) + UserConfig.Instance.co2.Name,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// Tag = UserConfig.Instance.co2
|
//};
|
//co2View.AddChidren (btnCO2Name);
|
|
//var btnCO2NameRight = new Button () {
|
// X = btnTempName.Right,
|
// Width = Application.GetRealWidth (28),
|
// Height = Application.GetRealHeight (40),
|
// Gravity = Gravity.CenterVertical,
|
// UnSelectedImagePath = "Item/Right.png",
|
// SelectedImagePath = "Item/RightSelected.png",
|
//};
|
//co2View.AddChidren (btnCO2NameRight);
|
|
//btnCO2Name.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorCO2, dialogView, btnCO2Name);
|
// dialogView.PageIndex = 1;
|
//};
|
//btnCO2NameRight.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorCO2, dialogView, btnCO2Name);
|
// dialogView.PageIndex = 1;
|
//};
|
//co2View.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorCO2, dialogView, btnCO2Name);
|
// dialogView.PageIndex = 1;
|
//};
|
|
//var btnLine5 = new Button () {
|
// Height = 1,
|
// BackgroundColor = SkinStyle.Current.LineColor,
|
//};
|
//setTargetView.AddChidren (btnLine5);
|
|
//var tvocView = new FrameLayout () {
|
// Height = Application.GetRealHeight (90),
|
//};
|
//setTargetView.AddChidren (tvocView);
|
//var btnTVOCName = new Button () {
|
// X = Application.GetRealWidth (40),
|
// Width = Application.GetRealWidth (400),
|
// Text = Language.StringByID (R.MyInternationalizationString.SourceOfTVOC) + UserConfig.Instance.tvoc.Name,
|
// TextAlignment = TextAlignment.CenterLeft,
|
// TextColor = SkinStyle.Current.TextColor1,
|
// Tag = UserConfig.Instance.tvoc
|
//};
|
//tvocView.AddChidren (btnTVOCName);
|
|
//var btnTVOCNameRight = new Button () {
|
// X = btnTempName.Right,
|
// Width = Application.GetRealWidth (28),
|
// Height = Application.GetRealHeight (40),
|
// Gravity = Gravity.CenterVertical,
|
// UnSelectedImagePath = "Item/Right.png",
|
// SelectedImagePath = "Item/RightSelected.png",
|
//};
|
//tvocView.AddChidren (btnTVOCNameRight);
|
|
//btnTVOCName.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorTVOC, dialogView, btnTVOCName);
|
// dialogView.PageIndex = 1;
|
//};
|
//btnTVOCNameRight.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorTVOC, dialogView, btnTVOCName);
|
// dialogView.PageIndex = 1;
|
//};
|
//tvocView.MouseUpEventHandler += (sender, e) => {
|
// ShowSettingHomePageSensorTarget (DeviceType.SensorTVOC, dialogView, btnTVOCName);
|
// dialogView.PageIndex = 1;
|
//};
|
|
//var btnLine6 = new Button () {
|
// Height = 1,
|
// BackgroundColor = SkinStyle.Current.LineColor,
|
//};
|
//setTargetView.AddChidren (btnLine6);
|
|
|
var bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight(640),
|
Height = Application.GetRealHeight(93),
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
};
|
bodyView.AddChidren (bottomView);
|
|
var btnClose = new Button () {
|
Width = Application.GetRealWidth (250),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.cancel,
|
};
|
bottomView.AddChidren (btnClose);
|
|
btnClose.MouseUpEventHandler += (sender, e) => {
|
dialog.Close ();
|
};
|
|
var btnConfrim = new Button () {
|
Width = Application.GetRealWidth(250),
|
X = btnClose.Right + 1,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Confrim,
|
};
|
bottomView.AddChidren (btnConfrim);
|
btnConfrim.MouseUpEventHandler += (sender, e) => {
|
UserConfig.Instance.IsSetHomePageSensor = btnCheck.IsSelected;
|
if (btnTempName.Tag != null) {
|
try {
|
UserConfig.Instance.temp = btnTempName.Tag as HomePageSensor;
|
} catch { }
|
}
|
if (btnPM25Name.Tag != null) {
|
try {
|
UserConfig.Instance.pm25 = btnPM25Name.Tag as HomePageSensor;
|
} catch { }
|
}
|
//if (btnTVOCName.Tag != null) {
|
// try {
|
// UserConfig.Instance.tvoc = btnTVOCName.Tag as HomePageSensor;
|
// } catch { }
|
//}
|
//if (btnCO2Name.Tag != null) {
|
// try {
|
// UserConfig.Instance.co2 = btnCO2Name.Tag as HomePageSensor;
|
// } catch { }
|
//}
|
if (btnHumidityName.Tag != null) {
|
try {
|
UserConfig.Instance.humidity = btnHumidityName.Tag as HomePageSensor;
|
} catch { }
|
}
|
UserConfig.Instance.SaveUserConfig ();
|
InitRoomView (Room.FavoriteRoom);
|
dialog.Close ();
|
};
|
|
dialog.Show ();
|
}
|
|
void ShowSettingHomePageSensorTarget (DeviceType deviceType, PageLayout viewLayout,Button targetButton)
|
{
|
|
var bodyView = new FrameLayout () {
|
Width = Application.GetRealWidth (500),
|
Height = Application.GetRealHeight (730),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
viewLayout.AddChidren (bodyView);
|
|
var backView = new FrameLayout () {
|
Height = Application.GetRealHeight (90),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
bodyView.AddChidren (backView);
|
var back = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
};
|
backView.AddChidren (back);
|
back.MouseUpEventHandler += (sender, e) => {
|
viewLayout.PageIndex = 0;
|
bodyView.RemoveFromParent ();
|
};
|
|
|
var setTargetView = new VerticalScrolViewLayout () {
|
Y = backView.Bottom,
|
Height = Application.GetRealHeight (640),
|
};
|
bodyView.AddChidren (setTargetView);
|
|
var customary = targetButton.Tag as HomePageSensor;
|
if (customary == null) {
|
customary = new HomePageSensor () { SubnetID = 255, DeviceID = 255, LoopID = 255, Name = "" };
|
}
|
var sensorList = UserDeviceView.allLocationFiles.FindAll ((obj) => obj.Split ('_').Length == 5 && obj.Split ('_') [1] == deviceType.ToString ());
|
foreach(var sensorPath in sensorList) {
|
var sensor =Newtonsoft.Json.JsonConvert.DeserializeObject<Common>(CommonPage.MyEncodingUTF8.GetString( IO.FileUtils.ReadFile (sensorPath)));
|
|
var view = new FrameLayout () {
|
Height = Application.GetRealHeight (100),
|
};
|
setTargetView.AddChidren (view);
|
|
var btnCheck = new Button () {
|
X = Application.GetRealWidth (400),
|
Y = Application.GetRealHeight (15),
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (61),
|
SelectedImagePath = "Skin/Check.png",
|
UnSelectedImagePath = "Item/Transparent.png",
|
};
|
view.AddChidren (btnCheck);
|
if(customary.SubnetID == sensor.SubnetID && customary.DeviceID == sensor.DeviceID && customary.LoopID == sensor.LoopID) {
|
btnCheck.IsSelected = true;
|
}
|
|
var btnDevice = new Button () {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (500),
|
Text = sensor.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
view.AddChidren (btnDevice);
|
view.MouseUpEventHandler += (sender, e) => {
|
if (customary.SubnetID == sensor.SubnetID && customary.DeviceID == sensor.DeviceID && customary.LoopID == sensor.LoopID) {
|
targetButton.Tag = null;
|
switch (deviceType) {
|
case DeviceType.SensorTemperature:
|
targetButton.Text = Language.StringByID(R.MyInternationalizationString.SourceOfTemp)+Language.StringByID(R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorHumidity:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfHumidity) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorPM25:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfPM25) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorCO2:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfCO2) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorTVOC:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTVOC) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
}
|
} else {
|
switch (deviceType) {
|
case DeviceType.SensorTemperature:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTemp) + sensor.Name;
|
break;
|
case DeviceType.SensorHumidity:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfHumidity) + sensor.Name;
|
break;
|
case DeviceType.SensorPM25:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfPM25) + sensor.Name;
|
break;
|
case DeviceType.SensorCO2:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfCO2) + sensor.Name;
|
break;
|
case DeviceType.SensorTVOC:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTVOC) + sensor.Name;
|
break;
|
}
|
targetButton.Tag = new HomePageSensor () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LoopID = sensor.LoopID, Name = sensor.Name };
|
}
|
viewLayout.PageIndex = 0;
|
bodyView.RemoveFromParent ();
|
};
|
|
btnDevice.MouseUpEventHandler += (sender, e) => {
|
if (customary.SubnetID == sensor.SubnetID && customary.DeviceID == sensor.DeviceID && customary.LoopID == sensor.LoopID) {
|
switch (deviceType) {
|
case DeviceType.SensorTemperature:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTemp) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorHumidity:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfHumidity) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorPM25:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfPM25) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorCO2:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfCO2) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
case DeviceType.SensorTVOC:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTVOC) + Language.StringByID (R.MyInternationalizationString.NotConfigured);
|
break;
|
}
|
targetButton.Tag = null;
|
} else {
|
switch (deviceType) {
|
case DeviceType.SensorTemperature:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTemp) + sensor.Name;
|
break;
|
case DeviceType.SensorHumidity:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfHumidity) + sensor.Name;
|
break;
|
case DeviceType.SensorPM25:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfPM25) + sensor.Name;
|
break;
|
case DeviceType.SensorCO2:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfCO2) + sensor.Name;
|
break;
|
case DeviceType.SensorTVOC:
|
targetButton.Text = Language.StringByID (R.MyInternationalizationString.SourceOfTVOC) + sensor.Name;
|
break;
|
}
|
targetButton.Tag = new HomePageSensor () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LoopID = sensor.LoopID, Name = sensor.Name };
|
}
|
viewLayout.PageIndex = 0;
|
bodyView.RemoveFromParent ();
|
};
|
|
|
var btnLine6 = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
};
|
setTargetView.AddChidren (btnLine6);
|
|
}
|
}
|
|
Button btnformaldehydeValues;
|
Button btnTvocValues;
|
Button btnco2Values;
|
Button btnhumidityValues;
|
Button btnPM25Values;
|
Button btnTempSensorValues;
|
|
public static void UpdateHomePageSensor(DeviceType deviceType,HomePageSensor homePageSensor)
|
{
|
if (UserConfig.Instance.IsSetHomePageSensor) {
|
if (curView != null) {
|
Application.RunOnMainThread (() => {
|
switch (deviceType) {
|
|
case DeviceType.SensorPM25:
|
if(curView.btnPM25Values!= null) {
|
curView.btnPM25Values.Text = homePageSensor.values.ToString ();
|
}
|
break;
|
case DeviceType.SensorTemperature:
|
if(curView.btnTempSensorValues!= null) {
|
curView.btnTempSensorValues.Text = homePageSensor.values.ToString ();
|
}
|
break;
|
case DeviceType.SensorCO2:
|
if(curView.btnco2Values!= null) {
|
curView.btnco2Values.Text = homePageSensor.values.ToString ();
|
}
|
break;
|
case DeviceType.SensorHumidity:
|
if(curView.btnhumidityValues!= null) {
|
curView.btnhumidityValues.Text = homePageSensor.values.ToString ();
|
}
|
break;
|
case DeviceType.SensorTVOC:
|
if (curView.btnTvocValues != null) {
|
curView.btnTvocValues.Text = homePageSensor.values.ToString ();
|
}
|
break;
|
}
|
});
|
}
|
}
|
}
|
|
public void InitRoomView (string RoomFilePath)
|
{
|
try {
|
curView = this;
|
RemoveAll ();
|
showList.Clear ();
|
roomFilePath = RoomFilePath;
|
|
room = Room.GetRoomByFilePath (roomFilePath);
|
//room = Room.Lists.Find ((obj) => obj.Name == sendRoom.Name);
|
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 () {
|
Width = Application.GetRealWidth (154),
|
Height = Application.GetRealHeight (90),
|
UnSelectedImagePath = MainPage.LogoString,
|
};
|
topView.AddChidren (LogoButton);
|
|
LogoButton.MouseUpEventHandler += (sender, e) => {
|
// int i = 10;
|
// while (i > 0) {
|
// i--;
|
// System.Threading.Tasks.Task.Run (() => {
|
// SmartHome.MqttCommon.StartCloudMqtt ();
|
// });
|
// }
|
|
};
|
} 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.GetMinRealAverage (55),
|
Height = Application.GetMinRealAverage (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);
|
};
|
|
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 = topView.Bottom,
|
Height = Application.GetRealHeight (Application.DesignHeight - 126),
|
Width = Application.GetRealWidth (640),
|
};
|
AddChidren (RoomView);
|
if (roomFilePath == Room.FavoriteRoom) {
|
RoomView.Height = Application.GetRealHeight (Application.DesignHeight - UserMiddle.userMenuItemHeight) - topView.Bottom;
|
|
Button btnGoDownTip = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight (90 - 26),
|
Width = Application.GetRealWidth (53),
|
Height = Application.GetRealHeight (26),
|
UnSelectedImagePath = "Room/godown.png",
|
};
|
#if wallon
|
NameButton.TextID = R.MyInternationalizationString.Favorite;
|
#else
|
NameButton.Text = UserConfig.Instance.CurrentRegion.RegionName;
|
topView.AddChidren (btnGoDownTip);
|
#endif
|
|
//顶部标题按钮切换住宅区域
|
NameButton.MouseUpEventHandler += (sdf, asf) => {
|
#if wallon
|
return;
|
#endif
|
MainPage.Loading.Start ();
|
System.Threading.Tasks.Task.Run (() => {
|
if (UserConfig.Instance.HomeLists.Count == 0) {
|
var requestObj2 = new HomeListObj ();
|
var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
|
var revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
|
if (revertObj2.StateCode == "SUCCESS") {
|
var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
|
UserConfig.Instance.HomeLists = responseDataObj;
|
UserConfig.Instance.SaveUserConfig ();
|
}
|
}
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
Dialog dialog = new Dialog ();
|
FrameLayout bodyView = new FrameLayout ();
|
dialog.AddChidren (bodyView);
|
bodyView.MouseUpEventHandler += (lkj, oiu) => {
|
dialog.Close ();
|
};
|
|
var 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 FrameLayout () {
|
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.RegionID != UserConfig.Instance.CurrentRegion.RegionID
|
};
|
rowView.AddChidren (btnPoint);
|
|
var btnName = new Button () {
|
Width = Application.GetRealWidth (550),
|
Text = homeTemp.RegionName,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (90),
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
rowView.AddChidren (btnName);
|
|
btnName.MouseUpEventHandler += (ss, ee) => {
|
if (UserConfig.Instance.CurrentRegion.RegionID == homeTemp.RegionID) {
|
return;
|
}
|
MainPage.Loading.Start ("");
|
new System.Threading.Thread (() => {
|
try {
|
var backuplist = IO.FileUtils.ReadFiles ();
|
int index = 0;
|
string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.RegionID.ToString());
|
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);
|
Console.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.RegionID.ToString ());
|
IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
|
UserConfig.Instance.RefreshUserConfig ();
|
UserConfig.Instance.CurrentRegion = homeTemp;
|
//UserConfig.Instance.GatewayMAC = homeTemp.MAC;
|
UserConfig.Instance.SaveUserConfig ();
|
|
MainPage.LoginUser.SaveUserInfo ();
|
Room.InitAllRoom ();
|
//UserConfig.Instance.RefreshUserConfig ();
|
//MainPage.LoginUser.SaveUserInfo ();
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SwitchRegionSuccessfully),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
this.InitRoomView (roomFilePath);
|
EquipmentPublicClass.CheckLinkRemote (2);
|
});
|
} catch (Exception ex) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
|
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
});
|
Console.WriteLine (ex.Message);
|
} finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
dialog.Close ();
|
});
|
}
|
}) { IsBackground = true }.Start ();
|
};
|
if (homeTemp.RegionID == UserConfig.Instance.CurrentRegion.RegionID) {
|
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 = MainPage.GetDesignHeight (360),
|
BackgroundImagePath = "Room/FavoriteRoom.png"
|
//BackGroundImage
|
};
|
RoomView.AddChidren (airQualityBackgroundView);
|
if (room.BackGroundImage != "Room/r1.png") {
|
airQualityBackgroundView.BackgroundImagePath = room.BackGroundImage;
|
}
|
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);
|
};
|
|
|
if (UserConfig.Instance.IsSetHomePageSensor ) {
|
|
if (UserConfig.Instance.temp != null ) {
|
btnTempSensorValues = new Button () {
|
X = Application.GetRealWidth(480),
|
Y = Application.GetRealHeight(140),
|
Width = Application.GetRealWidth (130),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterRight,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 28,
|
Text= "--°C"
|
};
|
airQualityView.AddChidren (btnTempSensorValues);
|
|
var btnIndoorTip = new Button () {
|
X =Application.GetRealWidth(530),
|
Y = btnTempSensorValues.Bottom,
|
Width = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(40),
|
BackgroundColor = 0xFFFFFFFF,
|
Radius = (uint)Application.GetRealHeight(20),
|
BorderColor = SkinStyle.Current.Transparent,
|
TextID = R.MyInternationalizationString.Indoor,
|
TextColor = 0xFF333333,
|
TextAlignment = TextAlignment.Center,
|
};
|
airQualityView.AddChidren (btnIndoorTip);
|
|
Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.temp.SubnetID, UserConfig.Instance.temp.DeviceID, new byte [] { 5, 2, UserConfig.Instance.temp.LoopID });
|
}
|
|
int sensorIndex = 0;
|
|
if (UserConfig.Instance.pm25 != null) {
|
var pm25View = new FrameLayout () {
|
X = Application.GetRealWidth(510),//640 - 145
|
Y = Application.GetRealHeight (275),
|
Width = Application.GetRealWidth(110),
|
};
|
airQualityView.AddChidren (pm25View);
|
|
var btnPM25Icon = new Button () {
|
X = Application.GetRealWidth(10),
|
Y = Application.GetRealHeight (5),
|
Width = Application.GetRealWidth (20),
|
Height = MainPage.GetDesignHeight (25),
|
UnSelectedImagePath = "AirQuality/PM25Icon.png",
|
};
|
pm25View.AddChidren (btnPM25Icon);
|
|
var btnPM25 = new Button () {
|
X = Application.GetRealWidth (25),
|
Width = Application.GetRealWidth (150),
|
Height = MainPage.GetDesignHeight (27),
|
Text = "PM2.5",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12
|
};
|
pm25View.AddChidren (btnPM25);
|
|
btnPM25Values = new Button () {
|
Y = btnPM25.Bottom,
|
Height = Application.GetRealHeight(30),
|
TextAlignment = TextAlignment.Center,
|
//TextSize = 20,
|
Text = "--",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
pm25View.AddChidren (btnPM25Values);
|
|
var btnPM25Uint = new Button () {
|
Y = btnPM25Values.Bottom,
|
Height = Application.GetRealHeight(30),
|
TextAlignment = TextAlignment.Center,
|
TextSize = 10,
|
Text = @"μg/m³",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
pm25View.AddChidren (btnPM25Uint);
|
|
sensorIndex++;
|
Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.pm25.SubnetID, UserConfig.Instance.pm25.DeviceID, new byte [] { 5, 6, UserConfig.Instance.pm25.LoopID });
|
}
|
|
if (UserConfig.Instance.humidity != null ) {
|
if (sensorIndex == 1) {
|
var btnAirLineNull = new Button () {
|
X = Application.GetRealWidth (510 - ((sensorIndex-1) * 90) - (sensorIndex*3)),
|
Y = Application.GetRealHeight (275),
|
Width = Application.GetRealWidth (3),
|
Height = Application.GetRealHeight (25),
|
BackgroundColor = 0xFFFFFFFF
|
};
|
airQualityView.AddChidren (btnAirLineNull);
|
}
|
|
var humidityView = new FrameLayout () {
|
X = Application.GetRealWidth (510 - (sensorIndex * 90) - (sensorIndex * 3)) + 3,
|
Y = Application.GetRealHeight (275),
|
Width = Application.GetRealWidth (85),
|
};
|
airQualityView.AddChidren (humidityView);
|
|
var btnhumidityIcon = new Button () {
|
Y = MainPage.GetDesignHeight (5),
|
Width = Application.GetRealWidth (18),
|
Height = MainPage.GetDesignHeight (22),
|
UnSelectedImagePath = "AirQuality/HumidityIcon.png",
|
Gravity = Gravity.CenterHorizontal,
|
};
|
humidityView.AddChidren (btnhumidityIcon);
|
|
btnhumidityValues = new Button () {
|
Y = MainPage.GetDesignHeight (27),
|
Height = Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.Center,
|
//TextSize = 20,
|
Text = "--",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
humidityView.AddChidren (btnhumidityValues);
|
|
var btnhumidityUint = new Button () {
|
Y = btnhumidityValues.Bottom,
|
Height = Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.Center,
|
TextSize = 10,
|
Text = @"%",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
humidityView.AddChidren (btnhumidityUint);
|
|
sensorIndex++;
|
|
Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.humidity.SubnetID, UserConfig.Instance.humidity.DeviceID, new byte [] { 5, 3, UserConfig.Instance.humidity.LoopID });
|
}
|
|
if (UserConfig.Instance.co2 != null ) {
|
if (sensorIndex > 0) {
|
var btnAirLineNull = new Button () {
|
X = Application.GetRealWidth (510 - ((sensorIndex - 1) * 90) - (sensorIndex * 3)),
|
Y = Application.GetRealHeight (275),
|
Width = Application.GetRealWidth (3),
|
Height = Application.GetRealHeight (25),
|
BackgroundColor = 0xFFFFFFFF
|
};
|
airQualityView.AddChidren (btnAirLineNull);
|
}
|
var co2View = new FrameLayout () {
|
X = Application.GetRealWidth (510 - (sensorIndex * 90) - (sensorIndex * 3)) + 3,
|
Y = Application.GetRealHeight (275),
|
Width = Application.GetRealWidth (85),
|
|
};
|
airQualityView.AddChidren (co2View);
|
|
var btnco2Icon = new Button () {
|
Y = MainPage.GetDesignHeight (5),
|
Width = Application.GetRealWidth (29),
|
Height = MainPage.GetDesignHeight (20),
|
UnSelectedImagePath = "AirQuality/co2.png",
|
Gravity = Gravity.CenterHorizontal,
|
};
|
co2View.AddChidren (btnco2Icon);
|
|
btnco2Values = new Button () {
|
Y = MainPage.GetDesignHeight (27),
|
Height = Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.Center,
|
//TextSize = 20,
|
Text = "--",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
co2View.AddChidren (btnco2Values);
|
|
var btnco2Uint = new Button () {
|
Y = btnco2Values.Bottom,
|
Height = Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.Center,
|
TextSize = 10,
|
Text = @"ppm",
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
co2View.AddChidren (btnco2Uint);
|
|
sensorIndex++;
|
|
Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.co2.SubnetID, UserConfig.Instance.co2.DeviceID, new byte [] { 5, 7, UserConfig.Instance.co2.LoopID });
|
}
|
|
//if (UserConfig.Instance.tvoc != null ) {
|
// if (sensorIndex > 1) {
|
// var btnAirLineNull = new Button () {
|
// X = Application.GetRealWidth (510 - ((sensorIndex - 1) * 90) - (sensorIndex * 3)),
|
// Y = Application.GetRealHeight (275),
|
// Width = Application.GetRealWidth (3),
|
// Height = Application.GetRealHeight (25),
|
// BackgroundColor = 0xFFFFFFFF
|
// };
|
// airQualityView.AddChidren (btnAirLineNull);
|
// }
|
// var tvocView = new FrameLayout () {
|
// X = Application.GetRealWidth (510 - (sensorIndex * 90) - (sensorIndex * 3)) + 3,
|
// Y = Application.GetRealHeight (275),
|
// Width = Application.GetRealWidth (85),
|
|
// };
|
// airQualityView.AddChidren (tvocView);
|
|
// var btnTvocIcon = new Button () {
|
// Y = MainPage.GetDesignHeight (1),
|
// Width = Application.GetRealWidth (27),
|
// Height = MainPage.GetDesignHeight (27),
|
// UnSelectedImagePath = "AirQuality/tvoc.png",
|
// Gravity = Gravity.CenterHorizontal,
|
// };
|
// tvocView.AddChidren (btnTvocIcon);
|
|
// btnTvocValues = new Button () {
|
// Y = MainPage.GetDesignHeight (27),
|
// Height = Application.GetRealHeight (30),
|
// TextAlignment = TextAlignment.Center,
|
// //TextSize = 20,
|
// Text = "--",
|
// TextColor = SkinStyle.Current.TextColor1,
|
// };
|
// tvocView.AddChidren (btnTvocValues);
|
|
// var btnTvocUint = new Button () {
|
// Y = btnTvocValues.Bottom,
|
// Height = Application.GetRealHeight (30),
|
// TextAlignment = TextAlignment.Center,
|
// TextSize = 10,
|
// Text = @"ppm",
|
// TextColor = SkinStyle.Current.TextColor1,
|
// };
|
// tvocView.AddChidren (btnTvocUint);
|
|
// sensorIndex++;
|
// Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.tvoc.SubnetID, UserConfig.Instance.tvoc.DeviceID, new byte [] { 5, 5, UserConfig.Instance.tvoc.LoopID });
|
|
//}
|
|
|
//if (UserConfig.Instance.formaldehyde != null) {
|
// if (sensorIndex > 1) {
|
// var btnAirLineNull = new Button () {
|
// X = Application.GetRealWidth (510 - ((sensorIndex - 1) * 90) - (sensorIndex * 3)),
|
// Y = Application.GetRealHeight (275),
|
// Width = Application.GetRealWidth (3),
|
// Height = Application.GetRealHeight (25),
|
// BackgroundColor = 0xFFFFFFFF
|
// };
|
// airQualityView.AddChidren (btnAirLineNull);
|
// }
|
// var formaldehydeView = new FrameLayout () {
|
// X = Application.GetRealWidth (510 - (sensorIndex * 90) - (sensorIndex * 3)) + 3,
|
// Y = Application.GetRealHeight (275),
|
// Width = Application.GetRealWidth (85),
|
|
// };
|
// airQualityView.AddChidren (formaldehydeView);
|
|
// var btnformaldehydeIcon = new Button () {
|
// Y = MainPage.GetDesignHeight (2),
|
// Width = Application.GetRealWidth (25),
|
// Height = MainPage.GetDesignHeight (25),
|
// UnSelectedImagePath = "AirQuality/formaldehyde.png",
|
// Gravity = Gravity.CenterHorizontal,
|
// };
|
// formaldehydeView.AddChidren (btnformaldehydeIcon);
|
|
// btnformaldehydeValues = new Button () {
|
// Y = MainPage.GetDesignHeight (27),
|
// Height = Application.GetRealHeight (30),
|
// TextAlignment = TextAlignment.Center,
|
// //TextSize = 20,
|
// Text = "--",
|
// TextColor = SkinStyle.Current.TextColor1,
|
// };
|
// formaldehydeView.AddChidren (btnformaldehydeValues);
|
|
// var btnformaldehydeUint = new Button () {
|
// Y = btnformaldehydeValues.Bottom,
|
// Height = Application.GetRealHeight (30),
|
// TextAlignment = TextAlignment.Center,
|
// TextSize = 10,
|
// Text = @"mg/m³",
|
// TextColor = SkinStyle.Current.TextColor1,
|
// };
|
// formaldehydeView.AddChidren (btnformaldehydeUint);
|
|
// sensorIndex++;
|
// Control.ControlBytesSend (Command.ReadAnalog, UserConfig.Instance.formaldehyde.SubnetID, UserConfig.Instance.formaldehyde.DeviceID, new byte [] { 5, 2, UserConfig.Instance.formaldehyde.LoopID });
|
|
//}
|
|
|
|
var btnCity = new Button () {
|
X = Application.GetRealWidth (30),
|
Width = Application.GetRealWidth (600),
|
Height = MainPage.GetDesignHeight (70),
|
TextAlignment = TextAlignment.BottomLeft,
|
Text = AirQCity,
|
TextSize = 22
|
};
|
airQualityView.AddChidren (btnCity);
|
var btnAirIcon = new Button () {
|
X = btnCity.X,
|
Y = btnCity.Bottom,
|
Width = Application.GetRealWidth (45),
|
Height = MainPage.GetDesignHeight (35),
|
UnSelectedImagePath = AirQAirIcon,
|
};
|
airQualityView.AddChidren (btnAirIcon);
|
var btnTemp = new Button () {
|
X = btnAirIcon.Right,
|
Y = btnAirIcon.Y,
|
Width = Application.GetRealWidth (90),
|
Height = MainPage.GetDesignHeight (35),
|
Text = AirQTemp,
|
TextSize = Application.DeviceType == Device.Ios ? 20 : 17,
|
TextAlignment = TextAlignment.CenterLeft,
|
FontName = "TitilliumText25L"
|
};
|
airQualityView.AddChidren (btnTemp);
|
btnCity.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
btnTemp.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
btnAirIcon.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
|
CommonPage.RefreshAir = () => {
|
var airQualityR = MainPage.AirQuality;
|
if (airQualityR != null ) {
|
AirQCity = btnCity.Text = airQualityR.city;
|
AirQTemp = btnTemp.Text = airQualityR.airQTemp + "°";
|
#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
|
|
}
|
};
|
|
} else {
|
var btnCity = new Button () {
|
X = Application.GetRealWidth (30),
|
Width = Application.GetRealWidth (600),
|
Height = MainPage.GetDesignHeight (70),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = AirQCity,
|
TextSize = 16
|
};
|
airQualityView.AddChidren (btnCity);
|
btnCity.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
|
Button btnAirIcon = new Button () {
|
X = Application.GetRealWidth (390),
|
Y = MainPage.GetDesignHeight (230),
|
Width = Application.GetRealWidth (91),
|
Height = MainPage.GetDesignHeight (69),
|
UnSelectedImagePath = AirQAirIcon,
|
};
|
airQualityView.AddChidren (btnAirIcon);
|
|
Button btnTemp = new Button () {
|
X = btnAirIcon.Right,
|
Y = btnAirIcon.Y,
|
Width = Application.GetRealWidth (180),
|
Height = MainPage.GetDesignHeight (70),
|
Text = AirQTemp,
|
TextSize = Application.DeviceType == Device.Ios ? 40 : 34,
|
TextAlignment = TextAlignment.Center,
|
FontName = "TitilliumText25L"
|
};
|
airQualityView.AddChidren (btnTemp);
|
|
btnTemp.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
btnAirIcon.MouseLongEventHandler += (sebder, enu) => {
|
ShowSettingHomePageSensor ();
|
};
|
Button btnHumidityIcon = new Button () {
|
X = btnAirIcon.X + Application.GetRealWidth (10),
|
Y = btnAirIcon.Bottom + MainPage.GetDesignHeight (20),
|
Width = Application.GetRealWidth (20),
|
Height = MainPage.GetDesignHeight (25),
|
UnSelectedImagePath = AirQHumidityIcon,
|
};
|
airQualityView.AddChidren (btnHumidityIcon);
|
Button btnHumidity = new Button () {
|
X = btnHumidityIcon.Right,
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (40),
|
Height = MainPage.GetDesignHeight (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 = SkinStyle.Current.White20Transparent,
|
};
|
airQualityView.AddChidren (btnAirLineNull);
|
|
Button btnPM25Icon = new Button () {
|
X = btnAirLineNull.Right + Application.GetRealWidth (5),
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (20),
|
Height = MainPage.GetDesignHeight (25),
|
UnSelectedImagePath = AirQAirPM25Icon,
|
};
|
airQualityView.AddChidren (btnPM25Icon);
|
|
Button btnPM25 = new Button () {
|
X = btnPM25Icon.Right + Application.GetRealWidth (5),
|
Y = btnHumidityIcon.Y,
|
Width = Application.GetRealWidth (150),
|
Height = MainPage.GetDesignHeight (27),
|
Text = AirQAirPM25,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = 12
|
};
|
airQualityView.AddChidren (btnPM25);
|
|
CommonPage.RefreshAir = () => {
|
var airQualityR = MainPage.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;
|
}
|
|
#region 美林空调系统
|
var ACMerrillList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.ACMerrill);
|
foreach (var devcieCommon in ACMerrillList) {
|
if (devcieCommon == null)
|
continue;
|
|
#region 美林空调系统
|
var acMl = devcieCommon as ACMerrill;
|
var mlRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (110),
|
Tag = devcieCommon.Type + "_" + devcieCommon.CommonLoopID
|
};
|
RoomView.AddChidren (mlRowView);
|
Button btnIcon = new Button () {
|
Width = Application.GetRealHeight (60),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
UnSelectedImagePath = "AC/AC.png",
|
SelectedImagePath = "AC/AC.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
mlRowView.AddChidren (btnIcon);
|
|
var tempDeviceName = new Button () {
|
X = btnIcon.Right + Application.GetRealWidth (10),
|
Width = Application.GetRealWidth (340),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = acMl.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
mlRowView.AddChidren (tempDeviceName);
|
tempDeviceName.MouseUpEventHandler += (sender2, e2) => {
|
if (Room.ACMerrillHost == null) return;
|
|
ACMerrillHomePage mACMerrillHomePage = new ACMerrillHomePage (Room.ACMerrillHost);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (mACMerrillHomePage);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (mACMerrillHomePage);
|
}
|
mACMerrillHomePage.ShowView ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
#endregion
|
|
var cacList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.Thermostat );
|
if (cacList.Count > 0) {
|
Room.ReadThermostatHostList ();
|
}
|
foreach (var devcieCommon in cacList) {
|
if (devcieCommon == null)
|
continue;
|
|
#region cacList
|
var capillaryAC = devcieCommon as Thermostat;
|
EventHandler<MouseEventArgs> openCapillaryACControlPageEvent = (button, mouseEventArgs) => {
|
ThermostatExtensionPage acView = new ThermostatExtensionPage ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (acView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (acView);
|
}
|
acView.ShowPage (capillaryAC);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
var acRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (120),
|
Tag = devcieCommon.Type
|
};
|
RoomView.AddChidren (acRowView);
|
acRowView.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var tempDeviceName = new Button () {
|
X = Application.GetRealWidth (40),
|
//Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = capillaryAC.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
acRowView.AddChidren (tempDeviceName);
|
tempDeviceName.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
Button btnThermometerIcon = new Button () {
|
X = Application.GetRealWidth (370),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (40),
|
Height = Application.GetMinRealAverage (40),
|
UnSelectedImagePath = "CapillaryAC/ThermometerIcon.png",
|
SelectedImagePath = "CapillaryAC/ThermometerIcon.png",
|
};
|
acRowView.AddChidren (btnThermometerIcon);
|
btnThermometerIcon.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var btnThermometerValues = new Button () {
|
X = btnThermometerIcon.Right,
|
Width = Application.GetRealWidth (60),
|
Text = Math.Round (capillaryAC.Indoor_Temperature_Values, 0) + "°C",
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 12,
|
Tag = "CapillaryACThermometerValues"
|
};
|
acRowView.AddChidren (btnThermometerValues);
|
|
Button btnHumidityIcon = new Button () {
|
X = btnThermometerValues.Right ,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (40),
|
Height = Application.GetMinRealAverage (40),
|
UnSelectedImagePath = "CapillaryAC/HumidityIcon.png",
|
SelectedImagePath = "CapillaryAC/HumidityIcon.png",
|
};
|
acRowView.AddChidren (btnHumidityIcon);
|
btnHumidityIcon.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var btnHumidityValues = new Button () {
|
X = btnHumidityIcon.Right,
|
Width = Application.GetRealWidth (60),
|
Text = Math.Round (capillaryAC.Indoor_Humidity_Values, 0) + "%",
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
TextSize = 12,
|
Tag = "CapillaryACHumidityValues"
|
};
|
acRowView.AddChidren (btnHumidityValues);
|
|
var btnCurMode = new Button () {
|
Width = Application.GetRealWidth (60),
|
Height = Application.GetRealHeight(60),
|
X = btnHumidityValues.Right,
|
Y = Application.GetRealHeight (30),
|
TextAlignment = TextAlignment.Center,
|
UnSelectedImagePath = "CapillaryAC/Heating.png",
|
SelectedImagePath = "CapillaryAC/Heating.png",
|
Tag = "CapillaryACCurMode"
|
};
|
acRowView.AddChidren (btnCurMode);
|
switch (capillaryAC.CurrentMode) {
|
case 5:// "HeatingAndDehumidification":
|
btnCurMode.UnSelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png";
|
btnCurMode.SelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png";
|
break;
|
case 1://"Cooling":
|
btnCurMode.UnSelectedImagePath = "CapillaryAC/Cooling.png";
|
btnCurMode.SelectedImagePath = "CapillaryAC/Cooling.png";
|
break;
|
case 2: //"Heating":
|
btnCurMode.UnSelectedImagePath = "CapillaryAC/Heating.png";
|
btnCurMode.SelectedImagePath = "CapillaryAC/Heating.png";
|
break;
|
case 4: //"Dehumidification":
|
btnCurMode.UnSelectedImagePath = "CapillaryAC/Dehumidification.png";
|
btnCurMode.SelectedImagePath = "CapillaryAC/Dehumidification.png";
|
break;
|
case 3: //"Aeration":
|
btnCurMode.UnSelectedImagePath = "CapillaryAC/Aeration.png";
|
btnCurMode.SelectedImagePath = "CapillaryAC/Aeration.png";
|
break;
|
}
|
|
btnCurMode.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
Control.ControlBytesSend (Command.ReadThermostatExtension, capillaryAC.SubnetID, capillaryAC.DeviceID, new byte [] { capillaryAC.ExtensionID });
|
Control.ControlBytesSend (Command.ReadThermostatHost, capillaryAC.SubnetID, capillaryAC.DeviceID, new byte [] { capillaryAC.HostID });
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
|
var faList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.FreshAir);
|
if (faList.Count > 0) {
|
var bLL = new FreshAirBLL ();
|
foreach (var devcieCommon in faList) {
|
if (devcieCommon == null)
|
continue;
|
#region FreshAir
|
var freshAirCommon = devcieCommon as FreshAir;
|
EventHandler<MouseEventArgs> openFreshAirControlPageEvent = (button, mouseEventArgs) => {
|
UserFreshAirPage faView = new UserFreshAirPage (freshAirCommon, room);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (faView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (faView);
|
}
|
faView.ShowRoomFreshAir ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
var acRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (140),
|
Tag = devcieCommon.Type + "_" + freshAirCommon.CommonLoopID
|
};
|
RoomView.AddChidren (acRowView);
|
acRowView.MouseUpEventHandler += openFreshAirControlPageEvent;
|
|
var tempDeviceName = new Button () {
|
X = Application.GetRealWidth (30),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = freshAirCommon.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
acRowView.AddChidren (tempDeviceName);
|
tempDeviceName.MouseUpEventHandler += openFreshAirControlPageEvent;
|
|
Button btnMode = new Button () {
|
X = Application.GetRealWidth (20),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Mode",
|
UnSelectedImagePath = bLL.GetModeIcon (freshAirCommon.SetPattern),
|
};
|
acRowView.AddChidren (btnMode);
|
btnMode.MouseUpEventHandler += openFreshAirControlPageEvent;
|
|
Button btnWind = new Button () {
|
X = btnMode.Right + Application.GetRealWidth (0),
|
Y = Application.GetRealHeight (40),
|
Width = Application.GetMinRealAverage (100),
|
Height = Application.GetMinRealAverage (100),
|
Tag = "Wind",
|
UnSelectedImagePath = bLL.GetWindIcon (freshAirCommon.WindSpeed),
|
};
|
acRowView.AddChidren (btnWind);
|
btnWind.MouseUpEventHandler += openFreshAirControlPageEvent;
|
|
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,
|
Text = freshAirCommon.InTemp.ToString () + "°"
|
};
|
acRowView.AddChidren (btnSetTemperature);
|
btnSetTemperature.MouseUpEventHandler += openFreshAirControlPageEvent;
|
|
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",
|
IsSelected = freshAirCommon.SwitchStatus == 0 ? true : false
|
};
|
acRowView.AddChidren (tempSiwtch);
|
tempSiwtch.MouseUpEventHandler += (sender3, e3) => {
|
tempSiwtch.IsSelected = !tempSiwtch.IsSelected;
|
if (tempSiwtch.IsSelected) {
|
freshAirCommon.SwitchStatus = 0;
|
} else {
|
freshAirCommon.SwitchStatus = 1;
|
}
|
bLL.ControlFreshAir (freshAirCommon);
|
};
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
|
#endregion
|
Control.ControlBytesSend (Command.FreshAirRead, freshAirCommon.SubnetID, freshAirCommon.DeviceID, new byte [] { freshAirCommon.LoopID });
|
}
|
}
|
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;
|
|
#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 (40),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = ac.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
acRowView.AddChidren (tempDeviceName);
|
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;
|
if (ac.Type == DeviceType.ACPanel) {
|
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) {
|
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;
|
}
|
|
if (ac.Type == DeviceType.ACPanel) {
|
new System.Threading.Thread (() => {
|
var readRecBytes = Control.ControlBytesSendHasReturn (Command.ReadPanelTempType, ac.SubnetID, ac.DeviceID, new byte [] { });
|
if (readRecBytes != null) {
|
try {
|
if (readRecBytes.Length > 0) {
|
if (ac.TemperatureMode != readRecBytes [0]) {
|
ac.TemperatureMode = readRecBytes [0];
|
IO.FileUtils.SaveEquipmentMessage (ac, ac.LoopID.ToString ());
|
Application.RunOnMainThread (() => {
|
if (readRecBytes [0] == 0) {
|
btnSetTemperature.Text = ac.SetTemperature.ToString () + "°C";
|
} else {
|
var f = ac.IndoorTemperature * 9 / 5 + 32;
|
btnSetTemperature.Text = ac.SetTemperature.ToString () + "°F";
|
}
|
});
|
}
|
}
|
} catch (Exception ex) {
|
Console.WriteLine (ex.Message);
|
}
|
}
|
}) { IsBackground = true }.Start ();
|
}
|
new System.Threading.Thread (() => {
|
if (ac.Type == DeviceType.ACPanel) {
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 3, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 4, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 5, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 6, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 7, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 8, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadInstructionPanelKey, ac.SubnetID, ac.DeviceID, new byte [] { 19, ac.LoopID, ac.LoopID }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadPanelTempTypeACK, ac.SubnetID, ac.DeviceID, new byte [] { }, SendCount.Zero);
|
Control.ControlBytesSend (Command.ReadPanleTemp, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID }, SendCount.Zero);
|
} else if (ac.Type == DeviceType.HVAC || ac.Type == DeviceType.ACInfrared) {
|
Control.ControlBytesSendHasReturn (Command.ReadACMode, ac.SubnetID, ac.DeviceID, new byte [] { ac.LoopID });
|
}
|
}) { IsBackground = true }.Start ();
|
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;
|
|
#region 地热模块
|
var fh = devcieCommon as FoolHeat;
|
var fhRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (110),
|
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.Right + Application.GetRealWidth (10),
|
Width = Application.GetRealWidth (340),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = fh.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
fhRowView.AddChidren (tempDeviceName);
|
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 () + "°",
|
TextSize = 26,
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
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) {
|
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 20, fh.Status, fh.LoopID });
|
} else if (fh.Type == DeviceType.FoolHeat) {
|
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch);
|
}
|
});
|
};
|
|
if (0 < fh.Status) {
|
tempSiwtch.IsSelected = true;
|
}
|
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
foreach (var deviceCommon in room.DeviceList) {
|
if (deviceCommon == null)
|
continue;
|
|
if (deviceCommon.Type == DeviceType.FoolHeat || deviceCommon.Type == DeviceType.FoolHeatPanel || deviceCommon.Type == DeviceType.Thermostat ||
|
deviceCommon.Type == DeviceType.HVAC || deviceCommon.Type == DeviceType.ACInfrared || deviceCommon.Type == DeviceType.ACPanel ||
|
deviceCommon.Type == DeviceType.FreshAir || deviceCommon.Type == DeviceType.LogicModule) {
|
continue;
|
} else {
|
var DeviceRowView = new FrameLayout () {
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Height = Application.GetRealHeight (100),
|
Tag = deviceCommon.Type + "_" + deviceCommon.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 = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.Right + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
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 = deviceCommon.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.DeviceFilePathList.Contains (deviceFilePath)) {
|
// // room.DeviceFilePathList.Remove (deviceFilePath);
|
// //}
|
// //else if (room.SceneFilePathList.Contains (deviceFilePath)) {
|
// // room.SceneFilePathList.Remove (deviceFilePath);
|
// //}
|
// room.Save (roomFilePath);
|
// this.InitRoomView (roomFilePath);
|
//};
|
//==============================
|
//if (deviceCommon.Type == DeviceType.LogicModule) {
|
// LogicModule lm = deviceCommon as LogicModule;
|
// btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
// btnIcon.SelectedImagePath = "Scene/Scene.png";
|
// btnName.MouseUpEventHandler += (sender, e) => {
|
// Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
// };
|
// DeviceRowView.MouseUpEventHandler += (sender, e) => {
|
// Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
// };
|
//}
|
if (deviceCommon.Type == DeviceType.FanModule) {
|
#region 风扇
|
FanModule fanModule = deviceCommon as FanModule;//(FanModule)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
|
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 });
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightDimming) {
|
#region 调光器A
|
LightDimming dimming = deviceCommon as LightDimming;
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
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);
|
|
var 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 () {
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = dimming.CurrentBrightness
|
};
|
proessView.AddChidren (horizontalSeekBar);
|
Button btnMaxBrightness = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (80),
|
X = horizontalSeekBar.Right + Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
Text = dimming.CurrentBrightness + "%",
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
proessView.AddChidren (btnMaxBrightness);
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnMaxBrightness.Text = horizontalSeekBar.Progress + "%";
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)e4;
|
if (e4 == 0 || e4 == 100) {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,dimming.DeviceID, new byte [] { dimming.LoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
return;
|
}
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 800) {
|
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) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
|
};
|
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.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,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.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
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "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);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
|
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightDALI) {
|
#region DALI
|
LightDALI dimming = deviceCommon as LightDALI;// (LightDimming)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
|
//if (dimming == null) {
|
// dimming = comm;
|
//}
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
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 (440),
|
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);
|
|
var btnCurBrightness = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = btnDialogTitle.Bottom,
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + dimming.CurrentBrightness + "%"
|
};
|
dimmingView.AddChidren (btnCurBrightness);
|
|
var proessView = new FrameLayout () {
|
Y = btnCurBrightness.Bottom,
|
Height = Application.GetRealHeight (80),
|
};
|
dimmingView.AddChidren (proessView);
|
|
var horizontalSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Progress = dimming.CurrentBrightness
|
};
|
proessView.AddChidren (horizontalSeekBar);
|
|
horizontalSeekBar.ProgressChanged += (sender2, e4) => {
|
//Console.WriteLine (DateTime.Now.ToString ());
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
dimming.LastOpenBrightness = dimming.CurrentBrightness = (byte)e4;
|
if (e4 == 0 || e4 == 100) {
|
horizontalSeekBar.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)e4;
|
return;
|
}
|
|
new System.Threading.Thread (() => {
|
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);
|
}) { IsBackground = true}.Start();
|
};
|
horizontalSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
dimming.CurrentBrightness = (byte)horizontalSeekBar.Progress;
|
btnCurBrightness.Text = Language.StringByID (R.MyInternationalizationString.brightness) + " " + horizontalSeekBar.Progress + "%";
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,dimming.DeviceID, new byte [] { dimming.LoopID, (byte)horizontalSeekBar.Progress, 0, 0 });
|
};
|
|
|
var btnCurTone = new Button () {
|
X = Application.GetRealWidth (30),
|
Y = proessView.Bottom + Application.GetRealHeight (20),
|
Width = Application.GetRealWidth (500 - 120),
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor,
|
Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K"
|
};
|
dimmingView.AddChidren (btnCurTone);
|
|
var proessToneView = new FrameLayout () {
|
Y = btnCurTone.Bottom,
|
Height = Application.GetRealHeight (60),
|
};
|
dimmingView.AddChidren (proessToneView);
|
|
var horizontalToneSeekBar = new HorizontalSeekBar () {
|
Width = Application.GetRealWidth (500 - 60),
|
X = Application.GetRealWidth (30),
|
Gravity = Gravity.CenterVertical,
|
Tag = DateTime.MinValue,
|
ThumbColor = SkinStyle.Current.SelectedColor,
|
Max = dimming.TonesRange / 100,
|
Progress = (dimming.CurTone - dimming.WarmTones) / 100
|
};
|
proessToneView.AddChidren (horizontalToneSeekBar);
|
|
var btnWarmToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (30),
|
TextID = R.MyInternationalizationString.Warm,
|
Y = proessToneView.Bottom,
|
TextAlignment = TextAlignment.TopLeft,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dimmingView.AddChidren (btnWarmToneText);
|
|
var btnColoToneText = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (60),
|
X = Application.GetRealWidth (380),
|
Y = proessToneView.Bottom,
|
TextID = R.MyInternationalizationString.CoolTones,
|
TextAlignment = TextAlignment.TopRight,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
dimmingView.AddChidren (btnColoToneText);
|
horizontalToneSeekBar.ProgressChanged += (sender2, e4) => {
|
var tonesValues = e4 * 100 + dimming.WarmTones;
|
dimming.CurTones_High = (byte)(tonesValues / 256);
|
dimming.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K";
|
System.Threading.Tasks.Task.Run (() => {
|
if ((System.DateTime.Now - (DateTime)(horizontalSeekBar.Tag)).TotalMilliseconds < 100) {
|
return;
|
}
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurTones_High, dimming.CurTones_Low }, SendCount.Zero);
|
});
|
};
|
horizontalToneSeekBar.MouseUpEventHandler += (sender2, e4) => {
|
horizontalToneSeekBar.Tag = DateTime.Now;
|
var tonesValues = horizontalToneSeekBar.Progress * 100 + dimming.WarmTones;
|
dimming.CurTones_High = (byte)(tonesValues / 256);
|
dimming.CurTones_Low = (byte)(tonesValues % 256);
|
btnCurTone.Text = Language.StringByID (R.MyInternationalizationString.Tones) + " " + dimming.CurTone + "K";
|
Control.ControlBytesSend (Command.control_lamp_color_Temperature, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurTones_High, dimming.CurTones_Low }, SendCount.Zero);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
};
|
|
dialogDimming.Show ();
|
};
|
|
tempSwitch.IsSelected = dimming.CurrentBrightness > 0 ? true : false;
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.LoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
|
};
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.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,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.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
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "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);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightMixDimming) {
|
#region 调光器
|
LightMixDimming comm = Newtonsoft.Json.JsonConvert.DeserializeObject<LightMixDimming> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceCommon.SavePath)));
|
LightMixDimming dimming = deviceCommon 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,
|
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) => {
|
//Console.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.PhysicsLoopID, (byte)e4, 0, 0 }, SendCount.Zero);
|
});
|
|
if (e4 == 0 || e4 == 100) {
|
System.Threading.Tasks.Task.Run (() => {
|
horizontalSeekBar.Tag = DateTime.Now;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID,
|
dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, (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.PhysicsLoopID, (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) {
|
dimming.CurrentBrightness = 100;
|
} else {
|
dimming.CurrentBrightness = 0;
|
}
|
byte delayHeight = 0;
|
byte delayLow = 0;
|
if (dimming.CurrentBrightness == 0) {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeClose / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeClose % 256);
|
} else {
|
delayHeight = Convert.ToByte (dimming.CustomDelayTimeOpen / 256);
|
delayLow = Convert.ToByte (dimming.CustomDelayTimeOpen % 256);
|
}
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, dimming.CurrentBrightness, delayHeight, delayLow });
|
};
|
#region 延时
|
Button btnLightSetting = new Button () {
|
Width = Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (60),
|
Radius = (uint)Application.GetRealHeight (30),
|
X = btnName.Right,
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Light/DimmingSetting.png",
|
SelectedImagePath = "Light/DimmingSetting.png",
|
Visible = dimming.DimmingFunction,
|
};
|
DeviceRowView.AddChidren (btnLightSetting);
|
btnLightSetting.MouseUpEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
FrameLayout dialogView = new FrameLayout () {
|
BackgroundColor = SkinStyle.Current.DialogColor,
|
Width = Application.GetRealWidth (480),
|
Height = Application.GetRealHeight (520),
|
Radius = 5,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
Gravity = Gravity.Center,
|
};
|
dialog.AddChidren (dialogView);
|
Button btnTitle = new Button () {
|
Height = Application.GetRealHeight (70),
|
TextAlignment = TextAlignment.Center,
|
Enable = false,
|
TextID = R.MyInternationalizationString.DelayTime2,
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (btnTitle);
|
|
#region ---延时开---
|
Button btnDelayTimeONTitle = new Button () {
|
Width = Application.GetRealWidth (310),
|
Height = Application.GetRealHeight (80),
|
X = Application.GetRealWidth (30),
|
TextAlignment = TextAlignment.CenterLeft,
|
Y = btnTitle.Bottom,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeON
|
};
|
dialogView.AddChidren (btnDelayTimeONTitle);
|
|
Button btnDelayTimeOnReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeONTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeOpen.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOnAdd);
|
DateTime newTime = DateTime.MaxValue;
|
byte delayTimeOn = dimming.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,
|
TextColor = SkinStyle.Current.TextColor,
|
TextID = R.MyInternationalizationString.DelayTimeOFF
|
};
|
dialogView.AddChidren (btnDelayTimeOFFTitle);
|
|
Button btnDelayTimeOffReduce = new Button () {
|
Width = Application.GetRealWidth (64),
|
Height = Application.GetRealHeight (62),
|
X = Application.GetRealWidth (90),
|
Y = btnDelayTimeOFFTitle.Bottom,
|
UnSelectedImagePath = "Light/Light-.png",
|
SelectedImagePath = "Light/Light-On.png",
|
};
|
dialogView.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 = dimming.CustomDelayTimeClose.ToString () + "s",
|
TextSize = 12,
|
TextColor = SkinStyle.Current.TextColor
|
};
|
dialogView.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",
|
};
|
dialogView.AddChidren (btnDelayTimeOffAdd);
|
|
byte delayTimeOff = dimming.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
|
|
FrameLayout bottomView = new FrameLayout () {
|
Y = Application.GetRealHeight (520 - 80),
|
Height = Application.GetRealHeight (80),
|
BackgroundColor = SkinStyle.Current.DialogTitle
|
};
|
dialogView.AddChidren (bottomView);
|
Button btnCancel = new Button () {
|
Width = Application.GetRealWidth (239),
|
TextID = R.MyInternationalizationString.Cancel,
|
};
|
bottomView.AddChidren (btnCancel);
|
btnCancel.MouseUpEventHandler += (sender2, e2) => {
|
dialog.Close ();
|
};
|
Button btnLine = new Button () {
|
BackgroundColor = SkinStyle.Current.White20Transparent,
|
Width = 1,
|
X = btnCancel.Right,
|
};
|
bottomView.AddChidren (btnLine);
|
Button btnSave = new Button () {
|
Width = Application.GetRealWidth (239),
|
X = btnLine.Right,
|
TextID = R.MyInternationalizationString.SAVE
|
};
|
bottomView.AddChidren (btnSave);
|
|
btnSave.MouseUpEventHandler += (send3er, e3) => {
|
string keyString = dimming.CommonLoopID;
|
dimming.CustomDelayTimeOpen = delayTimeOn;
|
dimming.CustomDelayTimeClose = delayTimeOff;
|
if (room.DelayTime.ContainsKey (dimming.CommonLoopID + "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);
|
IO.FileUtils.SaveEquipmentMessage (dimming, dimming.LoopID.ToString ());
|
dialog.Close ();
|
};
|
dialog.Show ();
|
};
|
#endregion
|
#endregion
|
} else if (deviceCommon.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 (deviceCommon.SavePath)));
|
LightMixSwitch dimming = deviceCommon 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;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 100, 0, 0 });
|
} else {
|
dimming.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, dimming.SubnetID, dimming.DeviceID, new byte [] { dimming.PhysicsLoopID, 0, 0, 0 });
|
}
|
};
|
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightRGB) {
|
#region RGB
|
LightLogic rgbLight = deviceCommon as LightLogic;//(LightLogic)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
if (rgbLight == null) {
|
rgbLight = Newtonsoft.Json.JsonConvert.DeserializeObject<LightLogic> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceCommon.SavePath)));
|
}
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
|
btnName.MouseUpEventHandler += (sender, e) => {
|
byte [] lightLigicBytes = new byte [11];
|
System.Threading.Tasks.Task.Run (() => {
|
try {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Start ("Loading..");
|
});
|
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 > 300) {
|
lightLigicBytes [6] = e2 [0];
|
lightLigicBytes [7] = e2 [1];
|
lightLigicBytes [8] = e2 [2];
|
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.TextColor,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
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.TextColor,
|
TextColor = SkinStyle.Current.TextColor,
|
};
|
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
|
var 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(e3 == 0 || e3 == 100) {
|
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;
|
}
|
if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 500) {
|
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;
|
}
|
};
|
|
var 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 ();
|
});
|
} catch { } finally {
|
Application.RunOnMainThread (() => {
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
};
|
|
tempSwitch.IsSelected = rgbLight.CurrentBrightness > 0 ? true : false;
|
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
var lightLigicBytes = Control.ControlBytesSendHasReturn (Command.ReadLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, new byte [] { rgbLight.LoopID });
|
if (lightLigicBytes != null) {
|
if (tempSwitch.IsSelected) {
|
rgbLight.CurrentBrightness = 100;
|
lightLigicBytes [1] = 100;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
} else {
|
rgbLight.CurrentBrightness = 0;
|
lightLigicBytes [1] = 0;
|
Control.ControlBytesSend (Command.SetLogicLoopColor, rgbLight.SubnetID, rgbLight.DeviceID, lightLigicBytes, SendCount.Zero);
|
}
|
}
|
});
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.LightSwitch || deviceCommon.Type == DeviceType.LightEnergySwitch || deviceCommon.Type == DeviceType.LightSwitchSocket) {
|
#region 继电器
|
LightSwitch switchLight = deviceCommon as LightSwitch;
|
tempSwitch.IsSelected = switchLight.CurrentBrightness == 100 ? true : false;
|
if (deviceCommon.Type == DeviceType.LightSwitchSocket) {
|
btnIcon.UnSelectedImagePath = "Light/Socket.png";
|
btnIcon.SelectedImagePath = "Light/Socket.png";
|
} else {
|
btnIcon.UnSelectedImagePath = "Item/Light.png";
|
btnIcon.SelectedImagePath = "Item/Light.png";
|
}
|
|
#if DEBUG
|
btnName.MouseLongEventHandler += (sender, e) => {
|
Dialog dialog = new Dialog ();
|
|
var bodyVV = new FrameLayout () {
|
BackgroundColor = 0xFF000000,
|
};
|
dialog.AddChidren (bodyVV);
|
|
var vView1 = new VerticalScrolViewLayout () {
|
Width = Application.GetRealWidth(320),
|
|
};
|
|
dialog.Show ();
|
};
|
#endif
|
|
if (deviceCommon.Type == DeviceType.LightEnergySwitch) {
|
Button btnEnergy = new Button () {
|
Width = Application.GetRealWidth (90),
|
Height = Application.GetRealHeight (30),
|
X = tempSwitch.X,
|
Y = tempSwitch.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
Tag = DeviceType.LightEnergySwitch.ToString (),
|
Text = "0 W"
|
};
|
DeviceRowView.AddChidren (btnEnergy);
|
EnergtLightList.Add (deviceCommon);
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
tempSwitch.IsSelected = !tempSwitch.IsSelected;
|
if (tempSwitch.IsSelected) {
|
switchLight.CurrentBrightness = 100;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 100, 0, 0 });
|
} else {
|
switchLight.CurrentBrightness = 0;
|
Control.ControlBytesSend (Command.SetSingleLight, switchLight.SubnetID, switchLight.DeviceID, new byte [] { switchLight.LoopID, 0, 0, 0 });
|
}
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainModel) {
|
#region 窗帘
|
//CurtainModel comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainModel> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainModel curtain = deviceCommon as CurtainModel;//(CurtainModel)room.DeviceList.Find ((obj) => obj.SubnetID == comm.SubnetID && obj.DeviceID == comm.DeviceID && obj.LoopID == comm.LoopID);
|
//if (curtain == null) {
|
// curtain = comm;
|
//}
|
tempSwitch.RemoveFromParent ();
|
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.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 });
|
}
|
//System.Threading.Tasks.Task.Factory.StartNew (() => {
|
// System.Threading.Thread.Sleep (2000);
|
// Application.RunOnMainThread (() => {
|
// });
|
//});
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.CurtainTrietex) {
|
#region 开合帘窗帘
|
//CurtainTrietex comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainTrietex> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainTrietex curtain = deviceCommon 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.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 (deviceCommon.Type == DeviceType.CurtainRoller) {
|
#region 卷帘
|
//CurtainRoller comm = Newtonsoft.Json.JsonConvert.DeserializeObject<CurtainRoller> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
CurtainRoller curtain = deviceCommon 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.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 (deviceCommon.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 (deviceCommon.Type == DeviceType.DryContact) {
|
#region 干接点
|
DryContact dc = deviceCommon 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 (deviceCommon.Type == DeviceType.InfraredMode) {
|
#region 红外电视
|
try {
|
InfraredMode infraredTV = deviceCommon as InfraredMode;// Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (deviceFilePath)));
|
if (infraredTV != null)
|
Console.WriteLine (infraredTV.InfraredType);
|
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;
|
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (fhView);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (fhView);
|
}
|
fhView.ShowUserTV (tempSwitch);
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
} catch (Exception ex) {
|
Console.WriteLine (ex.ToString ());
|
continue;
|
}
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.UniversalDevice) {
|
#region UniversalDevice
|
UniversalDevice udDevice = deviceCommon 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 == null ? Language.StringByID (R.MyInternationalizationString.ON) : udDevice.ON_Text;
|
//tempSwitch.TextID = R.MyInternationalizationString.ON;
|
} else if (udDevice.ActionType == 1) {
|
tempSwitch.Text = udDevice.OFF_Text == null ? Language.StringByID (R.MyInternationalizationString.OFF) : udDevice.OFF_Text;
|
//tempSwitch.TextID = R.MyInternationalizationString.OFF;
|
} else if (udDevice.ActionType == 2) {
|
tempSwitch.Text = udDevice.OFF_Text == null ? Language.StringByID (R.MyInternationalizationString.OFF) : 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,
|
BorderWidth = 2,
|
Text = udDevice.ON_Text,
|
//TextID = R.MyInternationalizationString.ON,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (tempON);
|
tempON.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
Control.ControlBytesSend (Command.SetCommonSwitch, udDevice.SubnetID, udDevice.DeviceID, new byte [] { udDevice.SendBytes [0], 255 }, SendCount.Zero);
|
}
|
};
|
tempON.MouseDownEventHandler += (sende3r, e3) => {
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempON.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempON.BorderColor = SkinStyle.Current.BorderColor;
|
});
|
});
|
};
|
}
|
tempSwitch.MouseUpEventHandler += (sender3, e3) => {
|
if (udDevice.UniversalType == 0xE01C) {
|
if (udDevice.ActionType == 0) {
|
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);
|
}
|
}
|
};
|
tempSwitch.MouseDownEventHandler += (sende3r, e3) => {
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
tempSwitch.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
tempSwitch.BorderColor = SkinStyle.Current.BorderColor;
|
});
|
});
|
};
|
#endregion
|
} else if (deviceCommon.Type == DeviceType.DoorLockRelay) {
|
#region 继电器门锁
|
try {
|
LightDoorLock mLightDoorLock = deviceCommon as LightDoorLock;
|
if (mLightDoorLock != null)
|
Console.WriteLine (mLightDoorLock.Type);
|
btnIcon.UnSelectedImagePath = "DoorLockPic/doorLockHomePage.png";
|
btnIcon.SelectedImagePath = "DoorLockPic/doorLockHomePage.png";
|
btnName.MouseUpEventHandler += (sender, e) => {
|
DoorLockRelayPage mDoorLockRelayPage = new DoorLockRelayPage (mLightDoorLock);
|
//UserMiddle.RoomPageView.AddChidren (mDoorLockRelayPage);
|
|
//UserMiddle.RoomPageView.PageIndex = 2;
|
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.AddChidren (mDoorLockRelayPage);
|
} else {
|
UserMiddle.RoomPageView.AddChidren (mDoorLockRelayPage);
|
}
|
mDoorLockRelayPage.showmLightDoorLocksRoom ();
|
if (roomFilePath == Room.FavoriteRoom) {
|
UserMiddle.FavoritePageView.PageIndex = 1;
|
} else {
|
UserMiddle.RoomPageView.PageIndex = 2;
|
}
|
};
|
tempSwitch.RemoveFromParent ();
|
} catch (Exception ex) {
|
Console.WriteLine (ex.ToString ());
|
continue;
|
}
|
#endregion
|
} else if (deviceCommon.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 (deviceCommon.Type == DeviceType.SensorCO2) {
|
SensorCO2 udDevice = deviceCommon 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 (deviceCommon.Type == DeviceType.SensorHumidity) {
|
SensorHumidity shDevice = deviceCommon 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 (deviceCommon.Type == DeviceType.SensorTVOC) {
|
SensorTVOC shDevice = deviceCommon as SensorTVOC;
|
btnValues.Text = shDevice.CurrentTVOC.ToString () + " mg/m3";
|
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 () + " mg/m3";
|
});
|
System.Threading.Thread.Sleep (60000);
|
}
|
});
|
thread.Start ();
|
UserMiddle.updateSensorhreadList.Add (thread);
|
} else if (deviceCommon.Type == DeviceType.SensorTemperature) {
|
SensorTemperature shDevice = deviceCommon 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 (deviceCommon.Type == DeviceType.SensorPM25) {
|
SensorPM25 shDevice = deviceCommon 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;
|
var DeviceRowView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
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,
|
};
|
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;
|
new System.Threading.Thread (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
});
|
}) { IsBackground = true }.Start ();
|
};
|
btnName.MouseUpEventHandler += (sender3, e3) => {
|
btnIcon.IsSelected = btnName.IsSelected = false;
|
new ScenePhoneMethod ().ControlScene (scenFilePath);
|
};
|
tempSwitch.MouseDownEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = true;
|
};
|
tempSwitch.MouseUpEventHandler += (sender, e) => {
|
tempSwitch.IsSelected = false;
|
var sceneView = new UserAddSceneDevice (typeof (Room).Name + "_" + room.Name, scenFilePath);
|
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
|
}
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
|
foreach (var deviceCommon in room.DeviceList) {
|
if (deviceCommon == null)
|
continue;
|
|
if (deviceCommon.Type == DeviceType.LogicModule) {
|
LogicModule lm = deviceCommon as LogicModule;
|
var DeviceRowView = new FrameLayout () {
|
Width = LayoutParams.MatchParent,
|
Height = Application.GetRealHeight (93),
|
Radius = 1,
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = (uint)Application.GetMinRealAverage (5),
|
Tag = deviceCommon.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 = deviceCommon.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = btnIcon.X + btnIcon.Width + Application.GetRealWidth (10),
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
DeviceRowView.AddChidren (btnName);
|
|
#region
|
btnIcon.UnSelectedImagePath = "Scene/Scene.png";
|
btnIcon.SelectedImagePath = "Scene/Scene.png";
|
btnName.MouseDownEventHandler += (sender2, e2) => {
|
btnIcon.IsSelected = btnName.IsSelected = true;
|
System.Threading.Tasks.Task.Factory.StartNew (() => {
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.SelectedColor;
|
});
|
System.Threading.Thread.Sleep (500);
|
Application.RunOnMainThread (() => {
|
DeviceRowView.BorderColor = SkinStyle.Current.Transparent;
|
});
|
});
|
};
|
btnName.MouseUpEventHandler += (sender3, e3) => {
|
btnIcon.IsSelected = btnName.IsSelected = false;
|
Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
};
|
DeviceRowView.MouseUpEventHandler += (sender, e) => {
|
Control.ControlBytesSendHasReturn (Command.SetScene, lm.SubnetID, lm.DeviceID, new byte [] { lm.AreaID, lm.AreaSceneID });
|
};
|
#endregion
|
var btnDeviceRowLine = new Button () {
|
Height = 1,
|
BackgroundColor = SkinStyle.Current.LineColor,
|
SelectedBackgroundColor = SkinStyle.Current.LineColor,
|
};
|
RoomView.AddChidren (btnDeviceRowLine);
|
}
|
}
|
} catch (Exception ex) {
|
Console.WriteLine ("exddd :" + ex.ToString ());
|
} finally {
|
readEnergyThead = new Thread ((obj) => {
|
while (true) {
|
foreach (var c in EnergtLightList) {
|
Control.ControlBytesSend (Command.ReadAnalogValue, c.SubnetID, c.DeviceID, new byte [] { 10, c.LoopID }, SendCount.Zero);
|
}
|
System.Threading.Thread.Sleep (10000);
|
}
|
});
|
readEnergyThead.Start ();
|
}
|
}
|
}
|
}
|