using System;
|
/// <summary>
|
/// 系统后台配置空调模块的页面类
|
/// </summary>
|
namespace Shared.SimpleControl.Phone
|
{
|
public class SystemACHost : FrameLayout
|
{
|
public EquipmentPublicClass epc;
|
public ACMethod acM;
|
public SystemACHost ()
|
{
|
epc = new EquipmentPublicClass ();
|
acM = new ACMethod ();
|
}
|
/// <summary>
|
/// 显示HVAC空调界面
|
/// </summary>
|
/// <returns>The ACH ost.</returns>
|
/// <param name="acHost">Ac host.</param>
|
/// <param name="deviceBase">Ac host device.</param>
|
public void ShowACHost (HVAC acHost, Common deviceBase)
|
{
|
#region top
|
RowLayout frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (100),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
AddChidren (frameLayout);
|
|
Button backButton = new Button () {
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (85),
|
UnSelectedImagePath = "Item/Back.png",
|
SelectedImagePath = "Item/BackSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
backButton.MouseUpEventHandler += (sender, e) => {
|
(Parent as PageLayout).PageIndex -= 1;
|
//SystemEquipmentBase.RefreshView (deviceBase);
|
};
|
frameLayout.AddChidren (backButton);
|
|
EditText textButton = new EditText () {
|
X = Application.GetRealWidth (30) + backButton.Right,
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (400),
|
Text = acHost.Name,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
SelectedBackgroundColor = SkinStyle.Current.SysEditBox,
|
Enable = false,
|
TextSize = 15,
|
TextColor = SkinStyle.Current.TextColor1
|
};
|
frameLayout.AddChidren (textButton);
|
|
Button editor = new Button () {
|
X = Application.GetRealWidth (520),
|
Height = Application.GetRealHeight (90),
|
Width = Application.GetRealWidth (70),
|
UnSelectedImagePath = "Item/Editor.png",
|
SelectedImagePath = "Item/EditorSelected.png",
|
Gravity = Gravity.CenterVertical,
|
};
|
frameLayout.AddChidren (editor);
|
editor.MouseUpEventHandler += (sender, e) => {
|
if (editor.IsSelected) {
|
MainPage.Loading.Start ();
|
editor.IsSelected = textButton.IsSelected = textButton.Enable = false;
|
acHost.Name = textButton.Text.Trim ();
|
byte [] remakeBytes = CommonPage.MyEncodingGB2312.GetBytes (textButton.Text.Trim ());
|
System.Threading.Tasks.Task.Run (() => {
|
byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, acHost.SubnetID, acHost.DeviceID, new byte [] {
|
acHost.BigClass,acHost.MinClass,acHost.LoopID
|
});
|
if (updateBytes == null) {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
return;
|
}
|
byte [] uBytes = new byte [20];
|
Array.Copy (remakeBytes, 0, uBytes, 0, remakeBytes.Length < 20 ? remakeBytes.Length : 20);
|
Array.Copy (uBytes, 0, updateBytes, 3, 20 < uBytes.Length ? 20 : uBytes.Length);
|
var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, acHost.SubnetID, acHost.DeviceID, updateBytes);
|
if (reBytes != null) {
|
Application.RunOnMainThread (() => {
|
acHost.Name = textButton.Text.Trim ();
|
IO.FileUtils.SaveEquipmentMessage (acHost, acHost.LoopID.ToString ());
|
MainPage.Loading.Hide ();
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
|
MainPage.Loading.Hide ();
|
});
|
}
|
});
|
} else {
|
textButton.Enable = textButton.IsSelected = editor.IsSelected = true;
|
}
|
};
|
#endregion
|
|
#region MyRegion
|
byte [] acHostBytes = new byte [13];
|
|
FrameLayout frameLayoutBody = new FrameLayout () {
|
Height = Application.GetRealHeight (700),
|
Width = LayoutParams.MatchParent,
|
Y = Application.GetRealHeight (100),
|
};
|
AddChidren (frameLayoutBody);
|
|
Button btnSetTemperature = new Button () {
|
Width = Application.GetRealHeight (450),
|
Height = Application.GetRealHeight (45),
|
X = backButton.Right,
|
Y = Application.GetRealHeight (60),
|
TextID = R.MyInternationalizationString.SetTemperature,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
Enable = false,
|
};
|
frameLayoutBody.AddChidren (btnSetTemperature);
|
|
byte temperature = 16;
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (temperature).ToString ());
|
Button btnReduceTemperature = new Button () {
|
Width = Application.GetMinRealAverage (94),
|
Height = Application.GetMinRealAverage (94),
|
X = Application.GetRealWidth (80),
|
Y = btnSetTemperature.Bottom + Application.GetRealHeight (60),
|
UnSelectedImagePath = "AC/AC-.png",
|
SelectedImagePath = "AC/AC-Selected.png",
|
};
|
frameLayoutBody.AddChidren (btnReduceTemperature);
|
btnReduceTemperature.MouseDownEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = true;
|
};
|
btnReduceTemperature.MouseUpEventHandler += (sender, e) => {
|
btnReduceTemperature.IsSelected = false;
|
if (temperature > 16 && acHostBytes [9] != 2) {
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (--temperature).ToString ());
|
acHost.SetTemperature = temperature;
|
acM.ControlAC (acHost);
|
}
|
};
|
Button btnSwitchAC = new Button () {
|
Width = Application.GetMinRealAverage (94),
|
Height = Application.GetMinRealAverage (94),
|
X = Application.GetRealWidth ((640 - 94) / 2),
|
Y = btnReduceTemperature.Y,
|
UnSelectedImagePath = "AC/ACClose.png",
|
SelectedImagePath = "AC/ACCloseSelected.png",
|
};
|
frameLayoutBody.AddChidren (btnSwitchAC);
|
btnSwitchAC.MouseUpEventHandler += (sender, e) => {
|
if (acHostBytes == null) {
|
return;
|
}
|
if (acHostBytes [8] == 0) {
|
acHostBytes [8] = 1;
|
btnSwitchAC.IsSelected = true;
|
} else {
|
acHostBytes [8] = 0;
|
btnSwitchAC.IsSelected = false;
|
}
|
acHost.Power = acHostBytes[8];
|
acM.ControlAC (acHost);
|
};
|
|
Button btnAddTemperature = new Button () {
|
Width = Application.GetMinRealAverage (94),
|
Height = Application.GetMinRealAverage (94),
|
X = Application.GetRealWidth (640 - 80 - 94),
|
Y = btnReduceTemperature.Y,
|
UnSelectedImagePath = "AC/AC+.png",
|
SelectedImagePath = "AC/AC+Selected.png",
|
};
|
frameLayoutBody.AddChidren (btnAddTemperature);
|
btnAddTemperature.MouseDownEventHandler += (sender, e) => {
|
btnAddTemperature.IsSelected = true;
|
};
|
btnAddTemperature.MouseUpEventHandler += (sender, e) => {
|
btnAddTemperature.IsSelected = false;
|
btnReduceTemperature.IsSelected = false;
|
if (temperature < 30 && acHostBytes [9] != 2) {
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (++temperature).ToString ());
|
acHost.SetTemperature = temperature;
|
acM.ControlAC (acHost);
|
}
|
};
|
#region ModeView
|
FrameLayout acModeView = new FrameLayout () {
|
Height = Application.GetRealHeight (97),
|
Width = LayoutParams.MatchParent,
|
//BackgroundImagePath = "Item/BottomLine.png",
|
Y = btnReduceTemperature.Bottom + Application.GetRealHeight (30),
|
};
|
frameLayoutBody.AddChidren (acModeView);
|
|
Button btnACModeLeft = new Button () {
|
Width = Application.GetMinRealAverage (129),
|
Height = Application.GetMinRealAverage (129),
|
X = btnReduceTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACLeft.png",
|
SelectedImagePath = "AC/ACLeft.png",
|
};
|
acModeView.AddChidren (btnACModeLeft);
|
|
Button btnModeIcon = new Button () {
|
Width = Application.GetMinRealAverage (110),
|
Height = Application.GetMinRealAverage (110),
|
Gravity = Gravity.Center,
|
UnSelectedImagePath = "AC/ACRefrigeration.png",
|
Enable = false,
|
};
|
acModeView.AddChidren (btnModeIcon);
|
Button btnACModeRight = new Button () {
|
Width = Application.GetMinRealAverage (129),
|
Height = Application.GetMinRealAverage (129),
|
X = btnAddTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACRight.png",
|
SelectedImagePath = "AC/ACRightSelected.png",
|
};
|
acModeView.AddChidren (btnACModeRight);
|
btnACModeRight.MouseDownEventHandler += (sender, e) => {
|
btnACModeRight.IsSelected = true;
|
};
|
btnACModeRight.MouseUpEventHandler += (sender, e) => {
|
btnACModeRight.IsSelected = false;
|
if (++acHostBytes [9] > 4)
|
acHostBytes [9] = 0;
|
acHost.SetMode = acHostBytes [9];
|
acM.ControlAC (acHost);
|
acM.UpdataACHostModeIcon (acHostBytes [9], btnModeIcon);
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (temperature).ToString ());
|
};
|
btnACModeLeft.MouseDownEventHandler += (sender, e) => {
|
btnACModeLeft.IsSelected = true;
|
};
|
btnACModeLeft.MouseUpEventHandler += (sender, e) => {
|
btnACModeLeft.IsSelected = false;
|
try {
|
acHostBytes [9]--;
|
if (acHostBytes [9] < 0)
|
acHostBytes [9] = 4;
|
} catch {
|
acHostBytes [9] = 4;
|
}
|
acHost.SetMode = acHostBytes [9];
|
acM.ControlAC (acHost);
|
acM.UpdataACHostModeIcon (acHostBytes [9], btnModeIcon);
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (temperature).ToString ());
|
};
|
#endregion
|
|
#region WindView
|
FrameLayout acWindView = new FrameLayout () {
|
Height = Application.GetRealHeight (97),
|
Width = LayoutParams.MatchParent,
|
Y = acModeView.Bottom + Application.GetRealHeight (35),
|
//BackgroundImagePath = "Item/BottomLine.png",
|
};
|
frameLayoutBody.AddChidren (acWindView);
|
|
Button btnACWindLeft = new Button () {
|
Width = Application.GetMinRealAverage (129),
|
Height = Application.GetMinRealAverage (129),
|
X = btnReduceTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACLeft.png",
|
SelectedImagePath = "AC/ACLeft.png",
|
};
|
acWindView.AddChidren (btnACWindLeft);
|
|
Button btnWindIcon = new Button () {
|
Width = Application.GetMinRealAverage (110),
|
Height = Application.GetMinRealAverage (110),
|
Gravity = Gravity.Center,
|
UnSelectedImagePath = "AC/ACAuto.png",
|
Enable = false,
|
};
|
acWindView.AddChidren (btnWindIcon);
|
Button btnACWindRight = new Button () {
|
Width = Application.GetMinRealAverage (129),
|
Height = Application.GetMinRealAverage (129),
|
X = btnAddTemperature.X - Application.GetRealWidth (17),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "AC/ACRight.png",
|
SelectedImagePath = "AC/ACRightSelected.png",
|
};
|
acWindView.AddChidren (btnACWindRight);
|
btnACWindLeft.MouseDownEventHandler += (sender, e) => {
|
btnACWindLeft.IsSelected = true;
|
};
|
btnACWindLeft.MouseUpEventHandler += (sender, e) => {
|
btnACWindLeft.IsSelected = false;
|
try {
|
acHostBytes [10]--;
|
if (acHostBytes [10] < 0) {
|
acHostBytes [10] = 3;
|
}
|
} catch {
|
acHostBytes [10] = 3;
|
}
|
acHost.SetFanSpeed = acHostBytes [10];
|
acM.ControlAC (acHost);
|
acM.UpdataACHostWindIcon (acHostBytes [10], btnWindIcon);
|
};
|
btnACWindRight.MouseDownEventHandler += (sender, e) => {
|
btnACWindRight.IsSelected = true;
|
};
|
btnACWindRight.MouseUpEventHandler += (sender, e) => {
|
btnACWindRight.IsSelected = false;
|
if (++acHostBytes [10] > 3)
|
acHostBytes [10] = 0;
|
acHost.SetFanSpeed = acHostBytes [10];
|
acM.ControlAC (acHost);
|
acM.UpdataACHostWindIcon (acHostBytes [10], btnWindIcon);
|
};
|
#endregion
|
|
#region ----加载完界面之后读取数据刷新界面----
|
System.Threading.Tasks.Task.Run (() => {
|
acHostBytes = Control.ControlBytesSendHasReturn (Command.ReadACMode, acHost.SubnetID, acHost.DeviceID, new byte [] { acHost.LoopID });
|
if (acHostBytes == null) {
|
Application.RunOnMainThread (() => {
|
epc.AlertNotOnline ();
|
acHostBytes = new byte [13];
|
});
|
} else {
|
Application.RunOnMainThread (() => {
|
temperature = acM.SetACTemperatureText (acHostBytes, btnSetTemperature);
|
btnSetTemperature.Text = Language.StringByID (R.MyInternationalizationString.SetTemperature).Replace ("--", (temperature).ToString ());
|
if (acHostBytes [8] == 1) {
|
btnSwitchAC.IsSelected = true;
|
} else {
|
btnSwitchAC.IsSelected = false;
|
}
|
// mode Icon
|
acM.UpdataACHostModeIcon (acHostBytes [9], btnModeIcon);
|
// wind Icon
|
acM.UpdataACHostWindIcon (acHostBytes [10], btnWindIcon);
|
});
|
}
|
});
|
#endregion
|
#endregion
|
//SystemMiddle.hideBottom ();
|
}
|
}
|
}
|