using System;
namespace Shared.SimpleControl.Phone
{
public class UserFHPage : FrameLayout
{
///
/// 当前视图
///
static UserFHPage curView;
FrameLayout fhBodyView;
FoolHeat fh;
Room room;
Button btnInterior;
Button btnFHSwitch;
Button btnSetTemperature;
Button btnReduceTemperature;
Button btnAddTemperature;
Button FH_Day;
Button FH_Night;
Button FH_Common;
Button Go_away;
Button FH_Auto;
Button btnValve;
Button text_Valve;
static DateTime controlTime = DateTime.MinValue;
///
/// 构造函数
///
/// Room.
public UserFHPage (FoolHeat fh, Room room)
{
this.fh = fh;
this.room = room;
curView = this;
BackgroundColor = SkinStyle.Current.MainColor;
}
///
/// 更新室内温度-针对面板单一状态更新
///
public static void UpdateIndoorTemp (string updateFalg, byte indoorTemp)
{
if (curView == null) {
return;
}
if (curView.fh.CommonLoopID != updateFalg) {
return;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
return;
}
Application.RunOnMainThread (() => {
var indoorT = indoorTemp;
string indoorTstr = Convert.ToString (indoorT, 2);
if (indoorT > 128) {
indoorTstr = "-" + (indoorT - 128) + "°";
} else if (indoorT == 128) {
indoorTstr = "--";
} else
indoorTstr = indoorT.ToString () + "°";
curView.btnInterior.Text = indoorTstr;
});
}
///
/// 更新工作温度-针对面板单一状态更新
///
public static void UpdateWorkingTemp (string updateFalg, byte workingTemp)
{
if (curView == null) {
return;
}
if (curView.fh.CommonLoopID != updateFalg) {
return;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
return;
}
Application.RunOnMainThread (() => {
curView.btnSetTemperature.Text = workingTemp + "°";
});
}
///
/// 更新地热开关状态-针对面板单一状态更新
///
public static void UpdatePower(string updateFalg, byte power)
{
if (curView == null) {
return;
}
if (curView.fh.CommonLoopID != updateFalg) {
return;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
return;
}
Application.RunOnMainThread (() => {
if (power == 1) {
//考虑到其他人控制的情况下,得使当前界面更新的数据和别人控制的一样
curView.btnFHSwitch.IsSelected = true;
curView.btnReduceTemperature.Enable = true;
curView.btnAddTemperature.Enable = true;
curView.FH_Day.Enable = true;
curView.FH_Auto.Enable = true;
curView.FH_Night.Enable = true;
curView.FH_Common.Enable = true;
curView.Go_away.Enable = true;
} else {
curView.btnFHSwitch.IsSelected = false;
curView.btnReduceTemperature.Enable = false;
curView.btnAddTemperature.Enable = false;
curView.FH_Day.Enable = false;
curView.FH_Auto.Enable = false;
curView.FH_Night.Enable = false;
curView.FH_Common.Enable = false;
curView.Go_away.Enable = false;
}
});
}
///
/// 更新工作模式-针对面板单一状态更新
///
public static void UpdateWorkingMode (string updateFalg, byte temperatureType)
{
if (curView == null) {
return;
}
if (curView.fh.CommonLoopID != updateFalg) {
return;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
return;
}
Application.RunOnMainThread (() => {
switch (temperatureType) {
case 1:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = true;
curView.Go_away.IsSelected = false;
break;
case 2:
curView.FH_Day.IsSelected = true;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
case 3:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = true;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
case 4:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = true;
break;
case 5:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = true;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
}
});
}
///
/// 更新地热
///
public static void UpdateStatus (FoolHeat updataFH, byte loopId)
{
if (curView == null) {
return;
}
if (curView.fh.LoopID != loopId)
return;
if (curView.fh.SubnetID != updataFH.SubnetID && curView.fh.DeviceID != updataFH.DeviceID) {
return;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
return;
}
Application.RunOnMainThread (() => {
try {
var indoorT = updataFH.IndoorTemperature;
string indoorTstr = Convert.ToString (indoorT, 2);
if (indoorT > 128) {
indoorTstr = "-" + (indoorT - 128) + "°";
} else if (indoorT == 128) {
indoorTstr = "--";
} else
indoorTstr = indoorT.ToString () + "°";
curView.btnInterior.Text = indoorTstr;
curView.btnSetTemperature.Text = updataFH.WorkingTemperature.ToString () + "°";
if (updataFH.Status == 1) {
//考虑到其他人控制的情况下,得使当前界面更新的数据和别人控制的一样
curView.btnFHSwitch.IsSelected = true;
curView.btnReduceTemperature.Enable = true;
curView.btnAddTemperature.Enable = true;
curView.FH_Day.Enable = true;
curView.FH_Auto.Enable = true;
curView.FH_Night.Enable = true;
curView.FH_Common.Enable = true;
curView.Go_away.Enable = true;
} else {
curView.btnFHSwitch.IsSelected = false;
curView.btnReduceTemperature.Enable = false;
curView.btnAddTemperature.Enable = false;
curView.FH_Day.Enable = false;
curView.FH_Auto.Enable = false;
curView.FH_Night.Enable = false;
curView.FH_Common.Enable = false;
curView.Go_away.Enable = false;
}
switch (updataFH.TemperatureType) {
case 1:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = true;
curView.Go_away.IsSelected = false;
break;
case 2:
curView.FH_Day.IsSelected = true;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
case 3:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = true;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
case 4:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = false;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = true;
break;
case 5:
curView.FH_Day.IsSelected = false;
curView.FH_Auto.IsSelected = true;
curView.FH_Night.IsSelected = false;
curView.FH_Common.IsSelected = false;
curView.Go_away.IsSelected = false;
break;
}
if (updataFH.PWDStatus == 0)//Close
{
curView.btnValve.Text = Language.StringByID (R.MyInternationalizationString.ValveStatus).Replace ("--", Language.StringByID (R.MyInternationalizationString.Close));
curView.text_Valve.Text = Language.StringByID (R.MyInternationalizationString.CurrentValue).Replace ("--", updataFH.PWDValue.ToString ());
} else {
curView.btnValve.Text = Language.StringByID (R.MyInternationalizationString.ValveStatus).Replace ("--", Language.StringByID (R.MyInternationalizationString.Open));
curView.text_Valve.Text = Language.StringByID (R.MyInternationalizationString.CurrentValue).Replace ("--", updataFH.PWDValue.ToString ());
}
} catch (Exception ex) {
Console.WriteLine ("UserACPage " + ex.ToString ());
}
});
}
///
/// 显示出当前房间所有的地热
///
public void ShowRoomFH ()
{
#region 标题
var topView = new FrameLayout () {
Y = Application.GetRealHeight (36),
Width = Application.GetRealWidth (640),
Height = Application.GetRealHeight (90),
};
AddChidren (topView);
var title = new Button () {
TextAlignment = TextAlignment.Center,
Text = fh.Name,
TextSize = 19,
TextColor = SkinStyle.Current.TextColor1
};
topView.AddChidren (title);
var logo = new Button () {
Width = Application.GetRealWidth (154),
Height = Application.GetRealHeight (90),
X = Application.GetRealWidth (486),
UnSelectedImagePath = MainPage.LogoString,
};
topView.AddChidren (logo);
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) => {
(Parent as PageLayout).PageIndex -= 1;
try {
curView = null;
} catch {
base.RemoveFromParent ();
}
};
#endregion
fhBodyView = new FrameLayout {
Height = Application.GetRealHeight (Application.DesignHeight - 126),
Width = Application.GetRealWidth (640),
Y = Application.GetRealHeight (126),
};
AddChidren (fhBodyView);
#region roomBackgroundImageView
var roomBackgroundImageView = new FrameLayout () {
Width = Application.GetRealWidth (640),
Height = MainPage.GetDesignHeight (360),
};
fhBodyView.AddChidren (roomBackgroundImageView);
roomBackgroundImageView.BackgroundImagePath = room.BackGroundImage;
//长按更换背景
#if wallon
#else
roomBackgroundImageView.MouseLongEventHandler += (sender, e) => {
Camera.SelectPicture ((obj) => {
if (obj != null) {
room.BackGroundImage = obj;
roomBackgroundImageView.BackgroundImagePath = obj;
room.Save (typeof (Room).Name + "_" + room.Name);
}
}, room.Name, false);
};
#endif
#endregion
#region 工作模式,开关按钮
FrameLayout WrokView = new FrameLayout () {
Height = Application.GetMinRealAverage (116),
Width = Application.GetRealWidth(640),
BackgroundColor = SkinStyle.Current.MainColor,
Y = Application.GetMinRealAverage (360),
};
fhBodyView.AddChidren (WrokView);
var FH_Heat = new Button () {
Width = Application.GetMinRealAverage (120),
Height = Application.GetMinRealAverage (120),
X = Application.GetRealWidth (35),
UnSelectedImagePath = "FH/FH_Heat_on.png",
SelectedImagePath = "FH/FH_Cold_on.png",
};
if (fh.WorkingMode == 0) {
FH_Heat.IsSelected = false;
} else {
FH_Heat.IsSelected = true;
}
FH_Heat.MouseUpEventHandler += (sender, e) => {
if (FH_Heat.IsSelected == false) {
FH_Heat.IsSelected = true;
fh.WorkingMode = 1;
} else {
FH_Heat.IsSelected = false;
fh.WorkingMode = 0;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
controlTime = DateTime.Now;
return;
}
controlTime = DateTime.Now;
Console.WriteLine ("controlTime reset");
System.Threading.Tasks.Task.Run (() => {
while (controlTime.AddSeconds (0.8) > DateTime.Now) {
System.Threading.Thread.Sleep (800);
Console.WriteLine ("sleep 800");
}
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.WorkMode);
}
});
};
if (fh.Type == DeviceType.FoolHeat) {
WrokView.AddChidren (FH_Heat);
}
btnFHSwitch = new Button () {
Width = Application.GetMinRealAverage (115),
Height = Application.GetMinRealAverage (115),
X = Application.GetRealWidth (640 - 152),
UnSelectedImagePath = "FH/FH_Switch.png",
SelectedImagePath = "FH/FH_Switch_on.png",
};
if (fh.Status == 1) {
btnFHSwitch.IsSelected = true;
} else {
btnFHSwitch.IsSelected = false;
}
btnFHSwitch.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
btnFHSwitch.IsSelected = true;
fh.Status = 1;
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
btnInterior.Text = fh.IndoorTemperature.ToString () + "°";
btnReduceTemperature.Enable = true;
btnAddTemperature.Enable = true;
FH_Day.Enable = true;
FH_Night.Enable = true;
FH_Common.Enable = true;
Go_away.Enable = true;
FH_Auto.Enable = true;
} else {
btnFHSwitch.IsSelected = false;
fh.Status = 0;
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
btnInterior.Text = fh.IndoorTemperature.ToString () + "°";
btnReduceTemperature.Enable = false;
btnAddTemperature.Enable = false;
FH_Day.Enable = false;
FH_Night.Enable = false;
FH_Common.Enable = false;
Go_away.Enable = false;
FH_Auto.Enable = false;
}
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
controlTime = DateTime.Now;
return;
}
controlTime = DateTime.Now;
Console.WriteLine ("controlTime reset");
System.Threading.Tasks.Task.Run (() => {
while (controlTime.AddSeconds (0.8) > DateTime.Now) {
System.Threading.Thread.Sleep (800);
Console.WriteLine ("sleep 800");
}
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);
}
});
};
WrokView.AddChidren (btnFHSwitch);
Button btnText = new Button () {
Width = Application.GetRealWidth (150),
Height = Application.GetRealHeight (40),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight (10),
TextID = R.MyInternationalizationString.ACInterior,
TextColor = SkinStyle.Current.TextColor1
};
WrokView.AddChidren (btnText);
var indoorT = fh.IndoorTemperature;
string indoorTstr = Convert.ToString (indoorT, 2);
if (indoorT > 127) {
indoorTstr = "-" + (indoorT - 128) + "°";
} else
indoorTstr = indoorT.ToString();
btnInterior = new Button () {
Width = Application.GetRealWidth (150),
Height = Application.GetRealHeight (80),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight (30),
Text = indoorTstr + "°",
TextSize = 15,
TextAlignment = TextAlignment.Center,
TextColor = SkinStyle.Current.TextColor1
};
WrokView.AddChidren (btnInterior);
#endregion
#region 温度
FrameLayout fhTemperatureView = new FrameLayout () {
Height = Application.GetRealHeight (550 / 3 - 40),
Width = LayoutParams.MatchParent,
BackgroundColor = SkinStyle.Current.ViewColor,
Y = WrokView.Bottom,
};
fhBodyView.AddChidren (fhTemperatureView);
var btnLine1 = new Button () {
Height = 1,
BackgroundColor = SkinStyle.Current.Black50Transparent,
Y = fhTemperatureView.Height - 2,
};
fhTemperatureView.AddChidren (btnLine1);
btnSetTemperature = new Button () {
Width = Application.GetRealWidth (310),
X = Application.GetRealWidth ((640 - 310) / 2),
Text = fh.WorkingTemperature.ToString () + "°",
TextAlignment = TextAlignment.Center,
Enable = false,
TextSize = 21,
TextColor = SkinStyle.Current.TextColor1
};
fhTemperatureView.AddChidren (btnSetTemperature);
btnReduceTemperature = new Button (){
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = Application.GetRealWidth (30),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac-1.png",
SelectedImagePath = "AC/ac_on-.png",
};
fhTemperatureView.AddChidren (btnReduceTemperature);
btnReduceTemperature.MouseDownEventHandler += (sender, e) => {
btnReduceTemperature.IsSelected = true;
};
btnReduceTemperature.MouseUpEventHandler += (sender, e) => {
if (fh.TemperatureType == 5)//时间模式不容许修改温度
return;
btnReduceTemperature.IsSelected = false;
if (--fh.WorkingTemperature <= 5) {
return;
} else {
switch (fh.TemperatureType) {
case 1:
fh.NormalTemperature = fh.WorkingTemperature;
break;
case 2:
fh.DayTemperature = fh.WorkingTemperature;
break;
case 3:
fh.NightTemperature = fh.WorkingTemperature;
break;
case 4:
fh.AwayTemperature = fh.WorkingTemperature;
break;
}
}
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
btnInterior.Text = fh.IndoorTemperature.ToString () + "°";
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
controlTime = DateTime.Now;
return;
}
controlTime = DateTime.Now;
Console.WriteLine ("controlTime reset");
System.Threading.Tasks.Task.Run (() => {
while (controlTime.AddSeconds (0.8) > DateTime.Now) {
System.Threading.Thread.Sleep (800);
Console.WriteLine ("sleep 800");
}
if (fh.Type == DeviceType.FoolHeatPanel) {
switch (fh.TemperatureType) {
case 1:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 25, fh.WorkingTemperature, fh.LoopID });
break;
case 2:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 26, fh.WorkingTemperature, fh.LoopID });
break;
case 3:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 27, fh.WorkingTemperature, fh.LoopID });
break;
case 4:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 28, fh.WorkingTemperature, fh.LoopID });
break;
default:
break;
}
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Temperatrue);
}
});
};
btnAddTemperature = new Button () {
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = Application.GetRealWidth (640 - 129 - 30),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac+1.png",
SelectedImagePath = "AC/ac_on+.png",
};
fhTemperatureView.AddChidren (btnAddTemperature);
btnAddTemperature.MouseDownEventHandler += (sender, e) => {
btnAddTemperature.IsSelected = true;
};
btnAddTemperature.MouseUpEventHandler += (sender, e) => {
if (fh.TemperatureType == 5)//时间模式不容许修改温度
return;
btnAddTemperature.IsSelected = false;
if (++fh.WorkingTemperature > 128) {
return;
} else {
switch (fh.TemperatureType) {
case 1:
fh.NormalTemperature = fh.WorkingTemperature;
break;
case 2:
fh.DayTemperature = fh.WorkingTemperature;
break;
case 3:
fh.NightTemperature = fh.WorkingTemperature;
break;
case 4:
fh.AwayTemperature = fh.WorkingTemperature;
break;
}
}
btnSetTemperature.Text = fh.WorkingTemperature.ToString () + "°";
btnInterior.Text = fh.IndoorTemperature.ToString () + "°";
if (controlTime.AddSeconds (0.8) > DateTime.Now) {
controlTime = DateTime.Now;
return;
}
controlTime = DateTime.Now;
Console.WriteLine ("controlTime reset");
System.Threading.Tasks.Task.Run (() => {
while (controlTime.AddSeconds (0.8) > DateTime.Now) {
System.Threading.Thread.Sleep (800);
Console.WriteLine ("sleep 800");
}
if (fh.Type == DeviceType.FoolHeatPanel) {
switch (fh.TemperatureType) {
case 1:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 25, fh.WorkingTemperature, fh.LoopID });
break;
case 2:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 26, fh.WorkingTemperature, fh.LoopID });
break;
case 3:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 27, fh.WorkingTemperature, fh.LoopID });
break;
case 4:
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 28, fh.WorkingTemperature, fh.LoopID });
break;
default:
break;
}
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Temperatrue);
}
});
};
Button btnTeNull = new Button () {
Y = fhTemperatureView.Height -1,
Height =1,
BackgroundColor = SkinStyle.Current.White20Transparent
};
fhTemperatureView.AddChidren (btnTeNull);
#endregion
#region FHTemperatrueTypeView
var FHTemperatrueTypeView = new FrameLayout () {
Height = Application.GetRealHeight (Application.DesignHeight - 126 - 360 - 150 -106),
Y = fhTemperatureView.Bottom,
BackgroundColor = SkinStyle.Current.ViewColor
};
fhBodyView.AddChidren (FHTemperatrueTypeView);
FH_Day = new Button () {
Width = Application.GetMinRealAverage (140),
Height = Application.GetMinRealAverage (140),
X = Application.GetRealWidth (30),
Y = Application.GetRealHeight (10),
UnSelectedImagePath = "FH/FH_Day.png",
SelectedImagePath = "FH/FH_Day_on.png",
// Enable = false,
};
if (fh.TemperatureType == 2) {
FH_Day.IsSelected = true;
} else {
FH_Day.IsSelected = false;
}
FHTemperatrueTypeView.AddChidren (FH_Day);
Button text_FH_Day = new Button () {
Width = Application.GetRealWidth (140),
Height = Application.GetRealHeight (40),
X = FH_Day.X,
Y = FH_Day.Bottom - Application.GetRealHeight (30),
TextID = R.MyInternationalizationString.Day,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_FH_Day);
FH_Night = new Button () {
Width = Application.GetMinRealAverage (140),
Height = Application.GetMinRealAverage (140),
X = Application.GetRealWidth (640 - 140 -30),
Y = FH_Day.Y,
UnSelectedImagePath = "FH/FH_Night.png",
SelectedImagePath = "FH/FH_Night_on.png",
//Enable =false ,
};
if (fh.TemperatureType == 3) {
FH_Night.IsSelected = true;
} else {
FH_Night.IsSelected = false;
}
FHTemperatrueTypeView.AddChidren (FH_Night);
if (fh.Type == DeviceType.FoolHeat) {
btnValve = new Button () {
Width = Application.GetMinRealAverage (200),
Height = Application.GetMinRealAverage (50),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight (40),
TextID = R.MyInternationalizationString.ValveStatus,
TextColor = SkinStyle.Current.TextColor1
};
FHTemperatrueTypeView.AddChidren (btnValve);
text_Valve = new Button () {
Width = Application.GetRealWidth (200),
Height = Application.GetRealHeight (50),
X = btnValve.X,
Y = btnValve.Bottom,
TextID = R.MyInternationalizationString.CurrentValue,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_Valve);
if (fh.PWDStatus == 0)//Close
{
btnValve.Text = Language.StringByID (R.MyInternationalizationString.ValveStatus).Replace ("--", Language.StringByID (R.MyInternationalizationString.Close));
text_Valve.Text = Language.StringByID (R.MyInternationalizationString.CurrentValue).Replace ("--", fh.PWDValue.ToString ());
} else {
btnValve.Text = Language.StringByID (R.MyInternationalizationString.ValveStatus).Replace ("--", Language.StringByID (R.MyInternationalizationString.Open));
text_Valve.Text = Language.StringByID (R.MyInternationalizationString.CurrentValue).Replace ("--", fh.PWDValue.ToString ());
}
}
Button text_FH_Night = new Button () {
Width = Application.GetRealWidth (140),
Height = Application.GetRealHeight (40),
X = FH_Night.X,
Y = FH_Night.Bottom - Application.GetRealHeight (30),
TextID = R.MyInternationalizationString.AtNight,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_FH_Night);
FH_Common = new Button () {
Width = Application.GetMinRealAverage (140),
Height = Application.GetMinRealAverage (140),
X = Application.GetRealWidth (30),
Y = FH_Day.Bottom + Application.GetRealHeight (30),
UnSelectedImagePath = "FH/FH_Common.png",
SelectedImagePath = "FH/FH_Common_on.png",
// Enable = false,
};
if (fh.TemperatureType == 1) {
FH_Common.IsSelected = true;
} else {
FH_Common.IsSelected = false;
}
FHTemperatrueTypeView.AddChidren (FH_Common);
Button text_FH_Common = new Button () {
Width = Application.GetRealWidth (140),
Height = Application.GetRealHeight (40),
X = FH_Common.X,
Y = FH_Common.Bottom - Application.GetRealHeight (30),
TextID = R.MyInternationalizationString.Ordinary,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_FH_Common);
Go_away = new Button () {
Width = Application.GetMinRealAverage (140),
Height = Application.GetMinRealAverage (140),
Gravity = Gravity.CenterHorizontal,
Y = FH_Day.Bottom + Application.GetRealHeight (30),
UnSelectedImagePath = "FH/FH_Leave.png",
SelectedImagePath = "FH/FH_Leave_on.png",
// Enable = false,
};
if (fh.TemperatureType == 4) {
Go_away.IsSelected = true;
} else {
Go_away.IsSelected = false;
}
FHTemperatrueTypeView.AddChidren (Go_away);
Button text_Go_away = new Button () {
Width = Application.GetRealWidth (140),
Height = Application.GetRealHeight (40),
X = Go_away.X,
Y = Go_away.Bottom - Application.GetRealHeight (30),
TextID = R.MyInternationalizationString.GoAway,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_Go_away);
FH_Auto = new Button () {
Width = Application.GetMinRealAverage (140),
Height = Application.GetMinRealAverage (140),
X = Application.GetRealWidth (640 - 140 - 30),
Y = FH_Day.Bottom + Application.GetRealHeight (30),
UnSelectedImagePath = "FH/FH_Auto.png",
SelectedImagePath = "FH/FH_Auto_on.png",
// Enable = false,
};
if (fh.TemperatureType == 5) {
FH_Auto.IsSelected = true;
} else {
FH_Auto.IsSelected = false;
}
FHTemperatrueTypeView.AddChidren (FH_Auto);
Button text_FH_Auto = new Button () {
Width = Application.GetRealWidth (140),
Height = Application.GetRealHeight (40),
X = FH_Auto.X,
Y = FH_Auto.Bottom - Application.GetRealHeight (30),
TextID = R.MyInternationalizationString.Timer,
TextColor = SkinStyle.Current.TextColor1,
};
FHTemperatrueTypeView.AddChidren (text_FH_Auto);
FH_Day.MouseDownEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Day.IsSelected = true;
};
FH_Day.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Day.IsSelected = true;
FH_Common.IsSelected = false;
FH_Night.IsSelected = false;
FH_Auto.IsSelected = false;
Go_away.IsSelected = false;
fh.TemperatureType = 2;
System.Threading.Tasks.Task.Run (() => {
if (fh.Type == DeviceType.FoolHeatPanel) {
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, fh.TemperatureType, fh.LoopID });
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 26, fh.LoopID, fh.LoopID });
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.TemperatrueMode);
}
Application.RunOnMainThread (() => {
btnSetTemperature.Text = fh.WorkingTemperature + "°";
});
});
};
FH_Night.MouseDownEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Night.IsSelected = true;
};
FH_Night.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Common.IsSelected = false;
FH_Night.IsSelected = true;
FH_Auto.IsSelected = false;
FH_Day.IsSelected = false;
Go_away.IsSelected = false;
fh.TemperatureType = 3;
System.Threading.Tasks.Task.Run (() => {
if (fh.Type == DeviceType.FoolHeatPanel) {
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, fh.TemperatureType, fh.LoopID });
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.TemperatrueMode);
}
Application.RunOnMainThread (() => {
btnSetTemperature.Text = fh.WorkingTemperature + "°";
});
});
};
Go_away.MouseDownEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
Go_away.IsSelected = true;
};
Go_away.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Common.IsSelected = false;
Go_away.IsSelected = true;
FH_Night.IsSelected = false;
FH_Day.IsSelected = false;
FH_Auto.IsSelected = false;
fh.TemperatureType = 4;
System.Threading.Tasks.Task.Run (() => {
if (fh.Type == DeviceType.FoolHeatPanel) {
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, fh.TemperatureType, fh.LoopID });
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.TemperatrueMode);
}
Application.RunOnMainThread (() => {
btnSetTemperature.Text = fh.WorkingTemperature + "°";
});
});
};
FH_Common.MouseDownEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Common.IsSelected = true;
};
FH_Common.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Auto.IsSelected = false;
FH_Common.IsSelected = true;
FH_Night.IsSelected = false;
FH_Day.IsSelected = false;
Go_away.IsSelected = false;
fh.TemperatureType = 1;
System.Threading.Tasks.Task.Run (() => {
if (fh.Type == DeviceType.FoolHeatPanel) {
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, fh.TemperatureType, fh.LoopID });
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.TemperatrueMode);
}
Application.RunOnMainThread (() => {
btnSetTemperature.Text = fh.WorkingTemperature + "°";
});
});
};
FH_Auto.MouseDownEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Auto.IsSelected = true;
};
FH_Auto.MouseUpEventHandler += (sender, e) => {
if (btnFHSwitch.IsSelected == false) {
return;
}
FH_Common.IsSelected = false;
FH_Night.IsSelected = false;
FH_Day.IsSelected = false;
Go_away.IsSelected = false;
FH_Auto.IsSelected = true;
fh.TemperatureType = 5;
System.Threading.Tasks.Task.Run (() => {
if (fh.Type == DeviceType.FoolHeatPanel) {
Control.ControlBytesSend (Command.InstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, 5, fh.LoopID });
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.TemperatrueMode);
}
Application.RunOnMainThread (() => {
btnSetTemperature.Text = fh.WorkingTemperature + "°";
});
});
};
#endregion
readStatus ();
}
///
/// 读取设备状态
///
void readStatus ()
{
System.Threading.Tasks.Task.Run (() => {
#if DEBUG
#else
if (fh.LastUpdateTime.AddMinutes (Common.Time) <= DateTime.Now) {
#endif
if (fh.Type == DeviceType.FoolHeatPanel) {
readFoolHeatPanelStatus ();
} else if (fh.Type == DeviceType.FoolHeat) {
fh = fh.Serverx_FH_CMD (FoolHeat.CommandType.Read);
}
#if DEBUG
#else
}
#endif
});
}
void readFoolHeatPanelStatus ()
{
Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 20, fh.LoopID, fh.LoopID });
Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 21, fh.LoopID, fh.LoopID });
Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 24, fh.LoopID, fh.LoopID });
//switch (fh.TemperatureType) {
//case 1:
// Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 25, fh.LoopID, fh.LoopID });
// break;
//case 2:
// Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 26, fh.LoopID, fh.LoopID });
// break;
//case 3:
// Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 27, fh.LoopID, fh.LoopID });
// break;
//case 4:
// Control.ControlBytesSend (Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte [] { 28, fh.LoopID, fh.LoopID });
// break;
//default:
// break;
//}
Control.ControlBytesSend (Command.ReadPanleTemp, fh.SubnetID, fh.DeviceID, new byte [] { fh.LoopID }, SendCount.Zero);
Control.ControlBytesSend (Command.Read_Floor_Heat_State, fh.SubnetID, fh.DeviceID, new byte [] { (byte)(fh.LoopID - 1) });
}
}
}