New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using Shared.Common;
|
| | | using Shared.Phone.UserCenter;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.MainPage
|
| | | {
|
| | | /// <summary>
|
| | | /// 主页的设备信息界面
|
| | | /// </summary>
|
| | | public class DeviceDetailInfoForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭事件(该事件目前给分类界面的自定义行控件使用)
|
| | | /// </summary>
|
| | | public Action FormCloseEvent = null;
|
| | | /// <summary>
|
| | | /// 设备对象
|
| | | /// </summary>
|
| | | private CommonDevice device;
|
| | | /// <summary>
|
| | | /// 房间对象(这个房间有可能是喜爱,有可能是null)
|
| | | /// </summary>
|
| | | private Room room = null;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private FrameListControl listview = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_device">设备对象</param>
|
| | | /// <param name="i_room">房间对象(这个房间有可能是喜爱)</param>
|
| | | public void ShowForm(CommonDevice i_device, Room i_room)
|
| | | {
|
| | | this.device = i_device;
|
| | | this.room = i_room;
|
| | |
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.FunctionSetting));
|
| | |
|
| | | //主人和管理员才能更改
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
|
| | | {
|
| | | //初始化中部控件(主人,管理员)
|
| | | this.InitMiddleFrameByAdmin();
|
| | | }
|
| | | //成员不允许变更
|
| | | else
|
| | | {
|
| | | //初始化中部控件(成员)
|
| | | this.InitMiddleFrameByMember();
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件(主人,管理员)
|
| | | /// </summary>
|
| | | private void InitMiddleFrameByAdmin()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listBackControl = new VerticalFrameControl();
|
| | | listBackControl.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listBackControl);
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | | this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
|
| | |
|
| | | //图片
|
| | | var btnPic = new DeviceInfoIconControl();
|
| | | btnPic.Y = Application.GetRealHeight(46);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | listBackControl.frameTable.AddChidren(btnPic);
|
| | | btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
|
| | | btnPic.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new SelectLocalDeviceImageForm();
|
| | | form.AddForm();
|
| | | form.FinishSelectEvent = (unSelectedImagePath) =>
|
| | | {
|
| | | //变更图片
|
| | | device.IconPath = unSelectedImagePath;
|
| | | device.IsCustomizeImage = true;
|
| | | device.ReSave();
|
| | | //刷新控件
|
| | | btnPic.RefreshControl();
|
| | | };
|
| | | };
|
| | |
|
| | | //设备所属类型
|
| | | var infoType = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
|
| | | var btnBelongType = new NormalViewControl(700, 62, true);
|
| | | btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
|
| | | btnBelongType.Gravity = Gravity.CenterHorizontal;
|
| | | btnBelongType.TextID = infoType.BeloneTextId;
|
| | | btnBelongType.TextSize = 15;
|
| | | btnBelongType.TextAlignment = TextAlignment.Center;
|
| | | listBackControl.frameTable.AddChidren(btnBelongType);
|
| | |
|
| | | //功能名称
|
| | | string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
|
| | | string deviceName = LocalDevice.Current.GetDeviceEpointName(device);
|
| | | var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
|
| | | listview.AddChidren(btnNote);
|
| | | btnNote.InitControl();
|
| | | //划线
|
| | | btnNote.AddBottomLine();
|
| | | btnNote.txtInput.FinishInputEvent += () =>
|
| | | {
|
| | | string oldName = LocalDevice.Current.GetDeviceEpointName(device);
|
| | | if (btnNote.Text == string.Empty)
|
| | | {
|
| | | btnNote.Text = oldName;
|
| | | }
|
| | | if (oldName != btnNote.Text)
|
| | | {
|
| | | //修改名字
|
| | | this.DeviceReName(btnNote.Text, false);
|
| | | }
|
| | | };
|
| | |
|
| | | //喜爱房间不允许变更区域
|
| | | if (this.room == null || this.room.IsLove == false)
|
| | | {
|
| | | //所属区域
|
| | | var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
|
| | | listview.AddChidren(rowBeloneArea);
|
| | | rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.device);
|
| | | //底线
|
| | | rowBeloneArea.AddBottomLine();
|
| | | rowBeloneArea.SelectRoomEvent += (roomKeys) =>
|
| | | {
|
| | | //房间重新获取
|
| | | this.room = HdlRoomLogic.Current.GetRoomById(roomKeys);
|
| | | HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
|
| | | };
|
| | | }
|
| | |
|
| | | //所属模块
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
|
| | | deviceName = Common.LocalDevice.Current.GetDeviceMacName(device);
|
| | | var rowBelongModul = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
|
| | | listview.AddChidren(rowBelongModul);
|
| | | rowBelongModul.InitControl();
|
| | | //划线
|
| | | rowBelongModul.AddBottomLine();
|
| | |
|
| | | //添加【功能类型】行(主人,管理员)
|
| | | this.AddFunctionTypeRowByAdmin(btnBelongType);
|
| | |
|
| | | //初始化桌布完成
|
| | | tableContr.FinishInitControl();
|
| | | tableContr = null;
|
| | |
|
| | | //保存
|
| | | var btnFinish = new BottomClickButton();
|
| | | btnFinish.TextID = R.MyInternationalizationString.uSave;
|
| | | bodyFrameLayout.AddChidren(btnFinish);
|
| | | btnFinish.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | string oldName = LocalDevice.Current.GetDeviceEpointName(device);
|
| | | if (btnNote.Text.Trim() == string.Empty)
|
| | | {
|
| | | btnNote.Text = oldName;
|
| | | }
|
| | | if (oldName != btnNote.Text.Trim())
|
| | | {
|
| | | //修改名字
|
| | | this.DeviceReName(btnNote.Text.Trim(), true);
|
| | | }
|
| | | else
|
| | | {
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件(成员)
|
| | | /// </summary>
|
| | | private void InitMiddleFrameByMember()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listBackControl = new VerticalFrameControl();
|
| | | listBackControl.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listBackControl);
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | | this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
|
| | |
|
| | | //图片
|
| | | var btnPic = new DeviceInfoIconControl();
|
| | | btnPic.Y = Application.GetRealHeight(92);
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | listBackControl.frameTable.AddChidren(btnPic);
|
| | | btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | //设备所属类型
|
| | | var infoType = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
|
| | | var btnBelongType = new NormalViewControl(700, 62, true);
|
| | | btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
|
| | | btnBelongType.Gravity = Gravity.CenterHorizontal;
|
| | | btnBelongType.TextID = infoType.BeloneTextId;
|
| | | btnBelongType.TextSize = 15;
|
| | | btnBelongType.TextAlignment = TextAlignment.Center;
|
| | | listBackControl.frameTable.AddChidren(btnBelongType);
|
| | |
|
| | | //功能名称
|
| | | string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
|
| | | string nameValue = LocalDevice.Current.GetDeviceEpointName(device);
|
| | | var btnNote = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
|
| | | btnNote.UseClickStatu = false;
|
| | | listview.AddChidren(btnNote);
|
| | | btnNote.InitControl();
|
| | | //划线
|
| | | btnNote.AddBottomLine();
|
| | |
|
| | | //喜爱房间不允许出现区域
|
| | | if (this.room == null || this.room.IsLove == false)
|
| | | {
|
| | | //所属区域
|
| | | caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
|
| | | nameValue = HdlRoomLogic.Current.GetRoomNameByDevice(device);
|
| | | var rowBeloneArea = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
|
| | | rowBeloneArea.UseClickStatu = false;
|
| | | listview.AddChidren(rowBeloneArea);
|
| | | rowBeloneArea.InitControl();
|
| | | //划线
|
| | | rowBeloneArea.AddBottomLine();
|
| | | }
|
| | |
|
| | | //所属模块
|
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
|
| | | nameValue = Common.LocalDevice.Current.GetDeviceMacName(device);
|
| | | var rowBelongModul = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
|
| | | rowBelongModul.UseClickStatu = false;
|
| | | listview.AddChidren(rowBelongModul);
|
| | | rowBelongModul.InitControl();
|
| | | //划线
|
| | | rowBelongModul.AddBottomLine();
|
| | |
|
| | | //添加【功能类型】行(成员)
|
| | | this.AddFunctionTypeRowByMember();
|
| | |
|
| | | //初始化桌布完成
|
| | | tableContr.FinishInitControl();
|
| | | tableContr = null;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 功能类型___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加【功能类型】行(主人,管理员)
|
| | | /// </summary>
|
| | | private void AddFunctionTypeRowByAdmin(NormalViewControl btnBelongType)
|
| | | {
|
| | | //自定义功能类型控件
|
| | | var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
|
| | | if (rowFunction.CanShowRow == true)
|
| | | {
|
| | | listview.AddChidren(rowFunction);
|
| | | rowFunction.InitControl();
|
| | | //底线
|
| | | rowFunction.AddBottomLine();
|
| | | rowFunction.FinishSelectEvent += (index) =>
|
| | | {
|
| | | //当类型变更时,头上的类型也一起变更
|
| | | btnBelongType.Text = rowFunction.Text;
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加【功能类型】行(成员)
|
| | | /// </summary>
|
| | | private void AddFunctionTypeRowByMember()
|
| | | {
|
| | | //自定义功能类型控件
|
| | | var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
|
| | | if (rowFunction.CanShowRow == true)
|
| | | {
|
| | | //强制干涉不能选择
|
| | | rowFunction.SetCanSelect = false;
|
| | | listview.AddChidren(rowFunction);
|
| | | rowFunction.InitControl();
|
| | | //底线
|
| | | rowFunction.AddBottomLine();
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 修改名字___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备重命名
|
| | | /// </summary>
|
| | | /// <param name="i_deviceName">deviceName.</param>
|
| | | private void DeviceReName(string i_deviceName, bool closeForm)
|
| | | {
|
| | | //修改MAC名
|
| | | string deviceName = i_deviceName.Trim();
|
| | | var result = LocalDevice.Current.ReName(this.device, deviceName);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | if (closeForm == true)
|
| | | {
|
| | | //关闭界面
|
| | | this.CloseForm();
|
| | | }
|
| | | else
|
| | | {
|
| | | //设备备注修改成功!
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess);
|
| | | this.ShowMassage(ShowMsgType.Tip, msg);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 界面关闭___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 界面关闭
|
| | | /// </summary>
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | this.FormCloseEvent?.Invoke();
|
| | | this.FormCloseEvent = null;
|
| | |
|
| | | base.CloseFormBefore();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|