using System;
|
using System.Text;
|
|
namespace Shared.SimpleControl.Phone
|
{
|
public class SystemFoolHeat:FrameLayout
|
{
|
public void SystemTerrestrialHeatShow(FoolHeat fh,Common thDevice)
|
{
|
#region top
|
RowLayout frameLayout = new RowLayout () {
|
Height = Application.GetRealHeight (100),
|
Width = LayoutParams.MatchParent,
|
BackgroundColor = SkinStyle.Current.MainColor
|
};
|
AddChidren (frameLayout);
|
|
Button backButton = new Button () {
|
X = Application.GetRealWidth (0),
|
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 (thDevice);
|
//Animate = Animate.RightToLeft;
|
};
|
frameLayout.AddChidren (backButton);
|
|
EditText textButton = new EditText () {
|
X = Application.GetRealWidth (30) + backButton.Right,
|
Height = Application.GetRealHeight (50),
|
Width = Application.GetRealWidth (400),
|
Text = fh.Name,
|
Gravity = Gravity.CenterVertical,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = SkinStyle.Current.TextColor1,
|
BackgroundColor = SkinStyle.Current.Transparent,
|
SelectedBackgroundColor = SkinStyle.Current.SysEditBox,
|
};
|
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) {
|
editor.IsSelected = false;
|
textButton.IsSelected = false;
|
textButton.Enable = false;
|
MainPage.Loading.Start ();
|
byte [] nameBytes = Encoding.Unicode.GetBytes (textButton.Text.Trim ());
|
System.Threading.Tasks.Task.Run (() => {
|
byte [] updateBytes = Control.ControlBytesSendHasReturn (Command.ReadDeviceLoopInfo, fh.SubnetID, fh.DeviceID, new byte [] {
|
fh.BigClass,fh.MinClass,fh.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 [] remakeBytes = new byte [20];
|
Array.Copy (nameBytes, 0, remakeBytes, 0, 20 < nameBytes.Length ? 20 : nameBytes.Length);
|
Array.Copy (remakeBytes, 0, updateBytes, 3, 20 );
|
var reBytes = Control.ControlBytesSendHasReturn (Command.SetDeviceLoopInfo, fh.SubnetID, fh.DeviceID, updateBytes);
|
if (reBytes != null) {
|
Application.RunOnMainThread (() => {
|
fh.Name = textButton.Text.Trim ();
|
IO.FileUtils.SaveEquipmentMessage (fh, fh.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
|
FrameLayout frameLayoutBody = new FrameLayout () {
|
Y = Application.GetRealHeight (100),
|
Height = Application.GetRealHeight (798),
|
Width = LayoutParams.MatchParent,
|
};
|
AddChidren (frameLayoutBody);
|
|
//---output test
|
Button btnOutput = new Button () {
|
Width = Application.GetRealWidth (203),
|
Height = Application.GetRealHeight (53),
|
X = Application.GetRealWidth (60),
|
Y = Application.GetRealHeight (40),
|
TextID = R.MyInternationalizationString.Test,
|
TextAlignment = TextAlignment.CenterLeft,
|
};
|
frameLayoutBody.AddChidren(btnOutput);
|
|
Button btnSwitch =new Button(){
|
Gravity = Gravity.CenterHorizontal,
|
Y = btnOutput.Bottom + Application.GetRealHeight(30),
|
Width = Application.GetRealWidth (215),
|
Height = Application.GetRealHeight (95),
|
SelectedImagePath = "Fan/FanSwitchOn.png",
|
UnSelectedImagePath = "Fan/FanSwitch.png",
|
};
|
if (fh.Status == 0)
|
btnSwitch.IsSelected = false;
|
else
|
btnSwitch.IsSelected = true;
|
frameLayoutBody.AddChidren(btnSwitch);
|
btnSwitch.MouseUpEventHandler+= (sender, e) => {
|
if(btnSwitch.IsSelected){
|
fh.Status = 0;
|
btnSwitch.IsSelected=false;
|
}
|
else
|
{
|
fh.Status = 1;
|
btnSwitch.IsSelected=true;
|
}
|
System.Threading.Tasks.Task.Run(()=>{
|
fh.Serverx_FH_CMD (FoolHeat.CommandType.Switch);
|
});
|
};
|
#endregion
|
}
|
}
|
}
|