HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-12-31 737c036a39176fd2085ce82b7c60391da8cb508c
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelButtonSettionForm.cs
@@ -36,6 +36,18 @@
        /// 设备需要保存的设备名字
        /// </summary>
        private Dictionary<int, string> dicDeviceSaveName = new Dictionary<int, string>();
        /// <summary>
        /// 简约面板的震动数据
        /// </summary>
        private HdlDevicePanelLogic.VibrationInfo vibrationInfo = null;
        /// <summary>
        /// 是否已经读取了震动数据
        /// </summary>
        private bool hadReadVibrationInfo = false;
        /// <summary>
        /// 信息编辑控件
        /// </summary>
        private InformationEditorControl tableContr = null;
        #endregion
@@ -68,15 +80,11 @@
            this.ClearBodyFrame();
            //初始化桌布
            var tableContr = new InformationEditorControl();
            this.tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 708, 1028);
            //初始化设备回路图标
            this.InitDeviceEpointIcon();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr = null;
            //保存
            var btnFinish = new BottomClickButton();
@@ -173,6 +181,11 @@
            this.AddBindRow();
            //添加背光灯行
            this.AddBackLightRow();
            //添加震动反馈行
            this.AddVibrationFeedbackRow();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
        }
        #endregion
@@ -293,6 +306,91 @@
        #endregion
        #region ■ 震动反馈___________________________
        /// <summary>
        /// 添加震动反馈行
        /// </summary>
        private void AddVibrationFeedbackRow()
        {
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(nowSelectDevice.DeviceAddr, false);
            var myType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
            //只有简约面板才会有这个菜单
            if (myType.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleTwo
                || myType.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleThree
                || myType.ConcreteType == Common.DeviceConcreteType.ButtonPanel_SimpleFour)
            {
                //震动反馈
                var rowContr = new FrameRowControl(listview.rowSpace / 2);
                rowContr.UseClickStatu = false;
                listview.AddChidren(rowContr);
                rowContr.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uVibrationFeedback), 600);
                //底线
                rowContr.AddBottomLine();
                //右箭头
                var btnSwitch = rowContr.AddMostRightSwitchIcon();
                if (vibrationInfo != null)
                {
                    btnSwitch.IsSelected = vibrationInfo.A震动使能;
                }
                btnSwitch.ButtonClickEvent += (sender, e) =>
                {
                    if (vibrationInfo == null)
                    {
                        //获取数据失败时,给他玩,但是没效果
                        btnSwitch.IsSelected = !btnSwitch.IsSelected;
                        return;
                    }
                    //点击一次之后,不能再次点击
                    btnSwitch.CanClick = false;
                    bool statu = !btnSwitch.IsSelected;
                    HdlThreadLogic.Current.RunThread(() =>
                    {
                        vibrationInfo.A震动使能 = statu;
                        //设置简约面板震动功能的信息
                        var result = HdlDevicePanelLogic.Current.SetPanelVibrationData(nowSelectDevice, vibrationInfo);
                        if (result == true)
                        {
                            HdlThreadLogic.Current.RunMain(() =>
                            {
                                btnSwitch.IsSelected = statu;
                            });
                        }
                        else
                        {
                            //失败时,数据还原
                            vibrationInfo.A震动使能 = !vibrationInfo.A震动使能;
                        }
                        //允许下一次点击
                        btnSwitch.CanClick = true;
                    });
                };
                if (hadReadVibrationInfo == true)
                {
                    //不再读取
                    return;
                }
                this.hadReadVibrationInfo = true;
                HdlThreadLogic.Current.RunThread(() =>
                {
                    //获取简约面板震动功能的信息(null表示出错)
                    vibrationInfo = HdlDevicePanelLogic.Current.GetPanelVibrationData(nowSelectDevice);
                    if (vibrationInfo != null)
                    {
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            btnSwitch.IsSelected = vibrationInfo.A震动使能;
                        });
                    }
                });
            }
        }
        #endregion
        #region ■ 初始化设备回路图标_________________
        /// <summary>