wxr
2022-09-26 418b0d0a4002bc06ba3a55d1809fe46043f06c09
HDL_ON/UI/UI2/FuntionControlView/Acst/AcstParentPage.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using Shared;
@@ -38,6 +39,12 @@
        /// 子控区域列表
        /// </summary>
        Dictionary<string, AcstSubControlView> subViewList;
        Button btnWorkSceneControl;
        Button btnModeControl;
        Button btnPowerControl;
        public override void RemoveFromParent()
@@ -82,7 +89,7 @@
            };
        }
        /// <summary>
        /// 传感器、耗电量组件
        /// 更新主控数据信息
        /// </summary>
        public static void UpdateAcstParentInfo(Function temp)
        {
@@ -91,22 +98,70 @@
                return;
            }
            if (basePage.sensorDiyView_Temp != null)
                basePage.sensorDiyView_Temp.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()).curValue.ToString());
                basePage.sensorDiyView_Temp.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_temp.ToString()).state);
            if (basePage.sensorDiyView_Humi != null)
                basePage.sensorDiyView_Humi.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString()).curValue.ToString());
                basePage.sensorDiyView_Humi.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString()).state);
            if (basePage.sensorDiyView_Pm25 != null)
                basePage.sensorDiyView_Pm25.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.pm25.ToString()).curValue.ToString());
                basePage.sensorDiyView_Pm25.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.pm25.ToString()).state);
            if (basePage.sensorDiyView_Co2 != null)
                basePage.sensorDiyView_Co2.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.co2.ToString()).curValue.ToString());
                basePage.sensorDiyView_Co2.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.co2.ToString()).state);
            if (basePage.sensorDiyView_Tvoc != null)
                basePage.sensorDiyView_Tvoc.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.tvoc.ToString()).curValue.ToString());
                basePage.sensorDiyView_Tvoc.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.tvoc.ToString()).state);
            if (basePage.sensorDiyView_EleDay != null)
                basePage.sensorDiyView_EleDay.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()).curValue.ToString());
                basePage.sensorDiyView_EleDay.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.day_electricity.ToString()).state);
            if (basePage.sensorDiyView_EleMonth != null)
                basePage.sensorDiyView_EleMonth.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString()).curValue.ToString());
                basePage.sensorDiyView_EleMonth.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.month_electricity.ToString()).state);
            if (basePage.sensorDiyView_EleTotal != null)
                basePage.sensorDiyView_EleTotal.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString()).curValue.ToString());
                basePage.sensorDiyView_EleTotal.UpdateValue(temp.GetAttribute(AcstParent_AttrEnum.total_electricity.ToString()).state);
            basePage.btnModeControl.IsSelected = basePage.btnWorkSceneControl.IsSelected = basePage.btnPowerControl.IsSelected = temp.trait_on_off.state == "on";
            switch (temp.GetAttrState("mode"))
            {
                case "cool"://制冷
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeCoolIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeCoolIcon2.png";
                    break;
                case "heat"://制热
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatIcon2.png";
                    break;
                case "fan"://通风
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeFanIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeFanIcon2.png";
                    break;
                case "dry"://除湿
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeDeHumiIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeDeHumiIcon2.png";
                    break;
                case "humidity"://加湿
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHumiIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHumiIcon2.png";
                    break;
                case "heat_humidity"://制热加湿
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeHeatHumiIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeHeatHumiIcon2.png";
                    break;
            }
            switch (temp.GetAttrState("scene"))
            {
                case "at_home"://在家
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAtHome2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/ModeCoolIcon2.png";
                    break;
                case "leave_home"://离家
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneAwayHomeIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneAwayHomeIcon2.png";
                    break;
                case "sleep"://睡眠
                    basePage.btnModeControl.UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneSleepIcon2.png";
                    basePage.btnModeControl.UnSelectedImagePath = $"FunctionIcon/Acst/{basePage.imageFolder}/SceneSleepIcon2.png";
                    break;
            }
        }
        /// <summary>
        /// 更新子控信息
@@ -155,8 +210,7 @@
            #region 头部信息区域
            FrameLayout topView = new FrameLayout()
            {
                Height = Application.GetRealHeight(181),
                BackgroundColor = 0xFFb0eafa,
                Height = Application.GetRealHeight(180),
                BackgroundImagePath = $"FunctionIcon/Acst/{imageFolder}/TopViewBg.png",
            };
            bodyView.AddChidren(topView);
@@ -172,13 +226,16 @@
            Button btnBackIcon = new Button()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(40),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = "Public/BackIcon.png",
                Width = Application.GetRealWidth(12),
                Height = Application.GetRealHeight(20),
                UnSelectedImagePath = "FunctionIcon/Acst/BackIcon.png",
            };
            backView.AddChidren(btnBackIcon);
            btnBackIcon.MouseUpEventHandler = (sender, e) => {
            Button btnBackClick = new Button();
            backView.AddChidren(btnBackClick);
            btnBackClick.MouseUpEventHandler = (sender, e) => {
                this.RemoveFromParent();
            };
@@ -195,7 +252,7 @@
            };
            topView.AddChidren(btnHelloText);
            btnOutdoorTemp = new Button()
            {
                X = Application.GetRealWidth(25),
@@ -303,12 +360,12 @@
            #region 传感器数据
            int sensorCount = 0;
            var tempObj = function.GetAttribute(AcstParent_AttrEnum.room_temp.ToString());
            if(tempObj!= null)
            if (tempObj != null)
            {
                sensorCount++;
            }
            var humiObj = function.GetAttribute(AcstParent_AttrEnum.room_humidity.ToString());
            if(humiObj != null)
            if (humiObj != null)
            {
                sensorCount++;
            }
@@ -338,23 +395,23 @@
            if (tempObj != null)
            {
                sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.curValue.ToString() + "°", "温度");
                sensorDiyView_Temp = new SensorDiyView(sensorListView, curColor, tempObj.state == "" ? "--" : tempObj.state + "°", "温度");
            }
            if (humiObj != null)
            {
                sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.curValue.ToString() + "%", "湿度");
                sensorDiyView_Humi = new SensorDiyView(sensorListView, curColor, humiObj.state == "" ? "--" : humiObj.state + "%", "湿度");
            }
            if (pm25Obj != null)
            {
                sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.curValue.ToString(), "PM2.5");
                sensorDiyView_Pm25 = new SensorDiyView(sensorListView, curColor, pm25Obj.state == "" ? "--" : pm25Obj.state, "PM2.5");
            }
            if (co2Obj != null)
            {
                sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.curValue.ToString(), "CO2");
                sensorDiyView_Co2 = new SensorDiyView(sensorListView, curColor, co2Obj.state == "" ? "--" : co2Obj.state, "CO2");
            }
            if (tvocObj != null)
            {
                sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.curValue.ToString(), "TVOC");
                sensorDiyView_Tvoc = new SensorDiyView(sensorListView, curColor, tvocObj.state == "" ? "--" : tvocObj.state, "TVOC");
            }
            #endregion
@@ -378,22 +435,22 @@
            var energyListView = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(60 * energyCount),
                Width = Application.GetRealWidth(100 * energyCount),
                Gravity = Gravity.Center,
                Visible = false,
            };
            infoContentView.AddChidren(energyListView);
            if (dayObj != null)
            {
                sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.curValue.ToString(), "今日耗电");
                sensorDiyView_EleDay = new SensorDiyView(energyListView, curColor, dayObj.state == "" ? "--" : dayObj.state + "KW", "今日耗电",100);
            }
            if (monthObj != null)
            {
                sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.curValue.ToString(), "本月耗电");
                sensorDiyView_EleMonth = new SensorDiyView(energyListView, curColor, monthObj.state == "" ? "--" : monthObj.state + "KWh", "本月耗电", 100);
            }
            if (totalObj != null)
            {
                sensorDiyView_EleTotal = new SensorDiyView(energyListView, curColor, totalObj.curValue.ToString(), "总耗电量");
                sensorDiyView_EleTotal = new SensorDiyView(energyListView, curColor, totalObj.state == "" ? "--" : totalObj.state + "KWh", "总耗电量", 100);
            }
            var btnChangeClick = new Button();
@@ -451,7 +508,7 @@
            };
            var btnTitleText = new Button()
            var btnTitleText2 = new Button()
            {
                X = btnCollection.Right,
                Text = "我的家庭",
@@ -461,7 +518,7 @@
                IsBold = true,
                Height = Application.GetRealHeight(54),
            };
            subTitleView.AddChidren(btnTitleText);
            subTitleView.AddChidren(btnTitleText2);
            int subFunctionCount = 0;
@@ -515,7 +572,7 @@
            };
            this.AddChidren(bottomView);
            var btnModeControl = new Button()
            btnModeControl = new Button()
            {
                X = Application.GetRealWidth(89),
                Gravity = Gravity.CenterVertical,
@@ -524,10 +581,15 @@
                UnSelectedImagePath = "FunctionIcon/Acst/grey/ModeCoolIcon2.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png",
                TextAlignment = TextAlignment.Center,
                IsSelected = function.trait_on_off.state == "on"
            };
            bottomView.AddChidren(btnModeControl);
            btnModeControl.MouseUpEventHandler = (sender, e) =>
            btnModeControl.MouseUpEventHandler = (sender3, e3) =>
            {
                if(function.trait_on_off.state == "off")
                {
                    return;
                }
                Dialog dialog = new Dialog();
                var dialogView = new FrameLayout();
@@ -539,8 +601,8 @@
                var dialogContentView = new FrameLayout() {
                    X = Application.GetRealWidth(34),
                    Y = Application.GetRealHeight(291),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(291),
                    Width = Application.GetRealWidth(148),
                    Height = Application.GetRealHeight(319),
                    BackgroundImagePath = "FunctionIcon/Acst/BgChooseMode.png",
                };
                dialogView.AddChidren(dialogContentView);
@@ -564,26 +626,219 @@
                };
                titleView.AddChidren(btnTitleText);
                #region 制冷
                var coolView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = titleView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(coolView);
                coolView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton coolIconButton = new IconButton("FunctionIcon/Acst/grey/ModeCoolIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon.png",
                    Language.StringByID(StringId.Cool),curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "cool");
                coolIconButton.Click(()=> {
                    dialog.Close();
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeCoolIcon2.png";
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add(AcstParent_AttrEnum.mode.ToString(), AcstParent_Attr_ModeValueEnum.cool.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    }) { IsBackground = true }.Start();
                });
                coolView.AddChidren(coolIconButton);
                #endregion
                #region 制热
                var heatView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = coolView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(heatView);
                heatView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton heatIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon.png",
                    Language.StringByID(StringId.Heat), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == "heat");
                heatIconButton.Click(() => {
                    dialog.Close();
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatIcon2.png";
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("mode", "heat");
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                heatView.AddChidren(heatIconButton);
                #endregion
                #region 除湿
                var dehumiView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = heatView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(dehumiView);
                dehumiView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton dehumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeDeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon.png",
                    Language.StringByID(StringId.Humidity), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.dry.ToString());
                dehumiIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeDeHumiIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("mode", AcstParent_Attr_ModeValueEnum.dry.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                dehumiView.AddChidren(dehumiIconButton);
                #endregion
                #region 通风
                var fanView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = dehumiView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(fanView);
                fanView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton fanIconButton = new IconButton("FunctionIcon/Acst/grey/ModeFanIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon.png",
                    Language.StringByID(StringId.Ventilated), curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.fan.ToString());
                fanIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeFanIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("mode", AcstParent_Attr_ModeValueEnum.fan.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                fanView.AddChidren(fanIconButton);
                #endregion
                #region 制热除湿
                var heatHumiView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = fanView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(heatHumiView);
                heatHumiView.AddChidren(new Button
                {
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(112),
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton heatHumiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHeatHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon.png",
                    "制热除湿", curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.heat_humidity.ToString());
                heatHumiIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHeatHumiIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("mode", AcstParent_Attr_ModeValueEnum.heat_humidity.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                heatHumiView.AddChidren(heatHumiIconButton);
                #endregion
                #region 加湿
                var humiView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = heatHumiView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(humiView);
                humiView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton humiIconButton = new IconButton("FunctionIcon/Acst/grey/ModeHumiIcon.png", $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon.png",
                    "加湿", curColor, function.GetAttrState(AcstParent_AttrEnum.mode.ToString()) == AcstParent_Attr_ModeValueEnum.humidity.ToString());
                humiIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/ModeHumiIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("mode", AcstParent_Attr_ModeValueEnum.humidity.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                humiView.AddChidren(humiIconButton);
                #endregion
                dialog.Show();
            };
            var btnPowerControl = new Button()
            btnPowerControl = new Button()
            {
                Gravity = Gravity.Center,
                Width = Application.GetRealWidth(38),
                Height = Application.GetRealWidth(38),
                UnSelectedImagePath = "FunctionIcon/Acst/grey/PowerOffIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerOnIcon.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/PowerIcon.png",
                TextAlignment = TextAlignment.Center,
                IsSelected = function.trait_on_off.state == "on"
            };
            bottomView.AddChidren(btnPowerControl);
            btnPowerControl.MouseUpEventHandler = (sender, e) => {
                btnPowerControl.IsSelected = !btnPowerControl.IsSelected;
                new System.Threading.Thread(() => {
                    Dictionary<string, string> d = new Dictionary<string, string>();
                    d.Add("onoff", btnPowerControl.IsSelected ? "on" : "off");
                    Control.Ins.SendWriteCommand(function, d);
                })
                { IsBackground = true }.Start();
            };
            var btnWorkSceneControl = new Button()
            btnWorkSceneControl = new Button()
            {
                Gravity = Gravity.CenterVertical,
                X = Application.GetRealWidth(249),
@@ -592,8 +847,150 @@
                UnSelectedImagePath = "FunctionIcon/Acst/grey/SceneSleepIcon2.png",
                SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png",
                TextAlignment = TextAlignment.Center,
                IsSelected = function.trait_on_off.state == "on"
            };
            bottomView.AddChidren(btnWorkSceneControl);
            btnWorkSceneControl.MouseUpEventHandler = (sender2, e2) =>
            {
                if (function.trait_on_off.state == "off")
                {
                    return;
                }
                Dialog dialog = new Dialog();
                var dialogView = new FrameLayout();
                dialog.AddChidren(dialogView);
                dialogView.MouseUpEventHandler = (sender, e) => {
                    dialog.Close();
                };
                var dialogContentView = new FrameLayout()
                {
                    X = Application.GetRealWidth(194),
                    Y = Application.GetRealHeight(419),
                    Width = Application.GetRealWidth(148),
                    Height = Application.GetRealHeight(191),
                    BackgroundImagePath = "FunctionIcon/Acst/BgChooseScene.png",
                };
                dialogView.AddChidren(dialogContentView);
                var titleView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = Application.GetRealHeight(3),
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(titleView);
                var btnTitleText = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(100),
                    Text = "选择场景",
                    TextSize = 16,
                    TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                    IsBold = true,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                titleView.AddChidren(btnTitleText);
                #region 在家
                var atHomeView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = titleView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(atHomeView);
                atHomeView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton atHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAtHome.png", $"FunctionIcon/Acst/{imageFolder}/SceneAtHome.png",
                    "在家", curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.at_home.ToString());
                atHomeIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAtHome2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add(AcstParent_AttrEnum.scene.ToString(), AcstParent_Attr_SceneValueEnum.at_home.ToString());
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                atHomeView.AddChidren(atHomeIconButton);
                #endregion
                #region 离家
                var awayHomeView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = atHomeView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(awayHomeView);
                awayHomeView.AddChidren(new Button
                {
                    Width = Application.GetRealWidth(112),
                    Gravity = Gravity.CenterHorizontal,
                    Height = 1,
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton awayHomeIconButton = new IconButton("FunctionIcon/Acst/grey/SceneAwayHomeIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon.png",
                    "离家", curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.leave_home.ToString());
                awayHomeIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneAwayHomeIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("scene", "leave_home");
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                awayHomeView.AddChidren(awayHomeIconButton);
                #endregion
                #region 睡眠
                var sleepView = new FrameLayout()
                {
                    X = Application.GetRealWidth(2),
                    Y = awayHomeView.Bottom,
                    Width = Application.GetRealWidth(144),
                    Height = Application.GetRealHeight(44),
                };
                dialogContentView.AddChidren(sleepView);
                sleepView.AddChidren(new Button
                {
                    Height = 1,
                    Gravity = Gravity.CenterHorizontal,
                    Width = Application.GetRealWidth(112),
                    BackgroundColor = CSS.CSS_Color.DividingLineColor,
                });
                IconButton sleepIconButton = new IconButton("FunctionIcon/Acst/grey/SceneSleepIcon.png", $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon.png",
                    Language.StringByID(StringId.Humidity), curColor, function.GetAttrState(AcstParent_AttrEnum.scene.ToString()) == AcstParent_Attr_SceneValueEnum.sleep.ToString());
                sleepIconButton.Click(() => {
                    btnModeControl.SelectedImagePath = $"FunctionIcon/Acst/{imageFolder}/SceneSleepIcon2.png";
                    dialog.Close();
                    new System.Threading.Thread(() => {
                        Dictionary<string, string> d = new Dictionary<string, string>();
                        d.Add("scene", "sleep");
                        Control.Ins.SendWriteCommand(function, d);
                    })
                    { IsBackground = true }.Start();
                });
                sleepView.AddChidren(sleepIconButton);
                #endregion
                dialog.Show();
            };
@@ -624,14 +1021,19 @@
        private Button btnText;
        public string Tag;
        public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string text)
        public SensorDiyView(HorizontalScrolViewLayout view,uint color,string value,string text,int setWidth = 60)
        {
            if (string.IsNullOrEmpty(value))
            {
                value = "--";
            }
            ///默认Tag 为传进来的Text
            Tag = text;
            contentView = new FrameLayout()
            {
                Width = Application.GetRealWidth(60),
                Width = Application.GetRealWidth(setWidth),
                Height = Application.GetRealHeight(72),
            };
            view.AddChidren(contentView);
@@ -673,9 +1075,12 @@
        public TextButton btnSubTempValues;
        public TextButton btnSubHumidityValues;
        public Button btnSubPower;
        public string Tag;
        public AcstSubControlView(Function sub, HorizontalScrolViewLayout subFunctionListView,string imageFolder)
        {
            Tag = sub.sid;
            var subFunctionView = new FrameLayout()
            {
                Width = Application.GetRealWidth(177),
@@ -753,7 +1158,28 @@
                TextAlignment = TextAlignment.Center,
            };
            subFunctionView.AddChidren(btnSubPower);
            btnSubPower.MouseUpEventHandler = (sender, e) => {
                btnSubPower.IsSelected = !btnSubPower.IsSelected;
                string onoff = btnSubPower.IsSelected ? "on" : "off";
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add(FunctionAttributeKey.OnOff, onoff);
                Control.Ins.SendWriteCommand(sub, d);
            };
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var page = new AcstSubPage(sub,imageFolder);
                MainPage.BasePageView.AddChidren(page);
                page.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
            };
            btnRoomInfo.MouseUpEventHandler = eventHandler;
            btnSubHumidityIcon.MouseUpEventHandler = eventHandler;
            btnSubHumidityValues.MouseUpEventHandler = eventHandler;
            btnSubPower.MouseUpEventHandler = eventHandler;
            btnSubTempIcon.MouseUpEventHandler = eventHandler;
            btnSubTempValues.MouseUpEventHandler = eventHandler;
            subFunctionView.MouseUpEventHandler = eventHandler;
        }
    }
@@ -775,7 +1201,7 @@
            btnIcon = new Button()
            {
                X = Application.GetRealWidth(16),
                Gravity = Gravity.CenterHorizontal,
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(24),
                Height = Application.GetRealWidth(24),
                UnSelectedImagePath = iconPath,
@@ -786,7 +1212,7 @@
            btnText = new Button()
            {
                X = btnIcon.Right + Application.GetRealWidth(12),
                X = Application.GetRealWidth(52),
                Width = Application.GetRealWidth(90),
                TextAlignment = TextAlignment.CenterLeft,
                Text = text,
@@ -799,5 +1225,19 @@
            
        }
        public void Click(Action action)
        {
            view.MouseUpEventHandler = (sender, e) => {
                action();
            };
            btnText.MouseUpEventHandler = (sender, e) => {
                action();
            };
            btnIcon.MouseUpEventHandler = (sender, e) => {
                action();
            };
        }
    }
}