From 30b5770f56f99c1f92e933ad31cf7d2af58b033c Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 02 十二月 2020 16:31:48 +0800 Subject: [PATCH] 20201202 --- HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs | 152 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 117 insertions(+), 35 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs index 93308e5..6232997 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs @@ -29,7 +29,7 @@ { if (btnOption.TextID == StringId.Save) { - if (string.IsNullOrEmpty(room.name)) + if (string.IsNullOrEmpty(room.roomName)) { new Tip() { @@ -39,7 +39,7 @@ }.Show(bodyView); return; } - if(string.IsNullOrEmpty( room.floorName)) + if (string.IsNullOrEmpty(room.floorName)) { new Tip() { @@ -49,15 +49,15 @@ }.Show(bodyView); return; } - foreach (var tempRoom in DB_ResidenceData.rooms) + foreach (var tempRoom in DB_ResidenceData.Rooms) { - if (room.name == tempRoom.name) + if (room.roomName == tempRoom.roomName) { new PublicAssmebly().TipMsg(StringId.Tip, StringId.AddingFailed_RoomAlreadyExists); return; } } - DB_ResidenceData.rooms.Add(room); + DB_ResidenceData.residenceData.AddRoom(room); room.SaveRoomData(); backAction(); this.RemoveFromParent(); @@ -68,12 +68,12 @@ { foreach (var f in DB_ResidenceData.functionList.GetAllFunction()) { - if (f.roomIds.Contains(room.sid)) + if (f.roomIds.Contains(room.uid)) { - f.roomIds.Remove(room.sid); + f.roomIds.Remove(room.uid); } } - DB_ResidenceData.DelRoom(room); + DB_ResidenceData.residenceData.DelRoom(room); backAction(); this.RemoveFromParent(); }; @@ -112,7 +112,7 @@ return; } btnRoomName.Text = str; - room.name = str; + room.roomName = str; if (pageTitleId == StringId.EditRoomInfo) { room.SaveRoomData(); @@ -121,17 +121,17 @@ EventHandler<MouseEventArgs> eventHandler = (sender, e) => { List<string> roomNameList = new List<string>(); - foreach (var rroom in DB_ResidenceData.rooms) + foreach (var rroom in DB_ResidenceData.Rooms) { - roomNameList.Add(rroom.name); + roomNameList.Add(rroom.roomName); } if (pageTitleId == StringId.AddRoom) { - new PublicAssmebly().LoadDialog_EditParater(StringId.RoomName, room.name, callBack, StringId.RoomNameCannotBeEmpty, StringId.RoomNameAlreadyExists, roomNameList); + new PublicAssmebly().LoadDialog_EditParater(StringId.RoomName, room.roomName, callBack, StringId.RoomNameCannotBeEmpty, StringId.RoomNameAlreadyExists, roomNameList); } else { - new PublicAssmebly().LoadDialog_EditParater(StringId.RoomName, room.name, callBack, StringId.RoomNameCannotBeEmpty, StringId.EidtFailed_RoomAlreadyExists, roomNameList); + new PublicAssmebly().LoadDialog_EditParater(StringId.RoomName, room.roomName, callBack, StringId.RoomNameCannotBeEmpty, StringId.EidtFailed_RoomAlreadyExists, roomNameList); } }; btnEditRoomNameIcon.MouseUpEventHandler = eventHandler; @@ -222,51 +222,133 @@ { baseView.RemoveFromParent(); }; - btnTakePicture.MouseDownEventHandler = (sender, e) => { + btnTakePicture.MouseDownEventHandler = (sender, e) => + { btnTakePicture.IsSelected = true; }; + //鎷嶇収 btnTakePicture.MouseUpEventHandler = (sender, e) => { btnTakePicture.IsSelected = false; - var pid = Guid.NewGuid(); + //var pid = Guid.NewGuid(); + //CropImage.TakePicture((imagePath) => + //{ + // if (imagePath != null) + // { + // btnRoomBg.ImagePath = imagePath.ToString(); + // room.backgroundImage = btnRoomBg.ImagePath; + // MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath); + // } + //}, pid.ToString(), 16, 9); + + //var imageName = Guid.NewGuid().ToString(); + var imageName = room.uid; CropImage.TakePicture((imagePath) => { - if (imagePath != null) - { - btnRoomBg.ImagePath = imagePath.ToString(); - room.backgroundImage = btnRoomBg.ImagePath; - MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath); - } - }, pid.ToString(), 16, 9); - if (pageTitleId == StringId.EditRoomInfo) - { - room.SaveRoomData(); - } + CropImageCallBack(imagePath, imageName); + + }, imageName, 16, 9); + baseView.RemoveFromParent(); }; - btnAlbum.MouseDownEventHandler = (sender, e) => { + //閫夋嫨鐓х墖 + btnAlbum.MouseDownEventHandler = (sender, e) => + { btnAlbum.IsSelected = true; }; btnAlbum.MouseUpEventHandler = (sender, e) => { btnAlbum.IsSelected = false; - var pid = Guid.NewGuid(); + //var pid = Guid.NewGuid(); + //CropImage.SelectPicture((imagePath) => + //{ + // if (imagePath != null) + // { + // btnRoomBg.ImagePath = imagePath.ToString(); + // room.backgroundImage = btnRoomBg.ImagePath; + // MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath); + // } + //}, pid.ToString(), 16, 9); + + //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀 + //var imageName = Guid.NewGuid().ToString(); + var imageName = room.uid; CropImage.SelectPicture((imagePath) => { - if (imagePath != null) + CropImageCallBack(imagePath, imageName); + + }, imageName, 16, 9); + + baseView.RemoveFromParent(); + + }; + + //鎴块棿榛樿鍥惧簱 + btnDefaultGallery.MouseUpEventHandler = (sender, e) => { + pictureOptionView.Parent.RemoveFromParent(); + Action<string> action = (obj) => { + room.backgroundImage = obj; + btnRoomBg.ImagePath = room.backgroundImage; + if (pageTitleId == StringId.EditRoomInfo) { - btnRoomBg.ImagePath = imagePath.ToString(); - room.backgroundImage = btnRoomBg.ImagePath; - MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath); + room.SaveRoomData(); } - }, pid.ToString(), 16, 9); + }; + + var galleryPage = new RoomGalleryPage(room.backgroundImage, action); + MainPage.BasePageView.AddChidren(galleryPage); + galleryPage.LoadPage(true); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + + }; + } + + /// <summary> + /// 瑁佸壀瀹岀収鐗囧洖璋冿紝缁熶竴澶勭悊 + /// </summary> + /// <param name="imagePath">瑁佸壀鍚庣殑鐪熷疄璺緞</param> + /// <param name="imageName">鑷畾涔夌殑鍥剧墖鍚嶇О</param> + void CropImageCallBack(string imagePath, string imageName) + { + if (string.IsNullOrEmpty(imagePath) == true) + { + return; + } + try + { + var mPath = imagePath; + MainPage.Log("SelectPicture 瑁佸壀鍥剧墖杩斿洖璺緞: " + imagePath); +#if __IOS__ + + +#else + //imageName = imageName + ".png"; + + //1.浣跨敤鏂板悕瀛楋紝瑙e喅鐩稿悓璺緞涓嶅埛鏂板浘鐗囬棶棰� + imageName = Guid.NewGuid().ToString() + ".png"; + //1.2濡傛灉鏄嚜瀹氫箟鍥剧墖鍒犻櫎涔嬪墠鐨� + if (!btnRoomBg.ImagePath.Contains("Room")) { + Utlis.WriteLine("鍒犻櫎: " + btnRoomBg.ImagePath); + System.IO.File.Delete(btnRoomBg.ImagePath); + } + //1.3濡傛灉鏄畨鍗撻渶瑕佹嫹璐濆洖鏉PP鏍圭洰褰� + FileUtils.FileCopyToRootPath(imagePath, imageName); + System.IO.File.Delete(imagePath); + mPath = imageName; +#endif + //娓呯┖鍘熸潵鍥剧墖 + btnRoomBg.ImagePath = "NULL"; + //鐢熸垚鍥剧墖 + room.backgroundImage = mPath; + btnRoomBg.ImagePath = mPath; + if (pageTitleId == StringId.EditRoomInfo) { room.SaveRoomData(); } - baseView.RemoveFromParent(); - }; + } + catch { } } } } \ No newline at end of file -- Gitblit v1.8.0