黄学彪
2019-12-31 737c036a39176fd2085ce82b7c60391da8cb508c
ZigbeeApp/Shared/Common/Room.cs
@@ -336,6 +336,19 @@
                }
            }
            Config.Instance.Home.InitFloor();
            RefreshRoomListView();
        }
        /// <summary>
        /// 刷新房间视图列表
        /// </summary>
        public static void RefreshRoomListView()
        {
            Application.RunOnMainThread(() =>
            {
                Phone.Device.Room.RoomManagement.Instance.Show();
            });
        }
        /// <summary>
@@ -445,8 +458,33 @@
            //删除来自拍照或者系统图库的房间背景图片
            if (room.BackgroundImageType == 1 || room.BackgroundImageType == 2)
            {
                DeleteBackGroundIamageFilebyHomeId(room.BackgroundImage);
                //删除掉原来的自定义图片
                if (Global.IsExistsByHomeId(room.BackgroundImage) == true)
                {
                    Global.DeleteFilebyHomeId(room.BackgroundImage);
                    //删除备份
                    HdlAutoBackupLogic.DeleteFile(room.BackgroundImage);
                }
            }
            //我的喜爱
            var loveRoom = this.GetLoveRoom();
            if (loveRoom != null)
            {
                //移除我的喜爱里面的设备
                for (int i = 0; i < room.DeviceUIFilePathList.Count; i++)
                {
                    loveRoom.DeviceUIFilePathList.Remove(room.DeviceUIFilePathList[i]);
                    loveRoom.DeviceUIList.RemoveAll((obj) => { return room.DeviceUIFilePathList[i] == obj.FileName; });
                }
                //移除我的喜爱里面的场景
                for (int i = 0; i < room.SceneUIFilePathList.Count; i++)
                {
                    loveRoom.SceneUIFilePathList.Remove(room.SceneUIFilePathList[i]);
                    loveRoom.SceneUIList.RemoveAll((obj) => { return room.SceneUIFilePathList[i] == obj.FileName; });
                }
                loveRoom.Save(false);
            }
            if (Global.IsExistsByHomeId(roomFilePath) == false)
            {
                return false;
@@ -770,31 +808,6 @@
        #endregion
        #region ◆ 房间背景图的相关___________________
        /// <summary>
        /// 删除背景图片
        /// </summary>
        /// <param name="fileName">fileName实际上包含了住宅路劲 如 住宅/文件名.</param>
        public static void DeleteBackGroundIamageFilebyHomeId(string fileName)
        {
            if (fileName == null)
            {
                return;
            }
            var pathLists = fileName.Split('/');
            if (pathLists == null || pathLists.Count() < 9 || pathLists[8] == null)
            {
                return;
            }
            var path = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
            if (!Global.IsExistsByHomeId(pathLists[8]))
            {
                return;
            }
            //删除本地图片
            System.IO.File.Delete(path);
            //删除备份
            Phone.UserCenter.HdlAutoBackupLogic.DeleteFile(pathLists[8]);
        }
        /// <summary>
        /// 移动背景图片到住宅目录下
@@ -930,6 +943,31 @@
            this.DeleteDevice(device);
        }
        /// <summary>
        /// 删除我的喜爱的设备
        /// </summary>
        /// <param name="device">要删除的设备对象</param>
        public void DeleteLoveDevice(CommonDevice device)
        {
            if (device == null)
            {
                return;
            }
            //我的喜爱
            var loveRoom = this.GetLoveRoom();
            if (loveRoom != null)
            {
                string deviceFile = device.FilePath;
                //移除缓存
                if (loveRoom.DeviceUIFilePathList.Contains(deviceFile) == false)
                {
                    return;
                }
                loveRoom.DeviceUIFilePathList.Remove(deviceFile);
                loveRoom.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile);
            }
        }
        #endregion
        #region ◆ 获取设备_________________________