JLChen
2021-08-05 ba275a7b58e56c61820ffccc86571447b2997e52
HDL_ON/UI/UI2/1-HomePage/HomePage.cs
@@ -194,6 +194,34 @@
                #region 环境数据
                var tempSensorList = FunctionList.List.GetEnvirSensorsList().FindAll((obj) => obj.spk == SPK.SensorTemperature);
                var humiSensorList = FunctionList.List.GetEnvirSensorsList().FindAll((obj) => obj.spk == SPK.SensorHumidity);
                var enviList = FunctionList.List.GetEnvirSensorsList().FindAll((obj) => obj.spk == SPK.SensorEnvironment);
                foreach (var enviTemp in enviList)
                {
                    var humiAttr = enviTemp.attributes.Find((obj) => obj.key == "humidity");
                    if (humiAttr != null)
                    {
                        var newTemp = new Function()
                        {
                            name = enviTemp.name,
                            sid = enviTemp.sid,
                            deviceId = enviTemp.deviceId,
                            attributes = new List<FunctionAttributes> { new FunctionAttributes { key = "value", state = humiAttr.state, curValue = humiAttr.curValue } },
                        };
                        humiSensorList.Add(newTemp);
                    }
                    var tempAttr = enviTemp.attributes.Find((obj) => obj.key == "temperature");
                    if (tempAttr != null)
                    {
                        var newTemp = new Function()
                        {
                            name = enviTemp.name,
                            sid = enviTemp.sid,
                            deviceId = enviTemp.deviceId,
                            attributes = new List<FunctionAttributes> { new FunctionAttributes { key = "value", state = tempAttr.state, curValue = tempAttr.curValue } },
                        };
                        tempSensorList.Add(newTemp);
                    }
                }
                var btnEnvirValuesTitle = new Button() {
                    X = Application.GetRealWidth(12),
@@ -245,15 +273,20 @@
                {
                    btnIndoorTempValues.Text = "/--°";
                    double tempTotalValues = 0;
                    double tempTotalCount = 0;
                    foreach (var temp in tempSensorList)
                    {
                        double tempValue = 0;
                        double.TryParse(temp.GetAttrState(FunctionAttributeKey.Value), out tempValue);
                        tempTotalValues += tempValue;
                        if (tempValue > 0)
                        {
                            tempTotalValues += tempValue;
                            tempTotalCount++;
                        }
                    }
                    if (tempTotalValues > 0)
                    {
                        btnIndoorTempValues.Text = "/" + tempTotalValues + "°";
                        btnIndoorTempValues.Text = "/" + (tempTotalValues/ tempTotalCount).ToString("0.0") + "°";
                    }
                }
                btnIndoorTempValues.Width = btnIndoorTempValues.GetTextWidth();
@@ -294,15 +327,20 @@
                {
                    btnIndoorHumiValues.Text = "/--%";
                    double humiTotalValues = 0;
                    double humiTotalCount = 0;
                    foreach (var humi in humiSensorList)
                    {
                        double humiValue = 0;
                        double.TryParse(humi.GetAttrState(FunctionAttributeKey.Value), out humiValue);
                        humiTotalValues += humiValue;
                        if (humiValue > 0)
                        {
                            humiTotalValues += humiValue;
                            humiTotalCount++;
                        }
                    }
                    if (humiTotalValues > 0)
                    {
                        btnIndoorHumiValues.Text = "/" + humiTotalValues + "%";
                        btnIndoorHumiValues.Text = "/" + (humiTotalValues / humiTotalCount).ToString("0") + "%";
                    }
                }
                btnIndoorHumiValues.Width = btnIndoorHumiValues.GetTextWidth();
@@ -948,12 +986,8 @@
                    LoadEvent_ControlCurtain(function, btnCurtainClose, btnCurtainOpen);
                }
                else if (function.spk == SPK.ElectricTV || function.spk == SPK.TvIr || function.spk == SPK.TvXmIr
                    || function.spk == SPK.StbIr || function.spk == SPK.PjtIr)
                else if (SPK.NotStatusSpkList.Contains(function.spk))
                {
                    //btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_blue.png";
                    //btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_white.png";
                    Button btnPower;
                    btnPower = new Button()
                    {
@@ -962,6 +996,7 @@
                        Width = Application.GetRealWidth(32),
                        Height = Application.GetRealWidth(32),
                        UnSelectedImagePath = "Public/PowerClose.png",
                        SelectedImagePath = "Public/PowerOpen.png",
                    };
                    view.AddChidren(btnPower);
                    LoadEvent_ControlTV(function, btnPower);
@@ -1057,62 +1092,8 @@
                    };
                    view.AddChidren(btnSwitch);
                    btnIcon.UnSelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_blue.png";
                    btnIcon.SelectedImagePath = $"FunctionIcon/Icon/HomeIcon/{function.IconName}_white.png";
                    //switch (function.Spk_Prefix)
                    //{
                    //    //todo 增加设备,主页收藏图标
                    //    case FunctionCategory.Light:
                    //        #region 灯光 Light
                    //        btnIcon.UnSelectedImagePath = "FunctionIcon/Light/LightIcon.png";
                    //        btnIcon.SelectedImagePath = "FunctionIcon/Light/LightOnIcon.png";
                    //        UpdataFunctionStates(function);
                    //        #endregion
                    //        break;
                    //    case FunctionCategory.AC:
                    //        #region 空调 AC
                    //        btnIcon.UnSelectedImagePath = "FunctionIcon/AC/AcIcon.png";
                    //        btnIcon.SelectedImagePath = "FunctionIcon/AC/AcOnIcon.png";
                    //        #endregion
                    //        break;
                    //    case FunctionCategory.FloorHeat:
                    //        #region 地热
                    //        btnIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingIcon.png";
                    //        btnIcon.SelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingOnIcon.png";
                    //        #endregion
                    //        break;
                    //    case FunctionCategory.Electric:
                    //        switch (function.spk)
                    //        {
                    //            case SPK.ElectricSocket:
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketIcon.png";
                    //                btnIcon.SelectedImagePath = "FunctionIcon/Socket/SocketOnIcon.png";
                    //                break;
                    //            case SPK.ElectricFan:
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanIcon.png";
                    //                btnIcon.SelectedImagePath = "FunctionIcon/Electrical/FanOnIcon.png";
                    //                break;
                    //            case SPK.ElectricTuyaAirCleaner:
                    //                btnIcon.SelectedImagePath = "FunctionIcon/HomePageIcon/AirCleanerIcon.png";
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/HomePageIcon/AirCleanerIconOn.png";
                    //                break;
                    //            case SPK.ElectricTuyaFan:
                    //                btnIcon.SelectedImagePath = "FunctionIcon/HomePageIcon/FanIcon.png";
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/HomePageIcon/FanIconOn.png";
                    //                break;
                    //            case SPK.ElectricTuyaWaterValve:
                    //                btnIcon.SelectedImagePath = "FunctionIcon/HomePageIcon/WaterValveIcon.png";
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/HomePageIcon/WaterValveIconOn.png";
                    //                break;
                    //            case SPK.ElectricTuyaWeepRobot:
                    //                btnIcon.SelectedImagePath = "FunctionIcon/HomePageIcon/WeepRobotIcon.png";
                    //                btnIcon.UnSelectedImagePath = "FunctionIcon/HomePageIcon/WeepRobotIconOn.png";
                    //                break;
                    //        }
                    //        break;
                    //}
                    LoadEvent_SwitchFunction(function, btnSwitch);
                }
                //取消收藏事件
@@ -1137,8 +1118,8 @@
                btnName.MouseUpEventHandler = skipControlPageEvent;
                btnIcon.MouseUpEventHandler = skipControlPageEvent;
                btnState.MouseUpEventHandler = skipControlPageEvent;
                //电视不需要更新状态
                if(function.spk!= SPK.ElectricTV && function.spk != SPK.StbIr && function.spk != SPK.PjtIr)
                //不需要更新状态的动能列表
                if(!SPK.NotStatusSpkList.Contains(function.spk))
                {
                    UpdataFunctionStates(function);
                }
@@ -1184,7 +1165,7 @@
                    Width = Application.GetRealWidth(32),
                    UnSelectedImagePath = "Public/FuncInfoSetIcon_white.png",
                };
                if (!DB_ResidenceData.Instance.CurrentRegion.isOtherShare)
                if (scene.userId == UserInfo.Current.ID)
                {
                    view.AddChidren(btnSettingIcon);
                }