gxc
2020-01-02 00ab3ddb140ba8bb88b5cf572b004a85e1da85e9
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
@@ -184,6 +197,11 @@
        /// </summary>
        private void InitTopRightMenu()
        {
            //检测此回路是否拥有定位功能
            if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false)
            {
                return;
            }
            var btnIcon = new MostRightIconControl(69, 69);
            btnIcon.UnSelectedImagePath = "Item/More.png";
            topFrameLayout.AddChidren(btnIcon);
@@ -204,11 +222,11 @@
            string deviceMenu = string.Empty;
            //检测此回路是否拥有定位功能
            bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice);
            if (canTest == true)
            {
                menuCount = 2;
            }
            var frame = new TopRightMenuControl(menuCount);
            //if (canTest == true)
            //{
            //    menuCount = 2;
            //}
            var frame = new TopRightMenuControl(menuCount, 1);
            if (canTest == true)
            {
                //定位
@@ -221,10 +239,10 @@
            }
            //删除
            deviceMenu = Language.StringByID(R.MyInternationalizationString.uDelete);
            frame.AddRowMenu(deviceMenu, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
            {
            });
            //deviceMenu = Language.StringByID(R.MyInternationalizationString.uDelete);
            //frame.AddRowMenu(deviceMenu, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
            //{
            //});
        }
        #endregion
@@ -283,6 +301,91 @@
                    var form = new PanelBackLightSettionForm();
                    form.AddForm((Panel)nowSelectDevice);
                };
            }
        }
        #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震动使能;
                        });
                    }
                });
            }
        }
@@ -369,7 +472,7 @@
            var btnIcon = new NormalViewControl(Application.GetMinRealAverage(52), Application.GetMinRealAverage(52), false);
            btnIcon.Name = "btn" + device.DeviceEpoint;
            btnIcon.Gravity = Gravity.Center;
            btnIcon.Radius = 6;
            btnIcon.RadiusEx = 16;
            btnIcon.BorderWidth = 2;
            btnIcon.BorderColor = 0xff979797;
            frame.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly);