using System;
using System.Collections.Generic;
using Shared.SimpleControl;
namespace Shared.SimpleControl.Phone
{
///
/// 空调控制界面
///
public class UserFreshAirPage : FrameLayout
{
static UserFreshAirPage curView;
Button btnIndoorTemp;
Button btnOutdoorTemp;
Button btnSwitch;
Button btnContentPM25;
Button btnContentTVOC;
Button btnContentCO2;
Button btnContentHumidity;
Button btnACModeLeft;
Button btnACModeRight;
Button btnModeName;
Button btnModeIcon;
Button btnModeText;
Button btnACWindLeft;
Button btnACWindRight;
Button btnWindName;
Button btnWindIcon;
Button btnWindText;
Room room;
FreshAir freshAir;
static FreshAirBLL bLL;
public UserFreshAirPage (FreshAir sendfa, Room room)
{
this.room = room;
freshAir = sendfa;
curView = this;
bLL = new FreshAirBLL ();
BackgroundColor = SkinStyle.Current.MainColor;
}
///
/// 更新空调
///
public static void UpdateStatus (FreshAir freshAir)
{
Application.RunOnMainThread (() => {
if (curView == null) {
return;
}
if (curView.freshAir.CommonLoopID == freshAir.CommonLoopID) {
curView.freshAir = freshAir;
try {
curView.btnIndoorTemp.Text = freshAir.InTemp.ToString () + "°";
curView.btnOutdoorTemp.Text = freshAir.OutTemp.ToString () + "°";
curView.btnContentTVOC.Text = freshAir.TVOC.ToString ();
curView.btnContentCO2.Text = freshAir.CO2.ToString ();
curView.btnContentHumidity.Text = freshAir.Humidity.ToString ();
curView.btnContentPM25.Text = freshAir.PM25.ToString ();
curView.btnModeIcon.UnSelectedImagePath = bLL.GetModeIcon (freshAir.SetPattern);
curView.btnModeText.TextID = bLL.GetModeTextID (freshAir.SetPattern);
curView.btnWindIcon.UnSelectedImagePath = bLL.GetWindIcon (freshAir.WindSpeed);
curView.btnWindText.TextID = bLL.GetWindTextID (freshAir.WindSpeed);
if (freshAir.SwitchStatus == 1) {
curView.btnSwitch.IsSelected = true;
curView.btnIndoorTemp.Enable = true;
curView.btnOutdoorTemp.Enable = true;
curView.btnContentPM25.Enable = true;
curView.btnContentTVOC.Enable = true;
curView.btnContentCO2.Enable = true;
curView.btnContentHumidity.Enable = true;
curView.btnACModeLeft.Enable = true;
curView.btnACModeRight.Enable = true;
curView.btnModeName.Enable = true;
curView.btnModeIcon.Enable = true;
curView.btnModeText.Enable = true;
curView.btnACWindLeft.Enable = true;
curView.btnACWindRight.Enable = true;
curView.btnWindName.Enable = true;
curView.btnWindIcon.Enable = true;
curView.btnWindText.Enable = true;
} else {
curView.btnSwitch.IsSelected = false;
curView.btnIndoorTemp.Enable = false;
curView.btnOutdoorTemp.Enable = false;
curView.btnContentPM25.Enable = false;
curView.btnContentTVOC.Enable = false;
curView.btnContentCO2.Enable = false;
curView.btnContentHumidity.Enable = false;
curView.btnACModeLeft.Enable = false;
curView.btnACModeRight.Enable = false;
curView.btnModeName.Enable = false;
curView.btnModeIcon.Enable = false;
curView.btnModeText.Enable = false;
curView.btnACWindLeft.Enable = false;
curView.btnACWindRight.Enable = false;
curView.btnWindName.Enable = false;
curView.btnWindIcon.Enable = false;
curView.btnWindText.Enable = false;
}
} catch (Exception ex) {
Console.WriteLine (ex.ToString ());
}
}
});
}
public void ShowRoomFreshAir ()
{
#region 标题
var topView = new FrameLayout () {
Y = Application.GetRealHeight (36),
Height = Application.GetRealHeight (90),
Width = Application.GetRealWidth (640),
};
AddChidren (topView);
var title = new Button () {
TextAlignment = TextAlignment.Center,
Text = freshAir.Name,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 19,
};
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 (100),
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 acBodyView = new FrameLayout {
Width = Application.GetRealWidth (640),
Height = Application.GetRealHeight (Application.DesignHeight - 126),
Y = Application.GetRealHeight (126)
};
AddChidren (acBodyView);
var roomBackgroundImageView = new FrameLayout () {
Height = Application.GetRealHeight (360),
Width = Application.GetRealWidth (640),
BackgroundImagePath = room.BackGroundImage
};
acBodyView.AddChidren (roomBackgroundImageView);
FrameLayout bodyView = new FrameLayout () {
Y = roomBackgroundImageView.Bottom,
Height = Application.GetRealHeight (700),
Width = LayoutParams.MatchParent,
};
acBodyView.AddChidren (bodyView);
#region temp
FrameLayout controlTopView = new FrameLayout () {
Height = Application.GetRealHeight (110),
BackgroundColor = SkinStyle.Current.ViewColor,
};
bodyView.AddChidren (controlTopView);
Button btnIndoor = new Button () {
X = Application.GetRealWidth (30),
Width = Application.GetRealWidth (110),
Height = Application.GetRealHeight (65),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.BottomLeft,
TextID = R.MyInternationalizationString.ACInterior
};
controlTopView.AddChidren (btnIndoor);
btnIndoorTemp = new Button () {
X = btnIndoor.Right,
Width = Application.GetRealWidth (60),
Height = Application.GetRealHeight (65),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.BottomLeft,
Text = freshAir.InTemp.ToString () + "°"
};
controlTopView.AddChidren (btnIndoorTemp);
Button btnTempNull = new Button () {
X = btnIndoorTemp.Right + Application.GetRealWidth (10),
Y = Application.GetRealHeight (40),
Width = Application.GetRealWidth (2),
Height = Application.GetRealHeight (20),
BackgroundColor = SkinStyle.Current.TextColor1,
};
controlTopView.AddChidren (btnTempNull);
var btnOutdoor = new Button () {
X = btnTempNull.Right + Application.GetRealWidth (20),
Width = Application.GetRealWidth (110),
Height = Application.GetRealHeight (65),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.BottomLeft,
TextID = R.MyInternationalizationString.Outdoor,
};
controlTopView.AddChidren (btnOutdoor);
btnOutdoorTemp = new Button () {
X = btnOutdoor.Right,
Width = Application.GetRealWidth (80),
Height = Application.GetRealHeight (65),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.BottomLeft,
Text = freshAir.OutTemp.ToString () + "°"
};
controlTopView.AddChidren (btnOutdoorTemp);
btnSwitch = new Button () {
Width = Application.GetMinRealAverage (115),
Height = Application.GetMinRealAverage (115),
X = Application.GetRealWidth (640 - 120),
UnSelectedImagePath = "FH/FH_Switch.png",
SelectedImagePath = "FH/FH_Switch_on.png",
};
controlTopView.AddChidren (btnSwitch);
btnSwitch.MouseUpEventHandler += (sender, e) => {
btnSwitch.IsSelected = !btnSwitch.IsSelected;
if (btnSwitch.IsSelected) {
freshAir.SwitchStatus = 1;
} else {
freshAir.SwitchStatus = 0;
}
bLL.ControlFreshAir (freshAir);
};
var btnLineControlTopView = new Button () {
Height = 1,
BackgroundColor = SkinStyle.Current.MainColor,
Y = controlTopView.Height - 1,
};
bodyView.AddChidren (btnLineControlTopView);
#endregion
#region sensor
FrameLayout valuesView = new FrameLayout () {
Y = controlTopView.Bottom,
Height = Application.GetRealHeight (180),
BackgroundColor = SkinStyle.Current.ViewColor,
};
bodyView.AddChidren (valuesView);
Button btnTitle = new Button () {
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextColor = SkinStyle.Current.TextColor1,
Text = "PM2.5",
TextSize = 16,
};
valuesView.AddChidren (btnTitle);
btnContentPM25 = new Button () {
Y = btnTitle.Bottom,
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextSize = 20,
Text = freshAir.PM25.ToString (),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.Center,
};
valuesView.AddChidren (btnContentPM25);
Button btnUnit = new Button () {
Y = btnContentPM25.Bottom,
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 16,
Text = @"μg/m³",
};
valuesView.AddChidren (btnUnit);
Button btnTitle0 = new Button () {
X = Application.GetRealWidth (160),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 16,
Text = "TVOC",
};
valuesView.AddChidren (btnTitle0);
btnContentTVOC = new Button () {
Y = btnTitle0.Bottom,
X = Application.GetRealWidth (160),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextColor = SkinStyle.Current.TextColor1,
TextSize = 20,
Text = freshAir.TVOC.ToString (),
TextAlignment = TextAlignment.Center,
};
valuesView.AddChidren (btnContentTVOC);
Button btnUnit0 = new Button () {
TextColor = SkinStyle.Current.TextColor1,
Y = btnContentTVOC.Bottom,
X = Application.GetRealWidth (160),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextSize = 16,
Text = "ppm",
};
valuesView.AddChidren (btnUnit0);
Button btnTitle1 = new Button () {
X = Application.GetRealWidth (320),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextSize = 16,
Text = "CO2",
TextColor = SkinStyle.Current.TextColor1,
};
valuesView.AddChidren (btnTitle1);
btnContentCO2 = new Button () {
Y = btnTitle1.Bottom,
X = Application.GetRealWidth (320),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextColor = SkinStyle.Current.TextColor1,
TextSize = 20,
Text = freshAir.CO2.ToString (),
TextAlignment = TextAlignment.Center,
};
valuesView.AddChidren (btnContentCO2);
Button btnUnit1 = new Button () {
Y = btnContentCO2.Bottom,
TextColor = SkinStyle.Current.TextColor1,
X = Application.GetRealWidth (320),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextAlignment = TextAlignment.Center,
TextSize = 16,
Text = "ppm",
};
valuesView.AddChidren (btnUnit1);
Button btnTitle2 = new Button () {
X = Application.GetRealWidth (160 * 3),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.Center,
TextSize = 16,
TextID = R.MyInternationalizationString.Humidity
};
valuesView.AddChidren (btnTitle2);
//if(Language.CurrentLanguage == "English") {
// btnTitle2.TextSize = 14;
//}
btnContentHumidity = new Button () {
X = Application.GetRealWidth (160 * 3),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
Y = btnTitle2.Bottom,
TextColor = SkinStyle.Current.TextColor1,
TextSize = 20,
Text = freshAir.Humidity.ToString (),
TextAlignment = TextAlignment.Center,
};
valuesView.AddChidren (btnContentHumidity);
Button btnUnit2 = new Button () {
Y = btnContentHumidity.Bottom,
X = Application.GetRealWidth (160 * 3),
Width = Application.GetRealWidth (160),
Height = Application.GetRealHeight (60),
TextColor = SkinStyle.Current.TextColor1,
TextAlignment = TextAlignment.Center,
TextSize = 16,
Text = "%",
};
valuesView.AddChidren (btnUnit2);
var btnLineValuesView = new Button () {
Height = 1,
BackgroundColor = SkinStyle.Current.MainColor,
Y = valuesView.Height - 1,
};
valuesView.AddChidren (btnLineValuesView);
#endregion
#region Pattern
var acModeView = new FrameLayout () {
Height = Application.GetRealHeight (180),
Width = Application.GetRealWidth (640),
BackgroundColor = SkinStyle.Current.ViewColor,
Y = valuesView.Bottom,
};
bodyView.AddChidren (acModeView);
btnACModeLeft = new Button () {
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = Application.GetRealWidth (30),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac_left.png",
SelectedImagePath = "AC/ACLeftSelected.png",
Enable = freshAir.SwitchStatus == 1 ? true : false,
};
acModeView.AddChidren (btnACModeLeft);
btnModeName = new Button () {
Width = Application.GetRealWidth (200),
Height = Application.GetRealHeight (30),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight (25),
TextID = R.MyInternationalizationString.UserACMode,
TextColor = SkinStyle.Current.ButtonColor,
};
acModeView.AddChidren (btnModeName);
btnModeIcon = new Button () {
Width = Application.GetMinRealAverage (110),
Height = Application.GetMinRealAverage (112),
Gravity = Gravity.Center,
Y = btnModeName.Bottom + Application.GetRealHeight (10),
UnSelectedImagePath = bLL.GetModeIcon (freshAir.SetPattern),
};
acModeView.AddChidren (btnModeIcon);
btnModeText = new Button () {
Width = Application.GetRealWidth (200),
Height = Application.GetRealHeight (50),
TextID = bLL.GetModeTextID (freshAir.SetPattern),
Gravity = Gravity.CenterHorizontal,
Y = btnModeIcon.Bottom - Application.GetRealHeight (20),
TextColor = SkinStyle.Current.TextColor1
};
acModeView.AddChidren (btnModeText);
btnACModeRight = new Button () {
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = Application.GetRealWidth (640 - 129 - 30),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac_right.png",
SelectedImagePath = "AC/ACRightSelected.png",
Enable = freshAir.SwitchStatus == 1 ? true : false,
};
acModeView.AddChidren (btnACModeRight);
btnACModeRight.MouseDownEventHandler += (sender, e) => {
btnACModeRight.IsSelected = true;
};
btnACModeRight.MouseUpEventHandler += (sender, e) => {
btnACModeRight.IsSelected = false;
freshAir.SetPattern++;
if (freshAir.SetPattern == 4) {
freshAir.SetPattern = 0;
}
bLL.ControlFreshAir (freshAir);
btnModeIcon.UnSelectedImagePath = bLL.GetModeIcon (freshAir.SetPattern);
btnModeText.TextID = bLL.GetModeTextID (freshAir.SetPattern);
};
btnACModeLeft.MouseDownEventHandler += (sender, e) => {
btnACModeLeft.IsSelected = true;
};
btnACModeLeft.MouseUpEventHandler += (sender, e) => {
btnACModeLeft.IsSelected = false;
if (freshAir.SetPattern == 0) {
freshAir.SetPattern = 4;
}
freshAir.SetPattern--;
bLL.ControlFreshAir (freshAir);
btnModeIcon.UnSelectedImagePath = bLL.GetModeIcon (freshAir.SetPattern);
btnModeText.TextID = bLL.GetModeTextID (freshAir.SetPattern);
};
#endregion
var btnLine1 = new Button () {
Height = 1,
BackgroundColor = SkinStyle.Current.MainColor,
Y = acModeView.Bottom,
};
bodyView.AddChidren (btnLine1);
#region 风速
var acWindView = new FrameLayout () {
Height = Application.GetRealHeight (180),
Width = Application.GetRealWidth (640),
Y = btnLine1.Bottom,
BackgroundColor = SkinStyle.Current.ViewColor,
};
bodyView.AddChidren (acWindView);
btnACWindLeft = new Button () {
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = Application.GetRealWidth (30),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac_left.png",
SelectedImagePath = "AC/ACLeftSelected.png",
Enable = freshAir.SwitchStatus == 1 ? true : false,
};
acWindView.AddChidren (btnACWindLeft);
btnWindName = new Button () {
Width = Application.GetRealWidth (200),
Height = Application.GetRealHeight (30),
Gravity = Gravity.CenterHorizontal,
Y = Application.GetRealHeight (21),
TextID = R.MyInternationalizationString.Speed,
TextColor = SkinStyle.Current.ButtonColor,
};
acWindView.AddChidren (btnWindName);
btnWindIcon = new Button () {
Width = Application.GetMinRealAverage (110),
Height = Application.GetMinRealAverage (112),
X = Application.GetRealWidth (262),
Y = Application.GetMinRealAverage (44),
UnSelectedImagePath = bLL.GetWindIcon (freshAir.WindSpeed),
};
acWindView.AddChidren (btnWindIcon);
btnWindText = new Button () {
Width = Application.GetRealWidth (200),
Height = Application.GetRealHeight (50),
TextID = bLL.GetWindTextID (freshAir.WindSpeed),
Gravity = Gravity.CenterHorizontal,
TextColor = SkinStyle.Current.TextColor1,
Y = btnWindIcon.Bottom - Application.GetRealHeight (16),
};
acWindView.AddChidren (btnWindText);
btnACWindRight = new Button () {
Width = Application.GetMinRealAverage (129),
Height = Application.GetMinRealAverage (129),
X = btnACModeRight.X,
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "AC/ac_right.png",
SelectedImagePath = "AC/ACRightSelected.png",
Enable = freshAir.SwitchStatus == 1 ? true : false,
};
btnACWindLeft.MouseDownEventHandler += (sender, e) => {
btnACWindLeft.IsSelected = true;
};
btnACWindLeft.MouseUpEventHandler += (sender, e) => {
btnACWindLeft.IsSelected = false;
freshAir.WindSpeed++;
if (freshAir.WindSpeed == 4) {
freshAir.WindSpeed = 0;
}
bLL.ControlFreshAir (freshAir);
btnWindIcon.UnSelectedImagePath = bLL.GetWindIcon (freshAir.WindSpeed);
btnWindText.TextID = bLL.GetWindTextID (freshAir.WindSpeed);
};
acWindView.AddChidren (btnACWindRight);
btnACWindRight.MouseDownEventHandler += (sender, e) => {
btnACWindRight.IsSelected = true;
};
btnACWindRight.MouseUpEventHandler += (sender, e) => {
btnACWindRight.IsSelected = false;
if (freshAir.WindSpeed == 0) {
freshAir.WindSpeed = 4;
}
freshAir.WindSpeed--;
bLL.ControlFreshAir (freshAir);
btnWindIcon.UnSelectedImagePath = bLL.GetWindIcon (freshAir.WindSpeed);
btnWindText.TextID = bLL.GetWindTextID (freshAir.WindSpeed);
};
btnModeIcon.UnSelectedImagePath = bLL.GetModeIcon (freshAir.SetPattern);
btnModeText.TextID = bLL.GetModeTextID (freshAir.SetPattern);
btnWindIcon.UnSelectedImagePath = bLL.GetWindIcon (freshAir.WindSpeed);
btnWindText.TextID = bLL.GetWindTextID (freshAir.WindSpeed);
#endregion
}
}
}