using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.UI2.PersonalCenter.PirDevice;
using Shared;
using System;
namespace HDL_ON.UI
{
///
/// 添加毫米波步骤1界面
///
public class SensorEnvironmentManagerPage : EditorCommonForm
{
#region ■ 变量声明___________________________
///
/// 添加设备完成之后的回调事件
///
public Action DelDeviceEvent = null;
Function function = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
public void ShowForm(Function device)
{
function = device;
//设置头部信息
base.SetTitleText(Language.StringByID(StringId.Add) + device.name);
//这个界面的背景需要白色
bodyFrameLayout.BackgroundColor = CSS.CSS_Color.BackgroundColor;
//初始化中部信息
this.InitMiddleFrame();
}
///
/// 初始化中部信息
///
private void InitMiddleFrame()
{
//图片
var btnPic = new PicViewControl(132, 132);
btnPic.Y = Application.GetRealHeight(69);
btnPic.Gravity = Gravity.CenterHorizontal;
btnPic.UnSelectedImagePath = "PersonalCenter/AddDevice/SenesorMegahealthBg.png";
bodyFrameLayout.AddChidren(btnPic);
var btnTip = new Button()
{
Y = Application.GetRealHeight(309 - 44),
Gravity = Gravity.CenterHorizontal,
Width = Application.GetRealWidth(319),
Height = Application.GetRealHeight(84),
IsMoreLines = true,
TextAlignment = TextAlignment.Center,
TextColor = CSS.CSS_Color.FirstLevelTitleColor,
TextSize = CSS.CSS_FontSize.SubheadingFontSize,
};
bodyFrameLayout.AddChidren(btnTip);
if (Language.CurrentLanguage == "Chinese")
{
btnTip.Text = "该设备已添加到传感器类别,可到对应功能板块查看";
}
else
{
btnTip.Text = "The device has been added to the sensor category, which can be viewed in the corresponding function block.";
}
var btnDel = new Button()
{
Y = Application.GetRealHeight(617 - 64),
Height = Application.GetRealHeight(50),
TextAlignment = TextAlignment.Center,
TextColor = CSS.CSS_Color.WarningColor,
TextSize = CSS.CSS_FontSize.SubheadingFontSize,
TextID = StringId.DeleteDevice,
BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
};
bodyFrameLayout.AddChidren(btnDel);
btnDel.MouseUpEventHandler = (sender, e) => {
var pack = PirSend.DeleteDevice(function.deviceId);
if (pack.Code == StateCode.SUCCESS)
{
DelDeviceEvent?.Invoke();
this.CloseForm();
var mes = "";
if (Language.CurrentLanguage == "Chinese")
{
mes = "设备删除成功。";
}
else
{
mes = "Device deleted successfully.";
}
var tip = new Tip()
{
Text = mes,
CloseTime = 2,
Direction = AMPopTipDirection.None
};
tip.Show(MainPage.BaseView);
}
else
{
IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
}
};
}
#endregion
#region ■ 关闭界面___________________________
///
/// 关闭界面
///
public override void CloseFormBefore()
{
this.DelDeviceEvent = null;
base.CloseFormBefore();
}
#endregion
}
}