黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/AirConditioner/IndoorUnitSettionForm.cs
@@ -15,7 +15,7 @@
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
        private FrameListControl listview = null;
        /// <summary>
        /// 当前选择的网关
        /// </summary>
@@ -78,50 +78,60 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var listBackControl = new VerticalFrameControl();
            listBackControl.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackControl);
            //初始化桌布
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 369, 1368);
            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uInfoEditor), 1368);
            //图片
            var btnPic = new DeviceInfoIconControl();
            btnPic.Y = Application.GetRealHeight(92);
            btnPic.Gravity = Gravity.CenterHorizontal;
            bodyFrameLayout.AddChidren(btnPic);
            listBackControl.frameTable.AddChidren(btnPic);
            btnPic.InitControl(this.deviceAc);
            //设备备注
            string caption = Language.StringByID(R.MyInternationalizationString.uDeviceNote);
            string nameValue = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc);
            string nameValue = HdlDeviceCommonLogic.Current.GetDeviceEpointName(deviceAc);
            var btnNote = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
            btnNote.txtInput.MaxByte = 48;//限制只能输入48个字节
            listview.AddChidren(btnNote);
            btnNote.InitControl();
            //划线
            btnNote.AddBottomLine();
            btnNote.txtInput.FinishInputEvent += async () =>
             {
                 string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc);
                 if (btnNote.Text.Trim() == string.Empty)
                 {
                     //将名字还原
                     btnNote.Text = oldName;
                 }
                 if (oldName != btnNote.Text)
                 {
                     //设备名称修改
                     var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text);
                     if (result == false)
                     {
                         return;
                     }
                     //设备备注修改成功!
                     string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess);
                     this.ShowMassage(ShowMsgType.Tip, msg);
                 }
             };
            btnNote.txtInput.FinishInputEvent += () =>
            {
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(deviceAc);
                if (btnNote.Text.Trim() == string.Empty)
                {
                    //将名字还原
                    btnNote.Text = oldName;
                }
                if (oldName != btnNote.Text)
                {
                    //查看模板时,不允许编辑
                    if (Common.Config.Instance.Home.IsShowTemplate == true)
                    {
                        return;
                    }
                    //设备名称修改
                    var result = HdlDeviceCommonLogic.Current.ReName(deviceAc, btnNote.Text);
                    if (result == false)
                    {
                        return;
                    }
                    //设备备注修改成功!
                    string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess);
                    this.ShowMassage(ShowMsgType.Tip, msg);
                }
            };
            //设备类型
            caption = Language.StringByID(R.MyInternationalizationString.uDeviceType);
            nameValue = Common.LocalDevice.Current.GetDeviceObjectText(new List<CommonDevice>() { deviceAc });
            nameValue = HdlDeviceCommonLogic.Current.GetDeviceObjectText(new List<CommonDevice>() { deviceAc });
            var btnType = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
            btnType.UseClickStatu = false;
            listview.AddChidren(btnType);
@@ -170,9 +180,9 @@
                string statu = btnSwingSwitch.IsSelected == true ? "0" : "1";
                //将二进制转换为十进制
                int sendData = Convert.ToInt32(this.fixValue + statu, 2);
                HdlThreadLogic.Current.RunThread(async () =>
                HdlThreadLogic.Current.RunThread(() =>
                {
                    var result = await HdlDeviceAirConditionerLogic.Current.SetUseAcSwingFunctionStatu(deviceAc, sendData);
                    var result = HdlDeviceAirConditionerLogic.Current.SetUseAcSwingFunctionStatu(deviceAc, sendData);
                    if (result == true)
                    {
                        HdlThreadLogic.Current.RunMain(() =>
@@ -190,20 +200,20 @@
            };
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr.FinishInitControl();
            tableContr = null;
            //保存
            var btnFinish = new BottomClickButton();
            btnFinish.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += async (sender, e) =>
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                string oldName = Common.LocalDevice.Current.GetDeviceEpointName(deviceAc);
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceEpointName(deviceAc);
                if (oldName != btnNote.Text)
                {
                    //设备名称修改
                    var result = await Common.LocalDevice.Current.ReName(deviceAc, btnNote.Text);
                    var result = HdlDeviceCommonLogic.Current.ReName(deviceAc, btnNote.Text);
                    if (result == false)
                    {
                        return;
@@ -211,6 +221,12 @@
                }
                this.CloseForm();
            };
            //查看模板时,不允许编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnFinish.CanClick = false;
                btnSwingSwitch.CanClick = false;
            }
        }
        #endregion
@@ -223,7 +239,7 @@
        private void InitTopRightMenu()
        {
            //检测此回路是否拥有定位功能(拿端点最小的那个回路去定位)
            bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(deviceAc);
            bool canTest = HdlDeviceCommonLogic.Current.DeviceIsCanFixedPosition(deviceAc);
            if (canTest == false)
            {
                return;
@@ -250,7 +266,7 @@
            frame.AddRowMenu(deviceMenu, "Item/FixedPosition.png", "Item/FixedPositionSelected.png", () =>
            {
                //发送定位功能
                Common.LocalDevice.Current.SetFixedPositionCommand(deviceAc);
                HdlDeviceCommonLogic.Current.SetFixedPositionCommand(deviceAc);
            });
        }
@@ -263,10 +279,22 @@
        /// </summary>
        private bool ReadAirConditionerSwingModeSupport()
        {
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(deviceAc);
            //如果是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                var data = HdlTemplateDeviceDataLogic.Current.GetAcSwingModeSupport(deviceAc);
                //转换为二进制
                var value = Convert.ToString(data, 2).PadLeft(16, '0');
                //这个设置是放在后面的
                this.fixValue = value.Substring(0, value.Length - 1);
                this.swingMode = Convert.ToInt32(value.Substring(this.fixValue.Length));
                return true;
            }
            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(deviceAc);
            HdlGatewayReceiveLogic.Current.AddAttributeEvent("ReadAirConditionerModeSupport", ReceiveComandDiv.A设备属性上报, (report) =>
            {
                string checkKeys = Common.LocalDevice.Current.GetDeviceMainKeys(report);
                string checkKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(report);
                if (checkKeys != mainkeys || report.DeviceStatusReport.CluterID != 514)
                {
                    return;
@@ -298,7 +326,7 @@
            {
                //获取空调摆风状态失败
                string msg = Language.StringByID(R.MyInternationalizationString.uGetAirConditionerSwingFunctionFail);
                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                this.ShowMassage(ShowMsgType.Tip, msg);
                return false;
            }