wxr
2020-03-19 b69d7735274b8d0f741da8a6bb8b8e1347477a5a
HDL_ON/UI/UI2/2-Classification/ClassificationPage.cs
@@ -22,12 +22,16 @@
        /// </summary>
        Button btnFuncTitle;
        #endregion
        /// <summary>
        /// 房间/功能分页区域
        /// </summary>
        PageLayout contentPageView;
        #region 房间区域
        FrameLayout roomPageView;
        /// <summary>
        /// 房间内容显示区域
        /// </summary>
        FrameLayout roomContentView;
        FrameLayout roomFloorChangeView;
        #region 房间底部切换显示区域
        /// <summary>
        /// 房间区域,顶部区域
@@ -54,6 +58,11 @@
        /// 房间区域集合
        /// </summary>
        List<FrameLayout> roomViewList;
        #endregion
        #region 功能区域
        VerticalScrolViewLayout functionsPageView;
        #endregion
@@ -99,25 +108,41 @@
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.PromptingColor1,
                SelectedTextColor = CSS_Color.MainColor,
                TextID = StringId.Devices,
                TextID = StringId.Functions,
            };
            topView.AddChidren(btnFuncTitle);
            #endregion
            contentPageView = new PageLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64-49+20),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                IsShowPoint = false
            };
            bodyView.AddChidren(contentPageView);
            LoadRoomPageView();
            LoadFunctionPageView();
            LoadEventList();
        }
        /// <summary>
        /// 加载房间列表界面
        /// </summary>
        void LoadRoomPageView()
        {
            #region 房间区域
            roomPageView = new FrameLayout();
            contentPageView.AddChidren(roomPageView);
            /// <summary>
            /// 房间内容显示区域
            /// </summary>
            roomContentView = new FrameLayout()
            roomFloorChangeView = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(52),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(roomContentView);
            roomPageView.AddChidren(roomFloorChangeView);
            #region 房间底部切换显示区域
            /// <summary>
            /// 房间区域,顶部区域
@@ -126,7 +151,7 @@
            {
                Height = Application.GetRealHeight(53),
            };
            roomContentView.AddChidren(roomTopView);
            roomFloorChangeView.AddChidren(roomTopView);
            /// <summary>
            /// 楼层选择下拉图标
            /// </summary>
@@ -138,7 +163,7 @@
                Y = Application.GetRealHeight(18),
                UnSelectedImagePath = "Public/DownIcon.png",
            };
            roomContentView.AddChidren(btnFoorDownIcon);
            roomFloorChangeView.AddChidren(btnFoorDownIcon);
            /// <summary>
            /// 楼层显示
            /// </summary>
@@ -153,7 +178,7 @@
                TextAlignment = TextAlignment.CenterLeft,
                Text = UserConfig.Instance.CurFoor,
            };
            roomContentView.AddChidren(btnFoor);
            roomFloorChangeView.AddChidren(btnFoor);
            /// <summary>
            /// 显示方式切换按钮
            /// </summary>
@@ -166,7 +191,7 @@
                UnSelectedImagePath = "Classification/ToggleDisplayThumbnail.png",//缩略图
                SelectedImagePath = "Classification/ToggleDisplayLarge.png",
            };
            roomContentView.AddChidren(btnSwitchDipaly);
            roomFloorChangeView.AddChidren(btnSwitchDipaly);
            #endregion
@@ -175,95 +200,15 @@
            /// </summary>
            roomListView = new VerticalScrolViewLayout()
            {
                Y = roomContentView.Bottom,
                Height = Application.GetRealHeight(497 + 10+30),
                Y = roomFloorChangeView.Bottom,
                Height = Application.GetRealHeight(497 + 10 + 30),
                BackgroundColor = CSS_Color.MainBackgroundColor,
            };
            bodyView.AddChidren(roomListView);
            roomPageView.AddChidren(roomListView);
            /// <summary>
            /// 房间区域集合
            /// </summary>
            roomViewList = new List<FrameLayout>();
#if DEBUG1
            var r = new Room() { sid = "0001", name = "Room-1", floor = "1F", backgroundImage = "Classification/Room/Roombg.png" };
            r.functions.Add(new Function()
            {
                sid = "000000000000000000000000000000000001",
                funcType = FunctionType.AC,
                name = "空调",
                roomIdList = new List<string>() { "0001" },
                lastState = "制冷 中风 18°C",
                bus_Data = "{" +
                        "\"SubnetID\":42" + "," +
                        "\"DeviceID\":8" + "," +
                        "\"LoopID\":1" +
                        "}",
            });
            r.functions.Add(new Dimmer()
            {
                sid = "0001002019101209000025670400010002",
                funcType = FunctionType.Light,
                name = "客厅灯",
                roomIdList = new List<string>() { "0001" },
                lastState = "20%",
                bus_Data = "{" +
                        "\"SubnetID\":111" + "," +
                        "\"DeviceID\":2" + "," +
                        "\"LoopID\":1" +
                        "}",
            });
            r.functions.Add(new MotorCurtain()
            {
                sid = "000000000000000000000000000000000003",
                funcType = FunctionType.Curtain,
                name = "窗帘",
                roomIdList = new List<string>() { "0001" },
                lastState = "20%",
                bus_Data = "{" +
                        "\"SubnetID\":42" + "," +
                        "\"DeviceID\":7" + "," +
                        "\"LoopID\":1" +
                        "}",
            });
            r.functions.Add(new Function()
            {
                sid = "000000000000000000000000000000000004",
                funcType = FunctionType.FloorHeating,
                name = "地热",
                roomIdList = new List<string>() { "0001" },
                lastState = ""
            });
            r.functions.Add(new Light()
            {
                sid = "0001002019101209000025670400010005",
                funcType = FunctionType.Light,
                name = "客厅大灯",
                roomIdList = new List<string>() { "0001" },
                bus_Data = "{" +
                        "\"SubnetID\":111" + "," +
                        "\"DeviceID\":6" + "," +
                        "\"LoopID\":1" +
                        "}",
            });
            r.functions.Add(new RGBLight()
            {
                sid = "0001002019101209000025670500010006",
                funcType = FunctionType.Light,
                name = "客厅RGB灯",
                roomIdList = new List<string>() { "0001" },
                bus_Data = "{" +
                        "\"SubnetID\":222" + "," +
                        "\"DeviceID\":222" + "," +
                        "\"LoopID\":222" +
                        "}",
            });
            DB_ResidenceData.residenceData.rooms.Add(r);
#endif
            foreach (var room in DB_ResidenceData.residenceData.rooms)
            {
@@ -311,7 +256,7 @@
                    Height = Application.GetRealHeight(32),
                    Tag = "EnvironmentalView",
                };
                topView.AddChidren(environmentalView);
                roomView.AddChidren(environmentalView);
                Button btnTempIcon = new Button()
                {
@@ -420,5 +365,256 @@
            #endregion
        }
        /// <summary>
        /// 加载功能列表界面
        /// </summary>
        void LoadFunctionPageView()
        {
            #region
            functionsPageView = new VerticalScrolViewLayout()
            {
                BackgroundColor = CSS_Color.BackgroundColor,
                Height = Application.GetRealHeight(667 - 64 - 49 + 20),
            };
            contentPageView.AddChidren(functionsPageView);
            FrameLayout functionContentView;
            functionContentView = new FrameLayout()
            {
                Y = Application.GetRealHeight(16),
                Height = Application.GetRealHeight(667 - 64 - 49 + 20),
            };
            if (DB_ResidenceData.residenceData.functionTypeList.Count > 4)
            {
                functionContentView.Height += Application.GetRealHeight((220  * (DB_ResidenceData.residenceData.functionTypeList.Count - 4 - 2) / 2) + 20);
            }
            functionsPageView.AddChidren(functionContentView);
            int index = 0;
            List<int> specialList = new List<int>() { 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22 };
            var s1View = new FrameLayout()
            {
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(164),
            };
            functionContentView.AddChidren(s1View);
            var s2View = new FrameLayout()
            {
                X = Application.GetRealWidth(196),
                Width = Application.GetRealWidth(164),
            };
            functionContentView.AddChidren(s2View);
            var lastY1 = Application.GetRealWidth(16);
            var lastY2 = Application.GetRealWidth(16);
            foreach (var item in DB_ResidenceData.residenceData.functionTypeList)
            {
                FrameLayout functionView = new FrameLayout()
                {
                    Height = Application.GetRealWidth(161),
                    Radius = (uint)Application.GetRealHeight(6),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                    Y = index % 2 == 1 ? lastY2 : lastY1
                };
                //高度稍高的view
                if (specialList.Contains(index))
                {
                    functionView.Height = Application.GetRealWidth(204);
                }
                if (index % 2 == 1)
                {
                    lastY2 += functionView.Height + Application.GetRealWidth(16);
                }
                else
                {
                    lastY1 += functionView.Height + Application.GetRealWidth(16);
                }
                if (index % 2 == 0)
                {
                    s1View.AddChidren(functionView);
                }
                else
                {
                    s2View.AddChidren(functionView);
                }
                Button btnFunctionViewBg;
                btnFunctionViewBg = new Button()
                {
                    Height = Application.GetRealWidth(161),
                    UnSelectedImagePath = "FunctionIcon/FunctionBg/" + item + "FunctionBg.png",
                };
                functionView.AddChidren(btnFunctionViewBg);
                Button btnName = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Y = Application.GetRealHeight(14),
                    Width = Application.GetRealWidth(120),
                    Height = Application.GetRealHeight(24),
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextAlignment = TextAlignment.CenterLeft,
                };
                functionView.AddChidren(btnName);
                int functionCount = 0;
                switch (item)
                {
                    case "Light":
                        #region Light
                        btnName.TextID = StringId.Lights;
                        functionCount = DB_ResidenceData.residenceData.functionList.lights.Count;
                        Button btnLightPower = new Button()
                        {
                            X = Application.GetRealWidth(120),
                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
                            Width = Application.GetRealWidth(32),
                            Height = Application.GetRealWidth(32),
                            SelectedImagePath = "Public/PowerOpen.png",
                            UnSelectedImagePath = "Public/PowerClose.png",
                        };
                        functionView.AddChidren(btnLightPower);
                        btnLightPower.MouseUpEventHandler = (sender, e) => {
                            LoadEvent_LightsPower(btnLightPower);
                        };
                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
                            var skipView = new FunctionPage();
                            MainPage.BasePageView.AddChidren(skipView);
                            skipView.LoadPage(StringId.Lights);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        };
                        #endregion
                        break;
                    case "AC":
                        #region AC
                        btnName.TextID = StringId.AC;
                        functionCount = DB_ResidenceData.residenceData.functionList.aCs.Count;
                        Button btnAcPower = new Button()
                        {
                            X = Application.GetRealWidth(120),
                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
                            Width = Application.GetRealWidth(32),
                            Height = Application.GetRealWidth(32),
                            SelectedImagePath = "Public/PowerOpen.png",
                            UnSelectedImagePath = "Public/PowerClose.png",
                        };
                        functionView.AddChidren(btnAcPower);
                        btnAcPower.MouseUpEventHandler = (sender, e) => {
                            LoadEvent_LightsPower(btnAcPower);
                        };
                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
                            var skipView = new FunctionPage();
                            MainPage.BasePageView.AddChidren(skipView);
                            skipView.LoadPage(StringId.AC);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        };
                        #endregion
                        break;
                    case "Curtain":
                        #region Curtain
                        btnName.TextID = StringId.Curtain;
                        functionCount = DB_ResidenceData.residenceData.functionList.curtains.Count;
                        Button btnClose;
                        btnClose = new Button()
                        {
                            X = Application.GetRealWidth(72),
                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
                            Width = Application.GetRealWidth(32),
                            Height = Application.GetRealWidth(32),
                            UnSelectedImagePath = "FunctionIcon/Curtain/CurtainCloseIcon.png",
                            SelectedImagePath = "FunctionIcon/Curtain/CurtainCloseOnIcon.png",
                        };
                        functionView.AddChidren(btnClose);
                        Button btnOpen;
                        btnOpen = new Button()
                        {
                            X = Application.GetRealWidth(120),
                            Y = specialList.Contains(index) ? Application.GetRealWidth(160) : Application.GetRealWidth(117),
                            Width = Application.GetRealWidth(32),
                            Height = Application.GetRealWidth(32),
                            UnSelectedImagePath = "FunctionIcon/Curtain/CurtainOpenIcon.png",
                            SelectedImagePath = "FunctionIcon/Curtain/CurtainOpenOnIcon.png",
                        };
                        functionView.AddChidren(btnOpen);
                        LoadEvent_CurtainSwitch(btnClose, btnOpen);
                        btnFunctionViewBg.MouseUpEventHandler = (sender, e) => {
                            var skipView = new FunctionPage();
                            MainPage.BasePageView.AddChidren(skipView);
                            skipView.LoadPage(StringId.Curtain);
                            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                        };
                        #endregion
                        break;
                    case "FloorHeating":
                        btnName.TextID = StringId.FloorHeating;
                        break;
                    case "DoorLock":
                        btnName.TextID = StringId.DoorLock;
                        break;
                    case "Electric":
                        btnName.TextID = StringId.Electric;
                        break;
                    case "EnergyMonitoring":
                        btnName.TextID = StringId.EnergyMonitoring;
                        break;
                    case "Environmental":
                        btnName.TextID = StringId.Environmental;
                        break;
                    case "FreshAir":
                        btnName.TextID = StringId.FreshAir;
                        break;
                    case "Music":
                        btnName.TextID = StringId.Music;
                        break;
                    case "Panel":
                        btnName.TextID = StringId.Panel;
                        break;
                    case "SecurityMonitoring":
                        btnName.TextID = StringId.SecurityMonitoring;
                        break;
                    case "Sensor":
                        btnName.TextID = StringId.Sensor;
                        break;
                    case "VideoIntercom":
                        btnName.TextID = StringId.VideoIntercom;
                        break;
                }
                Button btnFunctionCount = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Y = btnName.Bottom,
                    Width = Application.GetRealWidth(120),
                    Height = Application.GetRealHeight(24),
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = "0/" + functionCount.ToString()
                };
                functionView.AddChidren(btnFunctionCount);
                index++;
            }
            #endregion
        }
    }
}