From 23420922845c9e77019a55c3b3e3271eb1ec261e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 13 七月 2020 11:42:18 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs |   71 ++++++++++++++++++++++++++++++++---
 1 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
index abcd1c3..1bd57b2 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -102,10 +102,13 @@
             {
                 //绠�绾﹂潰鏉块殢渚夸竴涓洖璺潵鑾峰彇璁惧淇℃伅
                 var dev = Common.LocalDevice.Current.GetDevice(deviceMac, 62);
-                var key = new ZigBee.Device.Panel();
-                key.DeviceAddr = deviceMac;
-                key.CurrentGateWayId = dev.CurrentGateWayId;
-                InitBindInfo(key);
+                if (dev != null)
+                {
+                    var key = new ZigBee.Device.Panel();
+                    key.DeviceAddr = deviceMac;
+                    key.CurrentGateWayId = dev.CurrentGateWayId;
+                    InitBindInfo(key);
+                }
             }
         }
 
@@ -710,7 +713,8 @@
         private void AddPirSensorWorkModeRow()
         {
             if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir
-                || deviceEnumInfo.IsHdlDevice == false)
+                || deviceEnumInfo.IsHdlDevice == false
+                || this.listNewDevice.Count != 2)
             {
                 return;
             }
@@ -739,7 +743,8 @@
         /// </summary>
         private void AddPirSensorBindRow()
         {
-            if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir)
+            if (this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir
+                || this.listNewDevice.Count != 2)
             {
                 return;
             }
@@ -1207,6 +1212,10 @@
                 foreach (var bDev in bindList)
                 {
                     var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
+                    if (device == null)
+                    {
+                        continue;
+                    }
                     if (device.Type == DeviceType.TemperatureSensor)
                     {
                         var bD = device as TemperatureSensor;
@@ -1499,7 +1508,17 @@
             //妫�娴嬫鍥炶矾鏄惁鎷ユ湁瀹氫綅鍔熻兘(鎷跨鐐规渶灏忕殑閭d釜鍥炶矾鍘诲畾浣�)
             bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]);
 
-            var frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
+            TopRightMenuControl frame = null;
+
+            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_SimpleMultifunction)
+            {
+                frame = new TopRightMenuControl(3, 1);
+            }
+            else
+            {
+                frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
+            }
+
             string deviceMenu = string.Empty;
             if (canTest == true)
             {
@@ -1530,6 +1549,23 @@
                 });
             });
 
+            //鍚屾
+            deviceMenu = Language.StringByID(R.MyInternationalizationString.Synchronization);
+            if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]))
+            {
+                frame.AddRowMenu(deviceMenu, "", "Item/SynchronizationSelected.png", () =>
+                {
+                    //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�,姝ゅ姛鑳芥棤鏁�
+                    if (Common.Config.Instance.Home.IsVirtually == true)
+                    {
+                        return;
+                    }
+
+                    //鍚屾鎸囧畾璁惧
+                    this.SynchronizationDevice();
+                });
+            }
+
         }
 
         /// <summary>
@@ -1557,6 +1593,27 @@
                 });
             });
         }
+
+        /// <summary>
+        /// 鍚屾鎸囧畾璁惧
+        /// </summary>
+        private void SynchronizationDevice()
+        {
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                //鎵撳紑杩涘害鏉�
+                this.ShowProgressBar();
+
+                //鍚屾璁惧
+                bool result = await Common.LocalDevice.Current.SynchronizationDevice(listNewDevice);
+                //鍏抽棴杩涘害鏉�
+                this.CloseProgressBar();
+                if (result == false)
+                {
+                    return;
+                }
+            });
+        }
         #endregion
 
         #region 鈻� 鍏抽棴鐣岄潰___________________________

--
Gitblit v1.8.0