黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Shared.Common;
using ZigBee.Device;
@@ -6,18 +8,33 @@
{
    public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus
    {
        #region 界面
        /// <summary>
        ///  构造函数
        /// </summary>
        /// <param name="room"></param>
        /// <param name="doorLock"></param>
        public UserDoorLockPage(Shared.Common.Room room, DeviceUI doorLock)
        public UserDoorLockPage(Room room, CommonDevice doorLock)
        {
            this.doorLock = doorLock.CommonDevice as ZigBee.Device.DoorLock;
            //徐梅的门锁界面打开(网关全局接收时使用)
            //ControlCommonResourse.IsDoorLockPageOpen = true;
            this.doorLock = doorLock as ZigBee.Device.DoorLock;
            currentRoom = room;
            deviceUI = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
            BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZbGateway.StatusList.Add(this);
            Application.RunOnMainThread(() =>
            {
                UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction += (DoorlockKey, status) =>
                {
                    var key = doorLock.DeviceAddr;
                    if (DoorlockKey == key)
                    {
                        DoorLockCommonInfo.NormallyOpenModeValue(this.doorLock, status);
                        UpdateNomallyOpenStatus();
                    }
                };
            });
        }
        #region  变量申明
@@ -26,17 +43,46 @@
        /// </summary>
        ZigBee.Device.DoorLock doorLock;
        /// <summary>
        /// 底部布局
        /// 音量数据
        /// </summary>
        FrameLayout bottomFrameLayout;
        ZigBee.Device.DoorLock.VolumeResponseData volumeData = null;
        /// <summary>
        /// 等待获取电量的等待时间
        /// </summary>
        DateTime waitGetDoorLockPower = DateTime.MaxValue;
        /// <summary>
        /// 逻辑中是否有常开模式
        /// </summary>
        private bool haveLogicNormallyOpenMode = false;
        /// <summary>
        /// 当前电量
        /// </summary>
        bool canVolume = false;
        /// <summary>
        /// 是否支持常开
        /// </summary>
        bool canOpenNormallyMode = false;
        /// <summary>
        /// IsDrawerLockMode[主页左滑]
        /// </summary>
        public bool IsDrawerLockMode;
        /// <summary>
        /// 当前电量
        /// </summary>
        int currentPower = 0;
        /// <summary>
        /// 保留上一次音量
        /// </summary>
        int oldVolume = -1;
        /// <summary>
        /// 当前房间
        /// </summary>
        Shared.Common.Room currentRoom;
        Room currentRoom;
        /// <summary>
        /// 设备UI对象
        /// </summary>
        DeviceUI deviceUI;
        CommonDevice deviceUI;
        /// <summary>
        /// 设置二次验证Action
        /// </summary>
@@ -44,24 +90,119 @@
        /// <summary>
        /// 中部布局中门锁名称显示
        /// </summary>
        Button btnDoorLockTitle;
        NormalViewControl btnDoorLockTitle;
        /// <summary>
        /// 分享
        /// </summary>
        Button btnShare;
        /// <summary>
        /// 设置
        /// </summary>
        Button btnFuncSet;
        /// <summary>
        /// 设置FrameLayout
        /// </summary>
        FrameLayout btnFuncSetFrameLayout;
        FrameLayout progressFrameLayoutMatch;
        /// <summary>
        /// 点击开布局
        /// </summary>
        private FrameLayout openFrameLayout;
        /// <summary>
        /// 点击关布局
        /// </summary>
        private FrameLayout closeFrameLayout;
        /// <summary>
        /// 打开图片
        /// </summary>
        Button btnDoorOpenPic;
        /// <summary>
        /// 搜藏UI
        /// </summary>
        FrameLayout btnCollectFrameLayout;
        /// <summary>
        /// 搜藏
        /// </summary>
        Button btnCollect;
        /// <summary>
        /// 记录UI
        /// </summary>
        FrameLayout btnRecordFrameLayout;
        /// <summary>
        /// 记录按钮
        /// </summary>
        Button btnRecord;
        /// <summary>
        /// 当前状态
        /// </summary>
        Button btnStatus;
        /// <summary>
        /// 当前电量文本
        /// </summary>
        Button btnCurrentPowerText;
        /// <summary>
        /// 进度按钮
        /// </summary>
        Button progressButton;
        /// <summary>
        /// 进度
        /// </summary>
        DiyImageVerticalSeekBar diyImageVerticalSeekBar;
        /// <summary>
        /// 进度文本
        /// </summary>
        Button progressText;
        /// <summary>
        /// 门锁关图片
        /// </summary>
        Button btnDoorClosePic;
        /// <summary>
        /// 门锁开/关图片
        /// </summary>
        Button btnDoorLockPic;
        /// <summary>
        /// 电量
        /// </summary>
        Button btnPower;
        /// <summary>
        /// 常开
        /// </summary>
        Button btnNormallyOpen;
        /// <summary>
        /// 音量
        /// </summary>
        Button btnVolume;
        /// <summary>
        /// 常开FrameLayout
        /// </summary>
        FrameLayout btnNormallyOpenFrameLayout;
        /// <summary>
        /// 音量FrameLayout
        /// </summary>
        FrameLayout btnVolumeFrameLayout;
        /// <summary>
        ///  当前音量
        /// </summary>
        int currentVolume = -1;
        /// <summary>
        /// waitClickTime
        /// </summary>
        DateTime waitClickTime = DateTime.MaxValue;
        /// <summary>
        /// IsClick
        /// </summary>
        bool IsClick = true;
        #endregion
        /// <summary>
        /// UI显示
        /// <summary>
        /// UI显示
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, "");
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.TopFrameLayout(this, "");
            this.MidFrameLayout(this);
            var btnShare = new Button
            btnShare = new Button
            {
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
@@ -69,7 +210,7 @@
            };
            this.titleFrameLayout.AddChidren(btnShare);
            var btnFuncSetFrameLayout = new FrameLayout
            btnFuncSetFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
@@ -77,42 +218,36 @@
            };
            this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout);
            var btnFuncSet = new Button
            btnFuncSet = new Button
            {
                X = Application.GetRealWidth(103),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
                Height = Application.GetMinReal(69),
                Width = Application.GetMinReal(69),
                UnSelectedImagePath = "DoorLock/SettingIcon.png",
            };
            btnFuncSetFrameLayout.AddChidren(btnFuncSet);
            EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) =>
            MidFrameLayoutUI();
            ClickHandle();
            if (HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(doorLock) == true)
            {
                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                functionSetting.Show();
                functionSetting.devicNameAction += (deviceRename) =>
                {
                    if (!string.IsNullOrEmpty(deviceRename))
                    {
                        btnDoorLockTitle.Text = deviceRename;
                        //改房间
                        Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                        deviceUI.CommonDevice.ReSave();
                    }
                };
            };
            btnFuncSetFrameLayout.MouseDownEventHandler += btnFuncSetHander;
            btnFuncSet.MouseDownEventHandler += btnFuncSetHander;
            MidFrameLayoutContent();
                ReadDoorLockUserInfo();
            }
            else
            {
                string msg1 = Language.StringByID(R.MyInternationalizationString.DoorLockOffLine);
                this.ShowTipMsg(msg1);
                return;
            }
        }
        /// <summary>
        /// 中部布局
        /// </summary>
        public void MidFrameLayoutContent()
        public void MidFrameLayoutUI()
        {
            #region UI
            var midTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(58),
@@ -124,117 +259,89 @@
            };
            this.midFrameLayout.AddChidren(midTopFrameLayout);
            btnDoorLockTitle = new Button()
            {
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(60),
                X = Application.GetRealWidth(372),
                Y = Application.GetRealHeight(46),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 15,
                TextAlignment = TextAlignment.Center,
                IsBold = true,
            };
            //设备名称
            btnDoorLockTitle = new NormalViewControl(100, 60, true);
            btnDoorLockTitle.Y = Application.GetRealHeight(46);
            btnDoorLockTitle.TextSize = 15;
            btnDoorLockTitle.IsBold = true;
            btnDoorLockTitle.Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock);
            btnDoorLockTitle.Width = btnDoorLockTitle.GetRealWidthByText();
            btnDoorLockTitle.TextAlignment = TextAlignment.Center;
            btnDoorLockTitle.Gravity = Gravity.CenterHorizontal;
            midTopFrameLayout.AddChidren(btnDoorLockTitle);
            //获取Mac名字
            btnDoorLockTitle.Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock);
            var btnRecordFrameLayout = new FrameLayout()
            //记录
            btnRecordFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(69+15+46),
                Height = Application.GetRealHeight(69+46 * 2),
                X = Application.GetRealWidth(752-46),
             };
                Width = Application.GetRealWidth(69 + 15 + 46),
                Height = Application.GetRealHeight(69 + 46 * 2),
                X = Application.GetRealWidth(752 - 46),
            };
            midTopFrameLayout.AddChidren(btnRecordFrameLayout);
            var btnRecord = new Button()
            btnRecord = new Button()
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                X = Application.GetRealWidth(46),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "DoorLock/RecordIcon.png",
            };
            btnRecordFrameLayout.AddChidren(btnRecord);
            EventHandler<MouseEventArgs> handerRecord = (sender, e) =>
            {
                //历史记录 ----   stan
                var form = new DeviceDoorLock.DoorLockHistoryLogForm();
                form.AddForm(this.doorLock.DeviceAddr);
            };
            btnRecordFrameLayout.MouseDownEventHandler += handerRecord;
            btnRecord.MouseDownEventHandler += handerRecord;
            var btnCollectFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(69+15+46),
                Height = Application.GetRealHeight(69+46*2),
                X = Application.GetRealWidth(850-15),
             };
            midTopFrameLayout.AddChidren(btnCollectFrameLayout);
            var btnCollect = new Button()
            //搜藏UI
            btnCollectFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69 + 15 + 46),
                Height = Application.GetRealHeight(69 + 46 * 2),
                X = Application.GetRealWidth(850 - 15),
            };
            midTopFrameLayout.AddChidren(btnCollectFrameLayout);
            btnCollect = new Button()
            {
                Width = Application.GetMinReal(69),
                Height = Application.GetMinReal(69),
                X = Application.GetRealWidth(15),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "Item/Collection.png",
                SelectedImagePath = "Item/CollectionSelected.png"
            };
            btnCollectFrameLayout.AddChidren(btnCollect);
            var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == deviceUI.FileName);
            if (de == null)
            {
                btnCollect.IsSelected = false;
            }
            else
            {
                btnCollect.IsSelected = true;
            }
            EventHandler < MouseEventArgs > handerCollect = (sender, e) =>
            {
                btnCollect.IsSelected = !btnCollect.IsSelected;
                if (btnCollect.IsSelected)
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(deviceUI.FileName);//收藏
                }
                else
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); //取消收藏
                }
            };
            btnCollectFrameLayout.MouseDownEventHandler += handerCollect;
            btnCollect.MouseDownEventHandler += handerCollect;
            var btnCurrentText = new Button()
            {
                Width = Application.GetRealWidth(100),
                Height = Application.GetRealHeight(40),
                X = Application.GetRealWidth(415),
                Y = Application.GetRealHeight(118),
                Text = Language.StringByID(R.MyInternationalizationString.Current),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                TextSize = 10,
                TextAlignment = TextAlignment.CenterLeft,
            };
            midTopFrameLayout.AddChidren(btnCurrentText);
            btnCollectFrameLayout.AddChidren(btnCollect);
            var btnStatus = new Button()
            //当前状态
            btnStatus = new Button()
            {
                Width = Application.GetRealWidth(200),
                Width = Application.GetRealWidth(132 + 351),
                Height = Application.GetRealHeight(40),
                X = btnCurrentText.Right,
                Y = Application.GetRealHeight(118),
                Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Text = Language.StringByID(R.MyInternationalizationString.CLose),
                TextSize = 10,
                TextAlignment = TextAlignment.CenterLeft,
                TextAlignment = TextAlignment.CenterRight,
            };
            midTopFrameLayout.AddChidren(btnStatus);
            var btnDoorLockPic = new Button()
            //当前电量
            btnCurrentPowerText = new Button()
            {
                Width = Application.GetRealWidth(383),
                Height = Application.GetRealHeight(343),
                Width = Application.GetRealWidth(133 + 348),
                Height = Application.GetRealHeight(40),
                X = btnStatus.Right,
                Y = Application.GetRealHeight(118),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Text = Language.StringByID(R.MyInternationalizationString.DoorLockPower) + "%",
                TextSize = 10,
                TextAlignment = TextAlignment.CenterLeft,
            };
            midTopFrameLayout.AddChidren(btnCurrentPowerText);
#if Android
            btnCurrentPowerText.X = btnStatus.Right + Application.GetRealWidth(20);
#endif
            //门锁开/关图片
            btnDoorLockPic = new Button()
            {
                Width = Application.GetMinReal(383),
                Height = Application.GetMinReal(343),
                X = Application.GetRealWidth(161),
                Y = Application.GetRealHeight(415),
                UnSelectedImagePath = "DoorLock/DoorLockPicClose.png",
@@ -242,6 +349,7 @@
            };
            midTopFrameLayout.AddChidren(btnDoorLockPic);
            #region 开/关点击布局
            var btnFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(420 - 46),
@@ -252,7 +360,7 @@
            };
            midTopFrameLayout.AddChidren(btnFrameLayout);
            var openFrameLayout = new FrameLayout()
            openFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(420),//639-35
                Height = Application.GetRealHeight(446 / 2),
@@ -260,7 +368,7 @@
            };
            btnFrameLayout.AddChidren(openFrameLayout);
            var closeFrameLayout = new FrameLayout()
            closeFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(420),//639-35
                Height = Application.GetRealHeight(446 / 2),
@@ -269,47 +377,106 @@
            };
            btnFrameLayout.AddChidren(closeFrameLayout);
            progressFrameLayoutMatch = new FrameLayout()
            {
                Width = Application.GetRealHeight(84),//639-35
                Height = Application.GetRealHeight(446),
                X = Application.GetMinReal(51),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            btnFrameLayout.AddChidren(progressFrameLayoutMatch);
            var progressFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(9),//639-35
                Height = Application.GetRealHeight(446),
                X = Application.GetRealWidth(95),
                Y = Application.GetRealHeight(0),
                Width = Application.GetRealHeight(17),//639-35
                Gravity = Gravity.CenterHorizontal,
                BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar,
            };
            btnFrameLayout.AddChidren(progressFrameLayout);
            progressFrameLayoutMatch.AddChidren(progressFrameLayout);
            var progressButton = new Button()
            progressButton = new Button()
            {
                Width = Application.GetRealWidth(81),//639-35
                Height = Application.GetRealHeight(89),
                X = Application.GetRealWidth(58),
                Width = Application.GetMinReal(84),//639-35
                Height = Application.GetMinReal(93),
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(347),
                UnSelectedImagePath = "DoorLock/UnLockButton.png",
                SelectedImagePath = "DoorLock/UnLockButton.png",
            };
            btnFrameLayout.AddChidren(progressButton);
            progressFrameLayoutMatch.AddChidren(progressButton);
            var btnDoorOpenPic = new Button()
            btnDoorOpenPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(6),
                UnSelectedImagePath = "DoorLock/DoorLockOpen.png",
            };
            openFrameLayout.AddChidren(btnDoorOpenPic);
            var btnDoorClosePic = new Button()
            btnDoorClosePic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(117),
                UnSelectedImagePath = "DoorLock/DoorLockClose.png",
            };
            closeFrameLayout.AddChidren(btnDoorClosePic);
            #endregion
            //电量
            btnPower = new Button()
            {
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(253),
                Y = Application.GetRealHeight(994),
                UnSelectedImagePath = "DoorLock/PowerOffline.png",
            };
            midTopFrameLayout.AddChidren(btnPower);
            //音量
            btnVolumeFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(81 + 80),
                Height = Application.GetRealHeight(81 + 80),
                X = Application.GetRealWidth(444 - 40),
                Y = Application.GetRealHeight(994 - 40),
            };
            midTopFrameLayout.AddChidren(btnVolumeFrameLayout);
            btnVolume = new Button()
            {
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(40),
                Y = Application.GetRealHeight(40),
                UnSelectedImagePath = "DoorLock/VolumeIcon.png",
                SelectedImagePath = "DoorLock/VolumeIconOn.png",
            };
            btnVolumeFrameLayout.AddChidren(btnVolume);
            //常开
            btnNormallyOpenFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(81 + 80),
                Height = Application.GetRealHeight(81 + 80),
                X = Application.GetRealWidth(631 - 40),
                Y = Application.GetRealHeight(994 - 40),
            };
            midTopFrameLayout.AddChidren(btnNormallyOpenFrameLayout);
            btnNormallyOpen = new Button()
            {
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(40),
                Y = Application.GetRealHeight(40),
                UnSelectedImagePath = "DoorLock/NormallyOpen.png",
                SelectedImagePath = "DoorLock/NormallyOpenOn.png",
            };
            btnNormallyOpenFrameLayout.AddChidren(btnNormallyOpen);
            #region 背景圆角设置
            var btnCurrentTopFrameLayout = new FrameLayout()
            {
                Height = Application.GetRealHeight(50),
@@ -328,11 +495,13 @@
                Radius = 6,
            };
            midTopFrameLayout.AddChidren(btnCurrentFrameLayout);
            #endregion
            #region 当前房间
            var btnCurrentRoomPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                Width = Application.GetMinReal(81),
                Height = Application.GetMinReal(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(29),
                UnSelectedImagePath = "DoorLock/RoomPic.png",
@@ -351,109 +520,704 @@
                TextAlignment = TextAlignment.CenterLeft,
            };
            btnCurrentFrameLayout.AddChidren(btnCurrentRoomName);
            #endregion
            #endregion
        }
            #region 数据处理
            EventHandler<MouseEventArgs> hander1 = async (sender, e) =>
        #region 音量弹窗
        /// <summary>
        /// 进度条
        /// </summary>
        private void VolumeDialog(Button progressText, DiyImageVerticalSeekBar diyImageVerticalSeekBar)
        {
            var dialog = new Dialog { };
            dialog.Show();
            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
            dialog.AddChidren(flMain);
            flMain.MouseUpEventHandler += (sender11, e11) =>
            {
                openFrameLayout.Enable = false;
                btnDoorOpenPic.Enable = false;
                if (UserCenterResourse.UserInfo.AuthorityNo != 1)
                dialog.Close();
                //设置音量
                if (currentVolume != oldVolume)
                {
                    var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                    if (result == false)
                    SetVolume(currentVolume);
                }
            };
            var progressBackground = new FrameLayout()
            {
                Width = Application.GetRealWidth(271),
                Height = Application.GetRealHeight(700),
                X = Application.GetRealWidth(403),
                Y = Application.GetRealHeight(582),
                BackgroundImagePath = "DoorLock/ProgressBackground.png",
            };
            flMain.AddChidren(progressBackground);
            //var progressValue = (currentVolume * (Convert.ToInt32(((float)100 / 15) * 100))) / 100;
            progressText = new Button()
            {
                Height = Application.GetRealHeight(58),
                Y = Application.GetRealHeight(89),
                TextColor = ZigbeeColor.Current.XMGray2,
                TextAlignment = TextAlignment.Center,
                Text = currentVolume.ToString() + "%",
            };
            diyImageVerticalSeekBar = new DiyImageVerticalSeekBar()
            {
                Width = Application.GetRealWidth(271),
                Height = Application.GetRealHeight(447 + 63),
                Y = Application.GetRealHeight(155),
                IsProgressTextShow = false,//显示百分比
                ProgressBarColor = ZigbeeColor.Current.XMProgressBarColor,//选中进度条颜色
                SeekBarBackgroundColor = ZigbeeColor.Current.XMSeekBarBackgroundColor,//选中进度条颜色
                ThumbImagePath = "DoorLock/UnLockButton.png",//进度条按钮图标
                ThumbImageHeight = Application.GetRealHeight(81),//进度条按钮图标的高度(默认正方形:宽和高一样)
                ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                ProgressTextSize = 12,//显示百分比字体大小
                SeekBarViewHeight = Application.GetRealHeight(17),//进度条的宽度
                Progress = currentVolume,
            };
            progressBackground.AddChidren(progressText);
            progressBackground.AddChidren(diyImageVerticalSeekBar);
            diyImageVerticalSeekBar.OnProgressChangedEvent += (sender, e) =>
            {
                int curVolume = -1;
                curVolume = e;
                currentVolume = curVolume;
                progressText.Text = e.ToString() + "%";
            };
        }
        #endregion
        #endregion
        #region 处理接口数据
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice tempDevice, string typeTag)
        {
            //机械开锁上报。处理常开状态,开关状态
            if (typeTag == "DoorLockProgrammingEventNotificationCommand" && tempDevice != null)
            {
                var tempDoor = (ZigBee.Device.DoorLock)tempDevice;
                if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint
                                     && tempDevice.DeviceAddr == doorLock.DeviceAddr)
                {
                    if (tempDoor.doorLockOperatingEventNotificationCommand != null)
                    {
                        var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                        if (result1 == true)
                        //非主人不弹这个窗口
                        if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
                        {
                            RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                            devicNameSecAction += (deviceRename) =>
                             {
                                 if (!string.IsNullOrEmpty(deviceRename))
                                 {
                                     btnDoorLockTitle.Text = deviceRename;
                                     //改房间
                                     Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                                     deviceUI.CommonDevice.ReSave();
                                 }
                             };
                            openFrameLayout.Enable = true;
                            btnDoorOpenPic.Enable = true;
                            return;
                        }
                        if (doorLock.IsDoorLockNormallyMode)
                        {
                            if (canOpenNormallyMode)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    Action<bool> action = (obj) =>
                                    {
                                        UpdateNomallyOpenStatus();
                                    };
                                    DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.ServicePush, haveLogicNormallyOpenMode, action);
                                });
                            }
                        }
                    }
                }
            }
            if (typeTag == "DeviceStatusReport" && tempDevice != null)
            {
                if (tempDevice != null)
                {
                    if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint
                                      && tempDevice.DeviceAddr == doorLock.DeviceAddr)
                    {
                        if (tempDevice.DeviceStatusReport != null && tempDevice.DeviceStatusReport.AttriBute != null)
                        {
                            var dataReport = tempDevice.DeviceStatusReport.AttriBute[0];
                            if (tempDevice.DeviceStatusReport.CluterID == 1 && dataReport.AttributeId == 33)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    currentPower = dataReport.AttriButeData;
                                    UpdatePower();
                                });
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 初始化数据
        /// </summary>
        void ReadDoorLockUserInfo()
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
                try
                {
                    Application.RunOnMainThread(() =>
                    {
                        CommonPage.Loading.Start("");
                    });
                    //是否支持常开
                    canOpenNormallyMode = DoorLockCommonInfo.CanNormallyOpen(doorLock);
                    if (canOpenNormallyMode)
                    {
                        //1、获取门锁常开模式
                        var resultRes = await DoorLockCommonInfo.GetNormallyOpenMode(doorLock);
                        if (resultRes == null)
                        {
                            Application.RunOnMainThread(() =>
                            {
                                btnNormallyOpen.UnSelectedImagePath = "DoorLock/NormallyOpenOffline.png";
                                btnNormallyOpen.Enable = false;
                                string msg = Language.StringByID(R.MyInternationalizationString.GetNormallyOpenModeFailed);
                                this.ShowTipMsg(msg);
                            });
                        }
                        else
                        {
                            this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
                            openFrameLayout.Enable = true;
                            btnDoorOpenPic.Enable = true;
                            var tempRes = false;
                            if (resultRes == true)
                            {
                                tempRes = true;
                            }
                            else
                            {
                                tempRes = false;
                            }
                            DoorLockCommonInfo.NormallyOpenModeValue(doorLock, tempRes);
                            Application.RunOnMainThread(async () =>
                            {
                                var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(2, doorLock);
                                if (resTemp == 0)
                                {
                                    haveLogicNormallyOpenMode = false;
                                }
                                else
                                {
                                    haveLogicNormallyOpenMode = true;
                                }
                            });
                        }
                    }
                    else
                    {
                        this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
                        Application.RunOnMainThread(() =>
                        {
                            btnNormallyOpenFrameLayout.Width = Application.GetRealWidth(0);
                        });
                    }
                    //是否支持音量
                    canVolume = DoorLockCommonInfo.CanVolume(doorLock);
                    if (canVolume)
                    {
                        //2、读取音量
                        var resultRes = await doorLock.GetVolumeAsync();
                        if (resultRes == null || resultRes.volumeResponseData == null)
                        {
                            var listDevice = new List<CommonDevice> { };
                            listDevice.Add(doorLock);
                            var devTemp = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(listDevice);
                            if (devTemp.ConcreteType == DeviceConcreteType.IntelligentLocks_Sone)
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    var volumeMsg = Language.StringByID(R.MyInternationalizationString.GetVolumeFailed);
                                    this.ShowTipMsg(volumeMsg);
                                });
                            }
                        }
                        else
                        {
                            volumeData = resultRes.volumeResponseData;
                            Application.RunOnMainThread(() =>
                            {
                                UpdateVolume();
                            });
                        }
                    }
                    else
                    {
                        Application.RunOnMainThread(() =>
                        {
                            btnVolumeFrameLayout.Width = Application.GetRealWidth(0);
                            btnPower.X = Application.GetRealWidth(444);
                        });
                    }
                    //3、读取门锁电量:簇ID:1 属性ID 33
                    doorLock.ReadAttri(Cluster_ID.Power, AttriButeId.DoorLockPower);
                    //上报电量等1秒
                    System.Threading.Thread.Sleep(1000);
                }
                catch (Exception ex)
                {
                    var mess = ex.Message;
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        UpdateNomallyOpenStatus();
                        CommonPage.Loading.Hide();
                    });
                }
            });
        }
        #endregion
        #region 公共事件处理
        /// <summary>
        /// 事件处理
        /// </summary>
        public void ClickHandle()
        {
            //门锁标题
            btnDoorLockTitle.Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock);
            //返回
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            //设置
            EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) =>
            {
                var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                functionSetting.Show();
                //DoorLockCommonInfo.canShowDialog = false;
                functionSetting.devicNameAction += (deviceRename) =>
                {
                    if (!string.IsNullOrEmpty(deviceRename))
                    {
                        btnDoorLockTitle.Text = deviceRename;
                        //改房间
                        HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id);
                        deviceUI.ReSave();
                    }
                };
            };
            btnFuncSetFrameLayout.MouseDownEventHandler += btnFuncSetHander;
            btnFuncSet.MouseDownEventHandler += btnFuncSetHander;
            //搜藏状态
            if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false)
            {
                btnCollect.IsSelected = false;
            }
            else
            {
                btnCollect.IsSelected = true;
            }
            //历史记录点击事件
            EventHandler<MouseEventArgs> handerRecord = (sender, e) =>
            {
                //历史记录 ----   stan
                var form = new DeviceDoorLock.DoorLockHistoryLogForm();
                form.AddForm(this.doorLock.DeviceAddr);
                //DoorLockCommonInfo.canShowDialog = false;
            };
            btnRecordFrameLayout.MouseDownEventHandler += handerRecord;
            btnRecord.MouseDownEventHandler += handerRecord;
            //收藏点击事件
            EventHandler<MouseEventArgs> handerCollect = (sender, e) =>
            {
                btnCollect.IsSelected = !btnCollect.IsSelected;
                if (btnCollect.IsSelected)
                {
                    HdlRoomLogic.Current.AddLoveDevice(deviceUI);//收藏
                }
                else
                {
                    HdlRoomLogic.Current.DeleteLoveDevice(deviceUI);//取消收藏
                }
            };
            btnCollectFrameLayout.MouseDownEventHandler += handerCollect;
            btnCollect.MouseDownEventHandler += handerCollect;
            //开锁事件
            EventHandler<MouseEventArgs> hander1 = async (sender, e) =>
            {
                if (doorLock.IsDoorLockNormallyMode)
                {
                    if (canOpenNormallyMode)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            Action<bool> action = (obj) =>
                            {
                                UpdateNomallyOpenStatus();
                            };
                            DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action);
                        });
                    }
                    else
                    {
                        OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                    }
                }
                else
                {
                    OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus);
                }
            };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
            if (progressButton.Y == Application.GetRealHeight(10))
            {
                progressFrameLayoutMatch.MouseUpEventHandler += hander1;
            }
            //关锁事件
            EventHandler<MouseEventArgs> hander2 = (sender, e) =>
            {
                if (canOpenNormallyMode)
                {
                    if (doorLock.IsDoorLockNormallyMode)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            Action<bool> action = (obj) =>
                            {
                                UpdateNomallyOpenStatus();
                            };
                            DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action);
                        });
                    }
                }
                else
                {
                    btnDoorLockPic.IsSelected = false;
                    progressButton.Y = Application.GetRealHeight(347);
                }
            };
            closeFrameLayout.MouseUpEventHandler += hander2;
            btnDoorClosePic.MouseUpEventHandler += hander2;
            //音量点击事件
            EventHandler<MouseEventArgs> handerVolume = (sender, e) =>
            {
                if (canVolume)
                {
                    VolumeDialog(progressText, diyImageVerticalSeekBar);
                }
            };
            btnVolumeFrameLayout.MouseDownEventHandler += handerVolume;
            btnVolume.MouseDownEventHandler += handerVolume;
            //常开模式点击事件
            EventHandler<MouseEventArgs> handerNormallyOpen = (sender, e) =>
            {
                NomallyOpenDialog();
            };
            btnNormallyOpenFrameLayout.MouseUpEventHandler += handerNormallyOpen;
            btnNormallyOpen.MouseUpEventHandler += handerNormallyOpen;
        }
        #endregion
        #region 电量显示
        /// <summary>
        /// 电量更新
        /// </summary>
        private void UpdatePower()
        {
            btnCurrentPowerText.Text = Language.StringByID(R.MyInternationalizationString.DoorLockPower) + currentPower + "%";
            if (currentPower <= 20 && currentPower >= 0)
            {
                btnPower.UnSelectedImagePath = "DoorLock/LowPower.png";
            }
            else if (currentPower <= 40 && currentPower > 20)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power40.png";
            }
            else if (currentPower <= 60 && currentPower > 40)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power60.png";
            }
            else if (currentPower <= 80 && currentPower > 60)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power80.png";
            }
            else if (currentPower <= 100 && currentPower > 80)
            {
                btnPower.UnSelectedImagePath = "DoorLock/Power100.png";
            }
            else
            {
                btnPower.UnSelectedImagePath = "DoorLock/PowerOffline.png";
            }
        }
        #endregion
        #region 音量
        /// <summary>
        /// 更新音量
        /// </summary>
        private void UpdateVolume()
        {
            if (volumeData != null)
            {
                int curVol = 0;
                btnVolume.IsSelected = true;
                if (volumeData.command == "eb")
                {
                    curVol = 0;
                }
                else
                {
                    curVol = volumeData.value;
                }
                oldVolume = currentVolume = curVol;
            }
        }
        /// <summary>
        /// 设置音量
        /// </summary>
        private void SetVolume(int volume)
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
                try
                {
                    Application.RunOnMainThread(() =>
                    {
                        CommonPage.Loading.Start("");
                    });
                    var resultRes = await doorLock.SetVolumeAsync(volume);
                    if (resultRes == null || resultRes.defaultControlResponseData == null)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            var volumeMsg = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
                            this.ShowTipMsg(volumeMsg);
                            currentVolume = oldVolume;
                            CommonPage.Loading.Hide();
                        });
                        return;
                    }
                    if (resultRes.defaultControlResponseData.status != 0)
                    {
                        Application.RunOnMainThread(() =>
                        {
                            var volumeMsg = Language.StringByID(R.MyInternationalizationString.SetVolumeFailed);
                            this.ShowTipMsg(volumeMsg);
                            currentVolume = oldVolume;
                            CommonPage.Loading.Hide();
                        });
                        return;
                    }
                    Application.RunOnMainThread(() =>
                    {
                        var volumeMsg = Language.StringByID(R.MyInternationalizationString.SetVolumeSuccess);
                        this.ShowTipMsg(volumeMsg);
                        oldVolume = currentVolume;
                        CommonPage.Loading.Hide();
                    });
                }
                catch (Exception ex)
                {
                    var mes = ex.Message;
                }
            });
        }
        #endregion
        #region 常开模式
        /// <summary>
        /// 常开模式处理
        /// </summary>
        private async void NomallyOpenDialog()
        {
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
            {
                this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
                return;
            }
            if (!HdlUserCenterResourse.AccountOption.DoorUnLockByRemote)
            {
                SystemSecondAuthentication();
                return;
            }
            action = () =>
            {
                //WJC的代码:系统密码支持操作门锁后,调用温居城的界面【常开自动化】
                if (doorLock == null)
                {
                    ///防止抛异常
                    return;
                }
                ///备注:WJC的
                Shared.Phone.Device.Logic.Send.CurrentDoorLock = doorLock;
                ///进来刷新一次设备列表;
                Common.Logic.LogicDviceList.Clear();
                if (Common.Logic.LogicDviceList.Count == 0)
                {
                    Common.Logic.LogicDviceList.AddRange(HdlDeviceCommonLogic.Current.listAllDevice.ToArray());
                }
                var addLogicPage = new Shared.Phone.Device.Logic.SoneLogicList();
                UserView.HomePage.Instance.AddChidren(addLogicPage);
                UserView.HomePage.Instance.PageIndex += 1;
                addLogicPage.Show();
                addLogicPage.action += async (w) =>
                 {
                     DoorLockCommonInfo.NormallyOpenModeValue(doorLock, w);
                     UpdateNomallyOpenStatus();
                     //返回按键清空当前逻辑定义的LogicAction
                     UserCenter.DoorLock.DoorLockCommonInfo.LogicAction = null;
                     //是否存在常开模式
                     var resTemp = Shared.Common.Logic.SoneLogicList;
                     if (resTemp.Count == 0)
                     {
                         haveLogicNormallyOpenMode = false;
                     }
                     else
                     {
                         haveLogicNormallyOpenMode = true;
                     }
                     UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction -= addLogicPage.updateCurrentDoorlockActionTemp;
                 };
            };
            HdlCheckLogic.Current.CheckSecondarySecurity(action);
        }
        /// <summary>
        /// 常开模式状态更新
        /// </summary>
        private void UpdateNomallyOpenStatus()
        {
            if (!canOpenNormallyMode)
            {
                btnNormallyOpenFrameLayout.Width = Application.GetRealWidth(0);
                return;
            }
            if (doorLock.IsDoorLockNormallyMode)
            {
                btnNormallyOpen.IsSelected = true;
                btnDoorLockPic.IsSelected = true;
                progressButton.Y = Application.GetRealHeight(10);
                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.DoorLockOpen);
            }
            else if (!doorLock.IsDoorLockNormallyMode)
            {
                btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose);
                btnDoorLockPic.IsSelected = false;
                btnNormallyOpen.IsSelected = false;
                progressButton.Y = Application.GetRealHeight(347);
            }
        }
        #endregion
        #region 开锁处理
        /// <summary>
        /// 开锁处理
        /// </summary>
        /// <param name="progressButton">进度按钮</param>
        /// <param name="btnDoorLockPic">门锁图片</param>
        /// <param name="btnStatus">状态显示</param>
        async void OpenDoorLockHandle(Button progressButton, Button btnDoorLockPic, Button btnStatus)
        {
            openFrameLayout.Enable = false;
            btnDoorOpenPic.Enable = false;
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1)
            {
                var result = await DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                if (result == false)
                {
                    var result1 = await DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                    if (result1 == true)
                    {
                        RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                        devicNameSecAction += (deviceRename) =>
                        {
                            if (!string.IsNullOrEmpty(deviceRename))
                            {
                                btnDoorLockTitle.Text = deviceRename;
                                //改房间
                                HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id);
                                deviceUI.ReSave();
                            }
                        };
                        openFrameLayout.Enable = true;
                        btnDoorOpenPic.Enable = true;
                    }
                    else
                    {
                        this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess));
                        openFrameLayout.Enable = true;
                        btnDoorOpenPic.Enable = true;
                    }
                }
                else
                {
                    RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                    devicNameSecAction += (deviceRename) =>
                     {
                         if (!string.IsNullOrEmpty(deviceRename))
                         {
                             btnDoorLockTitle.Text = deviceRename;
                             //改房间
                             Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id);
                             deviceUI.CommonDevice.ReSave();
                         }
                     };
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
                    openFrameLayout.Enable = true;
                    btnDoorOpenPic.Enable = true;
                }
            };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
            EventHandler<MouseEventArgs> hander2 = (sender, e) =>
            }
            else
            {
                btnDoorLockPic.IsSelected = false;
                progressButton.Y = Application.GetRealHeight(347);
            };
            closeFrameLayout.MouseUpEventHandler += hander2;
            btnDoorClosePic.MouseUpEventHandler += hander2;
            #endregion
                RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle);
                devicNameSecAction += (deviceRename) =>
                {
                    if (!string.IsNullOrEmpty(deviceRename))
                    {
                        btnDoorLockTitle.Text = deviceRename;
                        //改房间
                        HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id);
                        deviceUI.ReSave();
                    }
                };
                openFrameLayout.Enable = true;
                btnDoorOpenPic.Enable = true;
            }
        }
        #endregion
        #region  接口实现
        #region 移除方法
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// 重写移除方法
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        public override void RemoveFromParent()
        {
        }
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
            UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction = null;
            if (IsDrawerLockMode)
            {
                CommonPage.Instance.IsDrawerLockMode = false;
            }
            ZbGateway.StatusList.Remove(this);
            DoorLockCommonInfo.LogicAction = null;
            base.RemoveFromParent();
        }
        #endregion
    }