From b3e96fce4cc01113128ddf8e0a18fc19594a9e56 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 05 十二月 2019 18:38:30 +0800 Subject: [PATCH] 一个新的版本 --- ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs | 91 ++++++++++++++++++++++----------------------- 1 files changed, 44 insertions(+), 47 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs index 9763cd1..9781c78 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/CategoryAddScene.cs @@ -59,7 +59,7 @@ /// <summary> /// backGround /// </summary> - private Button backGround; + private ImageView backGround; /// <summary> /// 鏄惁淇敼 @@ -78,6 +78,14 @@ /// </summary> public Common.Room modifyRoom; + /// <summary> + /// OldBackgroundImagePath + /// </summary> + private string OldBackgroundImagePath; + /// <summary> + /// OldIconPathType + /// </summary> + public int OldIconPathType; #endregion @@ -178,7 +186,6 @@ //璁惧璇︾粏璁剧疆鐣岄潰 void detailMouseUpEventHandler(object sender, MouseEventArgs e) { - //璁惧 if (targetDevice.Type == 0) { if (targetDevice.DeviceUI == null || targetDevice.DeviceUI.CommonDevice == null) @@ -204,7 +211,6 @@ }; } - //鏃堕棿闂撮殧 else if (targetDevice.Type == 2) { var delayTimeView = new SelectDelayTime(); @@ -223,7 +229,6 @@ RefreshTargetListView(); }; } - //鍦烘櫙 else if (targetDevice.Type == 1) { var sceneView = new SelectScene(); @@ -270,16 +275,7 @@ /// </summary> private void Init() { - //foreach (var floor in Config.Instance.Home.FloorDics) - //{ - // floorIds.Add(floor.Key); - // floorNames.Add(floor.Value); - // if(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key).Count>0) - // { - // roomNames.Add(Common.Room.CurrentRoom.GetRoomNamesByFloorId(floor.Key)); - // rooms.Add(Common.Room.CurrentRoom.GetRoomsByFloorId(floor.Key)); - // } - //} + } /// <summary> @@ -324,14 +320,13 @@ }; bodyFrameLayout.AddChidren(imgFL); - backGround = new Button() + backGround = new ImageView() { Width = Application.GetMinRealAverage(930), Height = Application.GetMinRealAverage(464), Gravity = Gravity.Center, Radius = (uint)Application.GetMinRealAverage(CommonFormResouce.BigFormRadius), - //UnSelectedImagePath = ImagePath - UnSelectedImagePath = "SceneIcon/3.jpg" + ImagePath = "SceneIcon/3.jpg" }; imgFL.AddChidren(backGround); backGround.SetViewShadow(true); @@ -421,12 +416,10 @@ }; addTargetFL.AddChidren(targetLine); - //娣诲姞鐩爣鍚庣殑灞曠ず鍒楄〃 TargetListScrolView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(49+127), Height = Application.GetRealHeight(730-127-49), - //BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor }; targetFL.AddChidren(TargetListScrolView); @@ -435,10 +428,22 @@ if(isModify) { - backGround.UnSelectedImagePath = modifySceneUI.IconPath; + IconPathType = modifySceneUI.IconPathType; + OldIconPathType = modifySceneUI.IconPathType; + if (IconPathType != 0) + { + OldBackgroundImagePath = modifySceneUI.IconPath; + } + if (modifySceneUI.IconPathType==0) + { + backGround.ImagePath = modifySceneUI.IconPath; + } + else + { + backGround.ImagePath = System.IO.Path.Combine(Config.Instance.FullPath, modifySceneUI.IconPath); + } nameRow.SetTitle(modifySceneUI.Name); zoneRow.SetTitle($"{Config.Instance.Home.GetFloorNameById(modifyRoom.FloorId)},{modifyRoom.Name}"); - IconPathType = modifySceneUI.IconPathType; curRoom = modifyRoom; sceneTargetDevicesList.AddRange(modifySceneTargetDevicesList); } @@ -447,7 +452,6 @@ #region event - //閫夋嫨鑳屾櫙鍥� EventHandler<MouseEventArgs> backGroundIMGHander = (sender, e) => { if (curRoom != null && curRoom.IsSharedRoom) @@ -540,14 +544,14 @@ { IconPathType = 0; backGround.ImageBytes = null; - backGround.UnSelectedImagePath = imgPath; + backGround.ImagePath = imgPath; }; }; selectPhotographBtn.MouseUpEventHandler += (send, ee) => { selectFL.RemoveFromParent(); var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - var fileName = $"Scene_{tradeTime}"; + var fileName = $"SceneIcon_{tradeTime}"; //閫氳繃鐩告満鎷嶇収瑁佸壀 CropImage.TakePicture((imagePath) => { @@ -555,13 +559,13 @@ { 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); @@ -571,7 +575,7 @@ { selectFL.RemoveFromParent(); var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - var fileName = $"Scene_{tradeTime}"; + var fileName = $"SceneIcon_{tradeTime}"; //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀 CropImage.SelectPicture((imagePath) => { @@ -579,13 +583,13 @@ { 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); @@ -832,44 +836,42 @@ try { var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); - var fileName = $"Scene_{tradeTime}"; - //鏀瑰悕 + var fileName = $"SceneIcon_{tradeTime}"; if (modifySceneUI.Name != nameRow.NameText.Text.Trim()) { if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) { - Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); + CommonFormResouce.ShowTip(Language.StringByID(R.MyInternationalizationString.TheSceneHadExist)); return; } - //淇敼鍚嶅瓧 var r = await ZigBee.Device.Scene.RenameSceneAsync(modifySceneUI.Id, nameRow.NameText.Text.Trim()); var reName = r.sceneRenameResponseData.Result; if (reName == 0) { - //澶辫触 return; } else if (reName == 1) { - //鎴愬姛 modifySceneUI.Name = nameRow.NameText.Text.Trim(); } else if (reName == 2) { - //娌℃湁璇ュ満鏅� return; } } - //鍥剧墖 - if(IconPathType==1 || IconPathType ==2) + if (OldIconPathType != 0) + { + Shared.IO.FileUtils.DeleteFile(System.IO.Path.Combine(Config.Instance.FullPath, OldBackgroundImagePath)); + } + if (IconPathType == 1 || IconPathType == 2) { Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); - modifySceneUI.IconPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + modifySceneUI.IconPath = fileName; } else { - modifySceneUI.IconPath = backGround.UnSelectedImagePath; + modifySceneUI.IconPath = backGround.ImagePath; } modifySceneUI.IconPathType = IconPathType; @@ -982,12 +984,10 @@ } else if (result == 0) { - //澶辫触 Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain); } else if (result == -1) { - //宸插瓨鍦� Common.CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); } } @@ -1020,15 +1020,14 @@ var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo); var fileName = $"SceneIcon_{tradeTime}.png"; string imgPath; - //鍥剧墖 if (IconPathType == 1 || IconPathType == 2) { Shared.IO.FileUtils.WriteFileByBytes(System.IO.Path.Combine(Config.Instance.FullPath, fileName), backGround.ImageBytes); - imgPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName); + imgPath = fileName; } else { - imgPath = backGround.UnSelectedImagePath; + imgPath = backGround.ImagePath; } if (Common.Room.CurrentRoom.GetSameFloorScenes(curRoom.FloorId).Find(s => s.Name == nameRow.NameText.Text.Trim()) != null) { @@ -1091,12 +1090,10 @@ } else if (result == 0) { - //澶辫触 CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.AddSceneFail); } else if (result == -1) { - //宸插瓨鍦� CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.TheSceneHadExist); } } -- Gitblit v1.8.0