| | |
| | | /// <summary> |
| | | /// The action. |
| | | /// </summary> |
| | | public Action<DeviceUI, Common.Room> action; |
| | | public Action<CommonDevice, Common.Room> action; |
| | | ///// <summary> |
| | | ///// The top view. |
| | | ///// </summary> |
| | |
| | | /// <summary> |
| | | /// 传过来的设备 |
| | | /// </summary> |
| | | private DeviceUI device; |
| | | private CommonDevice device; |
| | | /// <summary> |
| | | /// 传过来的ac |
| | | /// </summary> |
| | |
| | | { |
| | | var deviceUI = device; |
| | | //设备为空 |
| | | if (deviceUI.CommonDevice == null) |
| | | if (deviceUI == null) |
| | | { |
| | | return; |
| | | } |
| | | //是否为当前设备 |
| | | if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr) |
| | | if (deviceUI.DeviceEpoint != common.DeviceEpoint || deviceUI.DeviceAddr != common.DeviceAddr) |
| | | { |
| | | return; |
| | | } |
| | | if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) |
| | | if (deviceUI.Type == DeviceType.DimmableLight) |
| | | { |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as DimmableLight; |
| | | dimmableLight = deviceUI as DimmableLight; |
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport; |
| | | if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0) |
| | | { |
| | |
| | | } |
| | | dimmableLight.OnOffStatus = dimmableLight.DeviceStatusReport.AttriBute[0].AttriButeData; |
| | | switchBtn.IsSelected = dimmableLight.OnOffStatus == 1; |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} {UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | |
| | | if (switchBtn.IsSelected == true) |
| | | { |
| | |
| | | //亮度 |
| | | if (common.DeviceStatusReport.CluterID == 8) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; |
| | | dimmableLight = deviceUI as ZigBee.Device.DimmableLight; |
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport; |
| | | var attriButeList = dimmableLight.DeviceStatusReport.AttriBute; |
| | | if (attriButeList == null || attriButeList.Count == 0) |
| | |
| | | dimmableLight.Level = attriButeList[0].AttriButeData; |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | levelSeekBar.Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100); |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | break; |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="device">Device.</param> |
| | | /// <param name="room">Room.</param> |
| | | public void Show(DeviceUI device, Shared.Common.Room room) |
| | | public void Show(CommonDevice device, Shared.Common.Room room) |
| | | { |
| | | this.device = device; |
| | | this.room = room; |
| | | this.dimmableLight = device.CommonDevice as ZigBee.Device.DimmableLight; |
| | | this.dimmableLight = device as ZigBee.Device.DimmableLight; |
| | | |
| | | //添加topview |
| | | AddTopView(); |
| | |
| | | //发送读取状态命令 |
| | | UserView.UserHomeView.ReadStatus(dimmableLight, () => |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); |
| | | }); |
| | | } |
| | | else |
| | |
| | | //防止短时间内多次读取设备状态 |
| | | if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) |
| | | { |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// <summary> |
| | | /// AddBodyView |
| | | /// </summary> |
| | | public void AddBodyView(DeviceUI device) |
| | | public void AddBodyView(CommonDevice device) |
| | | { |
| | | bodyFrameLayout = new FrameLayout() |
| | | { |
| | |
| | | Width = Application.GetRealWidth(500), |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), |
| | | Text = Common.LocalDevice.Current.GetDeviceEpointName(device), |
| | | TextColor = ZigbeeColor.Current.GXCTextBlackColor, |
| | | TextSize = 15, |
| | | IsBold=true |
| | |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | Text = dimmableLight.Level>0?$"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" :$"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}", |
| | | Text = dimmableLight.Level>0?$"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" :$"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}", |
| | | TextSize=10 |
| | | }; |
| | | |
| | |
| | | Gravity = Gravity.CenterHorizontal, |
| | | UnSelectedImagePath = "Item/Switch.png", |
| | | SelectedImagePath = "Item/SwitchSelected.png", |
| | | IsSelected = (device.CommonDevice as DimmableLight).OnOffStatus == 1 |
| | | IsSelected = (device as DimmableLight).OnOffStatus == 1 |
| | | }; |
| | | itemView.AddChidren(switchBtn); |
| | | |
| | |
| | | private void Switch_MouseUpEvent(object sender, MouseEventArgs eventArgs) |
| | | { |
| | | switchBtn.IsSelected = !switchBtn.IsSelected; |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { device.GetDeviceStatu()}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | StatuBtn.Text = switchBtn.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.CurrentLightLevel)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; |
| | | if (switchBtn.IsSelected == true) |
| | | { |
| | | dimmableLight.SwitchControl(1); |
| | |
| | | /// </summary> |
| | | private void InitCollection() |
| | | { |
| | | if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) |
| | | if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) |
| | | { |
| | | collectionBtn.IsSelected = false; |
| | | } |
| | |
| | | //collection |
| | | if ((sender as Button).IsSelected) |
| | | { |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); |
| | | UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device); |
| | | (sender as Button).IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); |
| | | {
|
| | | UserCenter.HdlRoomLogic.Current.AddLoveDevice(device); |
| | | (sender as Button).IsSelected = true; |
| | | } |
| | | } |