黄学彪
2019-12-05 b3e96fce4cc01113128ddf8e0a18fc19594a9e56
ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
@@ -29,7 +29,7 @@
        /// <summary>
        /// backGround
        /// </summary>
        private Button backGround;
        private ImageView backGround;
        /// <summary>
        /// IconPathType
        /// </summary>
@@ -60,7 +60,7 @@
            room = r;
            IconPathType = r.BackgroundImageType;
            OldIconPathType= r.BackgroundImageType;
            if (IconPathType != 1)
            if (IconPathType != 0)
            {
                OldBackgroundImagePath = r.BackgroundImage;
            }
@@ -109,17 +109,21 @@
            };
            AddChidren(bodyFrameLayout);
            backGround = new Button()
            backGround = new ImageView()
            {
                Y = Application.GetRealHeight(60),
                Width = Application.GetMinRealAverage(887),
                Height = Application.GetMinRealAverage(444),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetRealHeight(CommonFormResouce.BigFormRadius),
                UnSelectedImagePath = room.BackgroundImage
                ImagePath = room.BackgroundImageType == 0 ? room.BackgroundImage : System.IO.Path.Combine(Config.Instance.FullPath, room.BackgroundImage)
            };
            bodyFrameLayout.AddChidren(backGround);
            backGround.SetViewShadow(true);
            if (room.BackgroundImageType != 0)
            {
                backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(backGround.ImagePath);
            }
            backGround.MouseUpEventHandler += backGroundIMGHander;
            var infoFL = new FrameLayout
@@ -150,6 +154,10 @@
            nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.RoomName)} :");
            nameRow.SetTitle(room.Name);
            infoFL.AddChidren(nameRow);
            if(room.IsLove)
            {
                nameRow.NameText.Enable = false;
            }
            var floorRow = new DeviceInfoRow(308);
            floorRow.Init();
@@ -391,18 +399,18 @@
                var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
                var fileName = $"RoomIcon_{tradeTime}.png";
                room.Name = nameRow.NameText.Text.Trim();
                if (OldIconPathType != 1)
                if (OldIconPathType != 0)
                {
                    Shared.IO.FileUtils.DeleteFile(OldBackgroundImagePath);
                    Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath,OldBackgroundImagePath));
                }
                if (IconPathType == 0)
                {
                    room.BackgroundImage = backGround.UnSelectedImagePath;
                    room.BackgroundImage = backGround.ImagePath;
                }
                else
                {
                    Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes);
                    room.BackgroundImage = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
                    room.BackgroundImage = fileName;
                }
                room.BackgroundImageType = IconPathType;
                room.Save();
@@ -509,7 +517,7 @@
                {
                    IconPathType = 0;
                    backGround.ImageBytes = null;
                    backGround.UnSelectedImagePath = imgPath;
                    backGround.ImagePath = imgPath;
                };
            };
            selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
@@ -522,12 +530,12 @@
                {
                    if (IconPathType != 0)
                    {
                        Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
                        Global.DeleteFilebyHomeId(backGround.ImagePath);
                    }
                    IconPathType = 1;
                    backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
                    backGround.UnSelectedImagePath = imagePath;
                    backGround.ImagePath = imagePath;
                    System.IO.File.Delete(imagePath);
                }, fileName, 2, 1);
@@ -543,12 +551,12 @@
                {
                    if (IconPathType != 0)
                    {
                        Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
                        Global.DeleteFilebyHomeId(backGround.ImagePath);
                    }
                    IconPathType = 2;
                    backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
                    backGround.UnSelectedImagePath = imagePath;
                    backGround.ImagePath = imagePath;
                    System.IO.File.Delete(imagePath);
                }, fileName, 2, 1);