From 16604a593202f2f87adf71abd57d036fe7da3b52 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 18 十一月 2019 10:39:42 +0800
Subject: [PATCH] 同步了全部的代码

---
 ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs |  257 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 208 insertions(+), 49 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
index 4ff8617..a9e7def 100755
--- a/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Room/EditRoom.cs
@@ -1,5 +1,6 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Globalization;
 using Shared.Common;
 using Shared.Phone.Device.CommonForm;
 using Shared.Phone.UserCenter;
@@ -18,12 +19,21 @@
         /// <summary>
         /// The room.
         /// </summary>
-        public  Shared.Common.Room room;
+        public Shared.Common.Room room;
 
         /// <summary>
         /// The action.
         /// </summary>
         public Action action;
+
+        /// <summary>
+        /// backGround
+        /// </summary>
+        private Button backGround;
+        /// <summary>
+        /// IconPathType
+        /// </summary>
+        public int IconPathType = 0;
 
         #endregion
 
@@ -38,7 +48,7 @@
         public void Show(Shared.Common.Room r)
         {
             room = r;
-
+            IconPathType = r.BackgroundImageType;
             AddTop();
 
             AddBodyView();
@@ -83,17 +93,17 @@
             };
             AddChidren(bodyFrameLayout);
 
-            var imgFL = new FrameLayout
+            var imgFL = new Button
             {
-                Y=Application.GetRealHeight(60),
-                Width=Application.GetMinRealAverage(916),
-                Height = Application.GetMinRealAverage(478),
-                Gravity=Gravity.CenterHorizontal,
-                BackgroundImagePath= "Room/Room_Rectangle.png"
+                Y = Application.GetRealHeight(60),
+                Width = Application.GetMinRealAverage(916),
+                Height = Application.GetMinRealAverage(487),
+                Gravity = Gravity.CenterHorizontal,
+                UnSelectedImagePath = "Room/Room_Rectangle.png"
             };
             bodyFrameLayout.AddChidren(imgFL);
 
-            var backGround = new Button()
+            backGround = new Button()
             {
                 Y = Application.GetRealHeight(60),
                 Width = Application.GetMinRealAverage(887),
@@ -103,6 +113,7 @@
                 UnSelectedImagePath = room.BackgroundImage
             };
             bodyFrameLayout.AddChidren(backGround);
+            backGround.MouseUpEventHandler += backGroundIMGHander;
 
             var infoFL = new FrameLayout
             {
@@ -115,7 +126,7 @@
             var infoEdit = new Button
             {
                 X = Application.GetRealWidth(CommonFormResouce.X_Left),
-                Y=Application.GetRealHeight(80),
+                Y = Application.GetRealHeight(80),
                 Height = Application.GetRealHeight(60),
                 Width = Application.GetRealWidth(700),
                 TextID = R.MyInternationalizationString.EditInfo,
@@ -134,29 +145,31 @@
             var floorRow = new DeviceInfoRow(308);
             floorRow.Init();
             floorRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongFloor)} :");
-            floorRow.SetTitle(room.FloorName);
             infoFL.AddChidren(floorRow);
-            floorRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
+            if (!room.IsLove)
             {
-                if (Config.Instance.Home.FloorDics != null)
+                floorRow.SetTitle(room.FloorName);
+                floorRow.ClickBtn.MouseUpEventHandler += (sender, e) =>
                 {
-                    List<string> floorIds = new List<string> { };
-                    List<string> floorNames = new List<string> { };
-                    foreach (var floor in Config.Instance.Home.FloorDics)
+                    if (Config.Instance.Home.FloorDics != null)
                     {
-                        floorIds.Add(floor.Key);
-                        floorNames.Add(floor.Value);
+                        List<string> floorIds = new List<string> { };
+                        List<string> floorNames = new List<string> { };
+                        foreach (var floor in Config.Instance.Home.FloorDics)
+                        {
+                            floorIds.Add(floor.Key);
+                            floorNames.Add(floor.Value);
+                        }
+
+                        PickerView.Show(floorNames, (index) =>
+                        {
+                            room.FloorId = floorIds[index];
+                            floorRow.SetTitle(room.FloorName);
+                        }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
                     }
-
-                    PickerView.Show(floorNames, (index) =>
-                     {
-                         room.FloorId = floorIds[index];
-                         floorRow.SetTitle(room.FloorName);
-                     }, floorIds.IndexOf(room.FloorId), Language.StringByID(R.MyInternationalizationString.BelongFloor), Language.StringByID(R.MyInternationalizationString.Confrim), Language.StringByID(R.MyInternationalizationString.Cancel));
-                }
-            };
-
-
+                };
+            }
+            
             var temperatureRow = new DeviceInfoRow(446);
             temperatureRow.Init();
             temperatureRow.SetTipTitle(R.MyInternationalizationString.Temperature);
@@ -172,12 +185,12 @@
                 tem.Show(room);
                 tem.selectDeviceAction = (selectTemp) =>
                 {
-                    if(selectTemp==null)
+                    if (selectTemp == null)
                     {
                         return;
                     }
-                    room.TemperatrueDevice =$"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
-                    
+                    room.TemperatrueDevice = $"{selectTemp.DeviceAddr}{selectTemp.DeviceEpoint}";
+
                     HdlDeviceAttributeLogic.Current.RemoveEvent("TemperatrueDevice");
                     HdlDeviceAttributeLogic.Current.AddAttributeEvent("TemperatrueDevice", "DeviceStatusReport", (Action<ZigBee.Device.CommonDevice>)((report) =>
                     {
@@ -361,34 +374,180 @@
                 }
             }
 
-            var shareRow = new DeviceInfoRow(723);
-            shareRow.Init();
-            shareRow.SetTipTitle(R.MyInternationalizationString.Share);
-            shareRow.SetTitle("2 浜�");
-            shareRow.NameText.TextAlignment = TextAlignment.CenterRight;
-            infoFL.AddChidren(shareRow);
-            shareRow.NextBtn.MouseUpEventHandler += (sender, e) =>
-            {
-                var tem = new RoomShareSetting { };
-                HomePage.Instance.AddChidren(tem);
-                HomePage.Instance.PageIndex += 1;
-                tem.Show(room);
-                tem.action = (selectTemp) =>
-                {
-
-                };
-            };
-
 
             var confirm = new Device.CommonForm.CompleteButton(1700, 700, 127);
             confirm.SetTitle(R.MyInternationalizationString.Confrim);
             AddChidren(confirm);
             confirm.MouseUpEventHandler += (sender, e) =>
             {
+                var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+                var fileName = $"Room_{tradeTime}";
                 room.Name = nameRow.NameText.Text.Trim();
+                if (IconPathType == 0)
+                {
+                    room.BackgroundImage = backGround.UnSelectedImagePath;
+                }
+                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.BackgroundImageType = IconPathType;
                 room.Save();
                 RemoveFromParent();
             };
+
+        }
+
+        /// <summary>
+        /// 閫夋嫨鑳屾櫙鍥�
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void backGroundIMGHander(object sender, MouseEventArgs e)
+        {
+            if (room != null && room.IsSharedRoom)
+            {
+                RoomCommon.ShowTipRoomIsShared();
+                return;
+            }
+
+            int selectRow_Height = 150;
+            int selectRow_Width = 1034;
+            var selectFL = new FrameLayout()
+            {
+                BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
+            };
+            AddChidren(selectFL);
+
+            var itemFL = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(1276),
+                Height = Application.GetRealHeight(450),
+                Width = Application.GetRealWidth(selectRow_Width),
+                Gravity = Gravity.CenterHorizontal,
+                Radius = (uint)Application.GetRealHeight(17),
+                BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor
+            };
+            selectFL.AddChidren(itemFL);
+            itemFL.Animate = Animate.DownToUp;
+
+            var selectLocalPicture = new Button()
+            {
+                Height = Application.GetRealHeight(selectRow_Height) - 1,
+                TextID = R.MyInternationalizationString.LocalPicture,
+                TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+            };
+            itemFL.AddChidren(selectLocalPicture);
+            var selectLocalLine = new Button()
+            {
+                Y = selectLocalPicture.Bottom,
+                Height = 1,
+                BackgroundColor = ZigbeeColor.Current.GXCLineColor
+            };
+            itemFL.AddChidren(selectLocalLine);
+
+            var selectPhotographBtn = new Button()
+            {
+                Y = selectLocalLine.Bottom,
+                Height = Application.GetRealHeight(selectRow_Height) - 1,
+                TextID = R.MyInternationalizationString.Photograph,
+                TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+            };
+            itemFL.AddChidren(selectPhotographBtn);
+            var selectPhotographLine = new Button()
+            {
+                Y = selectPhotographBtn.Bottom,
+                Height = 1,
+                BackgroundColor = ZigbeeColor.Current.GXCLineColor,
+            };
+            itemFL.AddChidren(selectPhotographLine);
+
+            var selectAblumsBtn = new Button()
+            {
+                Y = selectPhotographLine.Bottom,
+                Height = Application.GetRealHeight(selectRow_Height) - 1,
+                TextID = R.MyInternationalizationString.MyAblums,
+                TextColor = ZigbeeColor.Current.GXCTextSelectedColor4
+            };
+            itemFL.AddChidren(selectAblumsBtn);
+
+            var cancelBtn = new Button()
+            {
+                Y = Application.GetRealHeight(1742),
+                Height = Application.GetRealHeight(selectRow_Height),
+                Width = Application.GetRealWidth(selectRow_Width),
+                Gravity = Gravity.CenterHorizontal,
+                TextID = R.MyInternationalizationString.Cancel,
+                TextColor = ZigbeeColor.Current.GXCTextSelectedColor4,
+                BackgroundColor = ZigbeeColor.Current.GXCTextWhiteColor,
+                Radius = (uint)Application.GetRealHeight(17)
+            };
+            selectFL.AddChidren(cancelBtn);
+
+            selectLocalPicture.MouseUpEventHandler += (send, ee) =>
+            {
+                selectFL.RemoveFromParent();
+                var localPic = new AddRoomSelectPicByLocal();
+                Shared.Phone.UserView.HomePage.Instance.AddChidren(localPic);
+                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
+                localPic.Show();
+                localPic.action = (imgPath) =>
+                {
+                    IconPathType = 0;
+                    backGround.UnSelectedImagePath = imgPath;
+                };
+            };
+            selectPhotographBtn.MouseUpEventHandler += (send, ee) =>
+            {
+                selectFL.RemoveFromParent();
+                var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+                var fileName = $"Room_{tradeTime}";
+                //閫氳繃鐩告満鎷嶇収瑁佸壀
+                CropImage.TakePicture((imagePath) =>
+                {
+                    if (IconPathType != 0)
+                    {
+                        Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
+                    }
+
+                    IconPathType = 1;
+                    backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+                    backGround.UnSelectedImagePath = imagePath;
+                    System.IO.File.Delete(imagePath);
+
+                }, fileName, 2, 1);
+            };
+
+            selectAblumsBtn.MouseUpEventHandler += (send, ee) =>
+            {
+                selectFL.RemoveFromParent();
+                var tradeTime = DateTime.Now.ToString("yyyyMMddHHmmss", DateTimeFormatInfo.InvariantInfo);
+                var fileName = $"Room_{tradeTime}";
+                //浠庣浉鍐岄�夋嫨鍥剧墖瑁佸壀
+                CropImage.SelectPicture((imagePath) =>
+                {
+                    if (IconPathType != 0)
+                    {
+                        Global.DeleteFilebyHomeId(backGround.UnSelectedImagePath);
+                    }
+
+                    IconPathType = 2;
+                    backGround.ImageBytes = Shared.IO.FileUtils.ReadFile(imagePath);
+                    backGround.UnSelectedImagePath = imagePath;
+                    System.IO.File.Delete(imagePath);
+
+                }, fileName, 2, 1);
+            };
+
+            cancelBtn.MouseUpEventHandler += (send, ee) =>
+            {
+                selectFL.RemoveFromParent();
+            };
+            selectFL.MouseUpEventHandler += (send, ee) =>
+            {
+                selectFL.RemoveFromParent();
+            };
         }
 
         #endregion

--
Gitblit v1.8.0