HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/MainPage/ControlForm/DeviceAirerDetailCardForm.cs
@@ -6,174 +6,174 @@
using ZigBee.Device;
namespace Shared.Phone.MainPage.ControlForm
{
  /// <summary>
  /// 晾衣架类型的深度卡片界面
  /// </summary>
  public class DeviceAirerDetailCardForm : DeviceDetailCardCommonForm
  {
    #region ■ 变量声明___________________________
    /// <summary>
    /// 当前晾衣架
    /// 晾衣架类型的深度卡片界面
    /// </summary>
    Airer airer = null;
    /// <summary>
    /// 打开控件
    /// </summary>
    private IconBigViewControl btnOpen = null;
    /// <summary>
    /// 停止控件
    /// </summary>
    private IconBigViewControl btnStop = null;
    /// <summary>
    /// 关闭控件
    /// </summary>
    private IconBigViewControl btnClose = null;
    /// <summary>
    /// 照明
    /// </summary>
    private IconViewControl btnLight = null;
    /// <summary>
    /// 消毒
    /// </summary>
    private IconViewControl btnDisinfect = null;
    /// <summary>
    /// 风干
    /// </summary>
    private IconViewControl btnWind = null;
    /// <summary>
    /// 烘干
    /// </summary>
    private IconViewControl btnDry = null;
    /// <summary>
    /// 开合帘控件
    /// </summary>
    private CurtainSeekBar SeekBarOpenCurtain = null;
    /// <summary>
    /// 进度值是否在改变中
    /// </summary>
    private bool isProgressing = false;
    /// <summary>
    /// 是否已经初始化了控件(因为底层有可能会刷新整个界面)
    /// </summary>
    private bool hadInitControl = false;
    /// <summary>
    /// 烘干时间
    /// </summary>
    Button btnDryTimeText;
    /// <summary>
    /// 风干时间
    /// </summary>
    Button btnWindTimeText;
    /// <summary>
    /// 消毒时间
    /// </summary>
    Button btnDisinfectTimeText;
    /// <summary>
    /// 烘干文本时间处理
    /// </summary>
    public Action<string> actionDry = null;
    /// <summary>
    /// 风干文本时间处理
    /// </summary>
    public Action<string> actionWind = null;
    /// <summary>
    /// 消毒文本时间处理
    /// </summary>
    public Action<string> actionDisinfect = null;
    #endregion
    #region ■ 初始化_____________________________
    /// <summary>
    /// 底层初始化中部控件完成之后
    /// </summary>
    /// <param name="frameWhiteBack"></param>
    public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
    public class DeviceAirerDetailCardForm : DeviceDetailCardCommonForm
    {
      airer = this.device as Airer;
      //左滑不能
      this.ScrollEnabled = false;
      //设置状态文字
      this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
        #region ■ 变量声明___________________________
        /// <summary>
        /// 当前晾衣架
        /// </summary>
        Airer airer = null;
        /// <summary>
        /// 打开控件
        /// </summary>
        private IconBigViewControl btnOpen = null;
        /// <summary>
        /// 停止控件
        /// </summary>
        private IconBigViewControl btnStop = null;
        /// <summary>
        /// 关闭控件
        /// </summary>
        private IconBigViewControl btnClose = null;
        /// <summary>
        /// 照明
        /// </summary>
        private IconViewControl btnLight = null;
        /// <summary>
        /// 消毒
        /// </summary>
        private IconViewControl btnDisinfect = null;
        /// <summary>
        /// 风干
        /// </summary>
        private IconViewControl btnWind = null;
        /// <summary>
        /// 烘干
        /// </summary>
        private IconViewControl btnDry = null;
      var btnDoorLockPic = new Button()
      {
        Width = Application.GetMinReal(432),
        Height = Application.GetMinReal(302),
        Y = Application.GetRealHeight(228),
        UnSelectedImagePath = "Airer/DetailAirerPic.png",
        Gravity = Gravity.CenterHorizontal,
      };
      frameWhiteBack.AddChidren(btnDoorLockPic);
        /// <summary>
        /// 开合帘控件
        /// </summary>
        private CurtainSeekBar SeekBarOpenCurtain = null;
        /// <summary>
        /// 进度值是否在改变中
        /// </summary>
        private bool isProgressing = false;
        /// <summary>
        /// 是否已经初始化了控件(因为底层有可能会刷新整个界面)
        /// </summary>
        private bool hadInitControl = false;
        /// <summary>
        /// 烘干时间
        /// </summary>
        Button btnDryTimeText;
        /// <summary>
        /// 风干时间
        /// </summary>
        Button btnWindTimeText;
        /// <summary>
        /// 消毒时间
        /// </summary>
        Button btnDisinfectTimeText;
        /// <summary>
        /// 烘干文本时间处理
        /// </summary>
        public Action<string> actionDry = null;
        /// <summary>
        /// 风干文本时间处理
        /// </summary>
        public Action<string> actionWind = null;
        /// <summary>
        /// 消毒文本时间处理
        /// </summary>
        public Action<string> actionDisinfect = null;
        #endregion
      //打开控件
      this.btnOpen = new IconBigViewControl(81, 81);
      btnOpen.btnIcon.UseClickStatu = true;
      frameWhiteBack.AddChidren(btnOpen);
      btnOpen.InitControl();
      btnOpen.UnSelectedImagePath = "Airer/UpOffline.png";
      btnOpen.SelectedImagePath = "Airer/Up.png";
      btnOpen.X = Application.GetRealWidth(132) - btnOpen.XOffset;
      btnOpen.Y = Application.GetRealHeight(671);
        #region ■ 初始化_____________________________
      //停止控件
      this.btnStop = new IconBigViewControl(81, 81);
      btnStop.btnIcon.UseClickStatu = true;
      btnStop.UnSelectedImagePath = "Airer/StopOffline.png";
      btnStop.SelectedImagePath = "Airer/Stop.png";
      frameWhiteBack.AddChidren(btnStop);
      btnStop.InitControl();
      btnStop.X = Application.GetRealWidth(444) - btnStop.XOffset;
      btnStop.Y = btnOpen.Y;
        /// <summary>
        /// 底层初始化中部控件完成之后
        /// </summary>
        /// <param name="frameWhiteBack"></param>
        public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
        {
            airer = this.device as Airer;
            //左滑不能
            this.ScrollEnabled = false;
            //设置状态文字
            this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
      //关闭
      this.btnClose = new IconBigViewControl(81, 81);
      btnClose.btnIcon.UseClickStatu = true;
      frameWhiteBack.AddChidren(btnClose);
      btnClose.InitControl();
      btnClose.UnSelectedImagePath = "Airer/DownOffline.png";
      btnClose.SelectedImagePath = "Airer/Down.png";
      btnClose.X = Application.GetRealWidth(752) - btnClose.XOffset;
      btnClose.Y = btnOpen.Y;
            var btnDoorLockPic = new Button()
            {
                Width = Application.GetMinReal(432),
                Height = Application.GetMinReal(302),
                Y = Application.GetRealHeight(228),
                UnSelectedImagePath = "Airer/DetailAirerPic.png",
                Gravity = Gravity.CenterHorizontal,
            };
            frameWhiteBack.AddChidren(btnDoorLockPic);
      //烘干
      btnDry = new IconViewControl(81);
      btnDry.UnSelectedImagePath = "Airer/DryOffline.png";
      btnDry.SelectedImagePath = "Airer/Dry.png";
      btnDry.X = Application.GetRealWidth(98);
      btnDry.Y = Application.GetRealHeight(913);
      btnDry.IsSelected = ((Airer)this.device).DryOnOffStatus == 1 ? true : false;
      frameWhiteBack.AddChidren(btnDry);
            //打开控件
            this.btnOpen = new IconBigViewControl(81, 81);
            btnOpen.btnIcon.UseClickStatu = true;
            frameWhiteBack.AddChidren(btnOpen);
            btnOpen.InitControl();
            btnOpen.UnSelectedImagePath = "Airer/UpOffline.png";
            btnOpen.SelectedImagePath = "Airer/Up.png";
            btnOpen.X = Application.GetRealWidth(132) - btnOpen.XOffset;
            btnOpen.Y = Application.GetRealHeight(671);
      //风干
      btnWind = new IconViewControl(81);
      frameWhiteBack.AddChidren(btnWind);
      btnWind.UnSelectedImagePath = "Airer/WindOffline.png";
      btnWind.SelectedImagePath = "Airer/Wind.png";
      btnWind.X = Application.GetRealWidth(328);
      btnWind.IsSelected = ((Airer)this.device).WindOnOffStatus == 1 ? true : false;
      btnWind.Y = btnDry.Y;
            //停止控件
            this.btnStop = new IconBigViewControl(81, 81);
            btnStop.btnIcon.UseClickStatu = true;
            btnStop.UnSelectedImagePath = "Airer/StopOffline.png";
            btnStop.SelectedImagePath = "Airer/Stop.png";
            frameWhiteBack.AddChidren(btnStop);
            btnStop.InitControl();
            btnStop.X = Application.GetRealWidth(444) - btnStop.XOffset;
            btnStop.Y = btnOpen.Y;
      //消毒
      btnDisinfect = new IconViewControl(81);
      frameWhiteBack.AddChidren(btnDisinfect);
      btnDisinfect.UnSelectedImagePath = "Airer/DisinfectOffline.png";
      btnDisinfect.SelectedImagePath = "Airer/DisinfectSelected.png";
      btnDisinfect.IsSelected = ((Airer)this.device).DisinfectOnOffStatus == 1 ? true : false;
      btnDisinfect.X = Application.GetRealWidth(556);
      btnDisinfect.Y = btnDry.Y;
            //关闭
            this.btnClose = new IconBigViewControl(81, 81);
            btnClose.btnIcon.UseClickStatu = true;
            frameWhiteBack.AddChidren(btnClose);
            btnClose.InitControl();
            btnClose.UnSelectedImagePath = "Airer/DownOffline.png";
            btnClose.SelectedImagePath = "Airer/Down.png";
            btnClose.X = Application.GetRealWidth(752) - btnClose.XOffset;
            btnClose.Y = btnOpen.Y;
      //照明
      btnLight = new IconViewControl(81);
      frameWhiteBack.AddChidren(btnLight);
      btnLight.UnSelectedImagePath = "Airer/LightOffline.png";
      btnLight.SelectedImagePath = "Airer/LightSelected.png";
      btnLight.IsSelected = ((Airer)this.device).OnOffStatus == 1 ? true : false;
      btnLight.X = Application.GetRealWidth(786);
      btnLight.Y = btnDry.Y;
            //烘干
            btnDry = new IconViewControl(81);
            btnDry.UnSelectedImagePath = "Airer/DryOffline.png";
            btnDry.SelectedImagePath = "Airer/Dry.png";
            btnDry.X = Application.GetRealWidth(98);
            btnDry.Y = Application.GetRealHeight(913);
            btnDry.IsSelected = ((Airer)this.device).DryOnOffStatus == 1 ? true : false;
            frameWhiteBack.AddChidren(btnDry);
      string[] stringText = {
            //风干
            btnWind = new IconViewControl(81);
            frameWhiteBack.AddChidren(btnWind);
            btnWind.UnSelectedImagePath = "Airer/WindOffline.png";
            btnWind.SelectedImagePath = "Airer/Wind.png";
            btnWind.X = Application.GetRealWidth(328);
            btnWind.IsSelected = ((Airer)this.device).WindOnOffStatus == 1 ? true : false;
            btnWind.Y = btnDry.Y;
            //消毒
            btnDisinfect = new IconViewControl(81);
            frameWhiteBack.AddChidren(btnDisinfect);
            btnDisinfect.UnSelectedImagePath = "Airer/DisinfectOffline.png";
            btnDisinfect.SelectedImagePath = "Airer/DisinfectSelected.png";
            btnDisinfect.IsSelected = ((Airer)this.device).DisinfectOnOffStatus == 1 ? true : false;
            btnDisinfect.X = Application.GetRealWidth(556);
            btnDisinfect.Y = btnDry.Y;
            //照明
            btnLight = new IconViewControl(81);
            frameWhiteBack.AddChidren(btnLight);
            btnLight.UnSelectedImagePath = "Airer/LightOffline.png";
            btnLight.SelectedImagePath = "Airer/LightSelected.png";
            btnLight.IsSelected = ((Airer)this.device).OnOffStatus == 1 ? true : false;
            btnLight.X = Application.GetRealWidth(786);
            btnLight.Y = btnDry.Y;
            string[] stringText = {
               Language.StringByID(R.MyInternationalizationString.AirerUp),
               Language.StringByID(R.MyInternationalizationString.AirerStop),
               Language.StringByID(R.MyInternationalizationString.AirerDown),
@@ -183,630 +183,630 @@
               Language.StringByID(R.MyInternationalizationString.AirerLight)
            };
      for (int i = 0; i < stringText.Length; i++)
      {
        var btnText = new Button()
        {
          Width = Application.GetRealWidth(69 + 20),
          Height = Application.GetRealHeight(46),
          TextColor = ZigbeeColor.Current.XMGray2,
          TextSize = 12,
          Text = stringText[i],
        };
        frameWhiteBack.AddChidren(btnText);
        switch (i)
        {
          case 0:
            btnText.X = Application.GetRealWidth(128);
            btnText.Y = Application.GetRealHeight(780);
            break;
          case 1:
            btnText.X = Application.GetRealWidth(439);
            btnText.Y = Application.GetRealHeight(780);
            break;
          case 2:
            btnText.X = Application.GetRealWidth(747);
            btnText.Y = Application.GetRealHeight(780);
            break;
          case 3:
            btnText.X = Application.GetRealWidth(94);
            btnText.Y = Application.GetRealHeight(1022);
            btnText.BackgroundColor = 0xff00ff;
            break;
          case 4:
            btnText.X = Application.GetRealWidth(324);
            btnText.Y = Application.GetRealHeight(1022);
            btnText.BackgroundColor = 0xff00ff;
            break;
          case 5:
            btnText.X = Application.GetRealWidth(552);
            btnText.Y = Application.GetRealHeight(1022);
            break;
          case 6:
            btnText.X = Application.GetRealWidth(782);
            btnText.BackgroundColor = 0xff00ff;
            btnText.Y = Application.GetRealHeight(1022);
            break;
        }
      }
      //右箭头  {烘干、风干和消毒的设置默认时间暂时取去掉,且倒计时也去掉,因为第三方设备不支持」
      //TimeShow(frameWhiteBack);
      ClickEventHander();
    }
    #endregion
    #region ■ 时间显示_______________________
    /// <summary>
    /// 发送窗帘命令
    /// </summary>
    /// <param name="comand"></param>
    private void TimeShow(FrameLayout frameWhiteBack)
    {
      //烘干时间
      btnDryTimeText = new Button()
      {
        Width = Application.GetRealWidth(109 + 10),
        Height = Application.GetRealHeight(40),
        X = Application.GetRealWidth(81),
        Y = Application.GetRealHeight(1092),
        TextColor = ZigbeeColor.Current.XMOrange,
        TextSize = 10,
        Text = GetTimeString(airer.DryRemainTime),
      };
      frameWhiteBack.AddChidren(btnDryTimeText);
      //风干时间
      btnWindTimeText = new Button()
      {
        Width = Application.GetRealWidth(109 + 10),
        Height = Application.GetRealHeight(40),
        TextColor = ZigbeeColor.Current.XMOrange,
        TextSize = 10,
        X = Application.GetRealWidth(311),
        Y = btnDryTimeText.Y,
        Text = GetTimeString(airer.WindRemainTime),
      };
      frameWhiteBack.AddChidren(btnWindTimeText);
      //消毒时间
      btnDisinfectTimeText = new Button()
      {
        Width = Application.GetRealWidth(109 + 10),
        Height = Application.GetRealHeight(40),
        TextColor = ZigbeeColor.Current.XMOrange,
        TextSize = 10,
        Text = GetTimeString(airer.DisinfectRemainTime),
        X = Application.GetRealWidth(539),
        Y = btnDryTimeText.Y,
      };
      frameWhiteBack.AddChidren(btnDisinfectTimeText);
      var rowAirer = new AiererTimeControl(0);
      rowAirer.DetailCardActionTimeEvent += (timeCur, typeCur) =>
      {
        switch (typeCur)
        {
          case 1:
            btnDryTimeText.Text = GetTimeString(timeCur);
            break;
          case 2:
            btnWindTimeText.Text = GetTimeString(timeCur);
            break;
          case 3:
            btnDisinfectTimeText.Text = GetTimeString(timeCur);
            break;
        }
      };
      actionDry = (textTime) =>
      {
        btnDryTimeText.Text = textTime;
        TimerHandler(airer);
      };
      actionWind = (textTime) =>
     {
       btnWindTimeText.Text = textTime;
       TimerHandler(airer);
     };
      actionDisinfect = (textTime) =>
      {
        btnDisinfectTimeText.Text = textTime;
        TimerHandler(airer);
      };
      TimerHandler(airer);
    }
    #endregion
    #region ■ 点击事件处理_______________________
    /// <summary>
    /// 点击事件处理
    /// </summary>
    void ClickEventHander()
    {
      btnOpen.ButtonClickEvent += (sender, e) =>
      {
        //发送窗帘命令
        this.SetCurtainCommand(0);
      };
      btnStop.ButtonClickEvent += (sender, e) =>
      {
        //如果住宅为虚拟住宅,则此功能无效
        if (Common.Config.Instance.Home.IsVirtually == true)
        {
          return;
        }
        //发送窗帘命令
        this.SetCurtainCommand(2);
      };
      btnClose.ButtonClickEvent += (sender, e) =>
      {
        //发送窗帘命令
        this.SetCurtainCommand(1);
      };
      btnDry.ButtonClickEvent += (sender, e) =>
      {
        //发送开关命令
        this.SetSwitchCommand(!btnDry.IsSelected, 4);
      };
      btnWind.ButtonClickEvent += (sender, e) =>
      {
        //发送开关命令
        this.SetSwitchCommand(!btnWind.IsSelected, 3);
      };
      btnDisinfect.ButtonClickEvent += (sender, e) =>
      {
        //发送开关命令
        this.SetSwitchCommand(!btnDisinfect.IsSelected, 5);
      };
      btnLight.ButtonClickEvent += (sender, e) =>
      {
        //发送开关命令
        this.SetSwitchCommand(!btnLight.IsSelected, 2);
      };
    }
    #endregion
    #region ■ 发送开关命令_______________________
    /// <summary>
    /// 发送开关命令
    ///注意,衣架中不同端点代表不同功能
    ///回路1:窗帘控制
    ///回路2:照明控制
    ///回路3:风干控制
    ///回路4:烘干控制
    ///回路5:消毒控制
    /// </summary>
    /// <param name="isOpen">发送状态</param>
    /// <param name="type">发送类型:2:照明;3:风干;4:烘干;5消毒</param>
    private void SetSwitchCommand(bool isOpen, int type)
    {
      //如果住宅为虚拟住宅
      if (Common.Config.Instance.Home.IsVirtually == true)
      {
        switch (type)
        {
          case 2:
            ((Airer)this.device).OnOffStatus = isOpen == true ? 1 : 0;
            //变更卡片状态
            this.RefreshSwitchStatu(((Airer)this.device).OnOffStatus == 1, 2);
            break;
          case 3:
            ((Airer)this.device).WindOnOffStatus = isOpen == true ? 1 : 0;
            if (isOpen)
            for (int i = 0; i < stringText.Length; i++)
            {
              airer.WindRemainTime = airer.WindTime;
            }
            //变更卡片状态
            this.RefreshSwitchStatu(((Airer)this.device).WindOnOffStatus == 1, 3);
            break;
          case 4:
            ((Airer)this.device).DryOnOffStatus = isOpen == true ? 1 : 0;
            if (isOpen)
            {
              airer.DryRemainTime = airer.DryTime;
            }
            //变更卡片状态
            this.RefreshSwitchStatu(((Airer)this.device).DryOnOffStatus == 1, 4);
            break;
          case 5:
            ((Airer)this.device).DisinfectOnOffStatus = isOpen == true ? 1 : 0;
            if (isOpen)
            {
              airer.DisinfectRemainTime = airer.DisinfectTime;
            }
            //变更卡片状态
            this.RefreshSwitchStatu(((Airer)this.device).DisinfectOnOffStatus == 1, 5);
            break;
        }
        return;
      }
      //检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
      var listControl = new List<ButtonBase>();
      listControl.Add(btnDry);
      listControl.Add(btnWind);
      listControl.Add(btnDisinfect);
      listControl.Add(btnLight);
      this.StartCheckResponeResult(listControl, (result) =>
      {
        //接收到网关回复
        if (result == true)
        {
          HdlThreadLogic.Current.RunMain(() =>
                var btnText = new Button()
                {
                  //变更卡片状态
                  switch (type)
                  {
                    Width = Application.GetRealWidth(69 + 20),
                    Height = Application.GetRealHeight(46),
                    TextColor = ZigbeeColor.Current.XMGray2,
                    TextSize = 12,
                    Text = stringText[i],
                };
                frameWhiteBack.AddChidren(btnText);
                switch (i)
                {
                    case 0:
                        btnText.X = Application.GetRealWidth(128);
                        btnText.Y = Application.GetRealHeight(780);
                        break;
                    case 1:
                        btnText.X = Application.GetRealWidth(439);
                        btnText.Y = Application.GetRealHeight(780);
                        break;
                    case 2:
                      bool statu = ((Airer)this.device).OnOffStatus == 1;
                      this.RefreshSwitchStatu(statu, type);
                      break;
                        btnText.X = Application.GetRealWidth(747);
                        btnText.Y = Application.GetRealHeight(780);
                        break;
                    case 3:
                      bool statu5 = ((Airer)this.device).WindOnOffStatus == 1;
                      this.RefreshSwitchStatu(statu5, type);
                      break;
                        btnText.X = Application.GetRealWidth(94);
                        btnText.Y = Application.GetRealHeight(1022);
                        btnText.BackgroundColor = 0xff00ff;
                        break;
                    case 4:
                      bool statu4 = ((Airer)this.device).DryOnOffStatus == 1;
                      this.RefreshSwitchStatu(statu4, type);
                      break;
                        btnText.X = Application.GetRealWidth(324);
                        btnText.Y = Application.GetRealHeight(1022);
                        btnText.BackgroundColor = 0xff00ff;
                        break;
                    case 5:
                      bool statu3 = ((Airer)this.device).DisinfectOnOffStatus == 1;
                      this.RefreshSwitchStatu(statu3, type);
                      break;
                  }
                        btnText.X = Application.GetRealWidth(552);
                        btnText.Y = Application.GetRealHeight(1022);
                        break;
                    case 6:
                        btnText.X = Application.GetRealWidth(782);
                        btnText.BackgroundColor = 0xff00ff;
                        btnText.Y = Application.GetRealHeight(1022);
                        break;
                }
            }
                });
            //右箭头  {烘干、风干和消毒的设置默认时间暂时取去掉,且倒计时也去掉,因为第三方设备不支持」
            //TimeShow(frameWhiteBack);
            ClickEventHander();
        }
      });
      //打开
      //switch (type)
      //{
      //  case 3:
      //发送默认时间
      //if (airer.WindTime == 0)
      //{
      //  airer.WindTime = 180;
      //}
      //airer.SetAirerFunTimeDevice(airer.WindTime, 3);
      //  break;
      //case 4:
      //发送默认时间
      //if (airer.DryTime == 0)
      //{
      //  airer.DryTime = 180;
      //}
      //airer.SetAirerFunTimeDevice(airer.DryTime, 4);
      //  break;
      //case 5:
      //发送默认时间
      //if (airer.DisinfectTime == 0)
      //{
      //  airer.DisinfectTime = 30;
      //}
      //airer.SetAirerFunTimeDevice(airer.DisinfectTime, 5);
      //    break;
      //}
      if (isOpen == true)
      {
        airer.SwitchControl(1, type);
      }
      else
      {
        airer.SwitchControl(0, type);
      }
    }
        #endregion
    #endregion
        #region ■ 时间显示_______________________
    #region ■ 发送窗帘命令_______________________
    /// <summary>
    /// 发送窗帘命令
    ///注意,衣架中不同端点代表不同功能
    ///回路1:窗帘控制
    ///回路2:照明控制
    ///回路3:风干控制
    ///回路4:烘干控制
    ///回路5:消毒控制
    /// </summary>
    /// <param name="comand"></param>
    private void SetCurtainCommand(int comand)
    {
      //
      this.device.DeviceEpoint = 1;
      //发送命令
      ((Airer)device).AirerUpDownStopControl(comand);
    }
    #endregion
    #region ■ 刷新开关状态_______________________
    /// <summary>
    /// 刷新开关状态
    /// </summary>
    /// <param name="isOpen">打开状态</param>
    /// <param name="type">发送类型:2:照明;3:风干;4:烘干;5消毒</param>
    private void RefreshSwitchStatu(bool isOpen, int type)
    {
      switch (type)
      {
        case 2:
          btnLight.IsSelected = isOpen;
          break;
        case 3:
          btnWind.IsSelected = isOpen;
          //btnWindTimeText.Text = GetTimeString(airer.WindRemainTime);
          //if (!isOpen)
          //{
          //  airer.WindRemainTime = 0;
          //}
          break;
        case 4:
          btnDry.IsSelected = isOpen;
          //btnDryTimeText.Text = GetTimeString(airer.DryRemainTime);
          //if (!isOpen)
          //{
          //  airer.DryRemainTime = 0;
          //}
          break;
        case 5:
          btnDisinfect.IsSelected = isOpen;
          //btnDisinfectTimeText.Text = GetTimeString(airer.DisinfectRemainTime);
          //if (!isOpen)
          //{
          //  airer.DisinfectRemainTime = 0;
          //}
          break;
      }
      //设置状态文字
      this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
    }
    #endregion
    #region ■ 是否获取网关反馈的结果_____________
    /// <summary>
    /// 检测网关的反馈结果(属性上报的对象:device.DeviceStatusReport)
    /// </summary>
    /// <param name="comandDiv">命令区分</param>
    /// <param name="report">上报数据</param>
    /// <returns></returns>
    public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report)
    {
      if (comandDiv == ReceiveComandDiv.A设备属性上报)
      {
        HdlThreadLogic.Current.RunMain(() =>
        /// <summary>
        /// 发送窗帘命令
        /// </summary>
        /// <param name="comand"></param>
        private void TimeShow(FrameLayout frameWhiteBack)
        {
          //变更卡片状态
          switch (report.DeviceEpoint)
          {
            case 2:
              this.RefreshSwitchStatu(((Airer)this.device).OnOffStatus == 1, 2);
              break;
            case 3:
              this.RefreshSwitchStatu(((Airer)this.device).WindOnOffStatus == 1, 3);
              break;
            case 4:
              this.RefreshSwitchStatu(((Airer)this.device).DryOnOffStatus == 1, 4);
              break;
            case 5:
              this.RefreshSwitchStatu(((Airer)this.device).DisinfectOnOffStatus == 1, 5);
              break;
          }
        });
        return true;
      }
      return false;
    }
            //烘干时间
            btnDryTimeText = new Button()
            {
                Width = Application.GetRealWidth(109 + 10),
                Height = Application.GetRealHeight(40),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(1092),
                TextColor = ZigbeeColor.Current.XMOrange,
                TextSize = 10,
                Text = GetTimeString(airer.DryRemainTime),
            };
            frameWhiteBack.AddChidren(btnDryTimeText);
    #endregion
            //风干时间
            btnWindTimeText = new Button()
            {
                Width = Application.GetRealWidth(109 + 10),
                Height = Application.GetRealHeight(40),
                TextColor = ZigbeeColor.Current.XMOrange,
                TextSize = 10,
                X = Application.GetRealWidth(311),
                Y = btnDryTimeText.Y,
                Text = GetTimeString(airer.WindRemainTime),
            };
            frameWhiteBack.AddChidren(btnWindTimeText);
    /// <summary>
    /// 时间倒计时设置
    /// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
    /// </summary>
    /// <param name="sceneContr"></param>
    public async void TimerHandler(Airer airer)
    {
      if (airer.DryOnOffStatus == 1 && airer.DryRemainTime != 0)
      {
        new System.Threading.Thread(async () =>
       {
         while (airer.DryRemainTime > 0 && this.Parent != null)
         {
           System.Threading.Thread.Sleep(1000);
           HdlThreadLogic.Current.RunMain(() =>
                   {
                     actionDry?.Invoke(GetTimeString(airer.DryRemainTime));
                   }, ShowErrorMode.NO);
           airer.DryRemainTime--;
         }
         HdlThreadLogic.Current.RunMain(() =>
                 {
                   if (this.Parent != null)
                   {
                     //直接开启Loading特效
                     actionDry?.Invoke("");
                   }
                 }, ShowErrorMode.NO);
       })
        { IsBackground = true }.Start();
      }
      if (airer.WindOnOffStatus == 1 && airer.WindRemainTime != 0)
      {
        //开启风干时间
        new System.Threading.Thread(async () =>
            //消毒时间
            btnDisinfectTimeText = new Button()
            {
                Width = Application.GetRealWidth(109 + 10),
                Height = Application.GetRealHeight(40),
                TextColor = ZigbeeColor.Current.XMOrange,
                TextSize = 10,
                Text = GetTimeString(airer.DisinfectRemainTime),
                X = Application.GetRealWidth(539),
                Y = btnDryTimeText.Y,
            };
            frameWhiteBack.AddChidren(btnDisinfectTimeText);
            var rowAirer = new AiererTimeControl(0);
            rowAirer.DetailCardActionTimeEvent += (timeCur, typeCur) =>
            {
                switch (typeCur)
                {
                    case 1:
                        btnDryTimeText.Text = GetTimeString(timeCur);
                        break;
                    case 2:
                        btnWindTimeText.Text = GetTimeString(timeCur);
                        break;
                    case 3:
                        btnDisinfectTimeText.Text = GetTimeString(timeCur);
                        break;
                }
            };
            actionDry = (textTime) =>
            {
                btnDryTimeText.Text = textTime;
                TimerHandler(airer);
            };
            actionWind = (textTime) =>
           {
               btnWindTimeText.Text = textTime;
               TimerHandler(airer);
           };
            actionDisinfect = (textTime) =>
            {
                btnDisinfectTimeText.Text = textTime;
                TimerHandler(airer);
            };
            TimerHandler(airer);
        }
        #endregion
        #region ■ 点击事件处理_______________________
        /// <summary>
        /// 点击事件处理
        /// </summary>
        void ClickEventHander()
        {
          while (airer.WindRemainTime > 0 && this.Parent != null)
          {
            System.Threading.Thread.Sleep(1000);
            HdlThreadLogic.Current.RunMain(() =>
                    {
                      actionWind?.Invoke(GetTimeString(airer.WindRemainTime));
                    }, ShowErrorMode.NO);
            airer.WindRemainTime--;
          }
          HdlThreadLogic.Current.RunMain(() =>
                 {
                   if (this.Parent != null)
                   {
                     //直接开启Loading特效
                     actionWind?.Invoke("");
                   }
                 }, ShowErrorMode.NO);
        })
        { IsBackground = true }.Start();
      }
      if (airer.DisinfectOnOffStatus == 1 && airer.DisinfectRemainTime != 0)
      {
        //开启消毒时间
        new System.Threading.Thread(async () =>
        {
          while (airer.DisinfectRemainTime > 0 && this.Parent != null)
          {
            System.Threading.Thread.Sleep(1000);
            HdlThreadLogic.Current.RunMain(() =>
                    {
                      actionDisinfect?.Invoke(GetTimeString(airer.DisinfectRemainTime));
                    }, ShowErrorMode.NO);
            airer.DisinfectRemainTime--;
          }
            btnOpen.ButtonClickEvent += (sender, e) =>
            {
                //发送窗帘命令
                this.SetCurtainCommand(0);
            };
            btnStop.ButtonClickEvent += (sender, e) =>
            {
                //如果住宅为虚拟住宅,则此功能无效
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    return;
                }
                //发送窗帘命令
                this.SetCurtainCommand(2);
            };
            btnClose.ButtonClickEvent += (sender, e) =>
            {
                //发送窗帘命令
                this.SetCurtainCommand(1);
            };
          HdlThreadLogic.Current.RunMain(() =>
                  {
                    if (this.Parent != null)
            btnDry.ButtonClickEvent += (sender, e) =>
            {
                //发送开关命令
                this.SetSwitchCommand(!btnDry.IsSelected, 4);
            };
            btnWind.ButtonClickEvent += (sender, e) =>
            {
                //发送开关命令
                this.SetSwitchCommand(!btnWind.IsSelected, 3);
            };
            btnDisinfect.ButtonClickEvent += (sender, e) =>
            {
                //发送开关命令
                this.SetSwitchCommand(!btnDisinfect.IsSelected, 5);
            };
            btnLight.ButtonClickEvent += (sender, e) =>
            {
                //发送开关命令
                this.SetSwitchCommand(!btnLight.IsSelected, 2);
            };
        }
        #endregion
        #region ■ 发送开关命令_______________________
        /// <summary>
        /// 发送开关命令
        ///注意,衣架中不同端点代表不同功能
        ///回路1:窗帘控制
        ///回路2:照明控制
        ///回路3:风干控制
        ///回路4:烘干控制
        ///回路5:消毒控制
        /// </summary>
        /// <param name="isOpen">发送状态</param>
        /// <param name="type">发送类型:2:照明;3:风干;4:烘干;5消毒</param>
        private void SetSwitchCommand(bool isOpen, int type)
        {
            //如果住宅为虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                switch (type)
                {
                    case 2:
                        ((Airer)this.device).OnOffStatus = isOpen == true ? 1 : 0;
                        //变更卡片状态
                        this.RefreshSwitchStatu(((Airer)this.device).OnOffStatus == 1, 2);
                        break;
                    case 3:
                        ((Airer)this.device).WindOnOffStatus = isOpen == true ? 1 : 0;
                        if (isOpen)
                        {
                            airer.WindRemainTime = airer.WindTime;
                        }
                        //变更卡片状态
                        this.RefreshSwitchStatu(((Airer)this.device).WindOnOffStatus == 1, 3);
                        break;
                    case 4:
                        ((Airer)this.device).DryOnOffStatus = isOpen == true ? 1 : 0;
                        if (isOpen)
                        {
                            airer.DryRemainTime = airer.DryTime;
                        }
                        //变更卡片状态
                        this.RefreshSwitchStatu(((Airer)this.device).DryOnOffStatus == 1, 4);
                        break;
                    case 5:
                        ((Airer)this.device).DisinfectOnOffStatus = isOpen == true ? 1 : 0;
                        if (isOpen)
                        {
                            airer.DisinfectRemainTime = airer.DisinfectTime;
                        }
                        //变更卡片状态
                        this.RefreshSwitchStatu(((Airer)this.device).DisinfectOnOffStatus == 1, 5);
                        break;
                }
                return;
            }
            //检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
            var listControl = new List<ButtonBase>();
            listControl.Add(btnDry);
            listControl.Add(btnWind);
            listControl.Add(btnDisinfect);
            listControl.Add(btnLight);
            this.StartCheckResponeResult(listControl, (result) =>
            {
                //接收到网关回复
                if (result == true)
                {
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                      //直接开启Loading特效
                      actionDisinfect?.Invoke("");
                        //变更卡片状态
                        switch (type)
                        {
                            case 2:
                                bool statu = ((Airer)this.device).OnOffStatus == 1;
                                this.RefreshSwitchStatu(statu, type);
                                break;
                            case 3:
                                bool statu5 = ((Airer)this.device).WindOnOffStatus == 1;
                                this.RefreshSwitchStatu(statu5, type);
                                break;
                            case 4:
                                bool statu4 = ((Airer)this.device).DryOnOffStatus == 1;
                                this.RefreshSwitchStatu(statu4, type);
                                break;
                            case 5:
                                bool statu3 = ((Airer)this.device).DisinfectOnOffStatus == 1;
                                this.RefreshSwitchStatu(statu3, type);
                                break;
                        }
                    });
                }
            });
            //打开
            //switch (type)
            //{
            //  case 3:
            //发送默认时间
            //if (airer.WindTime == 0)
            //{
            //  airer.WindTime = 180;
            //}
            //airer.SetAirerFunTimeDevice(airer.WindTime, 3);
            //  break;
            //case 4:
            //发送默认时间
            //if (airer.DryTime == 0)
            //{
            //  airer.DryTime = 180;
            //}
            //airer.SetAirerFunTimeDevice(airer.DryTime, 4);
            //  break;
            //case 5:
            //发送默认时间
            //if (airer.DisinfectTime == 0)
            //{
            //  airer.DisinfectTime = 30;
            //}
            //airer.SetAirerFunTimeDevice(airer.DisinfectTime, 5);
            //    break;
            //}
            if (isOpen == true)
            {
                airer.SwitchControl(1, type);
            }
            else
            {
                airer.SwitchControl(0, type);
            }
        }
        #endregion
        #region ■ 发送窗帘命令_______________________
        /// <summary>
        /// 发送窗帘命令
        ///注意,衣架中不同端点代表不同功能
        ///回路1:窗帘控制
        ///回路2:照明控制
        ///回路3:风干控制
        ///回路4:烘干控制
        ///回路5:消毒控制
        /// </summary>
        /// <param name="comand"></param>
        private void SetCurtainCommand(int comand)
        {
            //
            this.device.DeviceEpoint = 1;
            //发送命令
            ((Airer)device).AirerUpDownStopControl(comand);
        }
        #endregion
        #region ■ 刷新开关状态_______________________
        /// <summary>
        /// 刷新开关状态
        /// </summary>
        /// <param name="isOpen">打开状态</param>
        /// <param name="type">发送类型:2:照明;3:风干;4:烘干;5消毒</param>
        private void RefreshSwitchStatu(bool isOpen, int type)
        {
            switch (type)
            {
                case 2:
                    btnLight.IsSelected = isOpen;
                    break;
                case 3:
                    btnWind.IsSelected = isOpen;
                    //btnWindTimeText.Text = GetTimeString(airer.WindRemainTime);
                    //if (!isOpen)
                    //{
                    //  airer.WindRemainTime = 0;
                    //}
                    break;
                case 4:
                    btnDry.IsSelected = isOpen;
                    //btnDryTimeText.Text = GetTimeString(airer.DryRemainTime);
                    //if (!isOpen)
                    //{
                    //  airer.DryRemainTime = 0;
                    //}
                    break;
                case 5:
                    btnDisinfect.IsSelected = isOpen;
                    //btnDisinfectTimeText.Text = GetTimeString(airer.DisinfectRemainTime);
                    //if (!isOpen)
                    //{
                    //  airer.DisinfectRemainTime = 0;
                    //}
                    break;
            }
            //设置状态文字
            this.SetStatuText(HdlDeviceOtherLogic.Current.GetDeviceStatu(this.device));
        }
        #endregion
        #region ■ 是否获取网关反馈的结果_____________
        /// <summary>
        /// 检测网关的反馈结果(属性上报的对象:device.DeviceStatusReport)
        /// </summary>
        /// <param name="comandDiv">命令区分</param>
        /// <param name="report">上报数据</param>
        /// <returns></returns>
        public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report)
        {
            if (comandDiv == ReceiveComandDiv.A设备属性上报)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //变更卡片状态
                    switch (report.DeviceEpoint)
                    {
                        case 2:
                            this.RefreshSwitchStatu(((Airer)this.device).OnOffStatus == 1, 2);
                            break;
                        case 3:
                            this.RefreshSwitchStatu(((Airer)this.device).WindOnOffStatus == 1, 3);
                            break;
                        case 4:
                            this.RefreshSwitchStatu(((Airer)this.device).DryOnOffStatus == 1, 4);
                            break;
                        case 5:
                            this.RefreshSwitchStatu(((Airer)this.device).DisinfectOnOffStatus == 1, 5);
                            break;
                    }
                  }, ShowErrorMode.NO);
        })
        { IsBackground = true }.Start();
      }
    }
    /// <summary>
    /// 获取场景延时字符串
    /// </summary>
    /// <param name="second"></param>
    /// <returns></returns>
    public static string GetTimeString(int second)
    {
      if (second == 0)
      {
        return null;
      }
      string timeStr = string.Empty;
      int hour = second / 3600;
      int minu = second % 3600 / 60;
      int sec = second % 60;
      string h = string.Empty;
      string m = string.Empty;
      string s = string.Empty;
      if (hour > 0)
      {
        if (hour < 10)
        {
          h = "0" + hour;
        }
        else
        {
          h = hour.ToString();
        }
        timeStr += $"{h}:";
        if (minu >= 0)
        {
          if (minu < 10)
          {
            m = "0" + minu;
          }
          else
          {
            m = minu.ToString();
          }
          timeStr += $"{m}:";
                });
                return true;
            }
            return false;
        }
        if (sec >= 0)
        {
          if (sec < 10)
          {
            s = "0" + sec;
          }
          else
          {
            s = minu.ToString();
          }
          timeStr += $"{s}";
        }
        #endregion
        return timeStr;
      }
      else
      {
        if (minu > 0)
        /// <summary>
        /// 时间倒计时设置
        /// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
        /// </summary>
        /// <param name="sceneContr"></param>
        public async void TimerHandler(Airer airer)
        {
          timeStr = "00:";
          if (minu < 10)
          {
            m = "0" + minu;
          }
          else
          {
            m = minu.ToString();
          }
          timeStr += $"{m}:";
          if (sec >= 0)
          {
            if (sec < 10)
            if (airer.DryOnOffStatus == 1 && airer.DryRemainTime != 0)
            {
              s = "0" + sec;
                new System.Threading.Thread(async () =>
               {
                   while (airer.DryRemainTime > 0 && this.Parent != null)
                   {
                       System.Threading.Thread.Sleep(1000);
                       HdlThreadLogic.Current.RunMain(() =>
                       {
                           actionDry?.Invoke(GetTimeString(airer.DryRemainTime));
                       }, ShowErrorMode.NO);
                       airer.DryRemainTime--;
                   }
                   HdlThreadLogic.Current.RunMain(() =>
                   {
                       if (this.Parent != null)
                       {
                           //直接开启Loading特效
                           actionDry?.Invoke("");
                       }
                   }, ShowErrorMode.NO);
               })
                { IsBackground = true }.Start();
            }
            if (airer.WindOnOffStatus == 1 && airer.WindRemainTime != 0)
            {
                //开启风干时间
                new System.Threading.Thread(async () =>
                {
                    while (airer.WindRemainTime > 0 && this.Parent != null)
                    {
                        System.Threading.Thread.Sleep(1000);
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            actionWind?.Invoke(GetTimeString(airer.WindRemainTime));
                        }, ShowErrorMode.NO);
                        airer.WindRemainTime--;
                    }
                    HdlThreadLogic.Current.RunMain(() =>
                   {
                       if (this.Parent != null)
                       {
                           //直接开启Loading特效
                           actionWind?.Invoke("");
                       }
                   }, ShowErrorMode.NO);
                })
                { IsBackground = true }.Start();
            }
            if (airer.DisinfectOnOffStatus == 1 && airer.DisinfectRemainTime != 0)
            {
                //开启消毒时间
                new System.Threading.Thread(async () =>
                {
                    while (airer.DisinfectRemainTime > 0 && this.Parent != null)
                    {
                        System.Threading.Thread.Sleep(1000);
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            actionDisinfect?.Invoke(GetTimeString(airer.DisinfectRemainTime));
                        }, ShowErrorMode.NO);
                        airer.DisinfectRemainTime--;
                    }
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        if (this.Parent != null)
                        {
                            //直接开启Loading特效
                            actionDisinfect?.Invoke("");
                        }
                    }, ShowErrorMode.NO);
                })
                { IsBackground = true }.Start();
            }
        }
        /// <summary>
        /// 获取场景延时字符串
        /// </summary>
        /// <param name="second"></param>
        /// <returns></returns>
        public static string GetTimeString(int second)
        {
            if (second == 0)
            {
                return null;
            }
            string timeStr = string.Empty;
            int hour = second / 3600;
            int minu = second % 3600 / 60;
            int sec = second % 60;
            string h = string.Empty;
            string m = string.Empty;
            string s = string.Empty;
            if (hour > 0)
            {
                if (hour < 10)
                {
                    h = "0" + hour;
                }
                else
                {
                    h = hour.ToString();
                }
                timeStr += $"{h}:";
                if (minu >= 0)
                {
                    if (minu < 10)
                    {
                        m = "0" + minu;
                    }
                    else
                    {
                        m = minu.ToString();
                    }
                    timeStr += $"{m}:";
                }
                if (sec >= 0)
                {
                    if (sec < 10)
                    {
                        s = "0" + sec;
                    }
                    else
                    {
                        s = minu.ToString();
                    }
                    timeStr += $"{s}";
                }
                return timeStr;
            }
            else
            {
              s = sec.ToString();
            }
            timeStr += $"{s}";
          }
                if (minu > 0)
                {
                    timeStr = "00:";
                    if (minu < 10)
                    {
                        m = "0" + minu;
                    }
                    else
                    {
                        m = minu.ToString();
                    }
                    timeStr += $"{m}:";
          return timeStr;
        }
        else
        {
          if (sec > 0)
          {
            timeStr = "00:00:";
            if (sec < 10)
            {
              s = "0" + sec;
                    if (sec >= 0)
                    {
                        if (sec < 10)
                        {
                            s = "0" + sec;
                        }
                        else
                        {
                            s = sec.ToString();
                        }
                        timeStr += $"{s}";
                    }
                    return timeStr;
                }
                else
                {
                    if (sec > 0)
                    {
                        timeStr = "00:00:";
                        if (sec < 10)
                        {
                            s = "0" + sec;
                        }
                        else
                        {
                            s = sec.ToString();
                        }
                        timeStr += $"{s}";
                        return timeStr;
                    }
                    else
                    {
                        return "";
                    }
                }
            }
            else
            {
              s = sec.ToString();
            }
            timeStr += $"{s}";
            return timeStr;
          }
          else
          {
            return "";
          }
        }
      }
    }
  }
}