| | |
| | | using System; |
| | | using Shared.Common; |
| | | using Shared.Phone.Device.CommonForm; |
| | | using Shared.Phone.Device.DeviceLogic; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.Device.Light |
| | |
| | | /// MaxLevel |
| | | /// </summary> |
| | | private const int MaxLevel = 254; |
| | | |
| | | /// <summary> |
| | | /// IsDrawerLockMode |
| | | /// </summary> |
| | | public bool IsDrawerLockMode; |
| | | /// <summary> |
| | | /// ProgressBtn |
| | | /// </summary> |
| | | Button ProgressBtn; |
| | | /// <summary> |
| | | /// ProgressBtnY |
| | | /// </summary> |
| | | int ProgressBtnY; |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 接口__________________________ |
| | |
| | | } |
| | | if (deviceUI.CommonDevice.Type == DeviceType.DimmableLight) |
| | | { |
| | | if ((common as DimmableLight).DeviceStatusReport.CluterID == 6) |
| | | if (common.DeviceStatusReport.CluterID == 6) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as DimmableLight; |
| | | dimmableLight.DeviceStatusReport = (common as DimmableLight).DeviceStatusReport; |
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport; |
| | | //记录、更新状态 |
| | | if (dimmableLight.DeviceStatusReport.AttriBute == null || dimmableLight.DeviceStatusReport.AttriBute.Count == 0) |
| | | { |
| | |
| | | { |
| | | levelSeekBar.IsClickable = true; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; |
| | | //levelSeekBar.Progress = 100; |
| | | } |
| | | else |
| | | { |
| | | levelSeekBar.IsClickable = false; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; |
| | | //levelSeekBar.Progress = 0; |
| | | } |
| | | //change color |
| | | dimmableLight.LastDateTime = DateTime.Now; |
| | | } |
| | | //亮度 |
| | | if ((common as ZigBee.Device.DimmableLight).DeviceStatusReport.CluterID == 8) |
| | | if (common.DeviceStatusReport.CluterID == 8) |
| | | { |
| | | dimmableLight = deviceUI.CommonDevice as ZigBee.Device.DimmableLight; |
| | | dimmableLight.DeviceStatusReport = (common as ZigBee.Device.DimmableLight).DeviceStatusReport; |
| | | dimmableLight.DeviceStatusReport = common.DeviceStatusReport; |
| | | var attriButeList = dimmableLight.DeviceStatusReport.AttriBute; |
| | | if (attriButeList == null || attriButeList.Count == 0) |
| | | { |
| | |
| | | { |
| | | ZbGateway.StatusList.Remove(this); |
| | | UserView.HomePage.Instance.ScrollEnabled = true; |
| | | action(); |
| | | action = null; |
| | | //action(); |
| | | //action = null; |
| | | if (IsDrawerLockMode) |
| | | { |
| | | CommonPage.Instance.IsDrawerLockMode = false; |
| | | } |
| | | base.RemoveFromParent(); |
| | | } |
| | | |
| | |
| | | /// </summary> |
| | | public DimmableLightControl() |
| | | { |
| | | UserView.HomePage.Instance.ScrollEnabled = false; |
| | | BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor; |
| | | ZbGateway.StatusList.Add(this); |
| | | } |
| | |
| | | //发送读取状态命令 |
| | | UserView.UserHomeView.ReadStatus(dimmableLight, () => |
| | | { |
| | | dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); |
| | | dimmableLight.ReadOnOffStatus(); |
| | | dimmableLight.ReadLevel(); |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); |
| | | }); |
| | | } |
| | | else |
| | |
| | | //防止短时间内多次读取设备状态 |
| | | if ((DateTime.Now - dimmableLight.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) |
| | | { |
| | | dimmableLight.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); |
| | | dimmableLight.ReadOnOffStatus(); |
| | | dimmableLight.ReadLevel(); |
| | | ReadDeviceAttributeLogic.Instance.SendDimmableLightStatuComand(device.CommonDevice); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | |
| | | var sharedBtn = new Button |
| | | { |
| | | X = Application.GetRealWidth(850), |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | Gravity = Gravity.CenterVertical, |
| | | UnSelectedImagePath = "Item/Shared.png" |
| | | }; |
| | | top.topView.AddChidren(sharedBtn); |
| | | |
| | | var moreBtn = new Button |
| | | { |
| | |
| | | Height = Application.GetRealHeight(60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | TextColor = ZigbeeColor.Current.GXCTextGrayColor, |
| | | Text = CommonFormResouce.GetSwitchStatu(device.CommonDevice.IsOnline == 1) |
| | | Text = CommonFormResouce.GetSwitchStatu((device.CommonDevice as DimmableLight).OnOffStatus == 1) |
| | | }; |
| | | itemView.AddChidren(StatuBtn); |
| | | |
| | |
| | | Width = Application.GetRealWidth(271), |
| | | Height = Application.GetRealHeight(533), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | WavePadding = 2, |
| | | WavePadding = Application.GetRealWidth(8), |
| | | MaxValue=100, |
| | | Progress = (int)(dimmableLight.Level*1.0/MaxLevel*100), |
| | | WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor |
| | | }; |
| | | itemView.AddChidren(levelSeekBar); |
| | | |
| | | if (dimmableLight.OnOffStatus==1) |
| | | if (dimmableLight.OnOffStatus == 1) |
| | | { |
| | | levelSeekBar.IsClickable = true; |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarColor; |
| | |
| | | levelSeekBar.WaveColor = ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor; |
| | | } |
| | | |
| | | levelSeekBar.OnProgressChangedEvent += (send2, e2) => |
| | | levelSeekBar.OnStartTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | OnProgressButtonMove(levelSeekBar.Progress);
|
| | | ProgressBtn.Visible = true;
|
| | | };
|
| | |
|
| | | levelSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
|
| | | {
|
| | | ProgressBtn.Visible = false;
|
| | | };
|
| | |
|
| | | levelSeekBar.OnProgressChangedEvent += (send2, e2) =>
|
| | | { |
| | | dimmableLight.SetLevel((int)(levelSeekBar.Progress*MaxLevel/100.0)); |
| | | }; |
| | | |
| | | OnProgressButtonMove(e2);
|
| | |
|
| | | //判断是否300ms屏蔽
|
| | | if (levelSeekBar.IsProgressChangeDelay()) return;
|
| | |
|
| | | dimmableLight.SetLevel((int)(levelSeekBar.Progress * MaxLevel / 100.0));
|
| | | };
|
| | |
|
| | | InitProgressBtn(itemView); |
| | | |
| | | switchBtn = new Button() |
| | | { |
| | |
| | | TextColor = ZigbeeColor.Current.GXCTextWhiteColor |
| | | }; |
| | | itemView.AddChidren(roomName); |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// OnProgressButtonMove
|
| | | /// </summary>
|
| | | private void OnProgressButtonMove(int mProgress)
|
| | | {
|
| | | ProgressBtn.Y = ProgressBtnY + levelSeekBar.NowProgressY;
|
| | | ProgressBtn.Text = mProgress + "%";
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加进度按钮
|
| | | /// </summary>
|
| | | private void InitProgressBtn(FrameLayout layout) |
| | | {
|
| | | ProgressBtnY = levelSeekBar.Y - Application.GetMinReal(154);
|
| | | ProgressBtn = new Button()
|
| | | {
|
| | | Y = ProgressBtnY,
|
| | | Width = Application.GetMinReal(135),
|
| | | Height = Application.GetMinReal(104),
|
| | | UnSelectedImagePath = "Item/ProgressBubbles.png",
|
| | | Visible = false,
|
| | | Gravity = Gravity.CenterHorizontal
|
| | | };
|
| | | layout.AddChidren(ProgressBtn);
|
| | | } |
| | | |
| | | #endregion |
| | |
| | | //collection |
| | | if ((sender as Button).IsSelected) |
| | | { |
| | | Shared.Common.Room.GetLoveRoom().DeleteDevice(device.FileName); |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); |
| | | (sender as Button).IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | Shared.Common.Room.GetLoveRoom().AddDevice(device.FileName); |
| | | Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); |
| | | (sender as Button).IsSelected = true; |
| | | } |
| | | } |