| | |
| | | /// </summary>
|
| | | private CommonDevice device = null;
|
| | | /// <summary>
|
| | | /// 当前选择的功能类型索引
|
| | | /// 当前选择的功能类型索引 -1:还没有设置过 0:不指定 1:开关 2:灯光 3:插座
|
| | | /// </summary>
|
| | | private int nowSelectNo = -1;
|
| | |
|
| | |
| | | //右箭头
|
| | | this.AddRightArrow();
|
| | |
|
| | | //读取设备功能类型
|
| | | this.ReadDeviceFunctionType();
|
| | |
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示选择设备功能类型的界面
|
| | |
| | |
|
| | | var form = new BottomItemSelectForm();
|
| | | form.CancelCallEvent = true;//允许取消
|
| | | form.AddForm(title, listText, nowSelectNo);
|
| | | form.AddForm(title, listText, null, nowSelectNo - 1);
|
| | | form.FinishSelectEvent += (selectNo) =>
|
| | | {
|
| | | if (selectNo == nowSelectNo - 1)
|
| | | {
|
| | | //选择的是相同的
|
| | | return;
|
| | | }
|
| | | //-1:选择取消
|
| | | this.Text = selectNo == -1 ? string.Empty : listText[selectNo];
|
| | | nowSelectNo = selectNo;
|
| | | nowSelectNo = selectNo + 1;
|
| | |
|
| | | //记录起当前选择的功能类型
|
| | | this.RefreshDfunctionType();
|
| | | this.CanClick = false;
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //设置功能类型到网关
|
| | | var result = Common.LocalDevice.Current.SendDeviceFunctionTypeToGateway(this.device, (DeviceFunctionType)nowSelectNo);
|
| | | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | if (result == true)
|
| | | {
|
| | | //记录起当前选择的功能类型
|
| | | this.RefreshDfunctionType();
|
| | |
|
| | | //调用回调函数
|
| | | this.FinishSelectEvent?.Invoke(nowSelectNo);
|
| | | //设备改变功能类型的话,主页需要重新刷新
|
| | | UserView.UserPage.Instance.RefreshAllForm = true;
|
| | |
|
| | | //调用回调函数
|
| | | this.FinishSelectEvent?.Invoke(nowSelectNo);
|
| | | }
|
| | | else
|
| | | {
|
| | | //设置设备功能类型失败
|
| | | var alert = new ShowMsgControl(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uSetDeviceFunctionTypeFail));
|
| | | alert.Show();
|
| | | }
|
| | | this.CanClick = true;
|
| | | });
|
| | | });
|
| | | };
|
| | | }
|
| | | #endregion
|
| | |
| | | var myFunType = this.device.DfunctionType;
|
| | | //功能类型的翻译名字
|
| | | string strType = string.Empty;
|
| | | if (myFunType == DeviceFunctionType.A灯光)
|
| | |
|
| | | if (this.device.DfunctionType == DeviceFunctionType.A不指定)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uLight);
|
| | | nowSelectNo = 1;
|
| | | nowSelectNo = 0;
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A开关)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSwitch);
|
| | | nowSelectNo = 0;
|
| | | nowSelectNo = 1;
|
| | | }
|
| | | else if (myFunType == DeviceFunctionType.A灯光)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uLight);
|
| | | nowSelectNo = 2;
|
| | | }
|
| | | else if (this.device.DfunctionType == DeviceFunctionType.A插座)
|
| | | {
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uSocket1);
|
| | | nowSelectNo = 2;
|
| | | nowSelectNo = 3;
|
| | | }
|
| | |
|
| | | if (this.device.Type == DeviceType.ColorDimmableLight
|
| | | || this.device.Type == DeviceType.ColorTemperatureLight
|
| | | || this.device.Type == DeviceType.DimmableLight)
|
| | | {
|
| | | //灯光类固定为 灯光
|
| | | strType = Language.StringByID(R.MyInternationalizationString.uLight);
|
| | | nowSelectNo = 1;
|
| | | nowSelectNo = 2;
|
| | | }
|
| | | else if (this.device.Type == DeviceType.WindowCoveringDevice)
|
| | | {
|
| | |
| | | {
|
| | | //新风固定为 新风
|
| | | 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.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.ColorTemperatureLight //色温灯
|
| | | || this.device.Type == DeviceType.WindowCoveringDevice)//窗帘
|
| | | {
|
| | | return true;
|
| | |
| | | /// </summary>
|
| | | private void RefreshDfunctionType()
|
| | | {
|
| | | if (this.nowSelectNo == 0)
|
| | | if (this.nowSelectNo == 1)
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A开关;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | |
| | | this.device.IconPath = "Device/Switch.png";
|
| | | }
|
| | | }
|
| | | else if (this.nowSelectNo == 1)
|
| | | else if (this.nowSelectNo == 2)
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A灯光;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | |
| | | this.device.IconPath = "Device/Light.png";
|
| | | }
|
| | | }
|
| | | else if (this.nowSelectNo == 2)
|
| | | else if (this.nowSelectNo == 3)
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A插座;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | this.device.DfunctionType = DeviceFunctionType.A未定义;
|
| | | this.device.DfunctionType = DeviceFunctionType.A不指定;
|
| | | if (this.device.IsCustomizeImage == false)
|
| | | {
|
| | | //重新设置图片
|
| | |
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 读取设备功能类型___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 读取设备功能类型
|
| | | /// </summary>
|
| | | private void ReadDeviceFunctionType()
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //读取设备功能类型
|
| | | var info = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(this.device);
|
| | | if (info != null && ((int)this.device.DfunctionType) != info.FunctionType)
|
| | | {
|
| | | this.device.DfunctionType = (DeviceFunctionType)info.FunctionType;
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //刷新控件
|
| | | this.InitDefultData();
|
| | | //刷新设备功能类型
|
| | | this.RefreshDfunctionType();
|
| | | });
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|