using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.DeviceLight
|
{
|
/// <summary>
|
/// mini夜灯的功能设置界面
|
/// </summary>
|
public class MiniNightLightFunctionSettionForm : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 设备的某一回路
|
/// </summary>
|
private CommonDevice device = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
/// <param name="i_device">设备的某一回路</param>
|
public void ShowForm(CommonDevice i_device)
|
{
|
this.device = i_device;
|
|
//设置头部信息
|
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uFunctionSettingUp));
|
|
//初始化中部信息
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
//清空bodyFrame
|
this.ClearBodyFrame();
|
|
//图片
|
var btnPic = new PicViewControl(508, 204);
|
btnPic.Y = Application.GetRealHeight(179);
|
btnPic.Gravity = Gravity.CenterHorizontal;
|
btnPic.UnSelectedImagePath = "DeviceItem/MiniNightLightDevice.png";
|
bodyFrameLayout.AddChidren(btnPic);
|
|
var listBackControl = new VerticalFrameControl();
|
listBackControl.Height = bodyFrameLayout.Height;
|
bodyFrameLayout.AddChidren(listBackControl);
|
|
//初始化桌布
|
var tableContr = new InformationEditorControl();
|
var listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1166);
|
|
//回路备注
|
string caption = Language.StringByID(R.MyInternationalizationString.uDeviceEpointNote);
|
string nameValue = HdlDeviceCommonLogic.Current.GetDeviceEpointName(this.device);
|
var btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
|
btnDeviceName.txtInput.MaxByte = 48;//限制只能输入48个字节
|
listview.AddChidren(btnDeviceName);
|
btnDeviceName.InitControl();
|
btnDeviceName.AddBottomLine();
|
btnDeviceName.txtInput.FinishInputEvent += () =>
|
{
|
string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(this.device);
|
if (btnDeviceName.Text.Trim() == string.Empty)
|
{
|
//将名字还原
|
btnDeviceName.Text = oldName;
|
}
|
if (oldName != btnDeviceName.Text.Trim())
|
{
|
//设备名称修改
|
var result = HdlDeviceCommonLogic.Current.ReName(this.device, btnDeviceName.Text.Trim());
|
if (result == false)
|
{
|
return;
|
}
|
//回路备注修改成功!
|
string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess);
|
this.ShowMassage(ShowMsgType.Tip, msg);
|
}
|
};
|
|
//所属区域
|
var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
|
listview.AddChidren(rowBeloneArea);
|
rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.device);
|
//底线
|
rowBeloneArea.AddBottomLine();
|
rowBeloneArea.SelectRoomEvent += (roomKeys) =>
|
{
|
//变更房间
|
HdlRoomLogic.Current.ChangedRoom(this.device, roomKeys);
|
};
|
|
//自定义功能类型控件
|
var rowFunction = new DeviceFunctionTypeRowControl(this.device, listview.rowSpace / 2);
|
if (rowFunction.CanShowRow == true)
|
{
|
listview.AddChidren(rowFunction);
|
rowFunction.InitControl();
|
//底线
|
rowFunction.AddBottomLine();
|
}
|
//初始化桌布完成
|
tableContr.FinishInitControl();
|
|
//保存
|
var btnFinish = new BottomClickButton();
|
btnFinish.TextID = R.MyInternationalizationString.uSave;
|
bodyFrameLayout.AddChidren(btnFinish);
|
btnFinish.ButtonClickEvent += (sender, e) =>
|
{
|
string newName = btnDeviceName.Text.Trim();
|
string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
|
if (oldName != newName)
|
{
|
//设备名称修改
|
var result = HdlDeviceCommonLogic.Current.ReName(device, newName);
|
if (result == false)
|
{
|
return;
|
}
|
}
|
//关闭自身
|
this.CloseForm();
|
};
|
}
|
|
#endregion
|
}
|
}
|