陈嘉乐
2020-07-10 48ba446936b51fffafa7c3600c0dadc6ac0e8c20
ZigbeeApp/Shared/Phone/MainPage/DeviceDetailInfoForm.cs
@@ -17,13 +17,13 @@
        /// <summary>
        /// 界面关闭事件(该事件目前给分类界面的自定义行控件使用)
        /// </summary>
        public Action<CommonDevice, Room> FormCloseEvent = null;
        public Action FormCloseEvent = null;
        /// <summary>
        /// 设备对象
        /// </summary>
        private CommonDevice device;
        /// <summary>
        /// 房间对象(这个房间有可能是喜爱)
        /// 房间对象(这个房间有可能是喜爱,有可能是null)
        /// </summary>
        private Room room = null;
        /// <summary>
@@ -132,7 +132,7 @@
            };
            //喜爱房间不允许变更区域
            if (this.room.IsLove == false)
            if (this.room == null || this.room.IsLove == false)
            {
                //所属区域
                var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
@@ -232,7 +232,7 @@
            btnNote.AddBottomLine();
            //喜爱房间不允许出现区域
            if (this.room.IsLove == false)
            if (this.room == null || this.room.IsLove == false)
            {
                //所属区域
                caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
@@ -272,105 +272,19 @@
        /// </summary>
        private void AddFunctionTypeRowByAdmin(NormalViewControl btnBelongType)
        {
            //如果是继电器,空气开关,调光器的话
            if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
            //自定义功能类型控件
            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
            if (rowFunction.CanShowRow == true)
            {
                //功能类型的翻译名字
                int nowSelectNo = 1;
                string strType = string.Empty;
                if (this.device.DfunctionType == DeviceFunctionType.A灯光)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uLight);
                    nowSelectNo = 1;
                }
                else if (this.device.DfunctionType == DeviceFunctionType.A开关)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
                    nowSelectNo = 0;
                }
                else if (this.device.DfunctionType == DeviceFunctionType.A插座)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
                    nowSelectNo = 2;
                }
                //功能类型
                var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
                btnFunction.UseClickStatu = false;
                listview.AddChidren(btnFunction);
                btnFunction.InitControl();
                listview.AddChidren(rowFunction);
                rowFunction.InitControl();
                //底线
                btnFunction.AddBottomLine();
                //如果是空气开关和继电器,才能修改
                if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.AirSwitch)
                rowFunction.AddBottomLine();
                rowFunction.FinishSelectEvent += (index) =>
                {
                    //右箭头
                    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.SelectRowCanCancel = false;//选择的不能取消
                        form.AddForm(title, listText, nowSelectNo);
                        form.FinishSelectEvent += (selectNo) =>
                        {
                            btnFunction.Text = listText[selectNo];
                            //当类型变更时,头上的类型也一起变更
                            btnBelongType.Text = listText[selectNo];
                            nowSelectNo = selectNo;
                            //记录起当前选择的功能类型
                            if (selectNo == 0)
                            {
                                this.device.DfunctionType = DeviceFunctionType.A开关;
                                if (this.device.IsCustomizeImage == false)
                                {
                                    //重新设置图片
                                    this.device.IconPath = "Device/Switch.png";
                                }
                            }
                            else if (selectNo == 1)
                            {
                                this.device.DfunctionType = DeviceFunctionType.A灯光;
                                if (this.device.IsCustomizeImage == false)
                                {
                                    //重新设置图片
                                    this.device.IconPath = "Device/Light.png";
                                }
                            }
                            else
                            {
                                this.device.DfunctionType = DeviceFunctionType.A插座;
                                if (this.device.IsCustomizeImage == false)
                                {
                                    //重新设置图片
                                    this.device.IconPath = "Device/Socket1.png";
                                }
                            }
                            this.device.ReSave();
                        };
                    };
                }
            }
            //如果是新风
            if (device.Type == DeviceType.FreshAir)
            {
                //功能类型
                string caption = Language.StringByID(R.MyInternationalizationString.uFunctionType);
                string strType = Language.StringByID(R.MyInternationalizationString.FreshAir);
                var btnFunction = new FrameCaptionViewControl(caption, strType, listview.rowSpace / 2);
                btnFunction.UseClickStatu = false;
                listview.AddChidren(btnFunction);
                btnFunction.InitControl();
                //底线
                btnFunction.AddBottomLine();
                    //当类型变更时,头上的类型也一起变更
                    btnBelongType.Text = rowFunction.Text;
                };
            }
        }
@@ -379,32 +293,16 @@
        /// </summary>
        private void AddFunctionTypeRowByMember()
        {
            //如果是继电器,空气开关,调光器的话
            if (device.Type == DeviceType.OnOffOutput || device.Type == DeviceType.DimmableLight
                || device.Type == DeviceType.ColorDimmableLight || device.Type == DeviceType.AirSwitch)
            //自定义功能类型控件
            var rowFunction = new DeviceFunctionTypeRowControl(device, listview.rowSpace / 2);
            if (rowFunction.CanShowRow == true)
            {
                //功能类型的翻译名字
                string strType = string.Empty;
                if (this.device.DfunctionType == DeviceFunctionType.A灯光)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uLight);
                }
                else if (this.device.DfunctionType == DeviceFunctionType.A开关)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
                }
                else if (this.device.DfunctionType == DeviceFunctionType.A插座)
                {
                    strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
                }
                //功能类型
                var btnFunction = new FrameCaptionViewControl(Language.StringByID(R.MyInternationalizationString.uFunctionType), strType, listview.rowSpace / 2);
                btnFunction.UseClickStatu = false;
                listview.AddChidren(btnFunction);
                btnFunction.InitControl();
                //强制干涉不能选择
                rowFunction.SetCanSelect = false;
                listview.AddChidren(rowFunction);
                rowFunction.InitControl();
                //底线
                btnFunction.AddBottomLine();
                rowFunction.AddBottomLine();
            }
        }
@@ -416,11 +314,11 @@
        /// 设备重命名
        /// </summary>
        /// <param name="i_deviceName">deviceName.</param>
        private async void DeviceReName(string i_deviceName, bool closeForm)
        private void DeviceReName(string i_deviceName, bool closeForm)
        {
            //修改MAC名
            string deviceName = i_deviceName.Trim();
            var result = await LocalDevice.Current.ReName(this.device, deviceName);
            var result = LocalDevice.Current.ReName(this.device, deviceName);
            if (result == false)
            {
                return;
@@ -447,7 +345,7 @@
        /// </summary>
        public override void CloseFormBefore()
        {
            this.FormCloseEvent?.Invoke(this.device, this.room);
            this.FormCloseEvent?.Invoke();
            this.FormCloseEvent = null;
            base.CloseFormBefore();