| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared.Common; |
| | | using ZigBee.Common; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.DevicePanel |
| | |
| | | /// <summary>
|
| | | /// 列表控件
|
| | | /// </summary>
|
| | | private VerticalListControl listview = null;
|
| | | private FrameListControl listview = null;
|
| | | /// <summary>
|
| | | /// 设备的某一回路
|
| | | /// </summary>
|
| | | private CommonDevice deviceObj = null; |
| | | /// <summary> |
| | | /// 新风目标名字 |
| | | /// </summary> |
| | | private string bindFreshAirName = string.Empty; |
| | | /// <summary> |
| | | /// 温度目标名字 |
| | | /// </summary> |
| | | private string bindTemperatureName = string.Empty; |
| | | /// <summary> |
| | | /// 湿度目标名字 |
| | | /// </summary> |
| | | private string bindHumidityName = string.Empty; |
| | | /// <summary> |
| | | /// PM目标名字 |
| | | /// </summary> |
| | | private string bindPmName = string.Empty; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________
|
| | | |
| | | /// <summary>
|
| | |
| | | public void ShowForm(CommonDevice i_device)
|
| | | {
|
| | | this.deviceObj = i_device;
|
| | | //获取数据 |
| | | ReadDoorLockUserInfo(deviceObj); |
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion));
|
| | |
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var listBackControl = new VerticalFrameControl(); |
| | | listBackControl.Height = bodyFrameLayout.Height; |
| | | bodyFrameLayout.AddChidren(listBackControl); |
| | | |
| | | //图片
|
| | | var btnPic = new PicViewControl(426, 426);
|
| | | btnPic.Y = Application.GetRealHeight(150);
|
| | | btnPic.UnSelectedImagePath = "RealDevice/ButtonPanelFangyueFreshAir.png";
|
| | | btnPic.Gravity = Gravity.CenterHorizontal;
|
| | | bodyFrameLayout.AddChidren(btnPic);
|
| | | listBackControl.frameTable.AddChidren(btnPic);
|
| | |
|
| | | //初始化桌布
|
| | | var tableContr = new InformationEditorControl();
|
| | | this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 708, 1028);
|
| | | this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1028);
|
| | |
|
| | | //初始化菜单行
|
| | | this.InitMenuRow();
|
| | |
|
| | | //初始化桌布完成
|
| | | tableContr.FinishInitControl(bodyFrameLayout, this.listview);
|
| | | tableContr.FinishInitControl();
|
| | | tableContr = null;
|
| | |
|
| | | //保存
|
| | |
| | | private void InitMenuRow()
|
| | | {
|
| | | this.listview.RemoveAll();
|
| | | //添加新风目标 |
| | | this.AddFreshAirRow(); |
| | | //PM2.5来源 |
| | | this.AddPMRow(); |
| | | //添加温度来源 |
| | | this.AddTemperatureSensorRow(); |
| | | //添加湿度来源 |
| | | this.AddHumiditySourceRow(); |
| | | //亮度调节 |
| | | this.AddLevelRow(); |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 初始化数据_________________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化数据 |
| | | /// </summary> |
| | | void ReadDoorLockUserInfo(CommonDevice curControlDev) |
| | | { |
| | | System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | |
| | | var result = await GetBindName(curControlDev); |
| | | if (!result) |
| | | { |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); |
| | | }); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | var mess = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | this.InitMenuRow(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | #endregion |
| | |
|
| | | #region ■ 新风目标_________________________ |
| | | /// <summary> |
| | | /// 新风目标行 |
| | | /// </summary> |
| | | private void AddFreshAirRow() |
| | | { |
| | | //新风目标
|
| | | var rowNewWind = new FrameRowControl(listview.rowSpace / 2);
|
| | | listview.AddChidren(rowNewWind);
|
| | |
| | | rowNewWind.AddBottomLine();
|
| | | //右箭头
|
| | | rowNewWind.AddRightArrow();
|
| | | var btnNewWindStatu = rowNewWind.AddMostRightView("新风1", 700);
|
| | | |
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | if (!string.IsNullOrEmpty(bindFreshAirName)) |
| | | { |
| | | msg = bindFreshAirName; |
| | | } |
| | | var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700);
|
| | | |
| | | rowNewWind.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new PanelFangyueEnvironmentTargetForm();
|
| | | form.AddForm(this.deviceObj, string.Empty, 3);
|
| | | }; |
| | | var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 1); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | addDevicePage.Show(); |
| | | |
| | | addDevicePage.actionFreshAirTarget += (bindName) => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(bindName)) |
| | | { |
| | | btnNewWindStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | } |
| | | else |
| | | { |
| | | btnNewWindStatu.Text = bindName; |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | //var form = new PanelFangyueFreshAirTargetForm(); |
| | | //form.AddForm(this.deviceObj, string.Empty, 3); |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取绑定目标 |
| | | /// </summary> |
| | | /// <param name="curControlDev"></param> |
| | | /// <returns></returns> |
| | | private async System.Threading.Tasks.Task<bool> GetBindName(CommonDevice curDev) |
| | | { |
| | | bool result = false; |
| | | //获取面板中存在的绑定目标 |
| | | FreshAir curControlDev = curDev as FreshAir; |
| | | var panelBindListRes = await curControlDev.GetDeviceBindAsync(); |
| | | if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null) |
| | | { |
| | | foreach (var bDev in panelBindListRes.getAllBindResponseData.BindList) |
| | | { |
| | | curControlDev.bindList.Add(bDev); |
| | | var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint); |
| | | |
| | | //获取设备类型的 |
| | | var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device }); |
| | | //新风面板的新风设备,则不显示 |
| | | if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (device.Type == DeviceType.FreshAir) |
| | | { |
| | | bindFreshAirName = device.DeviceEpointName; |
| | | } |
| | | if (device.Type == DeviceType.TemperatureSensor) |
| | | { |
| | | bindTemperatureName = device.DeviceEpointName; |
| | | } |
| | | if (device.Type == DeviceType.FreshAirHumiditySensor) |
| | | { |
| | | bindHumidityName = device.DeviceEpointName; |
| | | } |
| | | //if (device.Type == DeviceType.FreshAir) |
| | | //{ |
| | | // bindPmName = device.DeviceEpointName; |
| | | //} |
| | | } |
| | | result = true; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | #region ■ PM2.5来源_________________________ |
| | | /// <summary> |
| | | /// PM2.5来源行 |
| | | /// </summary> |
| | | private void AddPMRow() |
| | | { |
| | | //PM2.5 |
| | | var rowPM = new FrameRowControl(listview.rowSpace / 2); |
| | | listview.AddChidren(rowPM); |
| | | rowPM.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.PM25Source), 600); |
| | | //底线 |
| | | rowPM.AddBottomLine(); |
| | | //右箭头 |
| | | rowPM.AddRightArrow(); |
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | if (!string.IsNullOrEmpty(bindPmName)) |
| | | { |
| | | msg = bindPmName; |
| | | } |
| | | var btnPMStatu = rowPM.AddMostRightView(msg, 700); |
| | | rowPM.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 4); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | addDevicePage.Show(); |
| | | |
| | | addDevicePage.actionPMTarget += (bindName) => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(bindName)) |
| | | { |
| | | btnPMStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | } |
| | | else |
| | | { |
| | | btnPMStatu.Text = bindName; |
| | | } |
| | | }); |
| | | }; |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 温度来源_________________________ |
| | | /// <summary> |
| | | /// 温度来源行 |
| | | /// </summary> |
| | | private void AddTemperatureSensorRow()
|
| | | {
|
| | | //温度来源 |
| | | var rowTemPerature = new FrameRowControl(listview.rowSpace / 2); |
| | | listview.AddChidren(rowTemPerature); |
| | | rowTemPerature.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.TemperatureSource), 600); |
| | | //底线 |
| | | rowTemPerature.AddBottomLine(); |
| | | //右箭头 |
| | | rowTemPerature.AddRightArrow(); |
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | if (!string.IsNullOrEmpty(bindTemperatureName)) |
| | | { |
| | | msg = bindTemperatureName; |
| | | } |
| | | var btnTemperatureStatu = rowTemPerature.AddMostRightView(msg, 700); |
| | | rowTemPerature.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 2); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | addDevicePage.Show(); |
| | | |
| | | addDevicePage.actionTemperatureTarget += (bindName) => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(bindName)) |
| | | { |
| | | btnTemperatureStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | } |
| | | else |
| | | { |
| | | btnTemperatureStatu.Text = bindName; |
| | | } |
| | | }); |
| | | }; |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 湿度来源_________________________ |
| | | /// <summary> |
| | | /// 湿度来源行 |
| | | /// </summary> |
| | | private void AddHumiditySourceRow() |
| | | { |
| | | //湿度 |
| | | var rowHumidity = new FrameRowControl(listview.rowSpace / 2); |
| | | listview.AddChidren(rowHumidity); |
| | | rowHumidity.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.HumiditySource), 600); |
| | | //底线 |
| | | rowHumidity.AddBottomLine(); |
| | | //右箭头 |
| | | rowHumidity.AddRightArrow(); |
| | | var msg = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | if (!string.IsNullOrEmpty(bindHumidityName)) |
| | | { |
| | | msg = bindHumidityName; |
| | | } |
| | | var btnHumidityStatu = rowHumidity.AddMostRightView(msg, 700); |
| | | rowHumidity.ButtonClickEvent += (sender, e) => |
| | | { |
| | | var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, 3); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | addDevicePage.Show(); |
| | | |
| | | addDevicePage.actionHumidityTarget += (bindName) => |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(bindName)) |
| | | { |
| | | btnHumidityStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing); |
| | | } |
| | | else |
| | | { |
| | | btnHumidityStatu.Text = bindName; |
| | | } |
| | | }); |
| | | }; |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 亮度调节_________________________ |
| | | /// <summary> |
| | | /// 亮度调节行 |
| | | /// </summary> |
| | | private void AddLevelRow() |
| | | { |
| | | //亮度调节 |
| | | var rowLight = new FrameRowControl(listview.rowSpace / 2);
|
| | | listview.AddChidren(rowLight);
|