From 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 02 四月 2020 13:56:39 +0800 Subject: [PATCH] 2020-04-02-2 --- ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs | 135 ++++++++++++++++++++------------------------- 1 files changed, 60 insertions(+), 75 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs index bbc4894..bb3e05b 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/OnOffControl.cs @@ -20,7 +20,7 @@ /// <summary> /// The action. /// </summary> - public Action<DeviceUI, Common.Room> action; + public Action<CommonDevice, Common.Room> action; /// <summary> /// The light image. @@ -33,7 +33,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑鎴块棿 /// </summary> @@ -78,31 +78,7 @@ #endregion #region 鈼� 鎺ュ彛__________________________ - /// <summary> - /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange() - /// </summary> - /// <returns>The changed.</returns> - /// <param name="common">Common.</param> - public void Changed(CommonDevice common) - { - - } - /// <summary> - /// Changeds the IL ogic status. - /// </summary> - /// <param name="logic">Logic.</param> - public void ChangedILogicStatus(ZigBee.Device.Logic logic) - { - //throw new NotImplementedException(); - } - /// <summary> - /// Changeds the IS cene status. - /// </summary> - /// <param name="scene">Scene.</param> - public void ChangedISceneStatus(Scene scene) - { - //throw new NotImplementedException(); - } + /// <summary> /// 璁惧鐘舵�佹洿鏂版帴鍙� /// <para>type锛氬鏋滀负 DeviceInComingRespon:璁惧鏂颁笂鎶�</para> @@ -123,20 +99,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) @@ -144,13 +120,13 @@ return; } light.OnOffStatus = light.DeviceStatusReport.AttriBute[0].AttriButeData; - StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}"; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device); - if (device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if (device.DfunctionType == DeviceFunctionType.A寮�鍏�) { SetONOFFStatu(light.OnOffStatus == 1); } - else if (device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if (device.DfunctionType == DeviceFunctionType.A鎻掑骇) { deviceIMG.IsSelected = switchBtn.IsSelected = light.OnOffStatus == 1; } @@ -178,18 +154,18 @@ { 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; + deviceUI.IsOnline = common.IsOnline; //OnBtn.IsSelected = OffBtn.IsSelected= deviceUI.CommonDevice.IsOnline == 1; - deviceUI.CommonDevice.LastDateTime = DateTime.Now; + deviceUI.LastDateTime = DateTime.Now; } catch (Exception ex) { @@ -230,10 +206,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(); @@ -241,7 +217,7 @@ AddBodyView(device); - var light = dev.CommonDevice as ToggleLight; + var light = dev as ToggleLight; //琛ヤ笂闈炶繙绋� if (light.Gateway == null) { @@ -251,7 +227,7 @@ { UserHomeView.ReadStatus(light, () => { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); }); } else @@ -259,11 +235,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇鐘舵�� if (CommonPage.ReadDeviceStatuSpan < (DateTime.Now - light.LastDateTime).TotalSeconds) { - ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendLightStatuComand(device); } } - if(Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) + if(UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -310,7 +286,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -348,7 +324,7 @@ 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 @@ -362,7 +338,7 @@ Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, TextColor = ZigbeeColor.Current.GXCTextGrayColor, - Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} {device.GetDeviceStatu()}", + Text = Language.StringByID(R.MyInternationalizationString.Current) + " " + UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device), TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -415,11 +391,11 @@ /// </summary> private void AddByFunctionType(FrameLayout itemView) { - if(device.CommonDevice.DfunctionType == DeviceFunctionType.A寮�鍏�) + if(device.DfunctionType == DeviceFunctionType.A寮�鍏�) { AddOnOff(itemView); } - else if(device.CommonDevice.DfunctionType == DeviceFunctionType.A鎻掑骇) + else if(device.DfunctionType == DeviceFunctionType.A鎻掑骇) { AddPlug(itemView); } @@ -452,7 +428,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/OFF.png", SelectedImagePath = "Light/OFFSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 0 + IsSelected = (device as ToggleLight).OnOffStatus == 0 }; itemView.AddChidren(OffBtn); @@ -464,7 +440,7 @@ Height = Application.GetMinRealAverage(81), UnSelectedImagePath = "Light/ON.png", SelectedImagePath = "Light/ONSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(OnBtn); @@ -486,7 +462,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); @@ -498,7 +474,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); @@ -520,7 +496,7 @@ Gravity = Gravity.CenterHorizontal, UnSelectedImagePath = "Light/Plug.png", SelectedImagePath = "Light/PlugSelected.png", - IsSelected = (device.CommonDevice as ToggleLight).OnOffStatus == 1 + IsSelected = (device as ToggleLight).OnOffStatus == 1 }; itemView.AddChidren(deviceIMG); @@ -532,7 +508,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); @@ -565,19 +541,26 @@ sendedControlCommand = false; zbGateway.ReportAction += UpdateDeviceControllStatu; switchBtn.IsSelected = !switchBtn.IsSelected; - deviceIMG.IsSelected = !deviceIMG.IsSelected; - StatuBtn.Text = deviceIMG.IsSelected ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; - - if (switchBtn.IsSelected == true) + deviceIMG.IsSelected = !deviceIMG.IsSelected; + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; + if (deviceIMG.IsSelected == true) { - (device.CommonDevice as ToggleLight).SwitchControl(1); + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); } else { - (device.CommonDevice as ToggleLight).SwitchControl(0); + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); + } + if (switchBtn.IsSelected == true) + { + (device as ToggleLight).SwitchControl(1); + } + else + { + (device as ToggleLight).SwitchControl(0); } //鎺у埗寤舵椂鍥炶皟 - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -586,7 +569,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -599,10 +582,10 @@ private void ON(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(true); - (device.CommonDevice as ToggleLight).SwitchControl(1); + (device as ToggleLight).SwitchControl(1); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -611,7 +594,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -623,10 +606,10 @@ private void OFF(object sender, MouseEventArgs eventArgs) { SetONOFFStatu(false); - (device.CommonDevice as ToggleLight).SwitchControl(0); + (device as ToggleLight).SwitchControl(0); //鎺у埗寤舵椂鍥炶皟 zbGateway.ReportAction += UpdateDeviceControllStatu; - DeviceUI.SendCommandDelayAction(device.CommonDevice, () => + UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () => { if (Parent == null) { @@ -635,7 +618,7 @@ RemoveUpdateControlDeviceStatuAction(); if (sendedControlCommand == false) { - DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL); + UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL); } }); } @@ -645,18 +628,20 @@ /// </summary> /// <param name="statu"></param> private void SetONOFFStatu(bool statu) - { + { + StatuBtn.Text = Language.StringByID(R.MyInternationalizationString.Current) + " "; if (statu) { OnBtn.IsSelected = true; OffBtn.IsSelected = false; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.uOpen1); } else { OnBtn.IsSelected = false; - OffBtn.IsSelected = true; + OffBtn.IsSelected = true; + StatuBtn.Text += Language.StringByID(R.MyInternationalizationString.Close); } - StatuBtn.Text = statu ? $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Open)}" : $"{Language.StringByID(R.MyInternationalizationString.Current)} {Language.StringByID(R.MyInternationalizationString.Shut)}"; } @@ -693,12 +678,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; } } @@ -723,7 +708,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