黄学彪
2020-04-28 e22fdb94322e6cec38e5e4a9aec13d431a133fde
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceMacInfoEditorForm.cs
@@ -161,6 +161,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)
                    {
                        //如果这个回路之前都还没有区域,在本界面还没有关闭之前,可以无条件随便变更
@@ -200,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
@@ -245,8 +264,8 @@
                    //添加【按键设置】行(面板专用)
                    this.AddPanelSettionRow();
                }
                if (this.IsFangyueFreshaAirPanel() == false)
                //检测能否显示功能设置的菜单
                if (this.CheckCanShowFunctionSettionRow() == true)
                {
                    //添加【功能设置】行
                    this.AddFunctionSettionRow();
@@ -370,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) =>
@@ -552,22 +576,6 @@
        #endregion
        #region ■ 按键设置(方悦)_____________________
        /// <summary>
        /// 是否是方悦新风面板
        /// </summary>
        private bool IsFangyueFreshaAirPanel()
        {
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
            {
                return true;
            }
            return false;
        }
        #endregion
        #region ■ 干接点设置(干接点)_________________
        /// <summary>
@@ -674,7 +682,11 @@
            //只有回路数大于1才能有这个菜单
            if (Common.LocalDevice.Current.GetDevicesCountByMac(listNewDevice[0].DeviceAddr) == 1)
            {
                return;
                //要求新风小模块的新风有功能设置
                if (deviceEnumInfo.ConcreteType != DeviceConcreteType.Relay_FangyueFreshAirModul)
                {
                    return;
                }
            }
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueEnvironment
                || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir)
@@ -803,6 +815,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) =>
@@ -889,103 +906,12 @@
                //不是空气开关
                return;
            }
            //功能类型
            string caption = Language.StringByID(R.MyInternationalizationString.uFunctionType);
            var DfunctionType = this.listNewDevice[0].DfunctionType;
            //功能类型的翻译名字
            int nowSelectNo = 1;
            string strType = string.Empty;
            if (DfunctionType == DeviceFunctionType.A灯光)
            {
                strType = Language.StringByID(R.MyInternationalizationString.uLight);
                nowSelectNo = 1;
            }
            else if (DfunctionType == DeviceFunctionType.A开关)
            {
                strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
                nowSelectNo = 0;
            }
            else if (DfunctionType == DeviceFunctionType.A插座)
            {
                strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
                nowSelectNo = 2;
            }
            var btnFunction = new FrameCaptionViewControl(caption, strType, listview.rowSpace / 2);
            btnFunction.UseClickStatu = true;
            listview.AddChidren(btnFunction);
            btnFunction.InitControl();
            //自定义功能类型控件
            var rowFunction = new DeviceFunctionTypeRowControl(this.listNewDevice[0], listview.rowSpace / 2);
            listview.AddChidren(rowFunction);
            rowFunction.InitControl();
            //底线
            btnFunction.AddBottomLine();
            //右箭头
            btnFunction.AddRightArrow();
            btnFunction.ButtonClickEvent += (sender, e) =>
            {
                //显示列表
                var listText = new List<string>();
                listText.Add(Language.StringByID(R.MyInternationalizationString.uSwitch));//开关
                listText.Add(Language.StringByID(R.MyInternationalizationString.uLight));//灯光
                listText.Add(Language.StringByID(R.MyInternationalizationString.uSocket1));//插座
                //标题:选择功能类型
                var title = Language.StringByID(R.MyInternationalizationString.uSelectFunctionType);
                var form = new BottomItemSelectForm();
                form.CancelCallEvent = true;//允许取消
                form.AddForm(title, listText, nowSelectNo);
                form.FinishSelectEvent += (selectNo) =>
                {
                    if (selectNo == -1)
                    {
                        //选择取消
                        btnFunction.Text = string.Empty;
                    }
                    else
                    {
                        btnFunction.Text = listText[selectNo];
                    }
                    nowSelectNo = selectNo;
                    //记录起当前选择的功能类型
                    if (selectNo == 0)
                    {
                        this.listNewDevice[0].DfunctionType = DeviceFunctionType.A开关;
                        if (this.listNewDevice[0].IsCustomizeImage == false)
                        {
                            //重新设置图片
                            this.listNewDevice[0].IconPath = "Device/Switch.png";
                        }
                    }
                    else if (selectNo == 1)
                    {
                        this.listNewDevice[0].DfunctionType = DeviceFunctionType.A灯光;
                        if (this.listNewDevice[0].IsCustomizeImage == false)
                        {
                            //重新设置图片
                            this.listNewDevice[0].IconPath = "Device/Light.png";
                        }
                    }
                    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();
                };
            };
            rowFunction.AddBottomLine();
        }
        #endregion
@@ -1091,8 +1017,12 @@
                btnNewVersion.Visible = false;
            };
            //设置设备的版本信息
            this.SetDeviceVersionInfo(btnNewVersion, oTADevice);
            //如果当前住宅不是虚拟住宅
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                //设置设备的版本信息
                this.SetDeviceVersionInfo(btnNewVersion, oTADevice);
            }
        }
        /// <summary>
@@ -1153,15 +1083,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;
@@ -1206,7 +1130,7 @@
        {
            //检测此回路是否拥有定位功能(拿端点最小的那个回路去定位)
            bool canTest = Common.LocalDevice.Current.DeviceIsCanFixedPosition(listNewDevice[0]);
            var frame = new TopRightMenuControl(canTest == true ? 2 : 1, 1);
            string deviceMenu = string.Empty;
            if (canTest == true)
@@ -1224,6 +1148,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, () =>
@@ -1354,6 +1283,22 @@
            });
        }
        /// <summary>
        /// 检测能否显示功能设置的菜单
        /// </summary>
        /// <returns></returns>
        private bool CheckCanShowFunctionSettionRow()
        {
            //方悦新风面板没有功能设置
            if (deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FangyueFreshAir
                || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_FourButtonScene
                || deviceEnumInfo.ConcreteType == DeviceConcreteType.ButtonPanel_TwoButtonCurtain)
            {
                return false;
            }
            return true;
        }
        #endregion
    }
}