| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.Device |
| | | { |
| | | /// <summary> |
| | | /// 网关成功添加设备的显示画面 |
| | | /// </summary> |
| | | public class DeviceAddSuccessForm : EditorCommonForm |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.Device
|
| | | {
|
| | | /// <summary>
|
| | | /// 网关成功添加设备的显示画面
|
| | | /// </summary>
|
| | | public class DeviceAddSuccessForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 新上报的设备 |
| | | /// </summary> |
| | | /// <summary>
|
| | | /// 新上报的设备
|
| | | /// </summary>
|
| | | private List<CommonDevice> listNewDevice = null;
|
| | | /// <summary>
|
| | | /// 列表控件
|
| | |
| | | /// </summary>
|
| | | private string saveDefultName = string.Empty;
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________ |
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | /// <param name="deviceMac">设备Mac地址</param> |
| | | public void ShowForm(string deviceMac) |
| | | { |
| | | this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac); |
| | | |
| | | //设置标题信息 |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice)); |
| | | |
| | | //初始化中部控件 |
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="deviceMac">设备Mac地址</param>
|
| | | public void ShowForm(string deviceMac)
|
| | | {
|
| | | this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
|
| | |
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
|
| | |
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | |
|
| | | //设置全部回路的默认名字
|
| | | this.SetAllEpointName();
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部控件 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | { |
| | | //清空bodyFrame |
| | | this.ClearBodyFrame(); |
| | | |
| | | //初始化桌布 |
| | | this.InitFrameTable(); |
| | | |
| | | //设备图片 |
| | | var btnpictrue = new PicViewControl(855, 570); |
| | | btnpictrue.Gravity = Gravity.CenterHorizontal; |
| | | btnpictrue.Y = Application.GetRealHeight(58); |
| | | Common.LocalDevice.Current.SetRealDeviceIconToControl(btnpictrue, listNewDevice); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部控件
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | //初始化桌布
|
| | | this.InitFrameTable();
|
| | |
|
| | | //设备图片
|
| | | var btnpictrue = new PicViewControl(855, 570);
|
| | | btnpictrue.Gravity = Gravity.CenterHorizontal;
|
| | | btnpictrue.Y = Application.GetRealHeight(58);
|
| | | Common.LocalDevice.Current.SetRealDeviceIconToControl(btnpictrue, listNewDevice);
|
| | | bodyFrameLayout.AddChidren(btnpictrue);
|
| | |
|
| | | string nameValue = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | this.saveDefultName = nameValue;
|
| | |
|
| | | //设备备注
|
| | | string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote); |
| | | string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]); |
| | | var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2); |
| | | listview.AddChidren(btnNote); |
| | | btnNote.InitControl(); |
| | | //划线 |
| | | btnNote.AddBottomLine(); |
| | | string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
|
| | | string deviceName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
|
| | | listview.AddChidren(btnNote);
|
| | | btnNote.InitControl();
|
| | | //划线
|
| | | btnNote.AddBottomLine();
|
| | | btnNote.txtInput.FinishInputEvent += () =>
|
| | | {
|
| | | if (btnNote.Text.Trim() == string.Empty)
|
| | |
| | | }
|
| | | //修改名字
|
| | | this.DeviceReName(btnNote.Text.Trim());
|
| | | }; |
| | | |
| | | //设备类型 |
| | | caption = Language.StringByID(R.MyInternationalizationString.uDeviceType); |
| | | deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice); |
| | | };
|
| | |
|
| | | //设备类型
|
| | | caption = Language.StringByID(R.MyInternationalizationString.uDeviceType);
|
| | | deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice);
|
| | | var btnType = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
|
| | | btnType.UseClickStatu = false;
|
| | | listview.AddChidren(btnType); |
| | | listview.AddChidren(btnType);
|
| | | btnType.InitControl();
|
| | | //划线 |
| | | //划线
|
| | | btnType.AddBottomLine();
|
| | |
|
| | | //所属区域
|
| | |
| | | btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | btnLine.Gravity = Gravity.CenterHorizontal;
|
| | | btnLine.Y = btnHelp.Bottom - Application.GetRealHeight(8);
|
| | | bodyFrameLayout.AddChidren(btnLine); |
| | | bodyFrameLayout.AddChidren(btnLine);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | //弧度的圆的一半的高度(固定)
|
| | | int halfRoundHeigth = Application.GetRealHeight(116) / 2;
|
| | | //弧度的圆
|
| | | var btnRound = new NormalViewControl(bodyFrameLayout.Width, halfRoundHeigth * 2, false); |
| | | btnRound.Y = Application.GetRealHeight(708); |
| | | btnRound.BackgroundColor = UserCenterColor.Current.White; |
| | | btnRound.Radius = (uint)halfRoundHeigth; |
| | | bodyFrameLayout.AddChidren(btnRound); |
| | | //明细列表的桌布,白色背景(覆盖弧度的圆的半边) |
| | | var detailBackFrame = new FrameLayout(); |
| | | detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2; |
| | | var btnRound = new NormalViewControl(bodyFrameLayout.Width, halfRoundHeigth * 2, false);
|
| | | btnRound.Y = Application.GetRealHeight(708);
|
| | | btnRound.BackgroundColor = UserCenterColor.Current.White;
|
| | | btnRound.Radius = (uint)halfRoundHeigth;
|
| | | bodyFrameLayout.AddChidren(btnRound);
|
| | | //明细列表的桌布,白色背景(覆盖弧度的圆的半边)
|
| | | var detailBackFrame = new FrameLayout();
|
| | | detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2;
|
| | | detailBackFrame.Height = Application.GetRealHeight(1200);//高度就是要它超过
|
| | | detailBackFrame.BackgroundColor = UserCenterColor.Current.White; |
| | | detailBackFrame.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(detailBackFrame);
|
| | |
|
| | | //设备编辑
|
| | |
| | | detailBackFrame.AddChidren(listview);
|
| | |
|
| | | //完成
|
| | | var btnFinish = new BottomClickButton(); |
| | | btnFinish.Y = Application.GetRealHeight(736); |
| | | btnFinish.TextID = R.MyInternationalizationString.uFinish; |
| | | detailBackFrame.AddChidren(btnFinish); |
| | | btnFinish.MouseUpEventHandler += (sender, e) => |
| | | { |
| | | //关闭自身 |
| | | this.CloseForm(); |
| | | var btnFinish = new BottomClickButton();
|
| | | btnFinish.Y = Application.GetRealHeight(736);
|
| | | btnFinish.TextID = R.MyInternationalizationString.uFinish;
|
| | | detailBackFrame.AddChidren(btnFinish);
|
| | | btnFinish.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion |
| | | |
| | | #endregion
|
| | |
|
| | | #region ■ 修改名字___________________________
|
| | |
|
| | | /// <summary> |
| | | /// 设备重命名然后打开新的画面 |
| | | /// </summary> |
| | | /// <param name="i_deviceName">deviceName.</param> |
| | | /// <param name="mode">是否显示错误</param> |
| | | private async void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES) |
| | | { |
| | | //修改MAC名 |
| | | string deviceName = i_deviceName.Trim(); |
| | | var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode); |
| | | if (result == false) |
| | | /// <summary>
|
| | | /// 设备重命名然后打开新的画面
|
| | | /// </summary>
|
| | | /// <param name="i_deviceName">deviceName.</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | private async void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | {
|
| | | //修改MAC名
|
| | | string deviceName = i_deviceName.Trim();
|
| | | var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName, mode);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | } |
| | | //更改过一次之后,则界面关闭后不再更改 |
| | | this.saveDefultName = string.Empty; |
| | | |
| | | //如果它的回路只有一个的话,则在设备上报的时候,修改MAC名字之后,连同端点名字也一起修改 |
| | | }
|
| | | //更改过一次之后,则界面关闭后不再更改
|
| | | this.saveDefultName = string.Empty;
|
| | |
|
| | | //如果它的回路只有一个的话,则在设备上报的时候,修改MAC名字之后,连同端点名字也一起修改
|
| | | if (this.listNewDevice.Count == 1)
|
| | | {
|
| | | //修改端点名字
|
| | |
| | | {
|
| | | return;
|
| | | }
|
| | | } |
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | #endregion |
| | | #endregion
|
| | |
|
| | | #region ■ 画面关闭___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面关闭
|
| | | /// </summary>
|
| | | public override void CloseForm()
|
| | | public override void CloseFormBefore()
|
| | | {
|
| | | if (this.saveDefultName != string.Empty)
|
| | | {
|
| | |
| | | //添加设备到列表
|
| | | this.LoadFormMethodByName("DeviceListMainForm", "AddDeviceToFormTable", listNewDevice[0].DeviceAddr);
|
| | |
|
| | | base.CloseForm();
|
| | | base.CloseFormBefore();
|
| | | }
|
| | | #endregion
|
| | | } |
| | | } |
| | | }
|
| | | }
|