黄学彪
2020-05-13 2be70a32d2a8c517bd9868fb60913fcc843e66fe
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/RowLayoutControls/DeviceFunctionTypeRowControl.cs
@@ -13,11 +13,27 @@
        #region ■ 变量声明___________________________
        /// <summary>
        /// 判断该控件能否显示(最好确保设备对象不为null)
        /// 结束选择的事件 value:索引(从0开始)  文本信息请用Text获取
        /// </summary>
        public Action<int> FinishSelectEvent = null;
        /// <summary>
        /// 判断该控件能否显示
        /// </summary>
        public bool CanShowRow
        {
            get { return this.CheckCanShowRow(); }
        }
        private bool m_SetCanSelect = true;
        /// <summary>
        /// 强制设置能否进行选择(只对继电器和空气开关有效,个别界面需要这种操作)
        /// </summary>
        public bool SetCanSelect
        {
            set
            {
                m_SetCanSelect = value;
            }
        }
        /// <summary>
        /// 设备对象
@@ -33,10 +49,10 @@
        #region ■ 初始化_____________________________
        /// <summary>
        /// 设备功能类型的自定义行控件(此方法选择之后,无条件直接变更类型)
        /// 设备功能类型的自定义行控件(选择功能之后,无条件直接变更类型)
        /// </summary>
        /// <param name="i_device">设备的对象</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
        public DeviceFunctionTypeRowControl(CommonDevice i_device, int i_ChidrenYaxis = 0) : base("", "", i_ChidrenYaxis)
        {
            this.device = i_device;
@@ -53,25 +69,23 @@
            //初始化底层数据
            base.InitControl();
            if (this.device == null)
            {
                //此控件采用的是另外一种初始化方式
                return;
            }
            //空气开关和继电器可以选择功能类型
            if (this.device.Type == DeviceType.AirSwitch
                || this.device.Type == DeviceType.OnOffOutput)
            {
                this.UseClickStatu = true;
                //右箭头
                this.AddRightArrow();
                this.ButtonClickEvent += (sender, e) =>
                //没被强制干涉的话
                if (m_SetCanSelect == true)
                {
                    //显示选择设备功能类型的界面
                    this.ShowSelectDeviceFunctionListForm();
                };
                    this.UseClickStatu = true;
                    //右箭头
                    this.AddRightArrow();
                    this.ButtonClickEvent += (sender, e) =>
                    {
                        //显示选择设备功能类型的界面
                        this.ShowSelectDeviceFunctionListForm();
                    };
                }
            }
        }
@@ -97,12 +111,23 @@
            form.AddForm(title, listText, nowSelectNo);
            form.FinishSelectEvent += (selectNo) =>
            {
                if (selectNo == nowSelectNo)
                {
                    //选择的是相同的
                    return;
                }
                //-1:选择取消
                this.Text = selectNo == -1 ? string.Empty : listText[selectNo];
                nowSelectNo = selectNo;
                //记录起当前选择的功能类型
                this.RefreshDfunctionType();
                //设备改变功能类型的话,主页需要重新刷新
                UserView.UserPage.Instance.RefreshForm = true;
                //调用回调函数
                this.FinishSelectEvent?.Invoke(nowSelectNo);
            };
        }
        #endregion
@@ -117,12 +142,7 @@
            //标题:功能类型
            this.btnCaption.Text = Language.StringByID(R.MyInternationalizationString.uFunctionType);
            var myFunType = DeviceFunctionType.A未定义;
            if (this.device != null)
            {
                myFunType = this.device.DfunctionType;
            }
            var myFunType = this.device.DfunctionType;
            //功能类型的翻译名字
            string strType = string.Empty;
            if (myFunType == DeviceFunctionType.A灯光)
@@ -141,35 +161,44 @@
                nowSelectNo = 2;
            }
            //如果设备不为null
            if (this.device != null)
            if (this.device.Type == DeviceType.ColorDimmableLight
                || this.device.Type == DeviceType.DimmableLight)
            {
                if (this.device.Type == DeviceType.ColorDimmableLight
                    || this.device.Type == DeviceType.DimmableLight)
                {
                    //灯光类固定为 灯光
                    strType = Language.StringByID(R.MyInternationalizationString.uLight);
                    nowSelectNo = 1;
                }
                else if (this.device.Type == DeviceType.WindowCoveringDevice)
                {
                    //窗帘固定为 遮阳
                    strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100);
                    nowSelectNo = -1;
                }
                else if (this.device.Type == DeviceType.Thermostat)
                {
                    //空调固定为 空调
                    strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId3600);
                    nowSelectNo = -1;
                }
                else if (this.device.Type == DeviceType.DoorLock)
                {
                    //门锁固定为 门锁
                    strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2800);
                    nowSelectNo = -1;
                }
                //灯光类固定为 灯光
                strType = Language.StringByID(R.MyInternationalizationString.uLight);
                nowSelectNo = 1;
            }
            else if (this.device.Type == DeviceType.WindowCoveringDevice)
            {
                //窗帘固定为 遮阳
                strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId100);
                nowSelectNo = -1;
            }
            else if (this.device.Type == DeviceType.Thermostat)
            {
                //空调固定为 空调
                strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId3600);
                nowSelectNo = -1;
            }
            else if (this.device.Type == DeviceType.DoorLock)
            {
                //门锁固定为 门锁
                strType = Language.StringByID(R.MyInternationalizationString.uDeviceBelongId2800);
                nowSelectNo = -1;
            }
            else if (this.device.Type == DeviceType.FreshAir)
            {
                //新风固定为 新风
                strType = Language.StringByID(R.MyInternationalizationString.FreshAir);
                nowSelectNo = -1;
            }
            else if (this.device.Type == DeviceType.PMSensor)
            {
                //PM2.5传感器固定为 空气质量
                strType = Language.StringByID(R.MyInternationalizationString.AirQuality);
                nowSelectNo = -1;
            }
            //显示文本
            this.txtView.Text = strType;
        }
@@ -192,6 +221,8 @@
                || this.device.Type == DeviceType.DoorLock//门锁
                || this.device.Type == DeviceType.OnOffOutput//继电器
                || this.device.Type == DeviceType.Thermostat//空调
                || this.device.Type == DeviceType.FreshAir//新风
                || this.device.Type == DeviceType.PMSensor //PM2.5
                || this.device.Type == DeviceType.WindowCoveringDevice)//窗帘
            {
                return true;
@@ -201,6 +232,20 @@
        #endregion
        #region ■ 控件摧毁___________________________
        /// <summary>
        /// 控件摧毁
        /// </summary>
        public override void RemoveFromParent()
        {
            this.FinishSelectEvent = null;
            base.RemoveFromParent();
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>