wxr
2021-02-23 34d49c20c2c2543658e844847c5eaa87f4c954e9
HDL_ON/UI/UI2/2-Classification/FunctionPage.cs
@@ -69,7 +69,7 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextAlignment = TextAlignment.CenterLeft,
                Text = DB_ResidenceData.residenceData.CurFoor,
                Text = DB_ResidenceData.Instance.CurFloor.roomName,
            };
            roomFloorChangeView.AddChidren(btnFloor);
            #endregion
@@ -83,29 +83,33 @@
            if (titleId == StringId.Lights)
            {
                functionList.AddRange(DB_ResidenceData.functionList.lights);
                functionList.AddRange(FunctionList.List.lights);
            }
            else if (titleId == StringId.AC)
            {
                functionList.AddRange(DB_ResidenceData.functionList.aCs);
                functionList.AddRange(FunctionList.List.aCs);
            }
            else if (titleId == StringId.Curtain)
            {
                functionList.AddRange(DB_ResidenceData.functionList.curtains);
                functionList.AddRange(FunctionList.List.curtains);
            }
            else if (titleId == StringId.FloorHeating)
            {
                functionList.AddRange(DB_ResidenceData.functionList.floorHeatings);
                functionList.AddRange(FunctionList.List.floorHeatings);
            }
            else if (titleId == StringId.Electric)
            {
                functionList.AddRange(DB_ResidenceData.functionList.electricals);
                functionList.AddRange(FunctionList.List.electricals);
            }
            else if (titleId == StringId.EnvironmentalScience)
            {
                functionList.AddRange(DB_ResidenceData.functionList.sensorsEnvironmentalScience);
                functionList.AddRange(FunctionList.List.sensorsEnvironmentalScience);
            }
            functionList.OrderByDescending(o => o.usageCount).ToList();
            else if (titleId == StringId.Sensor)
            {
                functionList.AddRange(FunctionList.List.sensorsArm);
            }
            functionList.OrderByDescending(o => o.controlCounter).ToList();
            ShowFunctionRow(functionList);
@@ -121,7 +125,7 @@
            foreach (var function in showList)
            {
                if (function.functionType == FunctionType.RGB || function.functionType == FunctionType.Dimmer)
                if (function.spk == SPK.LightRGB || function.spk == SPK.LightDimming)
                {
                    var functionDiv = new FunctionControlZone(function)
                    {
@@ -132,7 +136,7 @@
                        BorderColor = 0x00FFFFFF,
                        BorderWidth = 1,
                        BackgroundColor = CSS_Color.MainBackgroundColor,
                        Tag = function.sid
                        Tag = function.spk + function.sid
                    };
                    functionDiv.LoadFunctionDiv();
                    functionListView.AddChidren(functionDiv);
@@ -148,7 +152,7 @@
                        BorderColor = 0x00FFFFFF,
                        BorderWidth = 1,
                        BackgroundColor = CSS_Color.MainBackgroundColor,
                        Tag = function.sid
                        Tag = function.spk + function.sid
                    };
                    functionDiv.LoadFunctionDiv();
                    functionListView.AddChidren(functionDiv);
@@ -163,146 +167,18 @@
        /// </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 (DB_ResidenceData.Rooms.Count < 2)
                {
                }
                else if (DB_ResidenceData.Rooms.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 (DB_ResidenceData.Rooms.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<Room> roomList = new List<Room>();
                roomList.Add(new Room() { uid = "", roomName = Language.StringByID(StringId.All) });
                roomList.AddRange(DB_ResidenceData.Rooms);
                foreach (var tempRoom in roomList)
                {
                    var roomName = tempRoom.roomName;
                    if (roomName != Language.StringByID(StringId.All))
                    {
                        contentView.AddChidren(new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Width = Application.GetRealWidth(112),
                            Height = Application.GetRealHeight(1),
                            BackgroundColor = CSS_Color.BackgroundColor
                        });
                    }
                    var btnHomeName = new Button()
                    {
                        Gravity = Gravity.CenterHorizontal,
                        Width = Application.GetRealWidth(112),
                        Height = Application.GetRealHeight(44),
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = CSS_Color.FirstLevelTitleColor,
                        SelectedTextColor = CSS_Color.MainColor,
                        Text = roomName,
                        TextSize = CSS_FontSize.SubheadingFontSize,
                        IsSelected = btnFloor.Text == roomName,
                        IsMoreLines = true,
                    };
                    contentView.AddChidren(btnHomeName);
                    btnHomeName.MouseUpEventHandler += (senderH, en) =>
                    {
                        dialog.Close();
                        btnFloor.Text = roomName;
                        if (roomName == Language.StringByID(StringId.All))
                        {
                            ShowFunctionRow(functionList);
                        }
                        else
                        {
                            var showList = new List<Function>();
                            foreach (var sf in functionList)
                            {
                                if(sf.roomIds.Contains(tempRoom.uid))
                                {
                                    showList.Add(sf);
                                }
                            }
                            ShowFunctionRow(showList);
                        }
                    };
                }
                dialog.Show();
            string nowSelectId = null;
            btnFloor.MouseUpEventHandler += (sender, e) =>
            {
                //显示下拉列表
                var form = new FloorRoomSelectPopupView();
                form.ShowDeviceFunctionView(btnFloor, this.functionList, (selectId, listFunc) =>
                {
                    nowSelectId = selectId;
                    //重新加载界面
                    ShowFunctionRow(listFunc);
                }, nowSelectId);
            };
            btnFloor.MouseUpEventHandler = eventHandler;
            btnFloorDownIcon.MouseUpEventHandler = eventHandler;
        }
    }
}