From 8407d6631ac8f5b65c4a14fa27babaa48026d4ca Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 30 三月 2023 16:13:40 +0800
Subject: [PATCH] Merge branch 'wjc' into Dev-Branch

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorLockPage.cs |  540 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 540 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorLockPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorLockPage.cs
new file mode 100644
index 0000000..42919c2
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorLockPage.cs
@@ -0,0 +1,540 @@
+锘縰sing Shared;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using HDL_ON.UI.CSS;
+using HDL_ON.Entity;
+using HDL_ON.DriverLayer;
+using HDL_ON.UI.Music;
+using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
+
+namespace HDL_ON.UI
+{
+    /// <summary>
+    /// 瑙嗛闂ㄩ攣鐨勬帶鍒剁晫闈�
+    /// </summary>
+    public class VideoDoorLockPage : FrameLayout
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+        /// <summary>
+        /// 璁惧
+        /// </summary>
+        private Function device;
+        /// <summary>
+        /// 涓婁竴绾х晫闈㈢殑璁惧鍚嶅瓧鎺т欢
+        /// </summary>
+        private Button btnDeviceName;
+        /// <summary>
+        /// 涓婁竴绾х晫闈㈢殑鎴块棿鍚嶅瓧鎺т欢
+        /// </summary>
+        private Button btnRoomName;
+        /// <summary>
+        /// 澶撮儴甯冨眬
+        /// </summary>
+        private TopView topView;
+        /// <summary>
+        /// 褰撳墠璁惧鍚嶇О
+        /// </summary>
+        private Button btnCurrDeviceName;
+        /// <summary>
+        /// 鍖哄煙
+        /// </summary>
+        private Button btnCurrDeviceRoom;
+        /// <summary>
+        /// 鐢甸噺鐖舵帶浠�
+        /// </summary>
+        private FrameLayout cellFrame;
+        /// <summary>
+        /// 鐢甸噺
+        /// </summary>
+        private Button btnCell;
+        /// <summary>
+        /// 鐢甸噺杩涘害鏉�
+        /// </summary>
+        private DiyArcSeekBar cellDiyArcSeekBar;
+        /// <summary>
+        ///鏀惰棌鍥炬爣
+        /// </summary>
+        private Button btnCollectIcon;
+        /// <summary>
+        /// 闂ㄩ攣鐘舵��
+        /// </summary>
+        private Button btnDoorLockIcon;
+        /// <summary>
+        /// 瀹炴椂瑙嗛
+        /// </summary>
+        private CustomFrameLayout rtvFL;
+        /// <summary>
+        /// 涓存椂瀵嗙爜
+        /// </summary>
+        private CustomFrameLayout pswFL;
+        /// <summary>
+        /// 鍘嗗彶璁板綍
+        /// </summary>
+        private CustomFrameLayout recordFL;
+
+        /// <summary>
+        /// 琛ㄧず鏉ヨ嚜閭d釜鐣岄潰
+        /// </summary>
+        private CommonMethod.Comerom comerom;
+        /// <summary>
+        /// 鍒犻櫎璁惧鍚庨渶瑕佹洿鏂扮晫闈㈢殑鍥炶皟
+        /// </summary>
+        public Action action;
+        #endregion
+
+
+        /// <summary>
+        /// 鏋勯�犲嚱鏁�
+        /// </summary>
+        /// <param name="function">璁惧</param>
+        /// <param name="btnDeviceName">涓婁竴绾х晫闈㈢殑璁惧鍚嶅瓧鎺т欢(娉�:涓嶈兘浼爊ull,娌℃湁鍙互浼爊ew Button())</param>
+        /// <param name="btnRoomName">涓婁竴绾х晫闈㈢殑鎴块棿鍚嶅瓧鎺т欢(娉�:涓嶈兘浼爊ull,娌℃湁鍙互浼爊ew Button())</param> 
+        public VideoDoorLockPage(Function function, Button btnDeviceName, Button btnRoomName, CommonMethod.Comerom comerom, Action action)
+        {
+            this.device = function;
+            this.btnDeviceName = btnDeviceName;
+            this.btnRoomName = btnRoomName;
+            this.comerom = comerom;
+            this.action = action;
+
+        }
+
+        public void Show()
+        {
+            //鍒濆鍖朥I
+            this.InitUI();
+            //鍒濆鍖栦簨浠�
+            this.EventListener();
+            //璇诲彇鏁版嵁
+            this.ReadData();
+
+        }
+
+
+        /// <summary>
+        /// 鍒濆鍖栫晫闈�
+        /// </summary>
+        private void InitUI()
+        {
+            #region   ---鐣岄潰甯冨眬---
+            this.BackgroundColor = MusicColor.ViewColor;
+            this.topView = new TopView();
+            this.topView.setBtn.Visible = true;
+            this.topView.topNameBtn.TextID = StringId.shipinmensuo;
+            this.AddChidren(topView.TopFLayoutView());
+            var middleFl = new FrameLayout
+            {
+                Y = topView.fLayout.Bottom,
+                Height = Application.GetRealHeight(H_W.H - H_W.T_Height),
+            };
+            this.AddChidren(middleFl);
+
+            var whiteFl = new FrameLayout
+            {
+                Y = Application.GetRealHeight(24),
+                X = Application.GetRealWidth(24),
+                Height = Application.GetRealHeight(526),
+                Width = Application.GetRealWidth(327),
+                BackgroundImagePath = "MusicIcon/playBj.png",
+                Name = "fl",
+            };
+            middleFl.AddChidren(whiteFl);
+
+            btnCollectIcon = new Button
+            {
+                X = Application.GetRealWidth(264),
+                Y = Application.GetRealHeight(14),
+                Width = Application.GetRealWidth(40),
+                Height = Application.GetRealWidth(40),
+                UnSelectedImagePath = "MusicIcon/collect.png",
+                SelectedImagePath = "MusicIcon/collectSelected.png",
+                IsSelected = this.device.collect,
+                Name = "collect"
+            };
+            whiteFl.AddChidren(btnCollectIcon);
+
+            btnCurrDeviceName = new Button
+            {
+                TextSize = TextSize.Text24,
+                TextColor = MusicColor.Text18Color,
+                Width = Application.GetRealWidth(160),
+                Height = Application.GetRealHeight(33),
+                Y = Application.GetRealHeight(16),
+                X = Application.GetRealWidth(16),
+                Text = this.device.name,
+                TextAlignment = TextAlignment.CenterLeft,
+            };
+            whiteFl.AddChidren(btnCurrDeviceName);
+
+
+            btnCurrDeviceRoom = new Button
+            {
+                TextSize = TextSize.Text12,
+                TextColor = MusicColor.MusicNoTxetColor,
+                Width = Application.GetRealWidth(160),
+                Height = Application.GetRealHeight(17),
+                Y = btnCurrDeviceName.Bottom + Application.GetRealHeight(4),
+                X = Application.GetRealWidth(16),
+                Text = this.device.GetRoomListName(),
+                TextAlignment = TextAlignment.CenterLeft,
+            };
+            whiteFl.AddChidren(btnCurrDeviceRoom);
+
+            cellFrame = new FrameLayout
+            {
+                X = btnCurrDeviceRoom.Right + Application.GetRealWidth(20),
+                Y = btnCurrDeviceName.Bottom + Application.GetRealHeight(5),
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealHeight(16),
+            };
+            whiteFl.AddChidren(cellFrame);
+
+            cellDiyArcSeekBar = new DiyArcSeekBar
+            {
+                X = Application.GetRealWidth(3),
+                Y = Application.GetRealHeight(3),
+                Width = cellFrame.Width + Application.GetRealWidth(-6),
+                Height = cellFrame.Height + Application.GetRealHeight(-6),
+                Progress = 60,
+                ProgressBarColor = MusicColor.MusicNoTxetColor,
+                MaxValue = 100,
+                MinValue = 0,
+
+                //IsCanMove = false,
+                //IsCanScrolled=false,
+            };
+            //cellFrame.AddChidren(cellDiyArcSeekBar);
+
+            btnCell = new Button
+            {
+                TextSize = TextSize.Text10,
+                TextColor = MusicColor.TextColor,
+                Text = "60" + "%",
+                TextAlignment = TextAlignment.Center,
+                UnSelectedImagePath = "FunctionIcon/DoorLock/Cell.png",
+            };
+            cellFrame.AddChidren(btnCell);
+
+
+            //闂ㄩ攣鐘舵��
+            btnDoorLockIcon = new Button
+            {
+                X = Application.GetRealWidth(65),
+                Y = Application.GetRealHeight(108),
+                Width = Application.GetRealWidth(198),
+                Height = Application.GetRealWidth(200),
+                UnSelectedImagePath = "FunctionIcon/DoorLock/UnLocked.png",
+                SelectedImagePath = "FunctionIcon/DoorLock/UnLocking.png",
+            };
+            whiteFl.AddChidren(btnDoorLockIcon);
+
+            this.CalculatedPosition();//閲嶆柊璁$畻瀹藉害
+
+            int heightY = btnDoorLockIcon.Bottom + Application.GetRealHeight(70);
+            //瀹炴椂瑙嗛
+            rtvFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
+            whiteFl.AddChidren(rtvFL);
+            rtvFL.Y = heightY;
+            rtvFL.X = Application.GetRealWidth(41);
+            rtvFL.AddImageView();
+            rtvFL.AddTextButtonView();
+            rtvFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/RTV.png";
+            rtvFL.GetTextButton().TextID = StringId.shishishipin;
+            //鍘嗗彶璁板綍
+            recordFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
+            whiteFl.AddChidren(recordFL);
+            recordFL.Y = heightY;
+            recordFL.X = rtvFL.Right + Application.GetRealWidth(CustomFrameLayout.interval);
+            recordFL.AddImageView();
+            recordFL.AddTextButtonView();
+            recordFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/HistoryList.png";
+            recordFL.GetTextButton().TextID = StringId.lishijilu;
+            //涓存椂瀵嗙爜
+            pswFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
+            whiteFl.AddChidren(pswFL);
+            pswFL.Y = heightY;
+            pswFL.X = recordFL.Right + Application.GetRealWidth(CustomFrameLayout.interval);
+            pswFL.AddImageView();
+            pswFL.AddTextButtonView();
+            pswFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/OneOpenLock.png";
+            pswFL.GetTextButton().TextID = StringId.linshimima1;
+
+
+
+            #endregion
+
+
+        }
+        /// <summary>
+        /// 娉ㄥ唽浜嬩欢
+        /// </summary>
+        private void EventListener()
+        {
+            //杩斿洖
+            this.topView.clickBackBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                this.RemoveFromParent();
+            };
+            //璁剧疆
+            this.topView.clickSetBtn.MouseUpEventHandler += (sender, e) =>
+            {
+                CommonMethod.Current.MainThread(() =>
+                {
+                    //璋冪敤绉�缁曠殑鐣岄潰
+                    var infoView = new UI.FunctionBaseInfoSetPage(this.device, () =>
+                     {
+                         if (this.btnDeviceName == null || this.btnRoomName == null || this.device == null)
+                         {
+                             return;
+                         }
+                         ////鍒锋柊鏄剧ず
+                         this.btnDeviceName.Text = this.device.name;
+                         this.btnRoomName.Text = this.device.GetRoomListName();
+                         this.btnCurrDeviceName.Text = this.device.name;
+                         this.btnCurrDeviceRoom.Text = this.device.GetRoomListName();
+                         this.CalculatedPosition();//閲嶆柊璁$畻瀹藉害
+
+                     });
+                    infoView.actionDel += () =>
+                      {
+                          //瑙g粦璁惧鍚�
+                          this.RemoveFromParent();
+                          this.action?.Invoke();
+
+                      };
+                    MainPage.BasePageView.AddChidren(infoView);
+                    infoView.LoadPage();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                });
+            };
+            //鏀惰棌
+            this.btnCollectIcon.MouseUpEventHandler += (sender, e) =>
+            {
+                btnCollectIcon.IsSelected = this.device.collect = !btnCollectIcon.IsSelected;
+                this.device.CollectFunction();
+            };
+            //瀹炴椂瑙嗛
+            this.rtvFL.SetClickListener((fl, btnStateImage, btnStateText) =>
+            {
+                CommonMethod.Current.SkipRTVActivity(this.device.sid, this.device.deviceId, this.device.spk, false);
+            });
+            //涓存椂瀵嗙爜
+            this.pswFL.SetClickListener((fl, btnStateImage, btnStateText) =>
+            {
+                CommonMethod.Current.SkipPSWActivity(this.device.deviceId);
+            });
+            //鍘嗗彶璁板綍
+            this.recordFL.SetClickListener((fl, btnStateImage, btnStateText) =>
+            {
+                CommonMethod.Current.SkipRecordActivity(this.device.deviceId);
+            });
+
+
+        }
+        /// <summary>
+        /// 鍒濆鏁版嵁
+        /// </summary>
+        private void ReadData()
+        {
+            CommonMethod.Current.Loading.Start();
+            CommonMethod.Current.SunThread(() =>
+            {
+                try
+                {
+                    var videoDoorLockInfo = VideDoorLockSend.Current.GetVideoDoorLockState(this.device);
+                    var cellInfo = VideDoorLockSend.Current.GetCellValue(this.device);
+                    CommonMethod.Current.MainThread(() =>
+                    {
+                        //this.cellDiyArcSeekBar.Progress = i;
+                        //鏇存柊鐢甸噺鍊�
+                        this.btnCell.Text = cellInfo.remain + "%";
+                        this.btnDoorLockIcon.IsSelected = videoDoorLockInfo.doorStatus == "open";
+                    });
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonMethod.Current.Loading.Hide();
+                    });
+                }
+            });
+        }
+
+
+
+        /// <summary>
+        /// 閲嶆柊璁$畻瀹藉害(璁惧鍚嶇О,鎴块棿鎺т欢)
+        /// </summary>
+        private void CalculatedPosition()
+        {
+            this.btnCurrDeviceName.Width = this.btnCurrDeviceName.GetTextWidth();
+            if (this.btnCurrDeviceName.GetTextWidth() > this.btnCollectIcon.X)
+            {
+                //閲嶆柊璁$畻瀹藉害
+                this.btnCurrDeviceName.Width = this.btnCollectIcon.X + Application.GetRealWidth(-10);
+            }
+            this.btnCurrDeviceRoom.Width = this.btnCurrDeviceRoom.GetTextWidth();
+            if (this.btnCurrDeviceRoom.GetTextWidth() > this.btnCollectIcon.X)
+            {
+                //閲嶆柊璁$畻瀹藉害
+                this.btnCurrDeviceRoom.Width = this.btnCollectIcon.X + Application.GetRealWidth(-20 - 10);
+            }
+            this.cellFrame.X = this.btnCurrDeviceRoom.Right + Application.GetRealWidth(20);
+        }
+
+        /// <summary>
+        /// 鏇存柊鐘舵��
+        /// </summary>
+        public void UpdateState(PushMessageType pushMessageType)
+        {
+            CommonMethod.Current.MainThread(() =>
+            {
+                if (pushMessageType == PushMessageType.Alarm)
+                {
+                    //闂ㄩ攣鐢垫睜鍊�
+                    if (this.btnCell != null)
+                    {
+                        //videoDoorLockPage.btnCell.Text = "";
+                    }
+                }
+                else
+                {
+                    if (this.btnDoorLockIcon != null && !this.btnDoorLockIcon.IsSelected)
+                    {
+                        this.btnDoorLockIcon.IsSelected = false;
+                    }
+                }
+
+            });
+
+        }
+
+    }
+    /// <summary>
+    /// 鑷繁寮勪竴涓狥rameLayout
+    /// </summary>
+    class CustomFrameLayout : FrameLayout
+    {
+        public const int widthFrameLayout = 48;
+        public const int heightFrameLayout = 53;
+        public const int yFrameLayout = 378;
+        public const int xFrameLayout = 41;
+        public const int interval = 51;//琛屼腑鐨勫垪闂撮殧鍊�
+
+        public CustomFrameLayout(int width, int height, int x = 0, int y = 0)
+        {
+            this.Width = Application.GetRealWidth(width);
+            this.Height = Application.GetRealHeight(height);
+            this.X = Application.GetRealWidth(x);
+            this.Y = Application.GetRealHeight(y);
+
+        }
+        Button btnStateImage = new Button
+        {
+            Width = Application.GetRealWidth(32),
+            Height = Application.GetRealWidth(32),
+            Gravity = Gravity.TopCenter,
+            Name = "btnStateImage",
+
+        };
+        Button btnStateText = new Button
+        {
+            Y = Application.GetRealHeight(4),
+            Width = Application.GetRealWidth(100),
+            Height = Application.GetRealWidth(20),
+            TextID = StringId.dangqianmenweiguan,
+            TextSize = TextSize.Text12,
+            TextColor = MusicColor.TextCancelColor,
+            TextAlignment = TextAlignment.Center,
+            Gravity = Gravity.CenterHorizontal,
+            Name = "btnStateText"
+        };
+        public void AddImageView()
+        {
+            this.AddChidren(btnStateImage);
+
+        }
+        public void AddTextButtonView()
+        {
+            btnStateText.Y += btnStateImage.Bottom;
+            this.AddChidren(btnStateText);
+        }
+        public Button GetImageButton()
+        {
+            //if (!this.AddWithout(this.btnStateImage))
+            //{
+            //    this.AddImageView();
+            //}
+            return this.btnStateImage;
+        }
+        public Button GetTextButton()
+        {
+            //if (!this.AddWithout(this.btnStateText))
+            //{
+            //    this.AddTextButtonView();
+            //}
+            return this.btnStateText;
+        }
+
+        /// <summary>
+        /// 浜嬩欢鐩戝惉鏂规硶
+        /// </summary>
+        /// <param name="action">鍥炶皟(绗竴涓槸鐖剁被瀵硅薄;绗簩涓槸鍥炬爣瀵硅薄;绗笁涓槸鐘舵�佸璞�</param>
+        /// <param name="button1">娉ㄦ剰:鍦⊿etClickListener()鍓嶉潰璋冪敤AddImageView()鎵嶆湁鏁�</param>
+        /// <param name="button2">娉ㄦ剰:鍦⊿etClickListener()鍓嶉潰璋冪敤AddImageView()鎵嶆湁鏁�</param>
+        public void SetClickListener(Action<FrameLayout, Button, Button> action)
+        {
+            EventHandler<MouseEventArgs> click = (sender, e) =>
+                    {
+                        action?.Invoke(this, btnStateImage, btnStateText);
+                    };
+            this.MouseUpEventHandler += click;
+            btnStateImage.MouseUpEventHandler += click;
+            btnStateText.MouseUpEventHandler += click;
+
+        }
+
+
+
+        /// <summary>
+        /// 鍦ㄧ埗甯冨眬鏌ユ壘瀛愭帶浠舵槸鍚﹀瓨鍦�
+        /// </summary>
+        /// <param name="btn">鏌ユ壘瀵硅薄</param>
+        /// <returns>瀛樺湪涓簍rue,鍚﹀垯涓篺alse</returns>
+        private bool AddWithout(View btn)
+        {
+
+            if (this.ChildrenCount <= 0 || btn == null)
+            {
+                return false;
+            }
+            for (int i = 0; i < this.ChildrenCount; i++)
+            {
+                View view = this.GetChildren(i);
+                if (view == null)
+                {
+                    continue;
+                }
+                if (view is Button)
+                {
+                    if (view.Name == btn.Name)
+                    {
+                        return true;
+                    }
+                }
+
+            }
+            return false;
+
+        }
+
+
+
+
+    }
+
+
+}

--
Gitblit v1.8.0