From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs |  154 +++++++++++----------------------------------------
 1 files changed, 33 insertions(+), 121 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
index 5512a41..435a274 100755
--- a/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
@@ -17,13 +17,13 @@
         /// <summary>
         /// 鐣岄潰鍏抽棴浜嬩欢(璇ヤ簨浠剁洰鍓嶇粰鍒嗙被鐣岄潰鐨勮嚜瀹氫箟琛屾帶浠朵娇鐢�)
         /// </summary>
-        public Action<CommonDevice, Room> FormCloseEvent = null;
+        public Action FormCloseEvent = null;
         /// <summary>
         /// 璁惧瀵硅薄
         /// </summary>
         private CommonDevice device;
         /// <summary>
-        /// 鎴块棿瀵硅薄(杩欎釜鎴块棿鏈夊彲鑳芥槸鍠滅埍)
+        /// 鎴块棿瀵硅薄(杩欎釜鎴块棿鏈夊彲鑳芥槸鍠滅埍,鏈夊彲鑳芥槸null)
         /// </summary>
         private Room room = null;
         /// <summary>
@@ -86,11 +86,9 @@
             btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
             btnPic.ButtonClickEvent += (sender, e) =>
             {
-                var localPic = new Device.CommonForm.DeviceIconSelectedIMGByLocal();
-                UserView.HomePage.Instance.AddChidren(localPic);
-                UserView.HomePage.Instance.PageIndex += 1;
-                localPic.Show();
-                localPic.action = (unSelectedImagePath, selectedImagePath) =>
+                var form = new SelectLocalDeviceImageForm();
+                form.AddForm();
+                form.FinishSelectEvent = (unSelectedImagePath) =>
                 {
                     //鍙樻洿鍥剧墖
                     device.IconPath = unSelectedImagePath;
@@ -106,7 +104,7 @@
             var btnBelongType = new NormalViewControl(700, 62, true);
             btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
             btnBelongType.Gravity = Gravity.CenterHorizontal;
-            btnBelongType.TextID = infoType.BeloneTextId;
+            btnBelongType.Text = infoType.BeloneText;
             btnBelongType.TextSize = 15;
             btnBelongType.TextAlignment = TextAlignment.Center;
             listBackControl.frameTable.AddChidren(btnBelongType);
@@ -115,6 +113,7 @@
             string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
             string deviceName = LocalDevice.Current.GetDeviceEpointName(device);
             var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
+            btnNote.txtInput.MaxByte = 48;//闄愬埗鍙兘杈撳叆48涓瓧鑺�
             listview.AddChidren(btnNote);
             btnNote.InitControl();
             //鍒掔嚎
@@ -134,7 +133,7 @@
             };
 
             //鍠滅埍鎴块棿涓嶅厑璁稿彉鏇村尯鍩�
-            if (this.room.IsLove == false)
+            if (this.room == null || this.room.IsLove == false)
             {
                 //鎵�灞炲尯鍩�
                 var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
@@ -151,7 +150,7 @@
             }
 
             //鎵�灞炴ā鍧�
-            caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
+            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
             deviceName = Common.LocalDevice.Current.GetDeviceMacName(device);
             var rowBelongModul = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
             listview.AddChidren(rowBelongModul);
@@ -218,7 +217,7 @@
             var btnBelongType = new NormalViewControl(700, 62, true);
             btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
             btnBelongType.Gravity = Gravity.CenterHorizontal;
-            btnBelongType.TextID = infoType.BeloneTextId;
+            btnBelongType.Text = infoType.BeloneText;
             btnBelongType.TextSize = 15;
             btnBelongType.TextAlignment = TextAlignment.Center;
             listBackControl.frameTable.AddChidren(btnBelongType);
@@ -234,7 +233,7 @@
             btnNote.AddBottomLine();
 
             //鍠滅埍鎴块棿涓嶅厑璁稿嚭鐜板尯鍩�
-            if (this.room.IsLove == false)
+            if (this.room == null || this.room.IsLove == false)
             {
                 //鎵�灞炲尯鍩�
                 caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
@@ -248,7 +247,7 @@
             }
 
             //鎵�灞炴ā鍧�
-            caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
+            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
             nameValue = Common.LocalDevice.Current.GetDeviceMacName(device);
             var rowBelongModul = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
             rowBelongModul.UseClickStatu = false;
@@ -274,90 +273,19 @@
         /// </summary>
         private void AddFunctionTypeRowByAdmin(NormalViewControl btnBelongType)
         {
-            //濡傛灉鏄户鐢靛櫒,绌烘皵寮�鍏�,璋冨厜鍣ㄧ殑璇�
-            if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
-                || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
+            //鑷畾涔夊姛鑳界被鍨嬫帶浠�
+            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
+            if (rowFunction.CanShowRow == true)
             {
-                //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛�
-                int nowSelectNo = 1;
-                string strType = string.Empty;
-                if (this.device.DfunctionType == DeviceFunctionType.A鐏厜)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uLight);
-                    nowSelectNo = 1;
-                }
-                else if (this.device.DfunctionType == DeviceFunctionType.A寮�鍏�)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
-                    nowSelectNo = 0;
-                }
-                else if (this.device.DfunctionType == DeviceFunctionType.A鎻掑骇)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
-                    nowSelectNo = 2;
-                }
-                //鍔熻兘绫诲瀷
-                var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
-                btnFunction.UseClickStatu = false;
-                listview.AddChidren(btnFunction);
-                btnFunction.InitControl();
+                listview.AddChidren(rowFunction);
+                rowFunction.InitControl();
                 //搴曠嚎
-                btnFunction.AddBottomLine();
-                //濡傛灉鏄┖姘斿紑鍏冲拰缁х數鍣�,鎵嶈兘淇敼
-                if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch)
+                rowFunction.AddBottomLine();
+                rowFunction.FinishSelectEvent += (index) =>
                 {
-                    //鍙崇澶�
-                    btnFunction.AddRightArrow();
-                    btnFunction.ButtonClickEvent += (sender, e) =>
-                    {
-                        //鏄剧ず鍒楄〃
-                        var listText = new List<string>();
-                        listText.Add(Language.StringByID(R.MyInternationalizationString.uSwitch));//寮�鍏�
-                        listText.Add(Language.StringByID(R.MyInternationalizationString.uLight));//鐏厜
-                        listText.Add(Language.StringByID(R.MyInternationalizationString.uSocket1));//鎻掑骇
-                        //鏍囬:閫夋嫨鍔熻兘绫诲瀷
-                        var title = Language.StringByID(R.MyInternationalizationString.uSelectFunctionType);
-
-                        var form = new BottomItemSelectForm();
-                        form.AddForm(title, listText, nowSelectNo);
-                        form.FinishSelectEvent += (selectNo) =>
-                        {
-                            btnFunction.Text = listText[selectNo];
-                            //褰撶被鍨嬪彉鏇存椂,澶翠笂鐨勭被鍨嬩篃涓�璧峰彉鏇�
-                            btnBelongType.Text = listText[selectNo];
-                            nowSelectNo = selectNo;
-                            //璁板綍璧峰綋鍓嶉�夋嫨鐨勫姛鑳界被鍨�
-                            if (selectNo == 0)
-                            {
-                                this.device.DfunctionType = DeviceFunctionType.A寮�鍏�;
-                                if (this.device.IsCustomizeImage == false)
-                                {
-                                    //閲嶆柊璁剧疆鍥剧墖
-                                    this.device.IconPath = "Device/Switch.png";
-                                }
-                            }
-                            else if (selectNo == 1)
-                            {
-                                this.device.DfunctionType = DeviceFunctionType.A鐏厜;
-                                if (this.device.IsCustomizeImage == false)
-                                {
-                                    //閲嶆柊璁剧疆鍥剧墖
-                                    this.device.IconPath = "Device/Light.png";
-                                }
-                            }
-                            else
-                            {
-                                this.device.DfunctionType = DeviceFunctionType.A鎻掑骇;
-                                if (this.device.IsCustomizeImage == false)
-                                {
-                                    //閲嶆柊璁剧疆鍥剧墖
-                                    this.device.IconPath = "Device/Socket1.png";
-                                }
-                            }
-                            this.device.ReSave();
-                        };
-                    };
-                }
+                    //褰撶被鍨嬪彉鏇存椂,澶翠笂鐨勭被鍨嬩篃涓�璧峰彉鏇�
+                    btnBelongType.Text = rowFunction.Text;
+                };
             }
         }
 
@@ -366,32 +294,16 @@
         /// </summary>
         private void AddFunctionTypeRowByMember()
         {
-            //濡傛灉鏄户鐢靛櫒,绌烘皵寮�鍏�,璋冨厜鍣ㄧ殑璇�
-            if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
-                || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
+            //鑷畾涔夊姛鑳界被鍨嬫帶浠�
+            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
+            if (rowFunction.CanShowRow == true)
             {
-                //鍔熻兘绫诲瀷鐨勭炕璇戝悕瀛�
-                string strType = string.Empty;
-                if (this.device.DfunctionType == DeviceFunctionType.A鐏厜)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uLight);
-                }
-                else if (this.device.DfunctionType == DeviceFunctionType.A寮�鍏�)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
-                }
-                else if (this.device.DfunctionType == DeviceFunctionType.A鎻掑骇)
-                {
-                    strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
-                }
-
-                //鍔熻兘绫诲瀷
-                var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
-                btnFunction.UseClickStatu = false;
-                listview.AddChidren(btnFunction);
-                btnFunction.InitControl();
+                //寮哄埗骞叉秹涓嶈兘閫夋嫨
+                rowFunction.SetCanSelect = false;
+                listview.AddChidren(rowFunction);
+                rowFunction.InitControl();
                 //搴曠嚎
-                btnFunction.AddBottomLine();
+                rowFunction.AddBottomLine();
             }
         }
 
@@ -403,11 +315,11 @@
         /// 璁惧閲嶅懡鍚�
         /// </summary>
         /// <param name="i_deviceName">deviceName.</param>
-        private async void DeviceReName(string i_deviceName, bool closeForm)
+        private void DeviceReName(string i_deviceName, bool closeForm)
         {
             //淇敼MAC鍚�
             string deviceName = i_deviceName.Trim();
-            var result = await LocalDevice.Current.ReName(this.device, deviceName);
+            var result = LocalDevice.Current.ReName(this.device, deviceName);
             if (result == false)
             {
                 return;
@@ -434,7 +346,7 @@
         /// </summary>
         public override void CloseFormBefore()
         {
-            this.FormCloseEvent?.Invoke(this.device, this.room);
+            this.FormCloseEvent?.Invoke();
             this.FormCloseEvent = null;
 
             base.CloseFormBefore();

--
Gitblit v1.8.0