From c47c3ec2488961b3a006aaebcb03dba582f8b19b Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 12 三月 2020 17:08:42 +0800 Subject: [PATCH] 2020-03-12-1 --- ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs | 92 +++++++++++++++++++++++++-------------------- 1 files changed, 51 insertions(+), 41 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs index 790e4e2..b08c627 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/LightControl.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using Shared.Common; using Shared.Phone.Device.CommonForm; +using Shared.Phone.Device.DeviceLogic; using Shared.Phone.UserView; using ZigBee.Device; namespace Shared.Phone.Device.Light @@ -19,7 +20,7 @@ /// <summary> /// The action. /// </summary> - public Action action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -32,7 +33,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -114,20 +115,20 @@ { 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.OnOffOutput) + if (deviceUI.Type == DeviceType.OnOffOutput) { if (common.DeviceStatusReport.CluterID == 6) { - var light = deviceUI.CommonDevice as ToggleLight; + var light = deviceUI as ToggleLight; light.DeviceStatusReport = common.DeviceStatusReport; //璁板綍銆佹洿鏂扮姸鎬� if (light.DeviceStatusReport.AttriBute == null || light.DeviceStatusReport.AttriBute.Count == 0) @@ -136,7 +137,7 @@ } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; - StatuBtn.Text = CommonFormResouce.GetSwitchStatu(deviceIMG.IsSelected); + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); light.LastDateTime = DateTime.Now; } } @@ -155,18 +156,17 @@ { 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; } - deviceUI.CommonDevice.IsOnline = common.IsOnline; - deviceIMG.IsSelected = switchBtn.IsSelected = deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.IsOnline = common.IsOnline; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -184,8 +184,8 @@ public override void RemoveFromParent() { ZbGateway.StatusList.Remove(this); - //action(); - //action = null; + action(device, room); + action = null; if (IsDrawerLockMode) { CommonPage.Instance.IsDrawerLockMode = false; @@ -207,10 +207,10 @@ /// </summary> /// <param name="dev">Device.</param> /// <param name="room">Room.</param> - public void Show(DeviceUI dev,Shared.Common.Room room) + public void Show(CommonDevice dev,Shared.Common.Room room) { device = dev; - zbGateway = this.device.CommonDevice.Gateway; + zbGateway = this.device.Gateway; this.room = room; AddTop(); @@ -218,7 +218,7 @@ AddBodyView(device); - var light = dev.CommonDevice as ToggleLight; + var light = dev as ToggleLight; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -228,8 +228,7 @@ { UserHomeView.ReadStatus(light, () => { - light.ReadOnOffStatus(); - light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -237,13 +236,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - light.ReadOnOffStatus(); - light.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); - if (de == null) + if(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -291,7 +288,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -329,9 +326,10 @@ Width=Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = device.CommonDevice.DeviceEpointName, + Text = Common.LocalDevice.Current.GetDeviceEpointName(device), TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextSize=15 + TextSize=15, + IsBold=true }; itemView.AddChidren(deviceNameBtn); @@ -342,9 +340,11 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text=CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline==1) + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), + TextSize = 10 }; itemView.AddChidren(StatuBtn); + deviceIMG = new Button() { @@ -354,7 +354,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/DeskLamp.png", SelectedImagePath = "Light/DeskLampSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -366,7 +366,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Item/Switch.png", SelectedImagePath = "Item/SwitchSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(switchBtn); @@ -405,7 +405,8 @@ Height = Application.GetRealHeight(50), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, - TextColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextWhiteColor, + TextSize=12 }; itemView.AddChidren(roomName); } @@ -438,17 +439,26 @@ zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = CommonFormResouce.GetSwitchStatu(deviceIMG.IsSelected); + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); + } + else + { + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } + if (switchBtn.IsSelected == true) { - (device.CommonDevice as ToggleLight).SwitchControl(1); + (device as ToggleLight).SwitchControl(1); } else { - (device.CommonDevice as ToggleLight).SwitchControl(0); + (device as ToggleLight).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if(Parent==null) { @@ -457,7 +467,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand==false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -478,9 +488,9 @@ UserView.HomePage.Instance.AddChidren(detailInfo); UserView.HomePage.Instance.PageIndex += 1; detailInfo.Show(device, room); - detailInfo.action = () => + detailInfo.EditAction += (curDev, curRoom) => { - Show(device, room); + Show(curDev, curRoom); }; } @@ -497,12 +507,12 @@ //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; } } @@ -527,7 +537,7 @@ return; } var tempDevice = (CommonDevice)objValue; - if (tempDevice.DeviceEpoint != this.device.CommonDevice.DeviceEpoint || tempDevice.DeviceAddr != this.device.CommonDevice.DeviceAddr) + if (tempDevice.DeviceEpoint != this.device.DeviceEpoint || tempDevice.DeviceAddr != this.device.DeviceAddr) { //涓嶆槸褰撳墠璁惧鐨勬帹閫侊紝鍒欎笉澶勭悊 return; -- Gitblit v1.8.0