From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期五, 28 二月 2020 15:25:13 +0800 Subject: [PATCH] 2020.2.28 --- ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs | 280 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 226 insertions(+), 54 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs old mode 100755 new mode 100644 index 681e7eb..fbeff98 --- a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs +++ b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs @@ -1,6 +1,7 @@ 锘縰sing System; using Shared.Common; using Shared.Phone.Device.CommonForm; +using Shared.Phone.Device.DeviceLogic; using Shared.Phone.UserView; using ZigBee.Device; @@ -12,7 +13,7 @@ /// <summary> /// The action. /// </summary> - public Action action; + public Action<DeviceUI,Common.Room> action; /// <summary> /// 鏀惰棌鎸夐挳 @@ -65,6 +66,33 @@ /// StopBtn /// </summary> public Button StopBtn; + /// <summary> + /// 寮�鍚堝笜 + /// </summary> + private CurtainSeekBar curtainSeekBar = new CurtainSeekBar { }; + /// <summary> + /// 鍗峰笜 + /// </summary> + private CurtainRollSeekBar curtainRollSeekBar = new CurtainRollSeekBar { }; + + /// <summary> + /// IsDrawerLockMode + /// </summary> + public bool IsDrawerLockMode; + + /// <summary> + /// ProgressBtn + /// </summary> + Button ProgressBtn; + /// <summary> + /// ProgressBtnY + /// </summary> + int ProgressBtnY; + /// <summary> + /// ProgressBtnX + /// </summary> + int ProgressBtnX; + #endregion #region 鈼� 鎺ュ彛___________________________ @@ -115,8 +143,14 @@ rollerShade.DeviceStatusReport = common.DeviceStatusReport; rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData; StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}"; - //SeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage; - //seekBarTitle.Text = $"{SeekBar.Progress} %"; + if(rollerShade.WcdType==0) + { + curtainRollSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage; + } + else if(rollerShade.WcdType==4) + { + curtainSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage; + } rollerShade.LastDateTime = DateTime.Now; } else if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0) @@ -184,8 +218,8 @@ /// Changeds the IS cene status. /// </summary> /// <param name="scene">Scene.</param> - public void ChangedISceneStatus(Scene scene) - { + public void ChangedISceneStatus(Scene scene) + { //throw new NotImplementedException(); } #endregion @@ -212,9 +246,13 @@ { UserView.HomePage.Instance.ScrollEnabled = true; ZigBee.Device.ZbGateway.StatusList.Remove(this); - //action(); - //action = null; + action(device,room); + action = null; RemoveUpdateControlDeviceStatuAction(); + if (IsDrawerLockMode) + { + CommonPage.Instance.IsDrawerLockMode = false; + } base.RemoveFromParent(); } @@ -248,8 +286,7 @@ { UserHomeView.ReadStatus(rollerShade, () => { - rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); - rollerShade.ReadWcdCurrentPositionLiftPercentage(); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); }); } else @@ -257,13 +294,11 @@ //闃叉鐭椂闂村唴澶氭璇诲彇 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan) { - rollerShade.ReadWcdCurrentPositionLiftPercentage(); - rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch); + ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice); } } - var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName); - if (de == null) + if (Common.Room.CurrentRoom.IsCollectInRoom(device.FileName) == false) { collectionBtn.IsSelected = false; } @@ -294,15 +329,6 @@ 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 { @@ -358,9 +384,10 @@ Width = Application.GetRealWidth(500), Height = Application.GetRealHeight(60), Gravity = Gravity.CenterHorizontal, - Text = device.CommonDevice.DeviceEpointName, + Text = Common.LocalDevice.Current.GetDeviceEpointName(device.CommonDevice), TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextSize = 15 + TextSize = 15, + IsBold=true }; itemView.AddChidren(deviceNameBtn); @@ -371,7 +398,8 @@ 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)} {device.GetDeviceStatu()}", + TextSize = 10 }; itemView.AddChidren(StatuBtn); @@ -386,7 +414,7 @@ itemView.AddChidren(OpenOrUpBtn); OpenOrUpBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0); + (device.CommonDevice as Rollershade).CurtainUpDownStopControl(0); }; StopBtn = new Button @@ -401,7 +429,7 @@ itemView.AddChidren(StopBtn); StopBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2); + (device.CommonDevice as Rollershade).CurtainUpDownStopControl(2); }; CloseOrDownBtn = new Button @@ -414,10 +442,9 @@ itemView.AddChidren(CloseOrDownBtn); CloseOrDownBtn.MouseUpEventHandler += (sender, e) => { - (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1); + (device.CommonDevice as Rollershade).CurtainUpDownStopControl(1); }; - SetRollerShadeIcon((device.CommonDevice as Rollershade).WcdType); if ((device.CommonDevice as Rollershade).WcdType == -1) { CommonPage.Loading.Start(); @@ -434,6 +461,9 @@ }) { IsBackground = true }.Start(); } + + SetCurtainType(itemView, (device.CommonDevice as Rollershade).WcdType); + var roomBG = new Button { Y = Application.GetRealHeight(1178 - 50), @@ -469,7 +499,8 @@ Height = Application.GetRealHeight(50), Text = room.Name, TextAlignment = TextAlignment.CenterLeft, - TextColor = ZigbeeColor.Current.GXCTextWhiteColor + TextColor = ZigbeeColor.Current.GXCTextWhiteColor, + TextSize = 12 }; itemView.AddChidren(roomName); } @@ -486,28 +517,12 @@ //upBtn.MouseUpEventHandler += Up; //stopBtn.MouseUpEventHandler += Stop; //downBtn.MouseUpEventHandler += Down; - //SeekBar.ProgressChanged += SeekBar_ProgressChange; - //collectionBtn.MouseUpEventHandler += Collection; - //moreBtn.MouseUpEventHandler += More; - //roomBtn.MouseUpEventHandler += BackToRoomHandler; - //roomName.MouseUpEventHandler += BackToRoomHandler; + collectionBtn.MouseUpEventHandler += Collection; } #endregion - #region 鈼� 鎺у埗___________________________ - - /// <summary> - /// 婊戞潯绉诲姩鍙戦�佸懡浠� - /// </summary> - /// <param name="sender">Sender.</param> - /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> - private void SeekBar_ProgressChange(object sender, int mouseEventArgs) - { - //seekBarTitle.Text = $"{SeekBar.Progress}%"; - //(device.CommonDevice as ZigBee.Device.Rollershade).WcdGoToTiltValue(SeekBar.Progress); - } - + #region 鈼� 鎺у埗__________________________ /// <summary> /// 涓娿�佸紑 @@ -638,10 +653,21 @@ 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); }; + } + + /// <summary> + /// SetCurtainType + /// </summary> + /// <param name="layout"></param> + /// <param name="type"></param> + private void SetCurtainType(FrameLayout layout, int type) + { + SetRollerShadeIcon(type); + SetRollerSeekBar(layout, type); } /// <summary> @@ -649,7 +675,7 @@ /// WcdType=0锛氬嵎甯� /// </summary> /// <param name="type"></param> - public void SetRollerShadeIcon(int type) + private void SetRollerShadeIcon(int type) { if (type == 0) { @@ -669,6 +695,153 @@ } } + /// <summary> + /// SetRollerSeekBar + /// </summary> + /// <param name="layout"></param> + /// <param name="type"></param> + private void SetRollerSeekBar(FrameLayout layout,int type) + { + if(type == 0) + { + curtainRollSeekBar.Y = Application.GetRealHeight(300); + curtainRollSeekBar.Width = Application.GetRealWidth(438); + curtainRollSeekBar.Height = Application.GetRealHeight(576); + curtainRollSeekBar.Gravity = Gravity.CenterHorizontal; + curtainRollSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage; + layout.AddChidren(curtainRollSeekBar); + curtainRollSeekBar.IsProgressTextShow = false; + curtainRollSeekBar.CurtainPaddingTop = Application.GetRealHeight(110); + curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) => + { + (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress); + }; + + curtainRollSeekBar.OnStartTrackingTouchEvent += (sender, e) => + { + OnProgressButtonMove(curtainRollSeekBar.Progress); + ProgressBtn.Visible = true; + }; + + curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) => + { + ProgressBtn.Visible = false; + }; + + curtainRollSeekBar.OnProgressChangedEvent += (send2, e2) => + { + + OnProgressButtonMove(e2); + + //鍒ゆ柇鏄惁300ms灞忚斀 + //if (curtainRollSeekBar.IsProgressChangeDelay()) return; + + //(device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress); + }; + + InitProgressBtn(layout); + } + else + { + curtainSeekBar.Y = Application.GetRealHeight(334); + curtainSeekBar.Width = Application.GetRealWidth(570); + curtainSeekBar.Height = Application.GetRealHeight(513); + curtainSeekBar.Gravity = Gravity.CenterHorizontal; + curtainSeekBar.IsProgressTextShow = false; + curtainSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage; + layout.AddChidren(curtainSeekBar); + + curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) => + { + (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainSeekBar.Progress); + }; + + curtainSeekBar.OnStartTrackingTouchEvent += (sender, e) => + { + OnProgressButtonMoveForCurtain(curtainSeekBar.Progress); + ProgressBtn.Visible = true; + }; + + curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) => + { + ProgressBtn.Visible = false; + }; + + curtainSeekBar.OnProgressChangedEvent += (send2, e2) => + { + + OnProgressButtonMoveForCurtain(e2); + + //鍒ゆ柇鏄惁300ms灞忚斀 + //if (curtainRollSeekBar.IsProgressChangeDelay()) return; + + //(device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress); + }; + InitProgressBtnForCurtain(layout); + } + } + + /// <summary> + /// 娣诲姞杩涘害鎸夐挳 + /// </summary> + private void InitProgressBtn(FrameLayout layout) + { + ProgressBtnY = curtainRollSeekBar.Y - Application.GetMinReal(204); + ProgressBtn = new Button() + { + Y = ProgressBtnY, + Width = Application.GetMinReal(135), + Height = Application.GetMinReal(104), + UnSelectedImagePath = "Item/ProgressBubbles.png", + Visible = false, + Gravity = Gravity.CenterHorizontal, + TextSize=14, + IsBold=true, + TextColor=ZigbeeColor.Current.GXCTextWhiteColor + }; + layout.AddChidren(ProgressBtn); + } + + /// <summary> + /// OnProgressButtonMove + /// </summary> + private void OnProgressButtonMove(int mProgress) + { + ProgressBtn.Y = ProgressBtnY + curtainRollSeekBar.NowProgressY; + ProgressBtn.Text = mProgress + "%"; + } + + + /// <summary> + /// 娣诲姞杩涘害鎸夐挳 + /// </summary> + private void InitProgressBtnForCurtain(FrameLayout layout) + { + ProgressBtnX = curtainSeekBar.X - Application.GetMinReal(20); + ProgressBtn = new Button() + { + X = ProgressBtnX, + Y = curtainSeekBar.Y + curtainSeekBar.Height / 2 - Application.GetMinReal(180), + Width = Application.GetMinReal(135), + Height = Application.GetMinReal(104), + UnSelectedImagePath = "Item/ProgressBubbles.png", + Visible = false, + TextSize = 14, + IsBold = true, + TextColor = ZigbeeColor.Current.GXCTextWhiteColor + }; + layout.AddChidren(ProgressBtn); + } + + /// <summary> + /// OnProgressButtonMove + /// </summary> + private void OnProgressButtonMoveForCurtain(int mProgress) + { + ProgressBtn.X = ProgressBtnX + curtainSeekBar.NowProgressX- Application.GetMinReal(5); + ProgressBtn.Text = mProgress + "%"; + } + #endregion #region 鈼� 鏀惰棌鍒颁富椤礯______________________ @@ -680,15 +853,14 @@ /// <param name="e">E.</param> private void Collection(object sender, MouseEventArgs e) { - //collection if (collectionBtn.IsSelected) { - Shared.Common.Room.Lists[0].DeleteDevice(device.FileName); + Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(device.FileName); collectionBtn.IsSelected = false; } else { - Shared.Common.Room.Lists[0].AddDevice(device.FileName); + Common.Room.CurrentRoom.GetLoveRoom().AddDevice(device.FileName); collectionBtn.IsSelected = true; } } -- Gitblit v1.8.0