using System;
|
using System.Collections.Generic;
|
using Shared.SimpleControl;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
/// <summary>
|
/// 控制界面
|
/// </summary>
|
public class ThermostatHostPage : FrameLayout
|
{
|
public static ThermostatHostPage curView;
|
static Thermostat thermostat;
|
|
static Button btnPM25Values;
|
static Button btnStrainer;
|
static Button btnCO2Values;
|
static Button btnTVOCValues;
|
static Button btnTempValues;
|
static Button btnHumidityValues;
|
static HorizontalScrolViewLayout modeListView;
|
static Button btnPower;
|
static FrameLayout sceneListView;
|
static VerticalScrolViewLayout extensionListView;
|
static FrameLayout pm25InnerView;
|
|
public static void UpdateStatus(Thermostat therm)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null)
|
return;
|
if(therm.SubnetID == thermostat.SubnetID && therm.DeviceID == thermostat.DeviceID && therm.HostID == thermostat.HostID) {
|
thermostat = therm;
|
btnStrainer.Text = Language.StringByID (R.MyInternationalizationString.StrainerState) + thermostat.StrainerState +"%" ;
|
btnPM25Values.Text = thermostat.Indoor_PM25_Values.ToString();
|
btnCO2Values.Text = thermostat.Indoor_CO2_Values.ToString ();
|
btnTVOCValues.Text = thermostat.Indoor_TVOC_Values.ToString ();
|
btnTempValues.Text = Math.Round (thermostat.Indoor_Temperature_Values,1).ToString ();
|
btnHumidityValues.Text = thermostat.Indoor_Humidity_Values.ToString ();
|
|
///运行模式 1-制冷,2-制热,3-通风,4-除湿,5-制热除湿
|
ChangeModeIcon (thermostat.CurrentModeString);
|
btnPower.IsSelected = thermostat.Power == 1;
|
if (btnPower.IsSelected) {
|
pm25InnerView.BorderColor = 0xFFFE5E01;
|
} else {
|
pm25InnerView.BorderColor = 0xFFbcbcbc;
|
}
|
|
ChangeSceneIcon (thermostat.CurrentSceneString);
|
|
|
#region 更新用户主界面灯光点亮总数
|
int acOponeCount = 0;
|
foreach (var caac in Room.Thermostat_HostList) {
|
if (caac.Power == 1) {
|
acOponeCount++;
|
}
|
}
|
UserDeviceView.UpdataDeviceCountNumber (acOponeCount, R.MyInternationalizationString.Thermostat);
|
#endregion
|
}
|
});
|
}
|
|
static void ChangeModeIcon (string modeTag)
|
{
|
int changedNumber = Application.GetMinRealAverage (70);
|
bool changedState = false;
|
for (int i = 0; i < modeListView.ChildrenCount; i++) {
|
var view = modeListView.GetChildren (i);
|
if (view.GetType () == typeof (FrameLayout)) {
|
var frameView = ((FrameLayout)view);
|
if (frameView.Tag != null && frameView.Tag.ToString () == modeTag) {
|
changedNumber = Application.GetMinRealAverage (110);
|
changedState = true;
|
} else {
|
changedNumber = Application.GetMinRealAverage (70);
|
changedState = false;
|
}
|
for (int j = 0; j < frameView.ChildrenCount; j++) {
|
var btn = frameView.GetChildren (j);
|
if (btn.GetType () == typeof (Button)) {
|
var btn0 = ((Button)btn);
|
if (btn0.Tag != null && !string.IsNullOrEmpty (btn0.Tag.ToString ())) {
|
btn0.Width = changedNumber;
|
btn0.Height = changedNumber;
|
btn0.Gravity = Gravity.Center;
|
if (frameView.Tag != null && frameView.Tag.ToString () == modeTag) {
|
btn0.IsSelected = changedState;
|
} else {
|
btn0.IsSelected = changedState;
|
}
|
}
|
btn0.IsSelected = changedState;
|
}
|
}
|
}
|
}
|
|
}
|
|
|
static void ChangeSceneIcon (string sceneTag)
|
{
|
bool changedState = false;
|
for (int i = 0; i < sceneListView.ChildrenCount; i++) {
|
var view = sceneListView.GetChildren (i);
|
if (view.GetType () == typeof (FrameLayout)) {
|
var frameView = ((FrameLayout)view);
|
if (frameView.Tag != null && frameView.Tag.ToString () == sceneTag) {
|
changedState = true;
|
} else {
|
changedState = false;
|
}
|
for (int j = 0; j < frameView.ChildrenCount; j++) {
|
var btn = frameView.GetChildren (j);
|
if (btn.GetType () == typeof (Button)) {
|
((Button)btn).IsSelected = changedState;
|
}
|
}
|
}
|
}
|
}
|
|
public static void UpdateExtensionStatus (Thermostat cac)
|
{
|
Application.RunOnMainThread (() => {
|
if (curView == null)
|
return;
|
if (cac.SubnetID == thermostat.SubnetID && cac.DeviceID == thermostat.DeviceID ) {
|
for (int i = 0; i < extensionListView.ChildrenCount; i++) {
|
var view = extensionListView.GetChildren (i);
|
if (view.GetType () == typeof (FrameLayout)) {
|
var frameView = ((FrameLayout)view);
|
if (frameView.Tag != null && frameView.Tag.ToString () == cac.Type + "_" + cac.CommonLoopID) {
|
for (int j = 0; j < frameView.ChildrenCount; j++) {
|
var btn = frameView.GetChildren (j);
|
if (btn.GetType () == typeof (Button)) {
|
var btn0 = ((Button)btn);
|
if (btn0.Tag != null) {
|
if (btn0.Tag.ToString() == "ThermometerValues") {
|
btn0.Text = Math.Round (thermostat.Indoor_Temperature_Values, 0) + "°C";
|
} else if (btn0.Tag.ToString() == "RoomHumidityValues") {
|
btn0.Text = Math.Round (thermostat.Indoor_Humidity_Values, 0) + "%";
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
});
|
}
|
|
public void ShowPage (List<string> hostSavePaths)
|
{
|
curView = this;
|
thermostat = Room.Thermostat_HostList [0];// Newtonsoft.Json.JsonConvert.DeserializeObject<CapillaryAC> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (hostSavePaths [0])));
|
#region 标题
|
var topView = new FrameLayout () {
|
Y = Application.GetRealHeight (36),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (640),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (topView);
|
|
var btnTitle = new Button () {
|
TextAlignment = TextAlignment.Center,
|
Text = thermostat.Name,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextSize = 19,
|
};
|
topView.AddChidren (btnTitle);
|
|
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;
|
curView = null;
|
};
|
#endregion
|
|
var bodyView = new FrameLayout () {
|
Y = topView.Bottom,
|
Height = this.Height - topView.Height,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
AddChidren (bodyView);
|
|
#region 模拟量view
|
var analogueQuantityView = new FrameLayout () {
|
Height = Application.GetRealHeight (440),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
bodyView.AddChidren (analogueQuantityView);
|
|
var btnJinMaoLogo = new Button () {
|
X = Application.GetRealWidth (420),
|
Y = Application.GetRealHeight (10),
|
Width = Application.GetRealWidth (200),
|
Height = Application.GetRealHeight (30),
|
UnSelectedImagePath = "CapillaryAC/JinMaoLogo.png",
|
};
|
analogueQuantityView.AddChidren (btnJinMaoLogo);
|
#region pm2.5
|
var pm25View = new FrameLayout () {
|
Y = Application.GetRealHeight (30),
|
Width = Application.GetMinRealAverage (260),
|
Height = Application.GetMinRealAverage (260),
|
Radius = (uint)Application.GetMinRealAverage (130),
|
BorderColor = SkinStyle.Current.Transparent,
|
BorderWidth = 0,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
Gravity = Gravity.CenterHorizontal,
|
};
|
analogueQuantityView.AddChidren (pm25View);
|
|
|
pm25InnerView = new FrameLayout () {
|
Gravity = Gravity.Center,
|
Radius = (uint)Application.GetMinRealAverage (105),
|
BorderColor = 0xFFbcbcbc,
|
BorderWidth = 2,
|
Width = Application.GetMinRealAverage (210),
|
Height = Application.GetMinRealAverage (210),
|
BackgroundColor = SkinStyle.Current.Transparent,
|
};
|
pm25View.AddChidren (pm25InnerView);
|
|
var btnPM25Title = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetMinRealAverage (40),
|
Width = Application.GetMinRealAverage (200),
|
Height = Application.GetMinRealAverage (60),
|
TextColor = 0xFFbdbdbd,
|
Text = "PM2.5",
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
};
|
pm25View.AddChidren (btnPM25Title);
|
|
btnPM25Values = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnPM25Title.Bottom,
|
Width = Application.GetMinRealAverage (120),
|
Height = Application.GetMinRealAverage (60),
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = thermostat.Indoor_PM25_Values.ToString (),
|
BackgroundColor = 0xFF292929,
|
TextSize = 24,
|
TextAlignment = TextAlignment.Center,
|
};
|
pm25View.AddChidren (btnPM25Values);
|
|
var btnPM25Unit = new Button () {
|
Y = pm25View.Height - Application.GetMinRealAverage (60),
|
Height = Application.GetMinRealAverage (40),
|
Width = Application.GetRealWidth (60),
|
Gravity = Gravity.CenterHorizontal,
|
TextColor = 0xFFbdbdbd,
|
Text = "μg",
|
TextAlignment = TextAlignment.Center,
|
BackgroundColor = SkinStyle.Current.MainColor,
|
};
|
pm25View.AddChidren (btnPM25Unit);
|
#endregion
|
|
|
btnStrainer = new Button () {
|
Height = Application.GetRealHeight (60),
|
Y = pm25View.Bottom,
|
Text = Language.StringByID (R.MyInternationalizationString.StrainerState) + thermostat.StrainerState,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
};
|
analogueQuantityView.AddChidren (btnStrainer);
|
|
|
var btnCO2Title = new Button () {
|
X = Application.GetRealWidth (80),
|
Y = btnStrainer.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = "CO2",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnCO2Title);
|
|
var btnCO2Unit = new Button () {
|
TextColor = 0xFFbdbdbd,
|
X = Application.GetRealWidth (80),
|
Y = btnCO2Title.Bottom,
|
Text = "(PPM)",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnCO2Unit);
|
|
|
btnCO2Values = new Button () {
|
TextColor = SkinStyle.Current.TextColor1,
|
X = Application.GetRealWidth (80),
|
Y = btnCO2Unit.Bottom,
|
Text = thermostat.Indoor_CO2_Values.ToString (),
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (40),
|
TextSize = 18,
|
};
|
analogueQuantityView.AddChidren (btnCO2Values);
|
|
|
var btnTVOCTitle = new Button () {
|
X = Application.GetRealWidth (80 + 120),
|
Y = btnStrainer.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
Text = "TVOC",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnTVOCTitle);
|
|
var btnTVOCUnit = new Button () {
|
TextColor = 0xFFbdbdbd,
|
X = Application.GetRealWidth (80 + 120),
|
Y = btnTVOCTitle.Bottom,
|
Text = "(PPM)",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnTVOCUnit);
|
|
|
btnTVOCValues = new Button () {
|
TextColor = SkinStyle.Current.TextColor1,
|
X = Application.GetRealWidth (80 + 120),
|
Y = btnTVOCUnit.Bottom,
|
Text = thermostat.Indoor_TVOC_Values.ToString (),
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (40),
|
TextSize = 18,
|
};
|
analogueQuantityView.AddChidren (btnTVOCValues);
|
|
|
var btnTempTitle = new Button () {
|
X = Application.GetRealWidth (80 + 120 + 120),
|
Y = btnStrainer.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID =R.MyInternationalizationString.Temp,
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnTempTitle);
|
|
var btnTempUnit = new Button () {
|
TextColor = 0xFFbdbdbd,
|
X = Application.GetRealWidth (80 + 120 + 120),
|
Y = btnTempTitle.Bottom,
|
Text = "(°C)",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnTempUnit);
|
|
|
btnTempValues = new Button () {
|
TextColor = SkinStyle.Current.TextColor1,
|
X = Application.GetRealWidth (80 + 120 + 120),
|
Y = btnTempUnit.Bottom,
|
Text = Math.Round (thermostat.Indoor_Humidity_Values, 1).ToString (),
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (40),
|
TextSize = 18,
|
};
|
analogueQuantityView.AddChidren (btnTempValues);
|
|
|
var btnHumidityTitle = new Button () {
|
X = Application.GetRealWidth (80 + 120 + 120 + 120),
|
Y = btnStrainer.Bottom,
|
TextColor = SkinStyle.Current.TextColor1,
|
TextID = R.MyInternationalizationString.Humidity,
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnHumidityTitle);
|
|
var btnHumidityUnit = new Button () {
|
TextColor = 0xFFbdbdbd,
|
X = Application.GetRealWidth (80 + 120 + 120 + 120),
|
Y = btnHumidityTitle.Bottom,
|
Text = "(%)",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (25),
|
TextSize = 12,
|
};
|
analogueQuantityView.AddChidren (btnHumidityUnit);
|
|
|
btnHumidityValues = new Button () {
|
TextColor = SkinStyle.Current.TextColor1,
|
X = Application.GetRealWidth (80 + 120 + 120 + 120),
|
Y = btnHumidityUnit.Bottom,
|
Text = "70",
|
TextAlignment = TextAlignment.Center,
|
Width = Application.GetRealWidth (120),
|
Height = Application.GetRealHeight (40),
|
TextSize = 18,
|
};
|
analogueQuantityView.AddChidren (btnHumidityValues);
|
|
#endregion
|
|
modeListView = new HorizontalScrolViewLayout () {
|
Y = analogueQuantityView.Bottom + Application.GetRealHeight (10),
|
Height = Application.GetRealHeight (140),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
bodyView.AddChidren (modeListView);
|
|
#region Heating and dehumidification mode
|
var heatingDehumiModeView = new FrameLayout () {
|
Width = Application.GetRealWidth (128),
|
Tag = "HeatingAndDehumidification",
|
};
|
modeListView.AddChidren (heatingDehumiModeView);
|
|
var btnHeatingDehumiTip = new Button () {
|
Y = Application.GetRealHeight (5),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (12),
|
UnSelectedImagePath = "Item/Transparent.png",
|
SelectedImagePath = "CapillaryAC/Triangle.png"
|
};
|
heatingDehumiModeView.AddChidren (btnHeatingDehumiTip);
|
|
var btnHeatingDehumiText = new Button () {
|
Y = Application.GetRealHeight (128 - 15),
|
Height = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.HeatingAndHumidity,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.Transparent,
|
TextSize = 10
|
};
|
heatingDehumiModeView.AddChidren (btnHeatingDehumiText);
|
|
var btnHeatingDehumIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetMinRealAverage (70),
|
Height = Application.GetMinRealAverage (70),
|
UnSelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png",
|
SelectedImagePath = "CapillaryAC/HeatingAndDehumidification.png",
|
Tag = "HeatingAndDehumidification",
|
};
|
heatingDehumiModeView.AddChidren (btnHeatingDehumIcon);
|
#endregion
|
|
#region Cooling Mode
|
var coolingModeView = new FrameLayout () {
|
Width = Application.GetRealWidth (128),
|
Tag = "Cooling",
|
};
|
modeListView.AddChidren (coolingModeView);
|
|
var btnCoolingTip = new Button () {
|
Y = Application.GetRealHeight (5),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (12),
|
UnSelectedImagePath = "Item/Transparent.png",
|
SelectedImagePath = "CapillaryAC/Triangle.png"
|
};
|
coolingModeView.AddChidren (btnCoolingTip);
|
|
var btnCoolingText = new Button () {
|
Y = Application.GetRealHeight (128 - 15),
|
Height = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Cool,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.Transparent,
|
TextSize = 10
|
};
|
coolingModeView.AddChidren (btnCoolingText);
|
|
var btnCoolingIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetMinRealAverage (70),
|
Height = Application.GetMinRealAverage (70),
|
UnSelectedImagePath = "CapillaryAC/Cooling.png",
|
SelectedImagePath = "CapillaryAC/Cooling.png",
|
Tag = "Cooling",
|
};
|
coolingModeView.AddChidren (btnCoolingIcon);
|
|
#endregion
|
|
#region Heating Mode
|
var heatingModeView = new FrameLayout () {
|
Width = Application.GetRealWidth (128),
|
Tag = "Heating",
|
};
|
modeListView.AddChidren (heatingModeView);
|
|
var btnHeatingTip = new Button () {
|
Y = Application.GetRealHeight (5),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (12),
|
UnSelectedImagePath = "Item/Transparent.png",
|
SelectedImagePath = "CapillaryAC/Triangle.png"
|
};
|
heatingModeView.AddChidren (btnHeatingTip);
|
|
var btnHeatingText = new Button () {
|
Y = Application.GetRealHeight (128 - 15),
|
Height = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Heating,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.Transparent,
|
TextSize = 10
|
};
|
heatingModeView.AddChidren (btnHeatingText);
|
|
var btnHeatingIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetMinRealAverage (70),
|
Height = Application.GetMinRealAverage (70),
|
UnSelectedImagePath = "CapillaryAC/Heating.png",
|
SelectedImagePath = "CapillaryAC/Heating.png",
|
Tag = "Heating",
|
};
|
heatingModeView.AddChidren (btnHeatingIcon);
|
|
#endregion
|
|
#region Dehumidification Mode
|
var dehumidificationModeView = new FrameLayout () {
|
Width = Application.GetRealWidth (128),
|
Tag = "Dehumidification",
|
};
|
modeListView.AddChidren (dehumidificationModeView);
|
|
var btnDehumidificationTip = new Button () {
|
Y = Application.GetRealHeight (5),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (12),
|
UnSelectedImagePath = "Item/Transparent.png",
|
SelectedImagePath = "CapillaryAC/Triangle.png"
|
};
|
dehumidificationModeView.AddChidren (btnDehumidificationTip);
|
|
var btnDehumidificationText = new Button () {
|
Y = Application.GetRealHeight (128 - 15),
|
Height = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Humidity,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.Transparent,
|
TextSize = 10
|
};
|
dehumidificationModeView.AddChidren (btnDehumidificationText);
|
|
var btnDehumidificationIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetMinRealAverage (70),
|
Height = Application.GetMinRealAverage (70),
|
UnSelectedImagePath = "CapillaryAC/Dehumidification.png",
|
SelectedImagePath = "CapillaryAC/Dehumidification.png",
|
Tag = "Dehumidification",
|
};
|
dehumidificationModeView.AddChidren (btnDehumidificationIcon);
|
|
#endregion
|
|
#region Aeration Mode
|
var aerationModeView = new FrameLayout () {
|
Width = Application.GetRealWidth (128),
|
Tag = "Aeration",
|
};
|
modeListView.AddChidren (aerationModeView);
|
|
var btnAerationTip = new Button () {
|
Y = Application.GetRealHeight (5),
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth (20),
|
Height = Application.GetRealHeight (12),
|
UnSelectedImagePath = "Item/Transparent.png",
|
SelectedImagePath = "CapillaryAC/Triangle.png"
|
};
|
aerationModeView.AddChidren (btnAerationTip);
|
|
var btnAerationText = new Button () {
|
Y = Application.GetRealHeight (128 - 15),
|
Height = Application.GetRealHeight (20),
|
TextAlignment = TextAlignment.Center,
|
TextID = R.MyInternationalizationString.Dehumidify,
|
SelectedTextColor = SkinStyle.Current.TextColor1,
|
TextColor = SkinStyle.Current.Transparent,
|
TextSize = 10
|
};
|
aerationModeView.AddChidren (btnAerationText);
|
|
var btnAerationIcon = new Button () {
|
Gravity = Gravity.Center,
|
Width = Application.GetMinRealAverage (70),
|
Height = Application.GetMinRealAverage (70),
|
UnSelectedImagePath = "CapillaryAC/Aeration.png",
|
SelectedImagePath = "CapillaryAC/Aeration.png",
|
Tag = "Aeration",
|
};
|
aerationModeView.AddChidren (btnAerationIcon);
|
#endregion
|
|
#region mode change function
|
EventHandler<MouseEventArgs> eventHandler_ModeChangeClick = (sender, e) => {
|
var thisButton = sender as Button;
|
/// 1-制冷,2-制热,3-通风,4-除湿,5-制热除湿
|
switch (thisButton.Tag.ToString ()) {
|
case "HeatingAndDehumidification":
|
thermostat.CurrentMode = 5;
|
break;
|
case "Cooling":
|
thermostat.CurrentMode = 1;
|
break;
|
case "Heating":
|
thermostat.CurrentMode = 2;
|
break;
|
case "Dehumidification":
|
thermostat.CurrentMode = 4;
|
break;
|
case "Aeration":
|
thermostat.CurrentMode = 3;
|
break;
|
}
|
ChangeModeIcon (thisButton.Tag.ToString ());
|
new System.Threading.Thread (() => {
|
thermostat.SetHost ();
|
}) { IsBackground = true }.Start ();
|
};
|
|
btnCoolingIcon.MouseUpEventHandler += eventHandler_ModeChangeClick;
|
btnHeatingIcon.MouseUpEventHandler += eventHandler_ModeChangeClick;
|
btnAerationIcon.MouseUpEventHandler += eventHandler_ModeChangeClick;
|
btnHeatingDehumIcon.MouseUpEventHandler += eventHandler_ModeChangeClick;
|
btnDehumidificationIcon.MouseUpEventHandler += eventHandler_ModeChangeClick;
|
ChangeModeIcon (thermostat.CurrentModeString);
|
#endregion
|
|
#region Extension List View
|
extensionListView = new VerticalScrolViewLayout () {
|
Y = modeListView.Bottom + Application.GetRealHeight(10),
|
Height = Application.GetRealHeight(270),
|
BackgroundColor = SkinStyle.Current.ViewColor,
|
};
|
bodyView.AddChidren (extensionListView);
|
|
foreach(var room in Room.Lists) {
|
if (string.IsNullOrEmpty(room.Name))
|
continue;
|
var cacList = room.DeviceList.FindAll ((obj) => obj.Type == DeviceType.Thermostat);
|
foreach (var devcieCommon in cacList) {
|
if (devcieCommon == null)
|
continue;
|
|
#region cacList
|
var capillaryAC_room = devcieCommon as Thermostat;
|
EventHandler<MouseEventArgs> openCapillaryACControlPageEvent = (button, mouseEventArgs) => {
|
ThermostatExtensionPage acView = new ThermostatExtensionPage ();
|
UserMiddle.DevicePageView.AddChidren (acView);
|
acView.ShowPage (capillaryAC_room);
|
UserMiddle.DevicePageView.PageIndex = UserMiddle.DevicePageView.ChildrenCount - 1;
|
};
|
var acRowView = new FrameLayout () {
|
Height = Application.GetRealHeight (120),
|
Tag = devcieCommon.Type + "_" + capillaryAC_room.CommonLoopID
|
};
|
extensionListView.AddChidren (acRowView);
|
acRowView.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var btnPoint = new Button () {
|
X = Application.GetRealWidth(35),
|
Gravity = Gravity.CenterVertical,
|
BackgroundColor = 0xFF5E5E5E,
|
Radius = (uint)Application.GetMinRealAverage(5),
|
Width = Application.GetMinRealAverage (10),
|
Height = Application.GetMinRealAverage(10),
|
};
|
acRowView.AddChidren (btnPoint);
|
|
var tempDeviceName = new Button () {
|
X = btnPoint.Right + Application.GetRealWidth (10),
|
//Height = Application.GetRealHeight (60),
|
TextAlignment = TextAlignment.CenterLeft,
|
Text = capillaryAC_room.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 (50),
|
Height = Application.GetMinRealAverage (50),
|
UnSelectedImagePath = "CapillaryAC/ThermometerIcon.png",
|
SelectedImagePath = "CapillaryAC/ThermometerIcon.png",
|
};
|
acRowView.AddChidren (btnThermometerIcon);
|
btnThermometerIcon.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var btnThermometerValues = new Button () {
|
X = btnThermometerIcon.Right,
|
Width = Application.GetRealWidth (80),
|
Text = Math.Round (capillaryAC_room.Indoor_Temperature_Values, 1) + "°C",
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
Tag = "ThermometerValues"
|
};
|
acRowView.AddChidren (btnThermometerValues);
|
|
Button btnHumidityIcon = new Button () {
|
X = btnThermometerValues.Right,
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage (50),
|
Height = Application.GetMinRealAverage (50),
|
UnSelectedImagePath = "CapillaryAC/HumidityIcon.png",
|
SelectedImagePath = "CapillaryAC/HumidityIcon.png",
|
};
|
acRowView.AddChidren (btnHumidityIcon);
|
btnHumidityIcon.MouseUpEventHandler += openCapillaryACControlPageEvent;
|
|
var btnRoomHumidityValues = new Button () {
|
X = btnHumidityIcon.Right,
|
Width = Application.GetRealWidth (80),
|
Text = Math.Round (capillaryAC_room.Indoor_Humidity_Values, 0) + "%",
|
TextColor = SkinStyle.Current.TextColor1,
|
TextAlignment = TextAlignment.Center,
|
Tag = "RoomHumidityValues"
|
};
|
acRowView.AddChidren (btnRoomHumidityValues);
|
|
Control.ControlBytesSend (Command.ReadThermostatExtension, capillaryAC_room.SubnetID, capillaryAC_room.DeviceID, new byte [] { capillaryAC_room.ExtensionID });
|
var btnDeviceRowLine = new Button () {
|
Height = Application.GetRealHeight(5),
|
BackgroundColor = SkinStyle.Current.MainColor,
|
SelectedBackgroundColor = SkinStyle.Current.MainColor,
|
};
|
extensionListView.AddChidren (btnDeviceRowLine);
|
#endregion
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region Scene List View
|
sceneListView = new FrameLayout () {
|
Y = extensionListView.Bottom + Application.GetRealHeight (10),
|
Height = Application.GetRealHeight (135),
|
BackgroundColor = SkinStyle.Current.ViewColor
|
};
|
bodyView.AddChidren (sceneListView);
|
|
btnPower = new Button () {
|
X = Application.GetRealWidth(40),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(100),
|
Height = Application.GetMinRealAverage(100),
|
UnSelectedImagePath = "CapillaryAC/Switch.png",
|
SelectedImagePath = "CapillaryAC/SwitchOn.png",
|
};
|
sceneListView.AddChidren (btnPower);
|
|
btnPower.MouseUpEventHandler += (sender, e) => {
|
btnPower.IsSelected = !btnPower.IsSelected;
|
thermostat.Power = btnPower.IsSelected == true ? (byte)1 : (byte)0;
|
new System.Threading.Thread (() => {
|
thermostat.SetHost ();
|
}) { IsBackground = true }.Start ();
|
};
|
|
var atHomeView = new FrameLayout () {
|
X= Application.GetRealWidth(160),
|
Width = Application.GetRealWidth(160),
|
Tag = "atHome"
|
};
|
sceneListView.AddChidren (atHomeView);
|
|
var btnAtHomeIcon = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetMinRealAverage(90),
|
Height = Application.GetMinRealAverage(90),
|
UnSelectedImagePath = "CapillaryAC/AtHomeModeIcon.png",
|
SelectedImagePath = "CapillaryAC/AtHomeModeIconOn.png",
|
Tag = "atHome"
|
};
|
atHomeView.AddChidren (btnAtHomeIcon);
|
|
var btnAtHomeText = new Button () {
|
Y = btnAtHomeIcon.Bottom,
|
Height = Application.GetRealHeight(40),
|
TextID = R.MyInternationalizationString.AtHomeMode,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.SelectedColor,
|
Tag = "atHome"
|
};
|
atHomeView.AddChidren (btnAtHomeText);
|
|
|
var awayHomeView = new FrameLayout () {
|
X= atHomeView.Right,
|
Width = Application.GetRealWidth(160),
|
Tag = "awayHome"
|
};
|
sceneListView.AddChidren (awayHomeView);
|
|
var btnAwayHomeIcon = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetMinRealAverage(90),
|
Height = Application.GetMinRealAverage(90),
|
UnSelectedImagePath = "CapillaryAC/AwayHomeModeIcon.png",
|
SelectedImagePath = "CapillaryAC/AwayHomeModeIconOn.png",
|
Tag = "awayHome"
|
};
|
awayHomeView.AddChidren (btnAwayHomeIcon);
|
|
var btnAwayHomeText = new Button () {
|
Y = btnAwayHomeIcon.Bottom,
|
Height = Application.GetRealHeight(40),
|
TextID = R.MyInternationalizationString.AwayHomeMode,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.SelectedColor,
|
Tag = "awayHome"
|
};
|
awayHomeView.AddChidren (btnAwayHomeText);
|
|
|
var sleepView = new FrameLayout () {
|
X = awayHomeView.Right,
|
Width = Application.GetRealWidth (160),
|
Tag = "sleep"
|
};
|
sceneListView.AddChidren (sleepView);
|
|
var btnSleepIcon = new Button () {
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(10),
|
Width = Application.GetMinRealAverage(90),
|
Height = Application.GetMinRealAverage(90),
|
UnSelectedImagePath = "CapillaryAC/SleepModeIcon.png",
|
SelectedImagePath = "CapillaryAC/SleepModeIconOn.png",
|
Tag = "sleep"
|
};
|
sleepView.AddChidren (btnSleepIcon);
|
|
var btnSleepText = new Button () {
|
Y = btnSleepIcon.Bottom,
|
Height = Application.GetRealHeight(40),
|
TextID = R.MyInternationalizationString.SleepMode,
|
TextAlignment = TextAlignment.Center,
|
TextColor = SkinStyle.Current.TextColor1,
|
SelectedTextColor = SkinStyle.Current.SelectedColor,
|
Tag = "sleep"
|
};
|
sleepView.AddChidren (btnSleepText);
|
|
ChangeSceneIcon (thermostat.CurrentSceneString);
|
|
EventHandler<MouseEventArgs> eventHandler_SceneChangeClick = (sender, e) => {
|
var thisButton = sender as Button;
|
/// 1-在家,2-离家,3-睡眠
|
switch (thisButton.Tag.ToString ()) {
|
case "atHome":
|
thermostat.CurrentScene = 1;
|
break;
|
case "awayHome":
|
thermostat.CurrentScene = 2;
|
break;
|
case "sleep":
|
thermostat.CurrentScene = 3;
|
break;
|
}
|
new System.Threading.Thread (() => {
|
thermostat.SetHost ();
|
}) { IsBackground = true }.Start ();
|
ChangeSceneIcon (thisButton.Tag.ToString());
|
};
|
btnAtHomeIcon.MouseUpEventHandler += eventHandler_SceneChangeClick;
|
btnAwayHomeIcon.MouseUpEventHandler += eventHandler_SceneChangeClick;
|
btnSleepIcon.MouseUpEventHandler += eventHandler_SceneChangeClick;
|
|
#endregion
|
|
Control.ControlBytesSend (Command.ReadThermostatHost, thermostat.SubnetID, thermostat.DeviceID, new byte [] {thermostat.HostID });
|
}
|
|
}
|
}
|