From 2ed75b8b337048e5d75e6d9ec8307633134f02fd Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 10 十月 2019 11:33:04 +0800
Subject: [PATCH] 个人中心添加楼层和创建房间,实装二级验证

---
 ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs |  469 ++++++++++++++++++++++++----------------------------------
 1 files changed, 196 insertions(+), 273 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs
index 384e134..51e053c 100755
--- a/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs
+++ b/ZigbeeApp/Shared/Phone/Device/CommonForm/DeviceDetailInfo.cs
@@ -7,333 +7,256 @@
 {
     public class DeviceDetailInfo : FrameLayout
     {
-        public List<string> RoomNameList;
-        public string BelongZoneStr;
+        #region 鈼� 鍙橀噺____________________________
+        /// <summary>
+        /// bodyFrameLayout
+        /// </summary>
+        private FrameLayout bodyFrameLayout;
+        /// <summary>
+        /// 鎵�灞炲尯鍩�
+        /// </summary>
+        private string roomName;
+        /// <summary>
+        /// action
+        /// </summary>
         public Action action;
+
+        #endregion
+
+        #region 鈼� 绉婚櫎____________________________
+        /// <summary>
+        /// RemoveFromParent
+        /// </summary>
         public override void RemoveFromParent()
         {
             action();
             base.RemoveFromParent();
         }
+        #endregion
+
+        #region 鈼� 鏋勯�犳柟娉昣________________________
+        /// <summary>
+        /// DeviceDetailInfo
+        /// </summary>
         public DeviceDetailInfo()
         {
             BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
         }
+
+        #endregion
+
+        #region 鈼� 鏄剧ず鐣岄潰_________________________
+        /// <summary>
+        /// Show
+        /// </summary>
+        /// <param name="device"></param>
+        /// <param name="room"></param>
         public void Show(DeviceUI device, Common.Room room)
         {
-            RoomNameList = new List<string> { };
-            RoomNameList = Common.Room.CurrentRoom.GetRoomListNameByDevice(device.CommonDevice);
-            #region topview
-            var topBGView = new FrameLayout()
-            {
-                Height = Application.GetRealHeight(CommonPage.Navigation_Height),
-                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
-            };
-            AddChidren(topBGView);
-            var topView = new FrameLayout()
-            {
-                Y = Application.GetRealHeight(CommonPage.NavigationTitle_Y),
-                Height = Application.GetRealHeight(CommonPage.Navigation_Height - CommonPage.NavigationTitle_Y),
-                BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor,
-            };
-            AddChidren(topView);
+            Init(device);
 
-            var title = new Button()
-            {
-                TextAlignment = TextAlignment.Center,
-                TextID = R.MyInternationalizationString.ChangeDeviceInfo,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                Width = Application.GetRealWidth(CommonPage.AppRealWidth - 500),
-                Gravity = Gravity.CenterHorizontal
-            };
-            topView.AddChidren(title);
+            AddTop();
 
-            var back = new BackButton() { };
-            topView.AddChidren(back);
-            back.MouseUpEventHandler += (sender, e) =>
-            {
-                this.RemoveFromParent();
-            };
-            #endregion
+            AddBodyView(device);
 
-            #region midFL
-            var midFL = new FrameLayout()
+        }
+
+        #endregion
+
+        #region Add____________________________________
+
+        /// <summary>
+        /// AddTop
+        /// </summary>
+        public void AddTop()
+        {
+            var top = new TopFrameLayout();
+            AddChidren(top);
+            top.InitTopview();
+            top.SetTopTitle(R.MyInternationalizationString.FunctionSetting);
+            top.backButton.MouseUpEventHandler += (sender, e) =>
             {
-                Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
-                Y = topView.Bottom,
+                RemoveFromParent();
+            };
+
+        }
+        /// <summary>
+        /// AddBodyView
+        /// </summary>
+        public void AddBodyView(DeviceUI device)
+        {
+            bodyFrameLayout = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(184),
+                Height = Application.GetRealHeight(1737),
+                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
+            };
+            AddChidren(bodyFrameLayout);
+
+            var deviceBG = new Button()
+            {
+                Y = Application.GetRealHeight(118),
+                Width = Application.GetMinRealAverage(207),
+                Height = Application.GetMinRealAverage(207),
+                Gravity = Gravity.CenterHorizontal,
                 BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
+                Radius=(uint)Application.GetMinRealAverage(207)
             };
-            this.AddChidren(midFL);
-            var r = new R.MyInternationalizationString();
-            object t;
-            try
+            bodyFrameLayout.AddChidren(deviceBG);
+
+            var deviceBG2 = new Button()
             {
-                t = r.GetType().InvokeMember(device.CommonDevice.Type.ToString(), System.Reflection.BindingFlags.GetField, null, r, null);
-            }
-            catch
-            {
-                t = 11070;
-            }
+                Y = Application.GetRealHeight(130),
+                Width = Application.GetMinRealAverage(184),
+                Height = Application.GetMinRealAverage(184),
+                Gravity = Gravity.CenterHorizontal,
+                BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
+                Radius = (uint)Application.GetMinRealAverage(184)
+            };
+            bodyFrameLayout.AddChidren(deviceBG2);
+
             var deviceIMG = new Button()
             {
-                Y = Application.GetRealHeight(30),
-                Width = Application.GetMinRealAverage(320),
-                Height = Application.GetMinRealAverage(320),
+                Y = Application.GetRealHeight(161),
+                Width = Application.GetMinRealAverage(124),
+                Height = Application.GetMinRealAverage(124),
                 UnSelectedImagePath = device.IconPath,
-                SelectedImagePath = device.OnlineIconPath,
-                IsSelected=device.CommonDevice.IsOnline==1,
                 Gravity = Gravity.CenterHorizontal
             };
-            midFL.AddChidren(deviceIMG);
+            bodyFrameLayout.AddChidren(deviceIMG);
+
             var deviceTypeName = new Button()
             {
-                Y = deviceIMG.Bottom,
+                Y = Application.GetRealHeight(360),
                 Width = Application.GetRealWidth(900),
-                Height = Application.GetRealHeight(100),
+                Height = Application.GetRealHeight(80),
                 TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                TextID = (int)t,
+                Text = DeviceUI.GetDeviceTypeName(device.CommonDevice.Type),
                 Gravity = Gravity.CenterHorizontal
             };
-            midFL.AddChidren(deviceTypeName);
+            bodyFrameLayout.AddChidren(deviceTypeName);
 
-            var deviceNameFL = new FrameLayout()
-            {
-                Y = deviceTypeName.Bottom,
-                Height = Application.GetRealHeight(170),
-            };
-            midFL.AddChidren(deviceNameFL);
-            var deviceNameTip = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Height = Application.GetRealHeight(70),
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 12,
-                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
-                TextID = R.MyInternationalizationString.DeviceName,
-            };
-            deviceNameFL.AddChidren(deviceNameTip);
-            var deviceName = new EditText()
-            {
-                X = Application.GetRealWidth(50),
-                Y = deviceNameTip.Bottom,
-                Height = Application.GetRealHeight(100) - 1,
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                Text = device.CommonDevice.DeviceEpointName,
-            };
-            deviceNameFL.AddChidren(deviceName);
-            var deviceNameLine = new Button()
-            {
-                Y = deviceName.Bottom,
-                Height = 1,
-                BackgroundColor = ZigbeeColor.Current.GXCLineColor
-            };
-            deviceNameFL.AddChidren(deviceNameLine);
 
-            var zoneFL = new FrameLayout()
+            var infoFL = new FrameLayout
             {
-                Y = deviceNameFL.Bottom,
-                Height = Application.GetRealHeight(170),
+                Y = Application.GetRealHeight(540),
+                Height = Application.GetRealHeight(1195),
+                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
             };
-            midFL.AddChidren(zoneFL);
-            var zoneTip = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Height = Application.GetRealHeight(70),
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 12,
-                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
-                TextID = R.MyInternationalizationString.BelongZone,
-            };
-            zoneFL.AddChidren(zoneTip);
-            var zone = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Y = deviceNameTip.Bottom,
-                Height = Application.GetRealHeight(100) - 1,
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                Text = Common.Room.CurrentRoom.GetRoomName(RoomNameList),
-            };
-            zoneFL.AddChidren(zone);
-            var zoneRight = new SelectedStatuButton()
-            {
-                X = Application.GetRealWidth(1080 - 150),
-                Width = Application.GetMinRealAverage(110),
-                Height = Application.GetMinRealAverage(110),
-                UnSelectedImagePath = "Item/Next.png",
-                SelectedImagePath="Item/NextSelected.png",
-                Gravity = Gravity.CenterVertical
-            };
-            zoneFL.AddChidren(zoneRight);
-            var zoneLine = new Button()
-            {
-                Y = zone.Bottom,
-                Height = 1,
-                BackgroundColor = ZigbeeColor.Current.GXCLineColor
-            };
-            zoneFL.AddChidren(zoneLine);
+            bodyFrameLayout.AddChidren(infoFL);
 
-            var modelFL = new FrameLayout()
+            var tipBtn = new Button
             {
-                Y = zoneFL.Bottom,
-                Height = Application.GetRealHeight(170),
-            };
-            midFL.AddChidren(modelFL);
-            var modelTip = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Height = Application.GetRealHeight(70),
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 12,
-                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
-                TextID = R.MyInternationalizationString.BelongModel,
-            };
-            modelFL.AddChidren(modelTip);
-            var model = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Y = deviceNameTip.Bottom,
-                Height = Application.GetRealHeight(100) - 1,
-                Width = Application.GetRealWidth(900),
-                TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                Text = device.CommonDevice.DeviceName==""?Language.StringByID(R.MyInternationalizationString.UNKnown):device.CommonDevice.DeviceName
-            };
-            modelFL.AddChidren(model);
-            var modelLine = new Button()
-            {
-                Y = model.Bottom,
-                Height = 1,
-                BackgroundColor = ZigbeeColor.Current.GXCLineColor
-            };
-            modelFL.AddChidren(modelLine);
-
-            var sharedFL = new FrameLayout()
-            {
-                Y = modelFL.Bottom,
-                Height = Application.GetRealHeight(170),
-            };
-            //midFL.AddChidren(sharedFL);
-            var sharedBtn = new Button()
-            {
-                X = Application.GetRealWidth(50),
-                Y = Application.GetRealHeight(70),
-                Height = Application.GetRealHeight(100) - 1,
+                X = Application.GetRealWidth(CommonFormResouce.X_Left),
+                Y = Application.GetRealHeight(81),
                 Width = Application.GetRealWidth(500),
+                Height = Application.GetRealHeight(60),
+                TextColor = ZigbeeColor.Current.GXCTextDeepBlackColor,
                 TextAlignment = TextAlignment.CenterLeft,
-                TextSize = 20,
-                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
-                TextID = R.MyInternationalizationString.Shared
+                TextSize = 15,
+                TextID = R.MyInternationalizationString.EditInfo
             };
-            sharedFL.AddChidren(sharedBtn);
+            infoFL.AddChidren(tipBtn);
 
-            var sharedRight = new Button()
-            {
-                X = Application.GetRealWidth(1080 - 150),
-                Width = Application.GetMinRealAverage(110),
-                Height = Application.GetMinRealAverage(110),
-                UnSelectedImagePath = "Item/Next.png",
-                Gravity = Gravity.CenterVertical
-            };
-            sharedFL.AddChidren(sharedRight);
+            var nameRow = new DeviceInfoEditRow(170);
+            nameRow.Init();
+            nameRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.FunctionName)} : ");
+            nameRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceEpointName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName);
+            infoFL.AddChidren(nameRow);
 
-            var sharedNum = new Button()
-            {
-                X = Application.GetRealWidth(1080 - 150 - 110),
-                Width = Application.GetRealWidth(110),
-                Height = Application.GetRealHeight(110),
-                TextAlignment = TextAlignment.CenterRight,
-                TextSize = 12,
-                TextColor = ZigbeeColor.Current.GXCButtonTipColor,
-                Text = "1浜�",
-                Gravity = Gravity.CenterVertical
-            };
-            sharedFL.AddChidren(sharedNum);
+            var zoneRow = new DeviceInfoRow(308);
+            zoneRow.Init();
+            zoneRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongZone)} : ");
+            zoneRow.SetTitle(roomName);
+            infoFL.AddChidren(zoneRow);
 
-            var sharedLine = new Button()
-            {
-                Y = sharedBtn.Bottom,
-                Height = 1,
-                BackgroundColor = ZigbeeColor.Current.GXCLineColor
-            };
-            sharedFL.AddChidren(sharedLine);
+            var modelRow = new DeviceInfoRow(446);
+            modelRow.Init();
+            modelRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.BelongModel)} : ");
+            modelRow.SetTitle(string.IsNullOrEmpty(device.CommonDevice.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : device.CommonDevice.DeviceName);
+            infoFL.AddChidren(modelRow);
 
-            var confirmBtn = new CommonForm.CompleteButton()
-            {
-            };
-            AddChidren(confirmBtn);
+            var sharedRow = new DeviceInfoRow(585);
+            sharedRow.Init();
+            sharedRow.SetTipTitle($"{Language.StringByID(R.MyInternationalizationString.Share)} : ");
+            sharedRow.SetTitle("2浜�");
+            infoFL.AddChidren(sharedRow);
 
-            confirmBtn.MouseUpEventHandler += async (sender, e) =>
-            {
-                if (device.CommonDevice == null)
-                {
-                    CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
-                    return;
-                }
-                var result = await Shared.Common.LocalDevice.Current.ReName(device.CommonDevice, deviceName.Text.Trim());
-                if (result)
-                {
-                    var alertSuccess = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.Success), Language.StringByID(R.MyInternationalizationString.Confrim));
-                    alertSuccess.Show();
-                    alertSuccess.ResultEventHandler += (senderSuccess, eSuccess) =>
-                    {
-                        //鏀瑰浘鐗�
-                        device.CommonDevice.IconPath = deviceIMG.UnSelectedImagePath;
-                        device.CommonDevice.IsCustomizeImage = true;
-                        device.CommonDevice.ReSave();
-                        //鏀规埧闂�
-                        Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, RoomNameList);
-                        RemoveFromParent();
-                    };
-                }
-                else
-                {
-                    return;
-                    //CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
-                }
-            };
-            #endregion
+
+            var confirmBtn = new CommonForm.CompleteButton(962, 907, 127);
+            confirmBtn.SetTitle(R.MyInternationalizationString.Confrim);
+            infoFL.AddChidren(confirmBtn);
 
             #region event
             EventHandler<MouseEventArgs> selectZoneEvent = (sender, e) =>
             {
-                UserCenter.SelectRoomForm selectedRoom = new UserCenter.SelectRoomForm();
-                selectedRoom.AddForm(selectedRoom, RoomNameList);
-                selectedRoom.ActionSelectRoom += ((rList) =>
-                {
-                    RoomNameList = rList;
-                    zone.Text = Shared.Common.Room.CurrentRoom.GetRoomName(RoomNameList);
-                });
+                //UserCenter.SelectRoomForm selectedRoom = new UserCenter.SelectRoomForm();
+                //selectedRoom.AddForm(selectedRoom, roomNameList);
+                //selectedRoom.ActionSelectRoom += ((rList) =>
+                //{
+                //    roomNameList = rList;
+                //    zone.Text = Shared.Common.Room.CurrentRoom.GetRoomName(roomNameList);
+                //});
             };
-            zoneRight.MouseUpEventHandler += selectZoneEvent;
-            zoneFL.MouseUpEventHandler += selectZoneEvent;
-            zone.MouseUpEventHandler += selectZoneEvent;
+            //zoneRight.MouseUpEventHandler += selectZoneEvent;
+            //zoneFL.MouseUpEventHandler += selectZoneEvent;
+            //zone.MouseUpEventHandler += selectZoneEvent;
 
             EventHandler<MouseEventArgs> selectDeviceIconEvent = (sender, e) =>
-             {
-                 var localPic = new DeviceIconSelectedIMGByLocal();
-                 UserView.HomePage.Instance.AddChidren(localPic);
-                 UserView.HomePage.Instance.PageIndex += 1;
-                 localPic.Show();
-                 localPic.action = (unSelectedImagePath,selectedImagePath) =>
-                 {
-                     deviceIMG.UnSelectedImagePath = unSelectedImagePath;
-                     deviceIMG.SelectedImagePath = selectedImagePath;
-                 };
-             };
+            {
+                var localPic = new DeviceIconSelectedIMGByLocal();
+                UserView.HomePage.Instance.AddChidren(localPic);
+                UserView.HomePage.Instance.PageIndex += 1;
+                localPic.Show();
+                localPic.action = (unSelectedImagePath, selectedImagePath) =>
+                {
+                    deviceIMG.UnSelectedImagePath = unSelectedImagePath;
+                    deviceIMG.SelectedImagePath = selectedImagePath;
+                };
+            };
             deviceIMG.MouseUpEventHandler += selectDeviceIconEvent;
+
+            confirmBtn.MouseUpEventHandler += async (sender, e) =>
+            {
+                //if (device.CommonDevice == null)
+                //{
+                //    CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
+                //    return;
+                //}
+                //var result = await Shared.Common.LocalDevice.Current.ReName(device.CommonDevice, deviceName.Text.Trim());
+                //if (result)
+                //{
+                //    var alertSuccess = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.Success), Language.StringByID(R.MyInternationalizationString.Confrim));
+                //    alertSuccess.Show();
+                //    alertSuccess.ResultEventHandler += (senderSuccess, eSuccess) =>
+                //    {
+                //        //鏀瑰浘鐗�
+                //        device.IconPath = deviceIMG.UnSelectedImagePath;
+                //        device.IsCustomizeImage = true;
+                //        device.ReSave();
+                //        //鏀规埧闂�
+                //        Shared.Common.Room.CurrentRoom.ChangedRoom(device.CommonDevice, roomNameList);
+                //        RemoveFromParent();
+                //    };
+                //}
+                //else
+                //{
+                //    return;
+                //    //CommonPage.Instance.ShowErrorInfoAlert(R.MyInternationalizationString.FailedPleaseTryAgain);
+                //}
+            };
 
             #endregion
         }
+
+        /// <summary>
+        /// Init
+        /// </summary>
+        /// <param name="device"></param>
+        public void Init(DeviceUI device)
+        {
+            roomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device.CommonDevice);
+        }
+        #endregion
     }
 }

--
Gitblit v1.8.0