From 05ce435c3b58e53eeab04c672affdeeab75f3036 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 15 十一月 2019 14:41:39 +0800
Subject: [PATCH] 2019.11.15-1

---
 ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs |  138 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 107 insertions(+), 31 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
old mode 100755
new mode 100644
index e248dfa..3ee1dd4
--- a/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
+++ b/ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
@@ -4,6 +4,7 @@
 using Shared.Phone.Device.AC;
 using ZigBee.Device;
 using Shared.Phone.Device.CommonForm;
+using Shared.Phone.UserCenter.DoorLock;
 
 namespace Shared.Phone.UserView
 {
@@ -170,8 +171,8 @@
                                                     return;
                                                 }
                                                 airSwitch.OnOffStatus = airSwitch.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                                (rowFL.GetChildren(0) as FunctionMainView).IsSelected = airSwitch.OnOffStatus == 1;
-                                                (rowFL.GetChildren(0) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu();
+                                                (rowFL.GetChildren(0) as FunctionMainView).IsSelected = airSwitch.OnOffStatus == 1;
+                                                (rowFL.GetChildren(0) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu();
                                                 //璁板綍鍥炲鏃堕棿
                                                 airSwitch.LastDateTime = DateTime.Now;
                                             }
@@ -217,35 +218,60 @@
                                         {
                                             continue;
                                         }
+
+                                        var curTemp = (attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
                                         switch (attriButeList[0].AttributeId)
                                         {
                                             case 0:
                                                 //姝ゅ睘鎬ц〃鏄庡鍐呭綋鍓嶇殑娓╁害 * 100锛屽疄闄呮俯搴︿负鈥淟ocalTemperature / 100鈥濓紝鍗曚綅锛氣剝
-                                                ac.currentLocalTemperature = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
+                                                ac.currentLocalTemperature = curTemp;
                                                 ac.LastDateTime = DateTime.Now;
                                                 break;
 
                                             case 17:
                                                 //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鍐锋俯搴︼紝瀹為檯娓╁害涓衡�淐oolingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                                ac.currentCoolingSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
+                                                ac.currentCoolingSetpoint = curTemp;
                                                 ac.LastDateTime = DateTime.Now;
                                                 break;
 
                                             case 18:
                                                 //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勫埗鐑俯搴︼紝瀹為檯娓╁害涓衡�淗eatingSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                                ac.currentHeatingSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
+                                                ac.currentHeatingSetpoint = curTemp;
                                                 ac.LastDateTime = DateTime.Now;
                                                 break;
 
                                             case 4096:
                                                 //姝ゅ睘鎬ц〃鏄庢璁惧褰撳墠鐨勮嚜鍔ㄦ俯搴︼紝瀹為檯娓╁害涓衡�淎utoSetpoint / 100鈥濓紝鍗曚綅锛氣剝銆�
-                                                ac.currentAutoSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
+                                                ac.currentAutoSetpoint = curTemp;
                                                 ac.LastDateTime = DateTime.Now;
                                                 break;
 
                                             case 28:
                                                 //姝ゅ睘鎬ф弿杩版亽娓╄澶囨澶勪簬鍝妯″紡
                                                 ac.currentSystemMode = attriButeList[0].AttriButeData;
+                                                ac.LastDateTime = DateTime.Now;
+                                                break;
+                                        }
+                                        (rowFL.GetChildren(0) as FunctionMainView).IsSelected = ac.currentSystemMode != 0;
+                                        (rowFL.GetChildren(0) as FunctionMainView).StatuButton.Text = deviceUI.GetDeviceStatu();
+                                    }
+                                    if (common.DeviceStatusReport.CluterID == 514)
+                                    {
+                                        var ac = deviceUI.CommonDevice as ZigBee.Device.AC;
+                                        var attriButeList = common.DeviceStatusReport.AttriBute;
+                                        if (attriButeList == null || attriButeList.Count == 0)
+                                        {
+                                            return;
+                                        }
+                                        ac.DeviceStatusReport = common.DeviceStatusReport;
+                                        switch (attriButeList[0].AttributeId)
+                                        {
+                                            case 0:
+                                                ac.currentFanMode = attriButeList[0].AttriButeData;
+                                                ac.LastDateTime = DateTime.Now;
+                                                break;
+                                            case 4096:
+                                                ac.currentFanSwingMode = attriButeList[0].AttriButeData;
                                                 ac.LastDateTime = DateTime.Now;
                                                 break;
                                         }
@@ -311,7 +337,7 @@
                     }
                 });
             }
-           
+
         }
         /// <summary>
         /// Changeds the IL ogic status.
@@ -614,7 +640,8 @@
                         roomPageView.AddChidren(roomBackView);
                         var roomBG = new Button()
                         {
-                            UnSelectedImagePath = "Room/HomeBG.png",
+                            //UnSelectedImagePath = "Room/HomeBG.png",
+                            UnSelectedImagePath = room.BackgroundImage
                         };
                         roomBackView.AddChidren(roomBG);
                         var roomName = new Button()
@@ -636,24 +663,11 @@
                             Width = Application.GetMinRealAverage(100),
                             Height = Application.GetMinRealAverage(100),
                             UnSelectedImagePath = "Item/List.png",
-                            SelectedImagePath = "Item/ListSelected.png"
                         };
                         roomBackView.AddChidren(roomListBtn);
 
                         roomListBtn.MouseUpEventHandler += (send, e) =>
                         {
-                            //var roomList = new Device.Room.RoomManagement();
-                            //HomePage.Instance.AddChidren(roomList);
-                            //HomePage.Instance.PageIndex += 1;
-                            //roomList.Show();
-                            //roomList.action += () =>
-                            //{
-                            //    Show();
-                            //};
-                            if(room.IsLove)
-                            {
-                                return;
-                            }
                             var editRoom = new Device.Room.EditRoom();
                             HomePage.Instance.AddChidren(editRoom);
                             HomePage.Instance.PageIndex += 1;
@@ -662,7 +676,6 @@
                             {
                                 Show();
                             };
-
                         };
                     }
                 }
@@ -688,7 +701,7 @@
                         Text = Language.StringByID(R.MyInternationalizationString.Favorite),
                         TextAlignment = TextAlignment.CenterLeft,
                         TextColor = ZigbeeColor.Current.GXCTextWhiteColor,
-                        TextSize = 18,
+                        TextSize = 18
                     };
                     roomBackView.AddChidren(roomName);
                     var roomListBtn = new Button()
@@ -778,7 +791,7 @@
             {
                 ShowNoGatewayTip();
             }
-
+
         }
 
         #endregion
@@ -920,7 +933,7 @@
         private void GoToAddGateWay(object sender, MouseEventArgs mouseEventArgs)
         {
             var selectNewGateWayForm = new UserCenter.GatewayAdd.NewGateWayMenuSelectForm { };
-            selectNewGateWayForm.AddForm();
+            selectNewGateWayForm.AddForm(selectNewGateWayForm);
         }
 
         #endregion
@@ -972,7 +985,7 @@
             else
             {
                 deviceVerticalScrolViewLayout = new VerticalScrolViewLayout { };
-                
+
                 functionSceneBodyView.AddChidren(deviceVerticalScrolViewLayout);
                for(int i=0;i<deviceList.Count;i++)
                 {
@@ -996,7 +1009,6 @@
                         deviceVerticalScrolViewLayout.AddChidren(itemView);
                     }
 
-                   
                     //鍒犻櫎璁惧
                     EventHandler<MouseEventArgs> delEvent = (sender, e) =>
                     {
@@ -1398,6 +1410,7 @@
                                 ac.ReadAutoSetpoint();
                                 ac.ReadFanMode();
                                 ac.ReadSystemMode();
+                                ac.ReadSystemFansSwingMode();
                             });
                         }
                         else
@@ -1412,6 +1425,7 @@
                                 ac.ReadAutoSetpoint();
                                 ac.ReadFanMode();
                                 ac.ReadSystemMode();
+                                ac.ReadSystemFansSwingMode();
                             }
                         }
                         var lightView = new FunctionMainView(xx, yy);
@@ -1600,14 +1614,65 @@
                             var dimmableLightControl = new Phone.Device.Light.DimmableLightControl();
                             UserView.HomePage.Instance.AddChidren(dimmableLightControl);
                             UserView.HomePage.Instance.PageIndex += 1;
-                            UserView.HomePage.Instance.ScrollEnabled = false;
                             //dimmableLightControl.action = RefreshBodyView;
                             dimmableLightControl.Show(device, Room.CurrentRoom);
                         };
 
                         lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                     }
-                    else if (device.CommonDevice.Type == DeviceType.OnOffSwitch)
+                    else if (device.CommonDevice.Type == ZigBee.Device.DeviceType.DoorLock)
+                    {
+                        //闂ㄩ攣
+                        var dimmableLight = device.CommonDevice as DoorLock;
+                        //琛ヤ笂闈炶繙绋�
+                        if (dimmableLight.Gateway == null)
+                        {
+                            continue;
+                        }
+                        if (dimmableLight.Gateway.IsVirtual)
+                        {
+                            ReadStatus(dimmableLight, () =>
+                            {
+                                dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                            });
+                        }
+                        else
+                        {
+                            if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
+                            {
+                                dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                            }
+                        }
+
+                        var lightView = new FunctionMainView(xx, yy);
+                        itemView.AddChidren(lightView);
+                        lightView.Init();
+                        lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath);
+                        lightView.SetStatuText(device.GetDeviceStatu());
+                        lightView.SetDeviceName(device.CommonDevice.DeviceEpointName);
+                        lightView.IsSelected = dimmableLight.IsOnline == 1;
+                        lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom, device.FileName));
+                        lightView.CanControl(false);
+                        var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
+                        if (dev == null)
+                        {
+                            lightView.CollectButton.IsSelected = false;
+                        }
+                        else
+                        {
+                            lightView.CollectButton.IsSelected = true;
+                        }
+
+                        lightView.CardBG.MouseUpEventHandler += (sender, e) =>
+                        {
+                            var userDoorLockPage = new UserDoorLockPage(Room.CurrentRoom,device);
+                            HomePage.Instance.AddChidren(userDoorLockPage);
+                            HomePage.Instance.PageIndex += 1;
+                            userDoorLockPage.Show();
+                        };
+                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
+                    }
+                    else
                     {
                         var lightView = new FunctionMainView(xx, yy);
                         itemView.AddChidren(lightView);
@@ -1615,9 +1680,20 @@
                         lightView.SetDeviceImage(device.IconPath, device.OnlineIconPath);
                         lightView.SetStatuText(device.GetDeviceStatu());
                         lightView.SetDeviceName(device.CommonDevice.DeviceEpointName);
-                        //lightView.SetStatu(true);
-                        lightView.IsSelected = true;
+                        lightView.CanControl(false);
+                        lightView.IsSelected = device.CommonDevice.IsOnline == 1;
                         lightView.SetCollect(Room.CurrentRoom.IsCollectInRoom(Room.CurrentRoom, device.FileName));
+
+                        var dev = Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
+                        if (dev == null)
+                        {
+                            lightView.CollectButton.IsSelected = false;
+                        }
+                        else
+                        {
+                            lightView.CollectButton.IsSelected = true;
+                        }
+                        lightView.CollectButton.MouseUpEventHandler += collectionEvent;
                     }
                 }
             }

--
Gitblit v1.8.0