| | |
| | | /// </summary>
|
| | | private VerticalListControl listview = null;
|
| | | /// <summary>
|
| | | /// 设备备注控件
|
| | | /// </summary>
|
| | | private FrameCaptionInputControl btnNote = null;
|
| | | /// <summary>
|
| | | /// 保存默认名字(主要针对没有修改名字的时候,必须要给一个默认名字给网关)
|
| | | /// </summary>
|
| | | private string saveDefultName = string.Empty;
|
| | |
| | | /// <param name="deviceMac">设备Mac地址</param>
|
| | | public void ShowForm(string deviceMac)
|
| | | {
|
| | | this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
|
| | | this.listNewDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceMac);
|
| | | if (listNewDevice.Count == 0)
|
| | | {
|
| | | //对应单纯只有200回路的设备
|
| | | listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
|
| | | listNewDevice.Add(HdlDeviceCommonLogic.Current.GetOTADevice(deviceMac));
|
| | | }
|
| | |
|
| | | //添加新设备的话,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | //设置标题信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
|
| | |
| | |
|
| | | //设置全部回路的默认名字
|
| | | this.SetAllEpointName();
|
| | | // 设置网关所在的时区的时间给门锁时间
|
| | | this.SetDoorTime();
|
| | | //新入网的设备,清空掉它的房间
|
| | | this.ClearDeviceFromRoom();
|
| | | //添加设备的时候,关闭左划菜单的未分配界面
|
| | | MainPage.LeftListRoomViewFrom.Instance?.CloseUnallocatedRoomForm();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | framePic.Y = Application.GetRealHeight(58);
|
| | | bodyFrameLayout.AddChidren(framePic);
|
| | |
|
| | | var imageFile = Common.LocalDevice.Current.GetRealDeviceIcon(listNewDevice);
|
| | | var imageFile = HdlDeviceCommonLogic.Current.GetRealDeviceIcon(listNewDevice);
|
| | | string fullName = IO.FileUtils.GetImageFilePath(imageFile);
|
| | |
|
| | | #if Android
|
| | |
| | | btnpictrue.UnSelectedImagePath = imageFile;
|
| | | framePic.AddChidren(btnpictrue);
|
| | |
|
| | | string nameValue = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | string nameValue = HdlDeviceCommonLogic.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);
|
| | | string deviceName = HdlDeviceCommonLogic.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | this.btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
|
| | | this.btnNote.txtInput.MaxByte = 48;//限制只能输入48个字节
|
| | | listview.AddChidren(btnNote);
|
| | | btnNote.InitControl();
|
| | | //划线
|
| | |
| | | {
|
| | | if (btnNote.Text.Trim() == string.Empty)
|
| | | {
|
| | | btnNote.Text = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | btnNote.Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(listNewDevice[0]);
|
| | | return;
|
| | | }
|
| | | //修改名字
|
| | |
| | |
|
| | | //设备类型
|
| | | caption = Language.StringByID(R.MyInternationalizationString.uDeviceType);
|
| | | deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice);
|
| | | deviceName = HdlDeviceCommonLogic.Current.GetDeviceObjectText(listNewDevice);
|
| | | var btnType = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
|
| | | btnType.UseClickStatu = false;
|
| | | listview.AddChidren(btnType);
|
| | |
| | | //划线
|
| | | btnType.AddBottomLine();
|
| | |
|
| | | //所属区域
|
| | | //安装位置
|
| | | var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
|
| | | listview.AddChidren(rowBeloneArea);
|
| | | rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.listNewDevice);
|
| | | rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uInstallationLocation), this.listNewDevice);
|
| | | //底线
|
| | | rowBeloneArea.AddBottomLine();
|
| | |
|
| | | var listCheck = new List<string>();
|
| | | rowBeloneArea.SelectRoomEvent += (roomKeys) =>
|
| | | {
|
| | | //选择未分配时,清空
|
| | | if (roomKeys == string.Empty) { listCheck = new List<string>(); }
|
| | | foreach (var device in this.listNewDevice)
|
| | | {
|
| | | if (device is OTADevice)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (roomKeys == string.Empty)
|
| | | {
|
| | | //如果选择的是未分配,则它的全部回路无条件全部清空房间
|
| | | HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
|
| | | continue;
|
| | | }
|
| | |
|
| | | var room = HdlRoomLogic.Current.GetRoomByDevice(device);
|
| | | string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
|
| | | if (room == null)
|
| | | {
|
| | | //这里有点特殊,如果回路没有设置有区域的时候,才设置
|
| | |
| | | }
|
| | | }
|
| | | //保存设备房间索引
|
| | | Common.LocalDevice.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
|
| | | HdlRoomLogic.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
|
| | | };
|
| | |
|
| | | //更多配置
|
| | |
| | | btnHelp.Text = Language.StringByID(R.MyInternationalizationString.uMoreSettion);
|
| | | btnHelp.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //更改过一次之后,则界面关闭后不再更改
|
| | | this.saveDefultName = string.Empty;
|
| | | //改名字
|
| | | btnNote.txtInput.FinishInputEvent();
|
| | |
|
| | | this.CloseForm();
|
| | |
|
| | | var form = new DeviceMacInfoEditorForm();
|
| | | form.AddForm(this.listNewDevice[0].DeviceAddr);
|
| | | };
|
| | | bodyFrameLayout.AddChidren(btnHelp);
|
| | | //底线
|
| | | int lineWidth = btnHelp.GetRealWidthByText();
|
| | | var btnLine = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false);
|
| | | var btnLine = new NormalViewControl(lineWidth, HdlControlResourse.BottomLineHeight, false);
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
|
| | | btnLine.Gravity = Gravity.CenterHorizontal;
|
| | | btnLine.Y = btnHelp.Bottom - Application.GetRealHeight(8);
|
| | |
| | |
|
| | | //设备编辑
|
| | | var btnTile = new NormalViewControl(800, 60, true);
|
| | | btnTile.X = ControlCommonResourse.XXLeft;
|
| | | btnTile.X = HdlControlResourse.XXLeft;
|
| | | btnTile.TextSize = 15;
|
| | | btnTile.TextColor = UserCenterColor.Current.TextColor2;
|
| | | btnTile.TextID = R.MyInternationalizationString.uDeviceEditor;
|
| | |
| | | detailBackFrame.AddChidren(btnFinish);
|
| | | btnFinish.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | //更改过一次之后,则界面关闭后不再更改
|
| | | this.saveDefultName = string.Empty;
|
| | | //改名字
|
| | | btnNote.txtInput.FinishInputEvent();
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | };
|
| | |
| | | /// </summary>
|
| | | /// <param name="i_deviceName">deviceName.</param>
|
| | | /// <param name="mode">是否显示错误</param>
|
| | | private async void DeviceReName(string i_deviceName, ShowErrorMode mode = ShowErrorMode.YES)
|
| | | private 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);
|
| | | var result = HdlDeviceCommonLogic.Current.ReMacName(this.listNewDevice, deviceName, mode);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | |
| | | /// <summary>
|
| | | /// 设置全部回路的默认名字
|
| | | /// </summary>
|
| | | private async void SetAllEpointName()
|
| | | private void SetAllEpointName()
|
| | | {
|
| | | foreach (var device in this.listNewDevice)
|
| | | {
|
| | | if ((device is OTADevice) || Common.LocalDevice.Current.GetSimpleEpointName(device) != string.Empty)
|
| | | if ((device is OTADevice) || HdlDeviceCommonLogic.Current.GetSimpleEpointName(device) != string.Empty)
|
| | | {
|
| | | //有名字不处理
|
| | | continue;
|
| | | }
|
| | | //获取端点名字
|
| | | var epointName = Common.LocalDevice.Current.GetDeviceEpointName(device);
|
| | | await Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO);
|
| | | var epointName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
|
| | | HdlDeviceCommonLogic.Current.ReName(device, epointName, ShowErrorMode.NO);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置网关所在的时区的时间给门锁时间
|
| | | /// </summary>
|
| | | private async void SetDoorTime()
|
| | | {
|
| | | //如果是门锁
|
| | | if (this.listNewDevice[0].Type == DeviceType.DoorLock)
|
| | | {
|
| | | var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
|
| | | //1、入网后先获取门锁在网关中的时区时间
|
| | | var curDateTime = DoorLock.DoorLockCommonInfo.GetDoorLockZoneTime();
|
| | | //2、将时间设置到网关中
|
| | | var dateTime = new DateTime(curDateTime.Year, curDateTime.Month, curDateTime.Day, curDateTime.Hour, curDateTime.Minute, curDateTime.Second);
|
| | | var setTimestamp = DoorLock.DoorLockCommonInfo.GetUnixTimeStamp(dateTime);
|
| | | await doorLock.RectifyDoorLockTimeAsync(int.Parse(setTimestamp));
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 新入网的设备,清空掉它的房间
|
| | | /// </summary>
|
| | | private void ClearDeviceFromRoom()
|
| | | {
|
| | | foreach (var device in this.listNewDevice)
|
| | | {
|
| | | HdlRoomLogic.Current.DeleteDevice(device);
|
| | | HdlRoomLogic.Current.DeleteLoveDevice(device);
|
| | | }
|
| | | HdlRoomLogic.Current.DeleteRealDeviceFromRoom(this.listNewDevice[0]);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 画面关闭___________________________
|