HDL Home App 第二版本 旧平台金堂用 正在使用
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs
old mode 100755 new mode 100644
@@ -1,414 +1,1230 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using Shared.Common;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
    public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus
  public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus
  {
    #region 界面
    /// <summary>
    ///  构造函数
    /// </summary>
    /// <param name="room"></param>
    /// <param name="doorLock"></param>
    public UserDoorLockPage(Room room, CommonDevice doorLock)
    {
        public UserDoorLockPage(Shared.Common.Room room, DeviceUI doorLock)
        {
            this.doorLock = doorLock.CommonDevice as ZigBee.Device.DoorLock;
            currentRoom = room;
            deviceUI = doorLock;
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
        #region ◆ 变量申明__________________________
        ZigBee.Device.DoorLock doorLock;
        FrameLayout bottomFrameLayout;
        Shared.Common.Room currentRoom;
        DeviceUI deviceUI;
        Action action;
        Button btnDoorLockTitle;
        #endregion
        /// <summary>
        /// UI显示
        /// </summary>
        public void Show()
        {
            this.TopFrameLayout(this, "");
            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
            {
                RemoveFromParent();
            };
            this.btnBack.MouseUpEventHandler += eHandlerBack;
            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            this.MidFrameLayout(this);
            var btnShare = new Button
            {
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
            };
            this.titleFrameLayout.AddChidren(btnShare);
            var btnFuncSetFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(850 - 116),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69 * 2 + 58),
            };
            this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout);
            var btnFuncSet = new Button
            {
                X = Application.GetRealWidth(103),
                Height = Application.GetRealHeight(69),
                Width = Application.GetRealWidth(69),
                UnSelectedImagePath = "DoorLock/SettingIcon.png",
            };
            btnFuncSetFrameLayout.AddChidren(btnFuncSet);
            btnFuncSet.MouseDownEventHandler += (sender, e) =>
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 1)
      //徐梅的门锁界面打开(网关全局接收时使用)
      //ControlCommonResourse.IsDoorLockPageOpen = true;
      this.doorLock = doorLock as ZigBee.Device.DoorLock;
      currentRoom = room;
      deviceUI = doorLock;
      BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor;
      ZbGateway.StatusList.Add(this);
      Application.RunOnMainThread(() =>
      {
        UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction += (DoorlockKey, status) =>
              {
                var key = doorLock.DeviceAddr;
                if (DoorlockKey == key)
                {
                    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();
                        }
                    };
                  DoorLockCommonInfo.NormallyOpenModeValue(this.doorLock, status);
                  UpdateNomallyOpenStatus();
                }
                else
                {
                    var functionSettingSub = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock);
                    Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSettingSub);
                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                    functionSettingSub.Show();
                    functionSettingSub.devicNameAction += (deviceRename) =>
                    {
                        if (!string.IsNullOrEmpty(deviceRename))
                        {
                            btnDoorLockTitle.Text = deviceRename;
                        }
                    };
                }
            };
              };
      });
    }
            btnShare.MouseDownEventHandler += (sender, e) =>
            {
    #region  变量申明
    /// <summary>
    /// 当前门锁
    /// </summary>
    ZigBee.Device.DoorLock doorLock;
    /// <summary>
    /// 音量数据
    /// </summary>
    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>
    Room currentRoom;
    /// <summary>
    /// 设备UI对象
    /// </summary>
    CommonDevice deviceUI;
    /// <summary>
    /// 设置二次验证Action
    /// </summary>
    Action action;
    /// <summary>
    /// 中部布局中门锁名称显示
    /// </summary>
    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
            MidFrameLayoutContent();
        }
    /// <summary>
    /// UI显示
    /// </summary>
    public void Show()
    {
      this.TopFrameLayout(this, "");
      this.MidFrameLayout(this);
        public void MidFrameLayoutContent()
      btnShare = new Button
      {
        X = Application.GetRealWidth(850 - 116),
        Height = Application.GetRealHeight(69),
        Width = Application.GetRealWidth(0),
      };
      this.titleFrameLayout.AddChidren(btnShare);
      btnFuncSetFrameLayout = new FrameLayout
      {
        X = Application.GetRealWidth(850 - 116),
        Height = Application.GetRealHeight(69),
        Width = Application.GetRealWidth(69 * 2 + 58),
      };
      this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout);
      btnFuncSet = new Button
      {
        X = Application.GetRealWidth(103),
        Height = Application.GetMinReal(69),
        Width = Application.GetMinReal(69),
        UnSelectedImagePath = "DoorLock/SettingIcon.png",
      };
      btnFuncSetFrameLayout.AddChidren(btnFuncSet);
      MidFrameLayoutUI();
      ClickHandle();
      if (Common.LocalDevice.Current.CheckDeviceIsOnline(doorLock) == true)
      {
        ReadDoorLockUserInfo();
      }
      else
      {
        string msg1 = Language.StringByID(R.MyInternationalizationString.DoorLockOffLine);
        this.ShowTipMsg(msg1);
        return;
      }
    }
    /// <summary>
    /// 中部布局
    /// </summary>
    public void MidFrameLayoutUI()
    {
      var midTopFrameLayout = new FrameLayout()
      {
        X = Application.GetRealWidth(58),
        Y = Application.GetRealHeight(115),
        Height = Application.GetRealHeight(1238),
        Width = Application.GetRealWidth(965),
        BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
        Radius = (uint)Application.GetRealHeight(17),
      };
      this.midFrameLayout.AddChidren(midTopFrameLayout);
      //设备名称
      btnDoorLockTitle = new NormalViewControl(100, 60, true);
      btnDoorLockTitle.Y = Application.GetRealHeight(46);
      btnDoorLockTitle.TextSize = 15;
      btnDoorLockTitle.IsBold = true;
      btnDoorLockTitle.Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock);
      btnDoorLockTitle.Width = btnDoorLockTitle.GetRealWidthByText();
      if (btnDoorLockTitle.Width > 664)
      {
        btnDoorLockTitle.Width = 664;
      }
      btnDoorLockTitle.TextAlignment = TextAlignment.Center;
      btnDoorLockTitle.Gravity = Gravity.CenterHorizontal;
      midTopFrameLayout.AddChidren(btnDoorLockTitle);
      //记录
      btnRecordFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealWidth(69 + 15 + 46),
        Height = Application.GetRealHeight(69 + 46 * 2),
        X = Application.GetRealWidth(752 - 46),
      };
      midTopFrameLayout.AddChidren(btnRecordFrameLayout);
      btnRecord = new Button()
      {
        Width = Application.GetMinReal(69),
        Height = Application.GetMinReal(69),
        X = Application.GetRealWidth(46),
        Y = Application.GetRealHeight(46),
        UnSelectedImagePath = "DoorLock/RecordIcon.png",
      };
      btnRecordFrameLayout.AddChidren(btnRecord);
      //搜藏UI
      btnCollectFrameLayout = new FrameLayout()
      {
        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);
      //当前状态
      btnStatus = new Button()
      {
        Width = Application.GetRealWidth(132 + 351),
        Height = Application.GetRealHeight(40),
        Y = Application.GetRealHeight(118),
        Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose),
        TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
        TextSize = 10,
        TextAlignment = TextAlignment.CenterRight,
      };
      midTopFrameLayout.AddChidren(btnStatus);
      //当前电量
      btnCurrentPowerText = new Button()
      {
        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",
        SelectedImagePath = "DoorLock/DooorLockPicOpen.png",
      };
      midTopFrameLayout.AddChidren(btnDoorLockPic);
      #region 开/关点击布局
      var btnFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealWidth(420 - 46),
        Height = Application.GetRealHeight(446),
        X = btnDoorLockPic.Right,
        Y = Application.GetRealHeight(354),
        BackgroundColor = ZigbeeColor.Current.XMWhite,
      };
      midTopFrameLayout.AddChidren(btnFrameLayout);
      openFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealWidth(420),//639-35
        Height = Application.GetRealHeight(446 / 2),
        BackgroundColor = ZigbeeColor.Current.XMWhite,
      };
      btnFrameLayout.AddChidren(openFrameLayout);
      closeFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealWidth(420),//639-35
        Height = Application.GetRealHeight(446 / 2),
        Y = Application.GetRealHeight(446 / 2),
        BackgroundColor = ZigbeeColor.Current.XMWhite,
      };
      btnFrameLayout.AddChidren(closeFrameLayout);
      progressFrameLayoutMatch = new FrameLayout()
      {
        Width = Application.GetRealHeight(84),//639-35
        Height = Application.GetRealHeight(446 + 30),
        X = Application.GetMinReal(51),
        BackgroundColor = ZigbeeColor.Current.XMWhite,
      };
      btnFrameLayout.AddChidren(progressFrameLayoutMatch);
      var progressFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealHeight(15),//639-35
        Height = Application.GetRealHeight(440),
        Radius = (uint)Application.GetRealHeight(17),
        Gravity = Gravity.CenterHorizontal,
        BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar,
      };
      progressFrameLayoutMatch.AddChidren(progressFrameLayout);
      progressButton = new Button()
      {
        Width = Application.GetMinReal(84),//639-35
        Height = Application.GetMinReal(93),
        Gravity = Gravity.CenterHorizontal,
        Y = Application.GetRealHeight(347),
        UnSelectedImagePath = "DoorLock/UnLockButton.png",
      };
      progressFrameLayoutMatch.AddChidren(progressButton);
      btnDoorOpenPic = new Button()
      {
        Width = Application.GetMinReal(81),
        Height = Application.GetMinReal(81),
        X = Application.GetRealWidth(164),
        Y = Application.GetRealHeight(6),
        UnSelectedImagePath = "DoorLock/DoorLockOpen.png",
      };
      openFrameLayout.AddChidren(btnDoorOpenPic);
      btnDoorClosePic = new Button()
      {
        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),
        Width = Application.GetRealWidth(965),
        BackgroundColor = ZigbeeColor.Current.XMBlack,
        Y = Application.GetRealHeight(1100),
      };
      midTopFrameLayout.AddChidren(btnCurrentTopFrameLayout);
      var btnCurrentFrameLayout = new FrameLayout()
      {
        Width = Application.GetRealWidth(965),
        Height = Application.GetRealHeight(138),
        Y = Application.GetRealHeight(1100),
        BackgroundColor = ZigbeeColor.Current.XMBlack,
        Radius = (uint)Application.GetRealHeight(17),
      };
      midTopFrameLayout.AddChidren(btnCurrentFrameLayout);
      #endregion
      #region 当前房间
      var btnCurrentRoomPic = new Button()
      {
        Width = Application.GetMinReal(81),
        Height = Application.GetMinReal(81),
        X = Application.GetRealWidth(58),
        Y = Application.GetRealHeight(29),
        UnSelectedImagePath = "DoorLock/RoomPic.png",
      };
      btnCurrentFrameLayout.AddChidren(btnCurrentRoomPic);
      var btnCurrentRoomName = new Button()
      {
        Width = Application.GetRealWidth(172),
        Height = Application.GetRealHeight(49),
        X = Application.GetRealWidth(150),
        Y = Application.GetRealHeight(46),
        Text = currentRoom.Name,
        TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
        TextSize = 12,
        TextAlignment = TextAlignment.CenterLeft,
      };
      btnCurrentFrameLayout.AddChidren(btnCurrentRoomName);
      #endregion
    }
    #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) =>
      {
        dialog.Close();
        //设置音量
        if (currentVolume != oldVolume)
        {
            #region UI
            var midTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(115),
                Height = Application.GetRealHeight(1238),
                Width = Application.GetRealWidth(965),
                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
            };
            this.midFrameLayout.AddChidren(midTopFrameLayout);
          SetVolume(currentVolume);
        }
      };
            btnDoorLockTitle = new Button()
            {
                Width = Application.GetRealWidth(250),
                Height = Application.GetRealHeight(60),
                X = Application.GetRealWidth(372),
                Y = Application.GetRealHeight(46),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Text = string.IsNullOrEmpty(doorLock.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : doorLock.DeviceName,
                TextSize = 15,
                TextAlignment = TextAlignment.Center,
            };
            midTopFrameLayout.AddChidren(btnDoorLockTitle);
      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 btnRecord = new Button()
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                X = Application.GetRealWidth(752),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "DoorLock/RecordIcon.png",
            };
            midTopFrameLayout.AddChidren(btnRecord);
            btnRecord.MouseDownEventHandler += (sender, e) =>
            {
                //历史记录 ----   stan
                var form = new DeviceDoorLock.DoorLockHistoryLogForm();
                form.AddForm(this.doorLock.DeviceAddr);
            };
      //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() + "%",
      };
            var btnCollect = new Button()
      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)
          {
            //非主人不弹这个窗口
            if (UserCenterResourse.UserInfo.AuthorityNo != 1)
            {
                Width = Application.GetRealWidth(69),
                Height = Application.GetRealHeight(69),
                X = Application.GetRealWidth(850),
                Y = Application.GetRealHeight(46),
                UnSelectedImagePath = "Item/Collection.png",
                SelectedImagePath = "Item/CollectionSelected.png"
            };
            midTopFrameLayout.AddChidren(btnCollect);
            var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == deviceUI.FileName);
            if (de == null)
            {
                btnCollect.IsSelected = false;
            }
            else
            {
                btnCollect.IsSelected = true;
              return;
            }
            btnCollect.MouseDownEventHandler += (sender, e) =>
            if (doorLock.IsDoorLockNormallyMode)
            {
                btnCollect.IsSelected = !btnCollect.IsSelected;
                if (btnCollect.IsSelected)
              if (canOpenNormallyMode)
              {
                Application.RunOnMainThread(() =>
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(deviceUI.FileName);//收藏
                }
                else
                {
                    Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); //取消收藏
                }
            };
                  Action<bool> action = (obj) =>
                                  {
                                    UpdateNomallyOpenStatus();
                                  };
                  DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.ServicePush, haveLogicNormallyOpenMode, action);
                });
              }
            }
          }
        }
      }
            var btnCurrentText = new Button()
      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)
            {
                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);
              var dataReport = tempDevice.DeviceStatusReport.AttriBute[0];
              if (tempDevice.DeviceStatusReport.CluterID == 1 && dataReport.AttributeId == 33)
              {
                Application.RunOnMainThread(() =>
                {
                  currentPower = dataReport.AttriButeData;
                  UpdatePower();
                });
              }
            }
          }
        }
      }
    }
            var btnStatus = new Button()
    /// <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)
            {
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(40),
                X = btnCurrentText.Right,
                Y = Application.GetRealHeight(118),
                TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                Text = Language.StringByID(R.MyInternationalizationString.CLose),
                TextSize = 10,
                TextAlignment = TextAlignment.CenterLeft,
            };
            midTopFrameLayout.AddChidren(btnStatus);
            var btnDoorLockPic = new Button()
              Application.RunOnMainThread(() =>
                    {
                      btnNormallyOpen.UnSelectedImagePath = "DoorLock/NormallyOpenOffline.png";
                      btnNormallyOpen.Enable = false;
                      string msg = Language.StringByID(R.MyInternationalizationString.GetNormallyOpenModeFailed);
                      this.ShowTipMsg(msg);
                    });
            }
            else
            {
                Width = Application.GetRealWidth(383),
                Height = Application.GetRealHeight(343),
                X = Application.GetRealWidth(161),
                Y = Application.GetRealHeight(415),
                UnSelectedImagePath = "DoorLock/DoorLockPicClose.png",
                SelectedImagePath = "DoorLock/DooorLockPicOpen.png",
            };
            midTopFrameLayout.AddChidren(btnDoorLockPic);
              var tempRes = false;
              if (resultRes == true)
              {
                tempRes = true;
              }
              else
              {
                tempRes = false;
              }
              DoorLockCommonInfo.NormallyOpenModeValue(doorLock, tempRes);
            var btnFrameLayout = new FrameLayout()
              Application.RunOnMainThread(async () =>
                    {
                      var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(2, doorLock);
                      if (resTemp == 0)
                      {
                        haveLogicNormallyOpenMode = false;
                      }
                      else
                      {
                        haveLogicNormallyOpenMode = true;
                      }
                    });
            }
          }
          else
          {
            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)
            {
                Width = Application.GetRealWidth(420 - 46),
                Height = Application.GetRealHeight(446),
                X = btnDoorLockPic.Right,
                Y = Application.GetRealHeight(354),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            midTopFrameLayout.AddChidren(btnFrameLayout);
            var openFrameLayout = new FrameLayout()
              var listDevice = new List<CommonDevice> { };
              listDevice.Add(doorLock);
              var devTemp = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
              if (devTemp.ConcreteType != DeviceConcreteType.IntelligentLocks_H06C)
              {
                Application.RunOnMainThread(() =>
                      {
                        var volumeMsg = Language.StringByID(R.MyInternationalizationString.GetVolumeFailed);
                        this.ShowTipMsg(volumeMsg);
                      });
              }
            }
            else
            {
                Width = Application.GetRealWidth(420),//639-35
                Height = Application.GetRealHeight(446 / 2),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            btnFrameLayout.AddChidren(openFrameLayout);
              volumeData = resultRes.volumeResponseData;
              Application.RunOnMainThread(() =>
                    {
                      UpdateVolume();
                    });
            }
          }
          else
          {
            Application.RunOnMainThread(() =>
                  {
                    btnVolumeFrameLayout.Width = Application.GetRealWidth(0);
                    btnPower.X = Application.GetRealWidth(444);
                  });
          }
            var closeFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(420),//639-35
                Height = Application.GetRealHeight(446 / 2),
                Y = Application.GetRealHeight(446 / 2),
                BackgroundColor = ZigbeeColor.Current.XMWhite,
            };
            btnFrameLayout.AddChidren(closeFrameLayout);
          //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();
                });
        }
      });
    }
            var progressFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(9),//639-35
                Height = Application.GetRealHeight(446),
                X = Application.GetRealWidth(95),
                Y = Application.GetRealHeight(0),
                BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar,
            };
            btnFrameLayout.AddChidren(progressFrameLayout);
    #endregion
            var progressButton = new Button()
            {
                Width = Application.GetRealWidth(81),//639-35
                Height = Application.GetRealHeight(89),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(347),
                UnSelectedImagePath = "DoorLock/UnLockButton.png",
                SelectedImagePath = "DoorLock/UnLockButton.png",
            };
            btnFrameLayout.AddChidren(progressButton);
    #region 公共事件处理
    /// <summary>
    /// 事件处理
    /// </summary>
    public void ClickHandle()
    {
      //门锁标题
      btnDoorLockTitle.Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock);
            var btnDoorOpenPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(6),
                UnSelectedImagePath = "DoorLock/DoorLockOpen.png",
            };
            openFrameLayout.AddChidren(btnDoorOpenPic);
      //返回
      EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
      {
        RemoveFromParent();
      };
      this.btnBack.MouseUpEventHandler += eHandlerBack;
      this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
            var btnDoorClosePic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(164),
                Y = Application.GetRealHeight(117),
                UnSelectedImagePath = "DoorLock/DoorLockClose.png",
            };
            closeFrameLayout.AddChidren(btnDoorClosePic);
      //设置
      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;
            var btnCurrentFrameLayout = new FrameLayout()
            {
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(138),
                Y = Application.GetRealHeight(1100),
                BackgroundColor = ZigbeeColor.Current.XMBlack,
            };
            midTopFrameLayout.AddChidren(btnCurrentFrameLayout);
      //搜藏状态
      if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false)
      {
        btnCollect.IsSelected = false;
      }
      else
      {
        btnCollect.IsSelected = true;
      }
            var btnCurrentRoomPic = new Button()
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(29),
                UnSelectedImagePath = "DoorLock/RoomPic.png",
            };
            btnCurrentFrameLayout.AddChidren(btnCurrentRoomPic);
      //历史记录点击事件
      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;
            var btnCurrentRoomName = new Button()
            {
                Width = Application.GetRealWidth(172),
                Height = Application.GetRealHeight(49),
                X = Application.GetRealWidth(150),
                Y = Application.GetRealHeight(46),
                Text = currentRoom.Name,
                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
                TextSize = 12,
                TextAlignment = TextAlignment.CenterLeft,
            };
            btnCurrentFrameLayout.AddChidren(btnCurrentRoomName);
            #endregion
      //收藏点击事件
      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 (UserCenterResourse.UserInfo.AuthorityNo != 1)
      //开锁事件
      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 (UserCenterResourse.UserInfo.AuthorityNo != 1)
      {
        this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate));
        return;
      }
      if (!UserCenterResourse.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(LocalDevice.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)
                 {
                     var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid);
                     if (result == false)
                     {
                         var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid);
                         if (result1 == true)
                         {
                             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();
                                 }
                             };
                         }
                         else
                         {
                             new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                         }
                     }
                     else
                     {
                         new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Down, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                     }
                   haveLogicNormallyOpenMode = false;
                 }
                 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();
                         }
                     };
                   haveLogicNormallyOpenMode = true;
                 }
             };
            openFrameLayout.MouseUpEventHandler += hander1;
            btnDoorOpenPic.MouseUpEventHandler += hander1;
            EventHandler<MouseEventArgs> hander2 = (sender, e) =>
            {
                btnDoorLockPic.IsSelected = false;
                progressButton.Y = Application.GetRealHeight(347);
            };
            closeFrameLayout.MouseUpEventHandler += hander2;
            btnDoorClosePic.MouseUpEventHandler += hander2;
        }
        #region ◆ 接口实现__________________________
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        {
                 UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction -= addLogicPage.updateCurrentDoorlockActionTemp;
               };
      };
      HdlCheckLogic.Current.CheckSecondarySecurity(action);
        }
        /// <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)
        {
        }
        #endregion
    }
    /// <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 (UserCenterResourse.UserInfo.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
        {
          this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed));
          openFrameLayout.Enable = true;
          btnDoorOpenPic.Enable = true;
        }
      }
      else
      {
        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 移除方法
    /// <summary>
    /// 重写移除方法
    /// </summary>
    public override void RemoveFromParent()
    {
      UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction = null;
      if (IsDrawerLockMode)
      {
        CommonPage.Instance.IsDrawerLockMode = false;
      }
      ZbGateway.StatusList.Remove(this);
      DoorLockCommonInfo.LogicAction = null;
      base.RemoveFromParent();
    }
    #endregion
  }
}