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/DimmableLightControl.cs | 117 ++++++++++++++++++++++------------------------------------ 1 files changed, 45 insertions(+), 72 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs b/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs index dc7d547..ce0324d 100755 --- a/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Light/DimmableLightControl.cs @@ -13,7 +13,7 @@ /// <summary> /// The action. /// </summary> - public Action action; + public Action<CommonDevice, Common.Room> action; ///// <summary> ///// The top view. ///// </summary> @@ -21,7 +21,7 @@ /// <summary> /// 浼犺繃鏉ョ殑璁惧 /// </summary> - private DeviceUI device; + private CommonDevice device; /// <summary> /// 浼犺繃鏉ョ殑ac /// </summary> @@ -38,7 +38,7 @@ /// 鏀惰棌鎸夐挳 /// </summary> private Button collectionBtn; - + /// <summary> /// 寮�鍏� /// </summary> @@ -47,7 +47,7 @@ /// 婊戞潯 /// </summary> private WaveSeekBar levelSeekBar; - + private Button StatuBtn; /// <summary> @@ -79,31 +79,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> @@ -124,49 +100,45 @@ { 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) { return; } 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) { levelSeekBar.IsClickable = true; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; - //levelSeekBar.Progress = 100; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); } else { levelSeekBar.IsClickable = false; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; - //levelSeekBar.Progress = 0; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } - //change color dimmableLight.LastDateTime = DateTime.Now; } //浜害 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) @@ -180,12 +152,11 @@ 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; } } - + } } catch (Exception ex) @@ -196,7 +167,7 @@ } else if (typeTag == "OnlineStatusChange") { - + } } @@ -211,8 +182,8 @@ { ZbGateway.StatusList.Remove(this); UserView.HomePage.Instance.ScrollEnabled = true; - //action(); - //action = null; + action(device, room); + action = null; if (IsDrawerLockMode) { CommonPage.Instance.IsDrawerLockMode = false; @@ -241,11 +212,11 @@ /// </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(); @@ -261,7 +232,7 @@ //鍙戦�佽鍙栫姸鎬佸懡浠� UserView.UserHomeView.ReadStatus(dimmableLight, () => { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); }); } else @@ -269,7 +240,7 @@ //闃叉鐭椂闂村唴澶氭璇诲彇璁惧鐘舵�� if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); + ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device); } } } @@ -314,9 +285,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); }; } @@ -327,7 +298,7 @@ /// <summary> /// AddBodyView /// </summary> - public void AddBodyView(DeviceUI device) + public void AddBodyView(CommonDevice device) { bodyFrameLayout = new FrameLayout() { @@ -376,7 +347,7 @@ 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, IsBold=true @@ -390,7 +361,7 @@ 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 }; @@ -405,7 +376,7 @@ WavePadding = Application.GetRealWidth(8), MaxValue=100, Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100), - WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor, + CornerRadius= Application.GetRealHeight(58) }; @@ -414,12 +385,12 @@ if (dimmableLight.OnOffStatus == 1) { levelSeekBar.IsClickable = true; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); } else { levelSeekBar.IsClickable = false; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } levelSeekBar.OnStartTrackingTouchEvent += (sender, e) => @@ -433,6 +404,7 @@ { ProgressBtn.Visible = false; levelSeekBar.IsProgressTextShow = true; + dimmableLight.SetLevel((int)(levelSeekBar.Progress * MaxLevel / 100.0)); }; levelSeekBar.OnProgressChangedEvent += (send2, e2) => @@ -441,9 +413,8 @@ OnProgressButtonMove(e2); //鍒ゆ柇鏄惁300ms灞忚斀 - if (levelSeekBar.IsProgressChangeDelay()) return; - - dimmableLight.SetLevel((int)(levelSeekBar.Progress * MaxLevel / 100.0)); + //if (levelSeekBar.IsProgressChangeDelay()) return; + //dimmableLight.SetLevel((int)(levelSeekBar.Progress * MaxLevel / 100.0)); }; InitProgressBtn(itemView); @@ -456,7 +427,7 @@ 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); @@ -523,7 +494,10 @@ Height = Application.GetMinReal(104), UnSelectedImagePath = "Item/ProgressBubbles.png", Visible = false, - Gravity = Gravity.CenterHorizontal + Gravity = Gravity.CenterHorizontal, + TextSize = 14, + IsBold = true, + TextColor = ZigbeeColor.Current.GXCTextWhiteColor }; layout.AddChidren(ProgressBtn); } @@ -552,18 +526,18 @@ 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); levelSeekBar.IsClickable = true; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarColor_Start, ZigbeeColor.Current.GXCWaveSeekBarColor_End); } else { dimmableLight.SwitchControl(0); levelSeekBar.IsClickable = false; - levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; + levelSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor); } } @@ -576,8 +550,7 @@ /// </summary> private void InitCollection() { - var dev = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); - if (dev == null) + if (UserCenter.HdlRoomLogic.Current.IsCollectInRoom(device) == false) { collectionBtn.IsSelected = false; } @@ -596,12 +569,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; } } -- Gitblit v1.8.0