gxc
2019-11-15 05ce435c3b58e53eeab04c672affdeeab75f3036
ZigbeeApp/Shared/Phone/UserView/UserHomeView.cs
old mode 100755 new mode 100644
@@ -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,实际温度为“LocalTemperature / 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:
                                                //此属性表明此设备当前的制冷温度,实际温度为“CoolingSetpoint / 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:
                                                //此属性表明此设备当前的制热温度,实际温度为“HeatingSetpoint / 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:
                                                //此属性表明此设备当前的自动温度,实际温度为“AutoSetpoint / 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;
                    }
                }
            }