黄学彪
2020-04-02 9904031f5291daaf56985146bb671f25e18ebbdf
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceAddSuccessForm.cs
@@ -35,6 +35,11 @@
        public void ShowForm(string deviceMac)
        {
            this.listNewDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
            if (listNewDevice.Count == 0)
            {
                //对应单纯只有200回路的设备
                listNewDevice.Add(Common.LocalDevice.Current.GetOTADevice(deviceMac));
            }
            //设置标题信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddDevice));
@@ -116,30 +121,43 @@
            //划线
            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)
                {
                    var room = Common.Room.CurrentRoom.GetRoomByDevice(device);
                    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);
                    if (room == null)
                    {
                        //这里有点特殊,如果回路没有设置有区域的时候,才设置
                        listCheck.Add(mainKeys);
                        Common.Room.CurrentRoom.ChangedRoom(device, roomKeys);
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                    else if (listCheck.Contains(mainKeys) == true)
                    {
                        //如果这个回路之前都还没有区域,在本界面还没有关闭之前,可以无条件随便变更
                        Common.Room.CurrentRoom.ChangedRoom(device, roomKeys);
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                }
                //保存设备房间索引
@@ -233,17 +251,6 @@
            }
            //更改过一次之后,则界面关闭后不再更改
            this.saveDefultName = string.Empty;
            //如果它的回路只有一个的话,则在设备上报的时候,修改MAC名字之后,连同端点名字也一起修改
            if (this.listNewDevice.Count == 1)
            {
                //修改端点名字
                result = await Common.LocalDevice.Current.ReName(this.listNewDevice[0], deviceName, mode);
                if (result == false)
                {
                    return;
                }
            }
        }
        /// <summary>
@@ -253,7 +260,7 @@
        {
            foreach (var device in this.listNewDevice)
            {
                if (Common.LocalDevice.Current.GetSimpleEpointName(device) != string.Empty)
                if ((device is OTADevice) || Common.LocalDevice.Current.GetSimpleEpointName(device) != string.Empty)
                {
                    //有名字不处理
                    continue;