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/Curtain/RollerShadeControl.cs |  242 ++++++++++++++++++++++++++++++++++-------------
 1 files changed, 173 insertions(+), 69 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs
index efbd1ec..ff4d23b 100755
--- 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<CommonDevice, Common.Room> action;
 
         /// <summary>
         /// 鏀惰棌鎸夐挳
@@ -21,7 +22,7 @@
         /// <summary>
         /// 浼犺繃鏉ョ殑璁惧
         /// </summary>
-        private DeviceUI device;
+        private CommonDevice device;
         /// <summary>
         /// 浼犺繃鏉ョ殑鎴块棿
         /// </summary>
@@ -79,6 +80,19 @@
         /// </summary>
         public bool IsDrawerLockMode;
 
+        /// <summary>
+        /// ProgressBtn
+        /// </summary>
+        Button ProgressBtn;
+        /// <summary>
+        /// ProgressBtnY
+        /// </summary>
+        int ProgressBtnY;
+        /// <summary>
+        /// ProgressBtnX
+        /// </summary>
+        int ProgressBtnX;
+
         #endregion
 
         #region 鈼� 鎺ュ彛___________________________
@@ -111,12 +125,12 @@
                     {
                         var deviceUI = this.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;
                         }
@@ -125,10 +139,10 @@
                             if (common.DeviceStatusReport.AttriBute[0].AttributeId == 8)
                             {
                                 //绐楀笜鐧惧垎姣�
-                                var rollerShade = deviceUI.CommonDevice as Rollershade;
+                                var rollerShade = deviceUI as Rollershade;
                                 rollerShade.DeviceStatusReport = common.DeviceStatusReport;
                                 rollerShade.WcdCurrentPositionLiftPercentage = common.DeviceStatusReport.AttriBute[0].AttriButeData;
-                                StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { deviceUI.GetDeviceStatu()}";
+                                StatuBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.Current)} { UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(deviceUI)}";
                                 if(rollerShade.WcdType==0)
                                 {
                                     curtainRollSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage;
@@ -137,14 +151,12 @@
                                 {
                                     curtainSeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage;
                                 }
-                                //SeekBar.Progress = rollerShade.WcdCurrentPositionLiftPercentage;
-                                //seekBarTitle.Text = $"{SeekBar.Progress} %";
                                 rollerShade.LastDateTime = DateTime.Now;
                             }
                             else if (common.DeviceStatusReport.AttriBute[0].AttributeId == 0)
                             {
                                 ////绐楀笜绫诲瀷
-                                var rollerShade = device.CommonDevice as Rollershade;
+                                var rollerShade = device as Rollershade;
                                 rollerShade.DeviceStatusReport = common.DeviceStatusReport;
                                 rollerShade.WcdType = common.DeviceStatusReport.AttriBute[0].AttriButeData;
                                 rollerShade.LastDateTime = DateTime.Now;
@@ -234,8 +246,8 @@
         {
             UserView.HomePage.Instance.ScrollEnabled = true;
             ZigBee.Device.ZbGateway.StatusList.Remove(this);
-            //action();
-            //action = null;
+            action(device,room);
+            action = null;
             RemoveUpdateControlDeviceStatuAction();
             if (IsDrawerLockMode)
             {
@@ -253,10 +265,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();
@@ -264,7 +276,7 @@
             AddBodyView(device);
 
 
-            var rollerShade = device.CommonDevice as ZigBee.Device.Rollershade;
+            var rollerShade = device as ZigBee.Device.Rollershade;
             //涓嶄笂闈炶繙绋�
             if (rollerShade.Gateway == null)
             {
@@ -274,8 +286,7 @@
             {
                 UserHomeView.ReadStatus(rollerShade, () =>
                 {
-                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
+                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device);
                 });
             }
             else
@@ -283,13 +294,11 @@
                 //闃叉鐭椂闂村唴澶氭璇诲彇
                 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                 {
-                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
-                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(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;
             }
@@ -337,7 +346,7 @@
         /// <summary>
         /// AddBodyView
         /// </summary>
-        public void AddBodyView(DeviceUI device)
+        public void AddBodyView(CommonDevice device)
         {
             bodyFrameLayout = new FrameLayout()
             {
@@ -375,9 +384,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);
 
@@ -388,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)} {UserCenter.HdlDeviceOtherLogic.Current.GetDeviceStatu(device)}",
+                TextSize = 10
             };
             itemView.AddChidren(StatuBtn);
 
@@ -403,7 +414,7 @@
             itemView.AddChidren(OpenOrUpBtn);
             OpenOrUpBtn.MouseUpEventHandler += (sender, e) =>
             {
-                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(0);
+                (device as Rollershade).CurtainUpDownStopControl(0);
             };
 
             StopBtn = new Button
@@ -418,7 +429,7 @@
             itemView.AddChidren(StopBtn);
             StopBtn.MouseUpEventHandler += (sender, e) =>
             {
-                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(2);
+                (device as Rollershade).CurtainUpDownStopControl(2);
             };
 
             CloseOrDownBtn = new Button
@@ -431,19 +442,19 @@
             itemView.AddChidren(CloseOrDownBtn);
             CloseOrDownBtn.MouseUpEventHandler += (sender, e) =>
             {
-                (device.CommonDevice as Rollershade).CurtainUpDownStopControl(1);
+                (device as Rollershade).CurtainUpDownStopControl(1);
             };
 
-            if ((device.CommonDevice as Rollershade).WcdType == -1)
+            if ((device as Rollershade).WcdType == -1)
             {
                 CommonPage.Loading.Start();
                 new System.Threading.Thread(() =>
                 {
-                    Rollershade.ReadWcdTypeAction(device.CommonDevice, () =>
+                    Rollershade.ReadWcdTypeAction(device, () =>
                     {
                         Application.RunOnMainThread(() =>
                         {
-                            SetRollerShadeIcon((device.CommonDevice as Rollershade).WcdType);
+                            SetRollerShadeIcon((device as Rollershade).WcdType);
                             CommonPage.Loading.Hide();
                         });
                     });
@@ -451,8 +462,8 @@
                 { IsBackground = true }.Start();
             }
 
-            SetCurtainType(itemView, (device.CommonDevice as Rollershade).WcdType);
-            
+            SetCurtainType(itemView, (device as Rollershade).WcdType);
+
             var roomBG = new Button
             {
                 Y = Application.GetRealHeight(1178 - 50),
@@ -488,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);
         }
@@ -505,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>
         /// 涓娿�佸紑
@@ -537,9 +533,9 @@
         {
             sendedControlCommand = false;
             zbGateway.ReportAction += UpdateDeviceControllStatu;
-            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0);
+            (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0);
             //鎺у埗寤舵椂鍥炶皟
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -548,7 +544,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -562,9 +558,9 @@
         {
             sendedControlCommand = false;
             zbGateway.ReportAction += UpdateDeviceControllStatu;
-            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1);
+            (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1);
             //鎺у埗寤舵椂鍥炶皟
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -573,7 +569,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -587,9 +583,9 @@
         {
             sendedControlCommand = false;
             zbGateway.ReportAction += UpdateDeviceControllStatu;
-            (device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2);
+            (device as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2);
             //鎺у埗寤舵椂鍥炶皟
-            DeviceUI.SendCommandDelayAction(device.CommonDevice, () =>
+            UserCenter.HdlDeviceOtherLogic.Current.SendCommandDelayAction(device, () =>
             {
                 if (Parent == null)
                 {
@@ -598,7 +594,7 @@
                 RemoveUpdateControlDeviceStatuAction();
                 if (sendedControlCommand == false)
                 {
-                    DeviceUI.ShowStatuTip(R.MyInternationalizationString.FAIL);
+                    UserCenter.HdlDeviceOtherLogic.Current.ShowStatuTip(R.MyInternationalizationString.FAIL);
                 }
             });
         }
@@ -619,7 +615,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;
@@ -657,9 +653,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);
             };
         }
 
@@ -712,13 +708,38 @@
                 curtainRollSeekBar.Width = Application.GetRealWidth(438);
                 curtainRollSeekBar.Height = Application.GetRealHeight(576);
                 curtainRollSeekBar.Gravity = Gravity.CenterHorizontal;
-                curtainRollSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage;
+                curtainRollSeekBar.Progress = (device as Rollershade).WcdCurrentPositionLiftPercentage;
                 layout.AddChidren(curtainRollSeekBar);
+                curtainRollSeekBar.IsProgressTextShow = false;
+                curtainRollSeekBar.CurtainPaddingTop = Application.GetRealHeight(110);
+                curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
+                {
+                    (device as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
+                };
+
+                curtainRollSeekBar.OnStartTrackingTouchEvent += (sender, e) =>
+                {
+                    OnProgressButtonMove(curtainRollSeekBar.Progress);
+                    ProgressBtn.Visible = true;
+                };
 
                 curtainRollSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
                 {
-                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
+                    ProgressBtn.Visible = false;
                 };
+
+                curtainRollSeekBar.OnProgressChangedEvent += (send2, e2) =>
+                {
+
+                    OnProgressButtonMove(e2);
+
+                    //鍒ゆ柇鏄惁300ms灞忚斀
+                    //if (curtainRollSeekBar.IsProgressChangeDelay()) return;
+
+                    //(device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
+                };
+
+                InitProgressBtn(layout);
             }
             else
             {
@@ -726,16 +747,100 @@
                 curtainSeekBar.Width = Application.GetRealWidth(570);
                 curtainSeekBar.Height = Application.GetRealHeight(513);
                 curtainSeekBar.Gravity = Gravity.CenterHorizontal;
+                curtainSeekBar.IsProgressTextShow = false;
+                curtainSeekBar.Progress = (device as Rollershade).WcdCurrentPositionLiftPercentage;
                 layout.AddChidren(curtainSeekBar);
 
                 curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
                 {
-                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
+                    (device 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
 
@@ -748,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);
+                UserCenter.HdlRoomLogic.Current.DeleteLoveDevice(device);
                 collectionBtn.IsSelected = false;
             }
             else
             {
-                Shared.Common.Room.Lists[0].AddDevice(device.FileName);
+                UserCenter.HdlRoomLogic.Current.AddLoveDevice(device);
                 collectionBtn.IsSelected = true;
             }
         }

--
Gitblit v1.8.0