陈嘉乐
2020-04-27 18b93d511dc764b469d7c4a7e755f7274f89cdb4
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -20,7 +20,7 @@
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
        private FrameListControl listview = null;
        /// <summary>
        /// 设备的设备类型
        /// </summary>
@@ -81,15 +81,19 @@
            //清空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(listNewDevice[0]);
            //设备备注
@@ -124,21 +128,29 @@
            //划线
            btnType.AddBottomLine();
            //所属区域
            //安装位置
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
            listview.AddChidren(rowBeloneArea);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.listNewDevice);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uInstallationLocation), this.listNewDevice);
            //底线
            rowBeloneArea.AddBottomLine();
            var listCheck = new List<string>();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //选择未分配时,清空
                if (roomKeys == string.Empty) { listCheck = new List<string>(); }
                foreach (var device in this.listNewDevice)
                {
                    if (device is OTADevice)
                    {
                        //针对单纯只有一个200端点的设备
                        continue;
                    }
                    if (roomKeys == string.Empty)
                    {
                        //如果选择的是未分配,则它的全部回路无条件全部清空房间
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                        continue;
                    }
                    var room = HdlRoomLogic.Current.GetRoomByDevice(device);
@@ -147,6 +159,12 @@
                    {
                        //这里有点特殊,如果回路没有设置有区域的时候,才设置
                        listCheck.Add(mainKeys);
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                    else if (this.deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
                      && device.Type == DeviceType.FreshAir)
                    {
                        //新风面板的新风设备,则区域跟着模块一起
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                    else if (listCheck.Contains(mainKeys) == true)
@@ -163,7 +181,7 @@
            this.AddAllMenuRow();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr.FinishInitControl();
            tableContr = null;
            //保存
@@ -188,6 +206,19 @@
                    this.CloseForm();
                }
            };
            //如果当前住宅是虚拟住宅的话,让所有菜单都不能点击
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                for (int i = 0; i < listview.ChildrenCount; i++)
                {
                    var myRow = listview.GetChildren(i) as FrameRowControl;
                    if (myRow != null)
                    {
                        myRow.UseClickStatu = false;
                        myRow.CanClick = false;
                    }
                }
            }
        }
        #endregion
@@ -233,8 +264,8 @@
                    //添加【按键设置】行(面板专用)
                    this.AddPanelSettionRow();
                }
                if (this.IsFangyueFreshaAirPanel() == false)
                //方悦新风面板没有功能设置
                if (deviceEnumInfo.ConcreteType != DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                {
                    //添加【功能设置】行
                    this.AddFunctionSettionRow();
@@ -295,7 +326,7 @@
                         };
                         actionNone = () =>
                         {
                             Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                             Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock);
                         };
                         HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
                     }
@@ -316,7 +347,7 @@
                             };
                             actionNone = () =>
                             {
                                 Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                                 Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock);
                             };
                             HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
@@ -358,6 +389,11 @@
                if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword) == false)
                {
                    btnswitch.IsSelected = true;
                }
                //如果当前住宅是虚拟住宅的话,让所有菜单都不能点击
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    btnswitch.CanClick = false;
                }
                btnswitch.ButtonClickEvent += async (sender, e) =>
@@ -533,22 +569,6 @@
                        form.AddForm(listNewDevice[0]);
                    }
                };
                return true;
            }
            return false;
        }
        #endregion
        #region ■ 按键设置(方悦)_____________________
        /// <summary>
        /// 是否是方悦新风面板
        /// </summary>
        private bool IsFangyueFreshaAirPanel()
        {
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
            {
                return true;
            }
            return false;
@@ -791,6 +811,11 @@
            btnFunction.AddLeftCaption(caption, 600);
            //开关图标
            var btnSwitch = btnFunction.AddMostRightSwitchIcon();
            //如果当前住宅是虚拟住宅的话,让所有菜单都不能点击
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                btnSwitch.CanClick = false;
            }
            //底线
            btnFunction.AddBottomLine();
            btnSwitch.ButtonClickEvent += async (sender, e) =>
@@ -920,10 +945,19 @@
                var title = Language.StringByID(R.MyInternationalizationString.uSelectFunctionType);
                var form = new BottomItemSelectForm();
                form.CancelCallEvent = true;//允许取消
                form.AddForm(title, listText, nowSelectNo);
                form.FinishSelectEvent += (selectNo) =>
                {
                    btnFunction.Text = listText[selectNo];
                    if (selectNo == -1)
                    {
                        //选择取消
                        btnFunction.Text = string.Empty;
                    }
                    else
                    {
                        btnFunction.Text = listText[selectNo];
                    }
                    nowSelectNo = selectNo;
                    //记录起当前选择的功能类型
                    if (selectNo == 0)
@@ -944,13 +978,22 @@
                            this.listNewDevice[0].IconPath = "Device/Light.png";
                        }
                    }
                    else
                    else if (selectNo == 2)
                    {
                        this.listNewDevice[0].DfunctionType = DeviceFunctionType.A插座;
                        if (this.listNewDevice[0].IsCustomizeImage == false)
                        {
                            //重新设置图片
                            this.listNewDevice[0].IconPath = "Device/Socket1.png";
                        }
                    }
                    else
                    {
                        this.listNewDevice[0].DfunctionType = DeviceFunctionType.A未定义;
                        if (this.listNewDevice[0].IsCustomizeImage == false)
                        {
                            //重新设置图片
                            this.listNewDevice[0].IconPath = "Device/Switch.png";
                        }
                    }
                    this.listNewDevice[0].ReSave();
@@ -1061,8 +1104,12 @@
                btnNewVersion.Visible = false;
            };
            //设置设备的版本信息
            this.SetDeviceVersionInfo(btnNewVersion, oTADevice);
            //如果当前住宅不是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                //设置设备的版本信息
                this.SetDeviceVersionInfo(btnNewVersion, oTADevice);
            }
        }
        /// <summary>
@@ -1123,15 +1170,9 @@
        /// <param name="i_deviceName">deviceName.</param>
        private async void DeviceReName(string i_deviceName, bool closeForm)
        {
            //开启进度条
            this.ShowProgressBar();
            //修改MAC名
            string deviceName = i_deviceName.Trim();
            var result = await Common.LocalDevice.Current.ReMacName(this.listNewDevice, deviceName);
            //关闭进度条
            this.CloseProgressBar();
            if (result == false)
            {
                return;
@@ -1176,18 +1217,8 @@
        {
            //检测此回路是否拥有定位功能(拿端点最小的那个回路去定位)
            bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]);
            if (this.deviceEnumInfo.BeloneType == DeviceBeloneType.A智能门锁)
            {
                canTest = false;
            }
            else if (this.deviceEnumInfo.BeloneType == DeviceBeloneType.A传感器
                && this.deviceEnumInfo.ConcreteType != DeviceConcreteType.Sensor_Pir)
            {
                //传感器除了Pir都没有定位功能
                canTest = false;
            }
            var frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
            var frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
            string deviceMenu = string.Empty;
            if (canTest == true)
            {
@@ -1204,6 +1235,11 @@
            deviceMenu = Language.StringByID(R.MyInternationalizationString.uDelete);
            frame.AddRowMenu(deviceMenu, "Item/DeleteIcon2.png", "Item/DeleteIcon2Selected.png", () =>
            {
                //如果当前住宅是虚拟住宅,此功能无效
                if (Common.Config.Instance.Home.IsVirtually == true)
                {
                    return;
                }
                //确认删除该设备及功能?
                string msg = Language.StringByID(R.MyInternationalizationString.uDeleteDeviceMsg);
                this.ShowMassage(ShowMsgType.Confirm, msg, () =>