WJC
2020-03-17 f6e34a69f1d1e0b0b3a6252fe20acddca7fe56e5
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));
@@ -57,12 +62,32 @@
            //初始化桌布
            this.InitFrameTable();
            var framePic = new FrameLayout();
            framePic.Width = Application.GetRealWidth(855);
            framePic.Height = Application.GetRealHeight(570);
            framePic.Gravity = Gravity.CenterHorizontal;
            framePic.Y = Application.GetRealHeight(58);
            bodyFrameLayout.AddChidren(framePic);
            var imageFile = Common.LocalDevice.Current.GetRealDeviceIcon(listNewDevice);
            string fullName = IO.FileUtils.GetImageFilePath(imageFile);
#if Android
            //设备图片
            var btnpictrue = new PicViewControl(855, 570);
            btnpictrue.Gravity = Gravity.CenterHorizontal;
            btnpictrue.Y = Application.GetRealHeight(58);
            Common.LocalDevice.Current.SetRealDeviceIconToControl(btnpictrue, listNewDevice);
            bodyFrameLayout.AddChidren(btnpictrue);
            var bim = Android.Graphics.BitmapFactory.DecodeFile(fullName);
            var btnpictrue = new PicViewControl(bim.Width, bim.Height);
#endif
#if iOS
            //设备图片
            var bim = UIKit.UIImage.FromFile(fullName);
            var btnpictrue = new PicViewControl((int)bim.Size.Width, (int)bim.Size.Height);
#endif
            bim.Dispose();
            bim = null;
            btnpictrue.Gravity = Gravity.Center;
            btnpictrue.UnSelectedImagePath = imageFile;
            framePic.AddChidren(btnpictrue);
            string nameValue = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
            this.saveDefultName = nameValue;
@@ -108,18 +133,22 @@
            {
                foreach (var device in this.listNewDevice)
                {
                    var room = Common.Room.CurrentRoom.GetRoomByDevice(device);
                    if (device is OTADevice)
                    {
                        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);
                    }
                }
                //保存设备房间索引
@@ -140,7 +169,7 @@
            };
            bodyFrameLayout.AddChidren(btnHelp);
            //底线
            int lineWidth = btnHelp.GetRealWidthByText(12);
            int lineWidth = btnHelp.GetRealWidthByText();
            var btnLine = new NormalViewControl(lineWidth, ControlCommonResourse.BottomLineHeight, false);
            btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
            btnLine.Gravity = Gravity.CenterHorizontal;
@@ -215,7 +244,7 @@
            this.saveDefultName = string.Empty;
            //如果它的回路只有一个的话,则在设备上报的时候,修改MAC名字之后,连同端点名字也一起修改
            if (this.listNewDevice.Count == 1)
            if (this.listNewDevice.Count == 1 && (this.listNewDevice[0] is OTADevice) == false)
            {
                //修改端点名字
                result = await Common.LocalDevice.Current.ReName(this.listNewDevice[0], deviceName, mode);
@@ -231,22 +260,15 @@
        /// </summary>
        private async void SetAllEpointName()
        {
            var tempValue = Common.LocalDevice.Current.GetDeviceObjectText(this.listNewDevice);
            var arry = tempValue.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
            var objName = arry[0].Trim();
            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;
                }
                var epointName = objName;
                if (this.listNewDevice.Count > 1)
                {
                    //XXXXX(N回路)
                    epointName += "(" + device.DeviceEpoint + Language.StringByID(R.MyInternationalizationString.uDeviceCircuit) + ")";
                }
                //获取端点名字
                var epointName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                await Common.LocalDevice.Current.ReName(device, epointName, ShowErrorMode.NO);
            }
        }