From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs |   67 +++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 28 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs
index 7f44d16..caaeaea 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFunctionSettionForm.cs
@@ -86,24 +86,24 @@
             var btnFinish = new BottomClickButton();
             btnFinish.TextID = R.MyInternationalizationString.uSave;
             bodyFrameLayout.AddChidren(btnFinish);
-            btnFinish.ButtonClickEvent += async (sender, e) =>
+            btnFinish.ButtonClickEvent += (sender, e) =>
             {
                 //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧
                 dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
                 foreach (var epoint in dicDeviceSaveName.Keys)
                 {
-                    var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
+                    var device = HdlDeviceCommonLogic.Current.GetDevice(deviceObj.DeviceAddr, epoint);
                     if (device == null || dicDeviceSaveName[epoint] == string.Empty)
                     {
                         //涓嶈兘鍏佽绌虹櫧鍚嶅瓧
                         continue;
                     }
                     string newName = dicDeviceSaveName[epoint];
-                    string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device);
+                    string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(device);
                     if (oldName != newName)
                     {
                         //璁惧鍚嶇О淇敼
-                        var result = await Common.LocalDevice.Current.ReName(device, newName);
+                        var result = HdlDeviceCommonLogic.Current.ReName(device, newName);
                         if (result == false)
                         {
                             return;
@@ -113,6 +113,11 @@
                 //鍏抽棴鑷韩
                 this.CloseForm();
             };
+            //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈�
+            if (Common.Config.Instance.Home.IsShowTemplate == true)
+            {
+                btnFinish.CanClick = false;
+            }
         }
 
         /// <summary>
@@ -124,37 +129,42 @@
 
             //鍥炶矾澶囨敞
             string caption = Language.StringByID(R.MyInternationalizationString.uDeviceEpointNote);
-            string nameValue = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
+            string nameValue = HdlDeviceCommonLogic.Current.GetDeviceEpointName(nowSelectDevice);
             if (dicDeviceSaveName.ContainsKey(nowSelectDevice.DeviceEpoint) == true)
             {
                 nameValue = dicDeviceSaveName[nowSelectDevice.DeviceEpoint];
             }
 
             this.btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
+            this.btnDeviceName.txtInput.MaxByte = 48;//闄愬埗鍙兘杈撳叆48涓瓧鑺�
             listview.AddChidren(btnDeviceName);
             btnDeviceName.InitControl();
             btnDeviceName.AddBottomLine();
-            btnDeviceName.txtInput.FinishInputEvent += async () =>
+            //濡傛灉褰撳墠鏄睍绀烘ā鏉�,鍒欎笉鑳界紪杈�
+            if (Common.Config.Instance.Home.IsShowTemplate == false)
             {
-                string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
-                if (btnDeviceName.Text.Trim() == string.Empty)
+                btnDeviceName.txtInput.FinishInputEvent += () =>
                 {
-                    //灏嗗悕瀛楄繕鍘�
-                    btnDeviceName.Text = oldName;
-                }
-                if (oldName != btnDeviceName.Text.Trim())
-                {
-                    //璁惧鍚嶇О淇敼
-                    var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim());
-                    if (result == false)
+                    string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(nowSelectDevice);
+                    if (btnDeviceName.Text.Trim() == string.Empty)
                     {
-                        return;
+                        //灏嗗悕瀛楄繕鍘�
+                        btnDeviceName.Text = oldName;
                     }
-                    //鍥炶矾澶囨敞淇敼鎴愬姛!
-                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess);
-                    this.ShowMassage(ShowMsgType.Tip, msg);
-                }
-            };
+                    if (oldName != btnDeviceName.Text.Trim())
+                    {
+                        //璁惧鍚嶇О淇敼
+                        var result = HdlDeviceCommonLogic.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim());
+                        if (result == false)
+                        {
+                            return;
+                        }
+                        //鍥炶矾澶囨敞淇敼鎴愬姛!
+                        string msg = Language.StringByID(R.MyInternationalizationString.uDeviceEpointReNoteSuccess);
+                        this.ShowMassage(ShowMsgType.Tip, msg);
+                    }
+                };
+            }
 
             //鎵�灞炲尯鍩�
             var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
@@ -184,7 +194,8 @@
         private void InitTopRightMenu()
         {
             //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘
-            if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false)
+            if (HdlDeviceCommonLogic.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false
+                || Common.Config.Instance.Home.IsShowTemplate == true)
             {
                 return;
             }
@@ -207,7 +218,7 @@
             int menuCount = 1;
             string deviceMenu = string.Empty;
             //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘
-            bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice);
+            bool canTest = HdlDeviceCommonLogic.Current.DeviceIsCanFixedPosition(nowSelectDevice);
             //if (canTest == true)
             //{
             //    menuCount = 2;
@@ -220,7 +231,7 @@
                 frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
                 {
                     //鍙戦�佸畾浣嶅姛鑳�
-                    Common.LocalDevice.Current.SetFixedPositionCommand(nowSelectDevice);
+                    HdlDeviceCommonLogic.Current.SetFixedPositionCommand(nowSelectDevice);
                 });
             }
 
@@ -261,7 +272,7 @@
         private void InitDeviceEpointIcon(VerticalFrameControl listBackControl)
         {
             bool hadDevice = false;
-            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
+            var listDevice = HdlDeviceCommonLogic.Current.GetDevicesByMac(deviceObj.DeviceAddr);
             var listSort = new List<CommonDevice>();
             foreach (var device in listDevice)
             {
@@ -337,7 +348,7 @@
             btnIcon.RadiusEx = 16;
             btnIcon.BorderWidth = 2;
             btnIcon.BorderColor = 0xff979797;
-            frame.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);
+            frame.AddChidren(btnIcon, ChidrenBindMode.BindEvent);
             //鐐瑰嚮浜嬩欢
             frame.ButtonClickEvent += (sender, e) =>
             {
@@ -510,7 +521,7 @@
             nowContr.TextColor = UserCenterColor.Current.TextColor1;
 
             nowSelectControl = nowContr;
-            nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
+            nowSelectDevice = HdlDeviceCommonLogic.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
 
             //閲嶆柊鍒濆鍖栬彍鍗曡
             this.InitMenuRow();

--
Gitblit v1.8.0