From eb424d24e39bab4a245725f35deab3f234ea0f13 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 13 十二月 2019 10:48:50 +0800
Subject: [PATCH] 2019.12.13

---
 ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs |  131 ++++++++++++++++++++++++++++++-------------
 1 files changed, 90 insertions(+), 41 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs b/ZigbeeApp/Shared/Phone/Device/Curtain/RollerShadeControl.cs
index e7933be..594075f 100644
--- 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;
 
@@ -65,6 +66,20 @@
         /// 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;
+
         #endregion
 
         #region 鈼� 鎺ュ彛___________________________
@@ -115,8 +130,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)
@@ -215,6 +236,10 @@
             //action();
             //action = null;
             RemoveUpdateControlDeviceStatuAction();
+            if (IsDrawerLockMode)
+            {
+                CommonPage.Instance.IsDrawerLockMode = false;
+            }
             base.RemoveFromParent();
         }
 
@@ -248,8 +273,7 @@
             {
                 UserHomeView.ReadStatus(rollerShade, () =>
                 {
-                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
-                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
+                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
                 });
             }
             else
@@ -257,8 +281,7 @@
                 //闃叉鐭椂闂村唴澶氭璇诲彇
                 if ((DateTime.Now - rollerShade.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
                 {
-                    rollerShade.ReadWcdCurrentPositionLiftPercentage();
-                    rollerShade.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
+                    ReadDeviceAttributeLogic.Instance.SendCurtainStatuComand(device.CommonDevice);
                 }
             }
 
@@ -294,15 +317,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
             {
@@ -386,7 +400,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 +415,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 +428,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 +447,9 @@
                 })
                 { IsBackground = true }.Start();
             }
+
+            SetCurtainType(itemView, (device.CommonDevice as Rollershade).WcdType);
+            
             var roomBG = new Button
             {
                 Y = Application.GetRealHeight(1178 - 50),
@@ -486,28 +502,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>
         /// 涓娿�佸紑
@@ -645,11 +645,22 @@
         }
 
         /// <summary>
+        /// SetCurtainType
+        /// </summary>
+        /// <param name="layout"></param>
+        /// <param name="type"></param>
+        private void SetCurtainType(FrameLayout layout, int type)
+        {
+            SetRollerShadeIcon(type);
+            SetRollerSeekBar(layout, type);
+        }
+
+        /// <summary>
         /// WcdType=4锛氬紑鍚堝笜
         /// WcdType=0锛氬嵎甯�
         /// </summary>
         /// <param name="type"></param>
-        public void SetRollerShadeIcon(int type)
+        private void SetRollerShadeIcon(int type)
         {
             if (type == 0)
             {
@@ -669,6 +680,45 @@
             }
         }
 
+        /// <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.OnStopTrackingTouchEvent += (sender, e) =>
+                {
+                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainRollSeekBar.Progress);
+                };
+            }
+            else
+            {
+                curtainSeekBar.Y = Application.GetRealHeight(334);
+                curtainSeekBar.Width = Application.GetRealWidth(570);
+                curtainSeekBar.Height = Application.GetRealHeight(513);
+                curtainSeekBar.Gravity = Gravity.CenterHorizontal;
+                curtainSeekBar.Progress = (device.CommonDevice as Rollershade).WcdCurrentPositionLiftPercentage;
+                layout.AddChidren(curtainSeekBar);
+
+                curtainSeekBar.OnStopTrackingTouchEvent += (sender, e) =>
+                {
+                    (device.CommonDevice as Rollershade).WcdGoToTiltValue(curtainSeekBar.Progress);
+                };
+            }
+        }
+
+
+
         #endregion
 
         #region 鈼� 鏀惰棌鍒颁富椤礯______________________
@@ -680,15 +730,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