wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
HDL_ON/UI/UI2/3-Intelligence/Scene/SceneFunctionListChoosePage.cs
@@ -21,22 +21,14 @@
        /// </summary>
        Button btnFloor;
        /// <summary>
        /// 筛选选择下拉图标
        /// </summary>
        Button btnScreenIcon;
        ///// <summary>
        ///// 筛选选择下拉图标
        ///// </summary>
        //Button btnScreenIcon;
        /// <summary>
        /// 筛选文本显示
        /// </summary>
        Button btnScreenText;
        /// <summary>
        /// 筛选条件1
        /// </summary>
        string screen1;
        /// <summary>
        /// 筛选条件2
        /// </summary>
        string screen2;
        VerticalScrolViewLayout functionListView;
@@ -102,28 +94,28 @@
            showdFunctionTypeRow.AddChidren(btnFloor);
            btnScreenIcon = new Button()
            {
                Width = Application.GetMinRealAverage(16),
                Height = Application.GetMinRealAverage(16),
                X = Application.GetRealWidth(122),
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            showdFunctionTypeRow.AddChidren(btnScreenIcon);
            //btnScreenIcon = new Button()
            //{
            //    Width = Application.GetMinRealAverage(16),
            //    Height = Application.GetMinRealAverage(16),
            //    X = Application.GetRealWidth(122),
            //    Y = Application.GetRealHeight(18),
            //    UnSelectedImagePath = "Public/DownIcon.png",
            //};
            //showdFunctionTypeRow.AddChidren(btnScreenIcon);
            btnScreenText = new Button()
            {
                X = btnScreenIcon.Right,
                Y = Application.GetRealHeight(18),
                Width = Application.GetRealWidth(200),
                Height = Application.GetMinRealAverage(16),
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = StringId.Screen
            };
            showdFunctionTypeRow.AddChidren(btnScreenText);
            //btnScreenText = new Button()
            //{
            //    X = btnScreenIcon.Right,
            //    Y = Application.GetRealHeight(18),
            //    Width = Application.GetRealWidth(200),
            //    Height = Application.GetMinRealAverage(16),
            //    TextColor = CSS_Color.FirstLevelTitleColor,
            //    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            //    TextAlignment = TextAlignment.CenterLeft,
            //    TextID = StringId.Screen
            //};
            //showdFunctionTypeRow.AddChidren(btnScreenText);
            #endregion
@@ -136,7 +128,7 @@
            };
            bodyView.AddChidren(functionListView);
            foreach (var function in FunctionList.List.GetDeviceFunctionList())
            foreach (var function in FunctionList.List.Functions)
            {
                if (function == null)
                {
@@ -153,7 +145,7 @@
                }
            }
            LoadFunctionListRow();
            LoadFunctionListRow(null);
            LoadEventList();
        }
@@ -162,36 +154,25 @@
        /// 显示功能Row
        /// </summary>
        /// <param name="showUnallocated">是否是显示未分配</param>
        void LoadFunctionListRow()
        void LoadFunctionListRow(List<Function> functions)
        {
            functionListView.RemoveAll();
            List<Function> functions = new List<Function>();
            functions.AddRange(unallocatedList);
            functions.AddRange(allocatedList);
            if (functions == null)
            {
                //初始值
                functions = new List<Function>();
                functions.AddRange(unallocatedList);
                functions.AddRange(allocatedList);
            }
            foreach (var function in functions)
            {
                if (function.functionCategory != FunctionCategory.Light &&
                    function.functionCategory != FunctionCategory.Thermostat &&
                    function.functionCategory != FunctionCategory.Curtain
                if (function.Spk_Prefix != FunctionCategory.Light &&
                    function.Spk_Prefix != FunctionCategory.AC &&
                    function.Spk_Prefix != FunctionCategory.FloorHeat &&
                    function.Spk_Prefix != FunctionCategory.Curtain
                    )
                {
                    continue;
                }
                //按楼层筛选
                if (!string.IsNullOrEmpty(screen1))
                {
                    if (!function.roomIds.Contains(screen1))
                    {
                        continue;
                    }
                }
                //按类型筛选
                if (!string.IsNullOrEmpty(screen2))
                {
                    //if (!function.functionType!= screen2)
                    //{
                    //    continue;
                    //}
                }
                functionListView.AddChidren(new Button()
                {
@@ -229,51 +210,8 @@
                    Height = Application.GetMinRealAverage(28),
                };
                functionRow.AddChidren(btnFunctionIcon);
                switch (function.functionCategory)
                {
                    case FunctionCategory.Thermostat:
                        switch (function.functionType)
                        {
                            case FunctionType.AC:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
                                break;
                            case FunctionType.FloorHeating:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Curtain:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
                        break;
                    case FunctionCategory.Light:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
                        break;
                    case FunctionCategory.SwitchDevice:
                        switch (function.functionType)
                        {
                            case FunctionType.Socket:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Electrical:
                        switch (function.functionType)
                        {
                            case FunctionType.Fan:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
                                break;
                            case FunctionType.TV:
                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
                                break;
                        }
                        break;
                    case FunctionCategory.Scene:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
                        break;
                    case FunctionCategory.Music:
                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
                        break;
                }
                btnFunctionIcon.UnSelectedImagePath = $"FunctionIcon/Icon/{function.IconName}.png";
                var btnFunctionName = new Button()
                {
@@ -319,135 +257,24 @@
        /// 住宅列表点击事件
        /// </summary>
        void LoadDialog_ChangeFloor()
        {
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                var dialog = new Dialog();
                var dialogBody = new FrameLayout();
                dialog.AddChidren(dialogBody);
                dialogBody.MouseUpEventHandler += (sender1, e1) => {
                    dialog.Close();
                };
                var dispalyView = new FrameLayout()
                {
                    X = Application.GetRealWidth(10),
                    Y = Application.GetRealHeight(100),
                    Width = Application.GetRealWidth(160),
                    Height = Application.GetRealHeight(110),
                    BackgroundImagePath = "PersonalCenter/HomeList1bg.png",
                };
                dialogBody.AddChidren(dispalyView);
                var contentView = new VerticalScrolViewLayout()
                {
                    X = Application.GetRealWidth(8),
                    Y = Application.GetRealHeight(15),
                    Width = Application.GetRealWidth(150),
                    Height = Application.GetRealHeight(45 * 2),
                    ScrollEnabled = false
                };
                dispalyView.AddChidren(contentView);
                if (SpatialInfo.CurrentSpatial.FloorList.Count < 2)
                {
                }
                else if (SpatialInfo.CurrentSpatial.FloorList.Count < 3)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(155),
                        BackgroundImagePath = "PersonalCenter/HomeList2bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
                    contentView.Height = Application.GetRealHeight(45 * 3);
                    dispalyView.AddChidren(contentView);
                }
                else if (SpatialInfo.CurrentSpatial.FloorList.Count < 4)
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(200),
                        BackgroundImagePath = "PersonalCenter/HomeList3bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
                    contentView.Height = Application.GetRealHeight(45 * 4);
                    dispalyView.AddChidren(contentView);
                }
                else
                {
                    dispalyView = new FrameLayout()
                    {
                        X = Application.GetRealWidth(10),
                        Y = Application.GetRealHeight(100),
                        Width = Application.GetRealWidth(160),
                        Height = Application.GetRealHeight(245),
                        BackgroundImagePath = "PersonalCenter/HomeList4bg.png",
                    };
                    dialogBody.AddChidren(dispalyView);
                    contentView.Height = Application.GetRealHeight(45 * 5);
                    contentView.ScrollEnabled = true;
                    dispalyView.AddChidren(contentView);
                }
                List<string> chooseList = new List<string>();
                chooseList.Add(Language.StringByID(StringId.All));
                foreach (var f in SpatialInfo.CurrentSpatial.FloorList)
                {
                    chooseList.Add(f.roomName);
                }
                foreach (var floor in chooseList)
                {
                    if (floor != Language.StringByID(StringId.All))
                    {
                        contentView.AddChidren(new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Width = Application.GetRealWidth(112),
                            Height = Application.GetRealHeight(1),
                            BackgroundColor = CSS.CSS_Color.BackgroundColor
                        });
                    }
                    var btnHomeName = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(44),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = CSS.CSS_Color.FirstLevelTitleColor,
                        SelectedTextColor = CSS.CSS_Color.MainColor,
                        Text = floor,
                        TextSize = CSS.CSS_FontSize.SubheadingFontSize,
                        IsSelected = btnFloor.Text == floor,
                        IsMoreLines = true,
                        Tag = floor
                    };
                    contentView.AddChidren(btnHomeName);
                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
                    {
                        dialog.Close();
                        btnFloor.Text = floor;
                    };
                }
                dialog.Show();
        {
            string nowSelectId = null;
            btnFloor.MouseUpEventHandler += (sender, e) =>
            {
                var listAllFun = new List<Function>();
                listAllFun.AddRange(unallocatedList);
                listAllFun.AddRange(allocatedList);
                //显示下拉界面
                var form = new FloorRoomSelectPopupView();
                form.ShowDeviceFunctionView(btnFloor, listAllFun, (selectId, listFun) =>
                {
                    nowSelectId = selectId;
                    //重新刷新设备列表
                    this.LoadFunctionListRow(listFun);
                }, nowSelectId);
            };
            btnFloor.MouseUpEventHandler = eventHandler;
            btnFloorDownIcon.MouseUpEventHandler = eventHandler;
        }
    }
    //---------------------------------------