wjc
2023-03-09 a0b77501012265c4638c9f49ccfd1e6cd0f71a45
HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorLockPage.cs
@@ -44,6 +44,10 @@
        /// </summary>
        private Button btnCell;
        /// <summary>
        /// 电量进度条
        /// </summary>
        private DiyArcSeekBar cellDiyArcSeekBar;
        /// <summary>
        ///收藏图标
        /// </summary>
        private Button btnCollectIcon;
@@ -55,10 +59,6 @@
        /// 实时视频
        /// </summary>
        private CustomFrameLayout rtvFL;
        /// <summary>
        /// 一键开锁
        /// </summary>
        private CustomFrameLayout openFL;
        /// <summary>
        /// 临时密码
        /// </summary>
@@ -72,6 +72,10 @@
        /// 表示来自那个界面
        /// </summary>
        private Comerom Comerom;
        /// <summary>
        /// 删除设备后需要更新界面的回调
        /// </summary>
        public Action action;
        #endregion
@@ -81,12 +85,13 @@
        /// <param name="function">设备</param>
        /// <param name="btnDeviceName">上一级界面的设备名字控件</param>
        /// <param name="btnRoomName">上一级界面的房间名字控件</param> 
        public VideoDoorLockPage(Function function, Button btnDeviceName, Button btnRoomName, Comerom comerom)
        public VideoDoorLockPage(Function function, Button btnDeviceName, Button btnRoomName, Comerom comerom, Action action)
        {
            this.device = function;
            this.btnDeviceName = btnDeviceName;
            this.btnRoomName = btnRoomName;
            this.Comerom = comerom;
            this.action = action;
        }
@@ -95,10 +100,15 @@
            //初始化UI
            this.InitUI();
            //初始化事件
            this.EventListener ();
            this.EventListener();
            //读取数据
            this.ReadData();
        }
        /// <summary>
        /// 初始化界面
        /// </summary>
@@ -108,16 +118,16 @@
            this.BackgroundColor = MusicColor.ViewColor;
            this.topView = new TopView();
            this.topView.setBtn.Visible = true;
            this.topView.topNameBtn.TextID =StringId.shipinmensuo;
            this.topView.topNameBtn.TextID = StringId.shipinmensuo;
            this.AddChidren(topView.TopFLayoutView());
            var middleFl=new FrameLayout
            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
            var whiteFl = new FrameLayout
            {
                Y = Application.GetRealHeight(24),
                X = Application.GetRealWidth(24),
@@ -128,48 +138,6 @@
            };
            middleFl.AddChidren(whiteFl);
            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(33),
                Y = btnCurrDeviceName.Bottom+ Application.GetRealHeight(4),
                X = Application.GetRealWidth(16),
                Text = this.device.GetRoomListName(),
                TextAlignment = TextAlignment.CenterLeft,
            };
            whiteFl.AddChidren(btnCurrDeviceRoom);
            btnCurrDeviceRoom.Width=btnCurrDeviceName.GetTextWidth();
            btnCell = new Button
            {
                TextSize = TextSize.Text10,
                TextColor = MusicColor.TextColor,
                Y = Application.GetRealHeight(43),
                X = btnCurrDeviceRoom.Right+Application.GetRealWidth(17),
                //Text ="60"+"%",
                //TextAlignment = TextAlignment.Center,
                Width = Application.GetRealWidth(36),
                Height = Application.GetRealWidth(36),
                UnSelectedImagePath ="FunctionIcon/DoorLock/Cell.png",
            };
            whiteFl.AddChidren(btnCell);
            btnCollectIcon = new Button
            {
                X = Application.GetRealWidth(264),
@@ -178,10 +146,84 @@
                Height = Application.GetRealWidth(40),
                UnSelectedImagePath = "MusicIcon/collect.png",
                SelectedImagePath = "MusicIcon/collectSelected.png",
                IsSelected= this.device.collect,
                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);
            btnCurrDeviceName.Width = btnCurrDeviceName.GetTextWidth();
            if (btnCurrDeviceName.GetTextWidth() > btnCollectIcon.X)
            {
                btnCurrDeviceName.Width = btnCollectIcon.X;
            }
            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);
            btnCurrDeviceRoom.Width = btnCurrDeviceRoom.GetTextWidth();
            var 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
            {
@@ -193,12 +235,12 @@
                SelectedImagePath = "FunctionIcon/DoorLock/UnLocking.png",
            };
            whiteFl.AddChidren(btnDoorLockIcon);
            int heightY = btnDoorLockIcon.Bottom + Application.GetRealHeight(70);
            //实时视频
            rtvFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
            whiteFl.AddChidren(rtvFL);
            rtvFL.Y = btnDoorLockIcon.Bottom+ Application.GetRealHeight(45);
            rtvFL.X = Application.GetRealWidth(68);
            rtvFL.Y = heightY;
            rtvFL.X = Application.GetRealWidth(41);
            rtvFL.AddImageView();
            rtvFL.AddTextButtonView();
            rtvFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/RTV.png";
@@ -206,32 +248,24 @@
            //历史记录
            recordFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
            whiteFl.AddChidren(recordFL);
            recordFL.Y = btnDoorLockIcon.Bottom + Application.GetRealHeight(45);
            recordFL.X = rtvFL.Right + Application.GetRealHeight(CustomFrameLayout.interval);
            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;
            //一键开锁
            openFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
            whiteFl.AddChidren(openFL);
            openFL.X = rtvFL.X;
            openFL.Y = rtvFL.Bottom+Application.GetRealHeight(14);
            openFL.AddImageView();
            openFL.AddTextButtonView();
            openFL.GetImageButton().UnSelectedImagePath = "FunctionIcon/DoorLock/OneOpenLock.png";
            openFL.GetTextButton().TextID = StringId.yijiankaisuo;
            //临时密码
            pswFL = new CustomFrameLayout(CustomFrameLayout.widthFrameLayout, CustomFrameLayout.heightFrameLayout);
            whiteFl.AddChidren(pswFL);
            pswFL.X = recordFL.X;
            pswFL.Y = rtvFL.Bottom + Application.GetRealHeight(14);
            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>
@@ -261,7 +295,7 @@
                    this.btnRoomName.Text = this.device.GetRoomListName();
                    this.topView.topNameBtn.Text = this.device.name;
                    this.btnCurrDeviceName.Text = this.device.name;
                    this.btnCurrDeviceRoom.Text= this.device.GetRoomListName();
                    this.btnCurrDeviceRoom.Text = this.device.GetRoomListName();
                    ////从新计算宽度
                    //this.btnDeviceName.Text = btnDeviceName.Text;
@@ -272,27 +306,54 @@
                    ////回调事件
                    //this.SettionFinishEvent?.Invoke();
                }, () =>
                {
                    //解绑设备后
                    this.RemoveFromParent();
                    this.action?.Invoke();
                });
                MainPage.BasePageView.AddChidren(infoView);
                infoView.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            //收藏
            btnCollectIcon.MouseUpEventHandler += (sender, e) =>
            this.btnCollectIcon.MouseUpEventHandler += (sender, e) =>
            {
                btnCollectIcon.IsSelected = this.device.collect = !btnCollectIcon.IsSelected;
                this.device.CollectFunction();
            };
            //实时视频
            rtvFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
            //一键开锁
            openFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
            //临时密码
            pswFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
            //历史记录
            recordFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
            this.rtvFL.SetClickListener((fl, btnStateImage, btnStateText) =>
            {
            });
            //临时密码
            this.pswFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
            //历史记录
            this.recordFL.SetClickListener((fl, btnStateImage, btnStateText) => { });
        }
        /// <summary>
        /// 初始数据
        /// </summary>
        private void ReadData()
        {
            new System.Threading.Thread(() =>
            {
                HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.Send.Currnet.GetCellValue(this.device, (value) =>
                {
                    Application.RunOnMainThread(() =>
                    {
                        //this.cellDiyArcSeekBar.Progress = i;
                        //更新电量值
                        this.btnCell.Text = value + "%";
                    });
                });
            })
            { IsBackground = true }.Start();
        }
    }
@@ -301,11 +362,11 @@
    /// </summary>
    class CustomFrameLayout : FrameLayout
    {
        public const int widthFrameLayout = 74;
        public const int heightFrameLayout = 70;
        public const int yFrameLayout = 353;
        public const int xFrameLayout = 68;
        public const int interval = 47;//行中的列间隔值
        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)
        {
@@ -372,11 +433,7 @@
        {
            EventHandler<MouseEventArgs> click = (sender, e) =>
                    {
                        if (action == null)
                        {
                            return;
                        }
                        action(this, btnStateImage, btnStateText);
                        action?.Invoke(this, btnStateImage, btnStateText);
                    };
            this.MouseUpEventHandler += click;
            btnStateImage.MouseUpEventHandler += click;