HDL Home App 第二版本 旧平台金堂用 正在使用
陈嘉乐
2020-09-02 07c647861d549a4c61f615dba9c008c29ad57f43
ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelSimpleEnvironmentButtonSettionForm.cs
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/Device/Panel/PanelFangyueFreshAirButtonSettionForm.cs
@@ -1,15 +1,16 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.UserCenter.Device.Bind;
using ZigBee.Common;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DevicePanel
{
    /// <summary>
    /// 方悦新风面板的按键配置界面
    /// 面板的按键配置界面【该类暂时舍弃】
    /// </summary>
    public class PanelFangyueFreshAirButtonSettionForm : EditorCommonForm
    public class PanelSimpleEnvironmentButtonSettionForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
@@ -36,7 +37,7 @@
        /// <summary>
        /// PM目标名字
        /// </summary>
        private string bindPmName = string.Empty;
        private string bindAcName = string.Empty;
        /// <summary>
        /// 被绑目标是新风
        /// </summary>
@@ -50,9 +51,9 @@
        /// </summary>
        private CommonDevice bindHumidityDev;
        /// <summary>
        /// 被绑目标是PM2.5
        /// 被绑目标是空调
        /// </summary>
        private CommonDevice bindPMDev;
        private CommonDevice bindAcDev;
        // <summary>
        /// 按键中被绑定的目标列表
        /// </summary>
@@ -70,7 +71,7 @@
        {
            this.deviceObj = i_device;
            //获取数据
            ReadDoorLockUserInfo(deviceObj);
            InitInfo(deviceObj);
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uPanelSettion));
@@ -97,7 +98,7 @@
            //图片
            var btnPic = new PicViewControl(426, 426);
            btnPic.Y = Application.GetRealHeight(150);
            btnPic.UnSelectedImagePath = "RealDevice/ButtonPanelFangyueFreshAir.png";
            btnPic.UnSelectedImagePath = "RealDevice/ButtonPanelSimpleEnvironment.png";
            btnPic.Gravity = Gravity.CenterHorizontal;
            listBackControl.frameTable.AddChidren(btnPic);
@@ -128,11 +129,11 @@
        /// </summary>
        private void InitMenuRow()
        {
            this.listview.RemoveAll();
            this.listview.RemoveAll();
            //Ac来源
            this.AddAcRow();
            //添加新风目标
            this.AddFreshAirRow();
            //PM2.5来源
            this.AddPMRow();
            //添加温度来源
            this.AddTemperatureSensorRow();
            //添加湿度来源
@@ -142,12 +143,11 @@
        }
        #endregion
        #region ■ 初始化数据_________________________
        #region ■ 数据处理_________________________
        /// <summary>
        /// 初始化数据
        /// </summary>
        void ReadDoorLockUserInfo(CommonDevice curControlDev)
        void InitInfo(CommonDevice curControlDev)
        {
            System.Threading.Tasks.Task.Run(async () =>
            {
@@ -164,7 +164,7 @@
                        Application.RunOnMainThread(() =>
                        {
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                            new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5007" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
                        });
                    }
                }
@@ -181,6 +181,181 @@
                    });
                }
            });
        }
        /// <summary>
        /// 获取绑定目标
        /// </summary>
        /// <param name="curControlDev"></param>
        /// <returns></returns>
        private async System.Threading.Tasks.Task<bool> GetBindName(CommonDevice curDev)
        {
            bool result = false;
            //获取面板中存在的绑定目标
            var curControlDev = new CommonDevice();
            curControlDev.DeviceAddr = curDev.DeviceAddr;
            curControlDev.CurrentGateWayId = curDev.CurrentGateWayId;
            curControlDev.Type = curDev.Type;
            int count = 0;
            for (int i = 1; i < 3; i++)
            {
                curControlDev.DeviceEpoint = i;
                var panelBindListRes = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
                if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null)
                {
                    bindList = panelBindListRes.getAllBindResponseData.BindList;
                    foreach (var bDev in bindList)
                    {
                        var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                        if (device == null)
                        {
                            continue;
                        }
                        if (device.Type == DeviceType.FreshAir)
                        {
                            //获取设备类型的
                            var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                            //新风面板的新风设备,则不显示
                            if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                            {
                                continue;
                            }
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindFreshAirName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindFreshAirName = bDev.ESName;
                            }
                            bindFreshAirDev = device;
                        }
                        else if (device.Type == DeviceType.TemperatureSensor)
                        {
                            var bD = device as TemperatureSensor;
                            if (bD.SensorDiv == 1)
                            {
                                if (string.IsNullOrEmpty(bDev.ESName))
                                {
                                    bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                                }
                                else
                                {
                                    bindTemperatureName = bDev.ESName;
                                }
                                bindTemperatureDev = device;
                            }
                            if (bD.SensorDiv == 2)
                            {
                                if (string.IsNullOrEmpty(bDev.ESName))
                                {
                                    bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                                }
                                else
                                {
                                    bindHumidityName = bDev.ESName;
                                }
                                bindHumidityDev = device;
                            }
                        }
                        else if (device.Type == DeviceType.FreshAirHumiditySensor)
                        {
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindHumidityName = bDev.ESName;
                            }
                            bindHumidityDev = device;
                        }
                        else if (device.Type == DeviceType.Thermostat)
                        {
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindAcName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindAcName = bDev.ESName;
                            }
                            bindAcDev = device;
                        }
                        else if (device.Type == DeviceType.PMSensor)
                        {
                            if (bDev.BindCluster == 1026)
                            {
                                bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                                bindTemperatureDev = device;
                            }
                            if (bDev.BindCluster == 1029)
                            {
                                bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                                bindHumidityDev = device;
                            }
                        }
                    }
                    count++;
                    if (count == 2)
                    {
                        result = true;
                    }
                }
            }
            return result;
        }
        #endregion
        #region ■ Ac来源_________________________
        /// <summary>
        ///  Ac来源行
        /// </summary>
        private void AddAcRow()
        {
            //Ac
            var rowAc = new FrameRowControl(listview.rowSpace / 2);
            listview.AddChidren(rowAc);
            rowAc.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.AcTargets), 600);
            //底线
            rowAc.AddBottomLine();
            //右箭头
            rowAc.AddRightArrow();
            var msg = Language.StringByID(R.MyInternationalizationString.nothing);
            if (!string.IsNullOrEmpty(bindAcName))
            {
                msg = bindAcName;
            }
            var btnAcStatu = rowAc.AddMostRightView(msg, 700);
            rowAc.ButtonClickEvent += (sender, e) =>
            {
                this.deviceObj.DeviceEpoint = 1;
                var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindAcDev, DeviceBind.BindInfo.BindType.AC);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                paneTargetsBaseFormp.Show();
                paneTargetsBaseFormp.actionAcTarget += (bindName) =>
                {
                    Application.RunOnMainThread(() =>
                    {
                        if (string.IsNullOrEmpty(bindName))
                        {
                            btnAcStatu.Text = Language.StringByID(R.MyInternationalizationString.nothing);
                        }
                        else
                        {
                            btnAcStatu.Text = bindName;
                        }
                    });
                };
            };
        }
        #endregion
@@ -207,13 +382,13 @@
            var btnNewWindStatu = rowNewWind.AddMostRightView(msg, 700);
            rowNewWind.ButtonClickEvent += (sender, e) =>
            {
                var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindFreshAirDev, 1);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage);
            {
                this.deviceObj.DeviceEpoint = 2;
                var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindAcDev, DeviceBind.BindInfo.BindType.FreshAir);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                addDevicePage.Show();
                addDevicePage.actionFreshAirTarget += (bindName) =>
                paneTargetsBaseFormp.Show();
                paneTargetsBaseFormp.actionFreshAirTarget += (bindName) =>
                {
                    Application.RunOnMainThread(() =>
                    {
@@ -228,163 +403,6 @@
                    });
                };
            };
        }
        #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 = HdlDeviceBindLogic.Current.GetDeviceBindAsync(curControlDev);
            if (panelBindListRes != null && panelBindListRes.getAllBindResponseData != null)
            {
                bindList = panelBindListRes.getAllBindResponseData.BindList;
                foreach (var bDev in bindList)
                {
                    var device = Common.LocalDevice.Current.GetDevice(bDev.BindMacAddr, bDev.BindEpoint);
                    if (device.Type == DeviceType.FreshAir)
                    {
                        //获取设备类型的
                        var deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice>() { device });
                        //新风面板的新风设备,则不显示
                        if (deviceEnumInfo.ConcreteType == Common.DeviceConcreteType.ButtonPanel_FangyueFreshAir)
                        {
                            continue;
                        }
                        if (string.IsNullOrEmpty(bDev.ESName))
                        {
                            bindFreshAirName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                        }
                        else
                        {
                            bindFreshAirName = bDev.ESName;
                        }
                        bindFreshAirDev = device;
                    }
                    if (device.Type == DeviceType.TemperatureSensor)
                    {
                        var bD = device as TemperatureSensor;
                        if (bD.SensorDiv == 1)
                        {
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindTemperatureName = bDev.ESName;
                            }
                            bindTemperatureDev = device;
                        }
                        if (bD.SensorDiv == 2)
                        {
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindHumidityName = bDev.ESName;
                            }
                            bindHumidityDev = device;
                        }
                    }
                    if (device.Type == DeviceType.FreshAirHumiditySensor)
                    {
                        if (string.IsNullOrEmpty(bDev.ESName))
                        {
                            bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                        }
                        else
                        {
                            bindHumidityName = bDev.ESName;
                        }
                        bindHumidityDev = device;
                    }
                    if (device.Type == DeviceType.PMSensor)
                    {
                        if (bDev.BindCluster == 1026)
                        {
                            bindTemperatureName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.TemperatureSensor);
                            bindTemperatureDev = device;
                        }
                        if (bDev.BindCluster == 1029)
                        {
                            bindHumidityName = Common.LocalDevice.Current.GetDeviceEpointName(device) + "-" + Language.StringByID(R.MyInternationalizationString.HumiditySensor);
                            bindHumidityDev = device;
                        }
                        if (bDev.BindCluster == 1066)
                        {
                            if (string.IsNullOrEmpty(bDev.ESName))
                            {
                                bindPmName = Common.LocalDevice.Current.GetDeviceEpointName(device);
                            }
                            else
                            {
                                bindPmName = bDev.ESName;
                            }
                            bindPMDev = device;
                        }
                    }
                }
                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, bindPMDev, 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
@@ -411,12 +429,12 @@
            var btnTemperatureStatu = rowTemPerature.AddMostRightView(msg, 700);
            rowTemPerature.ButtonClickEvent += (sender, e) =>
            {
                var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindTemperatureDev, 2);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage);
                this.deviceObj.DeviceEpoint = 1;
                var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindAcDev, DeviceBind.BindInfo.BindType.Temperature);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                addDevicePage.Show();
                addDevicePage.actionTemperatureTarget += (bindName) =>
                paneTargetsBaseFormp.Show();
                paneTargetsBaseFormp.actionTemperatureTarget += (bindName) =>
                {
                    Application.RunOnMainThread(() =>
                    {
@@ -456,12 +474,12 @@
            var btnHumidityStatu = rowHumidity.AddMostRightView(msg, 700);
            rowHumidity.ButtonClickEvent += (sender, e) =>
            {
                var addDevicePage = new Shared.Phone.UserCenter.DeviceBind.PanelFangyueFreshAirTargetsForm(this.deviceObj, bindHumidityDev, 3);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(addDevicePage);
                this.deviceObj.DeviceEpoint = 1;
                var paneTargetsBaseFormp = new PaneTargetsBaseForm(this.deviceObj, bindAcDev, DeviceBind.BindInfo.BindType.Humidity);
                Shared.Phone.UserView.HomePage.Instance.AddChidren(paneTargetsBaseFormp);
                Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                addDevicePage.Show();
                addDevicePage.actionHumidityTarget += (bindName) =>
                paneTargetsBaseFormp.Show();
                paneTargetsBaseFormp.actionHumidityTarget += (bindName) =>
                {
                    Application.RunOnMainThread(() =>
                    {
@@ -494,14 +512,9 @@
            //右箭头
            rowLight.AddRightArrow();
            rowLight.ButtonClickEvent += (sender, e) =>
            {
                //给新风面板建立一个新的支持面板对象,用200端点设置
                var panel = new Panel();
                panel.DeviceAddr = this.deviceObj.DeviceAddr;
                panel.DeviceEpoint = 200;
                panel.CurrentGateWayId = this.deviceObj.CurrentGateWayId;
                var form = new PanelFangyueFreshAirBackLightSettionForm();
                form.AddForm(panel);
            {
                var form = new PanelBrightnessAdjustForm();
                form.AddForm(this.deviceObj);
            };
        }
        #endregion
@@ -545,4 +558,4 @@
        #endregion
    }
}
}