From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs |  356 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 356 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
new file mode 100755
index 0000000..8ae60cd
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
@@ -0,0 +1,356 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using Shared.Common;
+using Shared.Phone.UserCenter;
+using ZigBee.Device;
+
+namespace Shared.Phone.MainPage
+{
+    /// <summary>
+    /// 涓婚〉鐨勮澶囦俊鎭晫闈�
+    /// </summary>
+    public class DeviceDetailInfoForm : EditorCommonForm
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 鐣岄潰鍏抽棴浜嬩欢(璇ヤ簨浠剁洰鍓嶇粰鍒嗙被鐣岄潰鐨勮嚜瀹氫箟琛屾帶浠朵娇鐢�)
+        /// </summary>
+        public Action FormCloseEvent = null;
+        /// <summary>
+        /// 璁惧瀵硅薄
+        /// </summary>
+        private CommonDevice device;
+        /// <summary>
+        /// 鎴块棿瀵硅薄(杩欎釜鎴块棿鏈夊彲鑳芥槸鍠滅埍,鏈夊彲鑳芥槸null)
+        /// </summary>
+        private Room room = null;
+        /// <summary>
+        /// 鍒楄〃鎺т欢
+        /// </summary>
+        private FrameListControl listview = null;
+
+        #endregion
+
+        #region 鈻� 鍒濆鍖朹____________________________
+
+        /// <summary>
+        /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
+        /// </summary>
+        /// <param name="i_device">璁惧瀵硅薄</param>
+        /// <param name="i_room">鎴块棿瀵硅薄(杩欎釜鎴块棿鏈夊彲鑳芥槸鍠滅埍)</param>
+        public void ShowForm(CommonDevice i_device, Room i_room)
+        {
+            this.device = i_device;
+            this.room = i_room;
+
+            //璁剧疆鏍囬淇℃伅
+            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.FunctionSetting));
+
+            //涓讳汉鍜岀鐞嗗憳鎵嶈兘鏇存敼
+            if (UserCenterResourse.UserInfo.AuthorityNo == 1 || UserCenterResourse.UserInfo.AuthorityNo == 2)
+            {
+                //鍒濆鍖栦腑閮ㄦ帶浠�(涓讳汉,绠$悊鍛�)
+                this.InitMiddleFrameByAdmin();
+            }
+            //鎴愬憳涓嶅厑璁稿彉鏇�
+            else
+            {
+                //鍒濆鍖栦腑閮ㄦ帶浠�(鎴愬憳)
+                this.InitMiddleFrameByMember();
+            }
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄦ帶浠�(涓讳汉,绠$悊鍛�)
+        /// </summary>
+        private void InitMiddleFrameByAdmin()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var listBackControl = new VerticalFrameControl();
+            listBackControl.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listBackControl);
+
+            //鍒濆鍖栨甯�
+            var tableContr = new InformationEditorControl();
+            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
+
+            //鍥剧墖
+            var btnPic = new DeviceInfoIconControl();
+            btnPic.Y = Application.GetRealHeight(46);
+            btnPic.Gravity = Gravity.CenterHorizontal;
+            listBackControl.frameTable.AddChidren(btnPic);
+            btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
+            btnPic.ButtonClickEvent += (sender, e) =>
+            {
+                var form = new SelectLocalDeviceImageForm();
+                form.AddForm();
+                form.FinishSelectEvent = (unSelectedImagePath) =>
+                {
+                    //鍙樻洿鍥剧墖
+                    device.IconPath = unSelectedImagePath;
+                    device.IsCustomizeImage = true;
+                    device.ReSave();
+                    //鍒锋柊鎺т欢
+                    btnPic.RefreshControl();
+                };
+            };
+
+            //璁惧鎵�灞炵被鍨�
+            var infoType = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
+            var btnBelongType = new NormalViewControl(700, 62, true);
+            btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
+            btnBelongType.Gravity = Gravity.CenterHorizontal;
+            btnBelongType.TextID = infoType.BeloneTextId;
+            btnBelongType.TextSize = 15;
+            btnBelongType.TextAlignment = TextAlignment.Center;
+            listBackControl.frameTable.AddChidren(btnBelongType);
+
+            //鍔熻兘鍚嶇О
+            string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
+            string deviceName = LocalDevice.Current.GetDeviceEpointName(device);
+            var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
+            listview.AddChidren(btnNote);
+            btnNote.InitControl();
+            //鍒掔嚎
+            btnNote.AddBottomLine();
+            btnNote.txtInput.FinishInputEvent += () =>
+            {
+                string oldName = LocalDevice.Current.GetDeviceEpointName(device);
+                if (btnNote.Text == string.Empty)
+                {
+                    btnNote.Text = oldName;
+                }
+                if (oldName != btnNote.Text)
+                {
+                    //淇敼鍚嶅瓧
+                    this.DeviceReName(btnNote.Text, false);
+                }
+            };
+
+            //鍠滅埍鎴块棿涓嶅厑璁稿彉鏇村尯鍩�
+            if (this.room == null || this.room.IsLove == false)
+            {
+                //鎵�灞炲尯鍩�
+                var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
+                listview.AddChidren(rowBeloneArea);
+                rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.device);
+                //搴曠嚎
+                rowBeloneArea.AddBottomLine();
+                rowBeloneArea.SelectRoomEvent += (roomKeys) =>
+                {
+                    //鎴块棿閲嶆柊鑾峰彇
+                    this.room = HdlRoomLogic.Current.GetRoomById(roomKeys);
+                    HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
+                };
+            }
+
+            //鎵�灞炴ā鍧�
+            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
+            deviceName = Common.LocalDevice.Current.GetDeviceMacName(device);
+            var rowBelongModul = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
+            listview.AddChidren(rowBelongModul);
+            rowBelongModul.InitControl();
+            //鍒掔嚎
+            rowBelongModul.AddBottomLine();
+
+            //娣诲姞銆愬姛鑳界被鍨嬨�戣(涓讳汉,绠$悊鍛�)
+            this.AddFunctionTypeRowByAdmin(btnBelongType);
+
+            //鍒濆鍖栨甯冨畬鎴�
+            tableContr.FinishInitControl();
+            tableContr = null;
+
+            //淇濆瓨
+            var btnFinish = new BottomClickButton();
+            btnFinish.TextID = R.MyInternationalizationString.uSave;
+            bodyFrameLayout.AddChidren(btnFinish);
+            btnFinish.ButtonClickEvent += (sender, e) =>
+            {
+                string oldName = LocalDevice.Current.GetDeviceEpointName(device);
+                if (btnNote.Text.Trim() == string.Empty)
+                {
+                    btnNote.Text = oldName;
+                }
+                if (oldName != btnNote.Text.Trim())
+                {
+                    //淇敼鍚嶅瓧
+                    this.DeviceReName(btnNote.Text.Trim(), true);
+                }
+                else
+                {
+                    //鍏抽棴鑷韩
+                    this.CloseForm();
+                }
+            };
+        }
+
+        /// <summary>
+        /// 鍒濆鍖栦腑閮ㄦ帶浠�(鎴愬憳)
+        /// </summary>
+        private void InitMiddleFrameByMember()
+        {
+            //娓呯┖bodyFrame
+            this.ClearBodyFrame();
+
+            var listBackControl = new VerticalFrameControl();
+            listBackControl.Height = bodyFrameLayout.Height;
+            bodyFrameLayout.AddChidren(listBackControl);
+
+            //鍒濆鍖栨甯�
+            var tableContr = new InformationEditorControl();
+            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1319);
+
+            //鍥剧墖
+            var btnPic = new DeviceInfoIconControl();
+            btnPic.Y = Application.GetRealHeight(92);
+            btnPic.Gravity = Gravity.CenterHorizontal;
+            listBackControl.frameTable.AddChidren(btnPic);
+            btnPic.InitControl(device.DeviceAddr, device.DeviceEpoint);
+
+            //璁惧鎵�灞炵被鍨�
+            var infoType = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
+            var btnBelongType = new NormalViewControl(700, 62, true);
+            btnBelongType.Y = btnPic.Bottom + Application.GetRealHeight(35);
+            btnBelongType.Gravity = Gravity.CenterHorizontal;
+            btnBelongType.TextID = infoType.BeloneTextId;
+            btnBelongType.TextSize = 15;
+            btnBelongType.TextAlignment = TextAlignment.Center;
+            listBackControl.frameTable.AddChidren(btnBelongType);
+
+            //鍔熻兘鍚嶇О
+            string caption = Language.StringByID(R.MyInternationalizationString.FunctionName);
+            string nameValue = LocalDevice.Current.GetDeviceEpointName(device);
+            var btnNote = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
+            btnNote.UseClickStatu = false;
+            listview.AddChidren(btnNote);
+            btnNote.InitControl();
+            //鍒掔嚎
+            btnNote.AddBottomLine();
+
+            //鍠滅埍鎴块棿涓嶅厑璁稿嚭鐜板尯鍩�
+            if (this.room == null || this.room.IsLove == false)
+            {
+                //鎵�灞炲尯鍩�
+                caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
+                nameValue = HdlRoomLogic.Current.GetRoomNameByDevice(device);
+                var rowBeloneArea = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
+                rowBeloneArea.UseClickStatu = false;
+                listview.AddChidren(rowBeloneArea);
+                rowBeloneArea.InitControl();
+                //鍒掔嚎
+                rowBeloneArea.AddBottomLine();
+            }
+
+            //鎵�灞炴ā鍧�
+            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
+            nameValue = Common.LocalDevice.Current.GetDeviceMacName(device);
+            var rowBelongModul = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
+            rowBelongModul.UseClickStatu = false;
+            listview.AddChidren(rowBelongModul);
+            rowBelongModul.InitControl();
+            //鍒掔嚎
+            rowBelongModul.AddBottomLine();
+
+            //娣诲姞銆愬姛鑳界被鍨嬨�戣(鎴愬憳)
+            this.AddFunctionTypeRowByMember();
+
+            //鍒濆鍖栨甯冨畬鎴�
+            tableContr.FinishInitControl();
+            tableContr = null;
+        }
+
+        #endregion
+
+        #region 鈻� 鍔熻兘绫诲瀷___________________________
+
+        /// <summary>
+        /// 娣诲姞銆愬姛鑳界被鍨嬨�戣(涓讳汉,绠$悊鍛�)
+        /// </summary>
+        private void AddFunctionTypeRowByAdmin(NormalViewControl btnBelongType)
+        {
+            //鑷畾涔夊姛鑳界被鍨嬫帶浠�
+            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
+            if (rowFunction.CanShowRow == true)
+            {
+                listview.AddChidren(rowFunction);
+                rowFunction.InitControl();
+                //搴曠嚎
+                rowFunction.AddBottomLine();
+                rowFunction.FinishSelectEvent += (index) =>
+                {
+                    //褰撶被鍨嬪彉鏇存椂,澶翠笂鐨勭被鍨嬩篃涓�璧峰彉鏇�
+                    btnBelongType.Text = rowFunction.Text;
+                };
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞銆愬姛鑳界被鍨嬨�戣(鎴愬憳)
+        /// </summary>
+        private void AddFunctionTypeRowByMember()
+        {
+            //鑷畾涔夊姛鑳界被鍨嬫帶浠�
+            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
+            if (rowFunction.CanShowRow == true)
+            {
+                //寮哄埗骞叉秹涓嶈兘閫夋嫨
+                rowFunction.SetCanSelect = false;
+                listview.AddChidren(rowFunction);
+                rowFunction.InitControl();
+                //搴曠嚎
+                rowFunction.AddBottomLine();
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 淇敼鍚嶅瓧___________________________
+
+        /// <summary>
+        /// 璁惧閲嶅懡鍚�
+        /// </summary>
+        /// <param name="i_deviceName">deviceName.</param>
+        private void DeviceReName(string i_deviceName, bool closeForm)
+        {
+            //淇敼MAC鍚�
+            string deviceName = i_deviceName.Trim();
+            var result = LocalDevice.Current.ReName(this.device, deviceName);
+            if (result == false)
+            {
+                return;
+            }
+            if (closeForm == true)
+            {
+                //鍏抽棴鐣岄潰
+                this.CloseForm();
+            }
+            else
+            {
+                //璁惧澶囨敞淇敼鎴愬姛!
+                string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess);
+                this.ShowMassage(ShowMsgType.Tip, msg);
+            }
+        }
+
+        #endregion
+
+        #region 鈻� 鐣岄潰鍏抽棴___________________________
+
+        /// <summary>
+        /// 鐣岄潰鍏抽棴
+        /// </summary>
+        public override void CloseFormBefore()
+        {
+            this.FormCloseEvent?.Invoke();
+            this.FormCloseEvent = null;
+
+            base.CloseFormBefore();
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0