From b271bcceb1c4e718377ca86b6213816abcf7482a Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 11 一月 2021 13:57:18 +0800
Subject: [PATCH] 20210111-删除功能类别,统一使用spk去设备功能

---
 HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditFunctionPage.cs |  271 ++++++++++++++++++++++++++++++-----------------------
 1 files changed, 153 insertions(+), 118 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditFunctionPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditFunctionPage.cs
old mode 100755
new mode 100644
index 8bb99ac..c04648e
--- a/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditFunctionPage.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditFunctionPage.cs
@@ -153,6 +153,7 @@
                 Y = showdFunctionTypeRow.Bottom,
                 Height = Application.GetRealHeight(518 - 40 - 62),
                 BackgroundColor = CSS_Color.BackgroundColor,
+                
             };
             bodyView.AddChidren(functionListView);
 
@@ -171,11 +172,20 @@
 
             LoadFunctionListRow(unallocatedList);
 
+            var bottomView = new FrameLayout()
+            {
+                Y = Application.GetRealHeight(591),
+                Height = Application.GetRealHeight(76) + Application.GetRealWidth(44),
+                Radius = (uint)Application.GetRealWidth(22),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+            };
+            bodyView.AddChidren(bottomView);
+            
 
             btnConfrim = new Button()
             {
                 Gravity = Gravity.CenterHorizontal,
-                Y = Application.GetRealHeight(582),
+                Y = Application.GetRealHeight(603),
                 Width = Application.GetRealWidth(220),
                 Height = Application.GetRealWidth(44),
                 Radius = (uint)Application.GetRealWidth(22),
@@ -184,7 +194,7 @@
                 TextSize = CSS_FontSize.SubheadingFontSize,
                 TextAlignment = TextAlignment.Center,
                 IsBold = true,
-                TextID = StringId.Confirm,
+                TextID = StringId.ConfirmAdd,
             };
             bodyView.AddChidren(btnConfrim);
 
@@ -200,15 +210,24 @@
             showdFunctionCount = 0;
             functionListView.RemoveAll();
 
+            bool isFrist = true;
+
             foreach (var function in functions)
             {
-                functionListView.AddChidren(new Button()
+                if (isFrist)
                 {
-                    Gravity = Gravity.CenterHorizontal,
-                    Width = Application.GetRealWidth(343),
-                    Height = Application.GetRealWidth(1),
-                    BackgroundColor = CSS_Color.DividingLineColor,
-                });
+                    isFrist = false;
+                }
+                else
+                {
+                    functionListView.AddChidren(new Button()
+                    {
+                        Gravity = Gravity.CenterHorizontal,
+                        Width = Application.GetRealWidth(343),
+                        Height = Application.GetRealWidth(1),
+                        BackgroundColor = CSS_Color.DividingLineColor,
+                    });
+                }
 
                 FrameLayout functionRow = new FrameLayout()
                 {
@@ -225,18 +244,13 @@
                     Height = Application.GetMinRealAverage(28),
                 };
                 functionRow.AddChidren(btnFunctionIcon);
-                switch (function.functionCategory)
+                switch (function.Spk_Prefix)
                 {
-                    case FunctionCategory.Thermostat:
-                        switch (function.functionType)
-                        {
-                            case FunctionType.AC:
+                    case FunctionCategory.AC:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/AC/AcThinIcon1.png";
-                                break;
-                            case FunctionType.FloorHeating:
-                                btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
-                                break;
-                        }
+                        break;
+                    case FunctionCategory.FloorHeat:
+                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/FloorHeating/FloorHeatingThinIcon.png";
                         break;
                     case FunctionCategory.Curtain:
                         btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Curtain/CurtainThinIcon.png";
@@ -244,47 +258,42 @@
                     case FunctionCategory.Light:
                         btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Light/LightThinIcon.png";
                         break;
-                    case FunctionCategory.SwitchDevice:
-                        switch (function.functionType)
+                    case FunctionCategory.Electric:
+                        switch (function.spk)
                         {
-                            case FunctionType.Socket:
+                            case SPK.ElectricSocket:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Socket/SocketThinIcon.png";
                                 break;
-                        }
-                        break;
-                    case FunctionCategory.Electrical:
-                        switch (function.functionType)
-                        {
-                            case FunctionType.Fan:
+                            case SPK.ElectricFan:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/FanThinIcon.png";
                                 break;
-                            case FunctionType.TV:
+                            case SPK.ElectricTV:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/TVThinIcon.png";
                                 break;
                         }
                         break;
-                    case FunctionCategory.Scene:
-                        btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
-                        break;
+                    //case FunctionCategory.Scene:
+                    //    btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Scene/SceneIcon.png";
+                        //break;
                     case FunctionCategory.Music:
                         btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/Music/MusicThinIcon.png";
                         break;
                     case FunctionCategory.Sensor:
-                        switch(function.functionType)
+                        switch(function.spk)
                         {
-                            case FunctionType.PM25:
+                            case SPK.SensorPm25:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconPm25.png";
                                 break;
-                            case FunctionType.CO2:
+                            case SPK.SensorCO2:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconCO2.png";
                                 break;
-                            case FunctionType.TVOC:
+                            case SPK.SensorTVOC:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTVOC.png";
                                 break;
-                            case FunctionType.Humidity:
+                            case SPK.SensorHumidity:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconHumidity.png";
                                 break;
-                            case FunctionType.Temp:
+                            case SPK.SensorTemperature:
                                 btnFunctionIcon.UnSelectedImagePath = "FunctionIcon/EnvironmentalScience/FunctionIconTemp.png";
                                 break;
                         }
@@ -362,91 +371,117 @@
         /// </summary>
         void LoadPage_LoadChooseRoomDialog()
         {
-            Dialog dialog = new Dialog();
-            FrameLayout dialogBodyView = new FrameLayout()
-            {
-                BackgroundColor = CSS_Color.DialogTransparentColor1,
-            };
-            dialog.AddChidren(dialogBodyView);
-
-            FrameLayout contentView;
-            contentView = new FrameLayout()
-            {
-                X = Application.GetRealWidth(205),
-                Y = Application.GetRealHeight(106),
-                Width = Application.GetRealWidth(160),
-                Height = Application.GetRealHeight(200),
-                BackgroundImagePath = "Public/ChooseRoomListbg.png",
-            };
-            dialogBodyView.AddChidren(contentView);
-
-            VerticalScrolViewLayout roomListView;
-            roomListView = new VerticalScrolViewLayout()
-            {
-                X = Application.GetRealWidth(8),
-                Y = Application.GetRealHeight(15),
-                Width = Application.GetRealWidth(160),
-                Height = Application.GetRealHeight(45 * 4),
-            };
-            contentView.AddChidren(roomListView);
-
-            Button btnAllRoom;
-            btnAllRoom = new Button()
-            {
-                X = Application.GetRealWidth(16),
-                Width = Application.GetRealWidth(128),
-                Height = Application.GetRealHeight(50),
-                TextID = StringId.All,
-                TextColor = CSS_Color.FirstLevelTitleColor,
-                SelectedTextColor = CSS_Color.MainColor,
-                TextSize = CSS_FontSize.SubheadingFontSize,
-                IsSelected = showedFunctionRoomId == "0",
-                TextAlignment = TextAlignment.CenterLeft,
-                Tag = "0"
-            };
-            roomListView.AddChidren(btnAllRoom);
-            LoadEvent_ChangeShowedFunctionList(btnAllRoom, dialog, Language.StringByID(StringId.All));
-
-            roomListView.AddChidren(new Button()
-            {
-                Gravity = Gravity.CenterHorizontal,
-                Width = Application.GetRealWidth(112),
-                Height = Application.GetRealWidth(1),
-                BackgroundColor = CSS_Color.DividingLineColor,
-            });
-            foreach (var tempRoom in SpatialInfo.CurrentSpatial.RoomList)
-            {
-
-                Button btnRoom = new Button()
+            Action<string, string> action = (key, value) => {
+                if (lastButton != null)
                 {
-                    X = Application.GetRealWidth(16),
-                    Width = Application.GetRealWidth(128),
-                    Height = Application.GetRealHeight(50),
-                    Text = tempRoom.roomName,
-                    TextColor = CSS_Color.FirstLevelTitleColor,
-                    SelectedTextColor = CSS_Color.MainColor,
-                    TextSize = CSS_FontSize.SubheadingFontSize,
-                    TextAlignment = TextAlignment.CenterLeft,
-                    IsSelected = showedFunctionRoomId == tempRoom.roomId,
-                    Tag = tempRoom.roomId,
-                };
-                roomListView.AddChidren(btnRoom);
-                LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.roomName);
-
-                roomListView.AddChidren(new Button()
+                    lastButton.IsSelected = false;
+                }
+                showedFunctionRoomId = key;
+                if (showedFunctionRoomId == "0")
                 {
-                    Gravity = Gravity.CenterHorizontal,
-                    Width = Application.GetRealWidth(112),
-                    Height = Application.GetRealWidth(1),
-                    BackgroundColor = CSS_Color.DividingLineColor,
-                });
+                    LoadFunctionListRow(allocatedList);
+                }
+                else
+                {
+                    LoadFunctionListRow(allocatedList.FindAll((obj) => obj.roomIds.Contains(showedFunctionRoomId)));
+                }
+                btnChoosedRoom.Text = value;
+            };
+
+            Dictionary<string, string> items = new Dictionary<string, string>();
+            items.Add("0",Language.StringByID(StringId.All));
+            foreach(var room in SpatialInfo.CurrentSpatial.RoomList)
+            {
+                items.Add(room.roomId,room.roomName);
             }
-            dialogBodyView.MouseUpEventHandler = (sender, e) =>
-            {
-                dialog.Close();
-            };
+            var chooseDialog = new ListCellDialog(items,showedFunctionRoomId,action);
+            chooseDialog.ShowRightDialog();
 
-            dialog.Show();
+            //Dialog dialog = new Dialog();
+            //FrameLayout dialogBodyView = new FrameLayout()
+            //{
+            //    BackgroundColor = CSS_Color.DialogTransparentColor1,
+            //};
+            //dialog.AddChidren(dialogBodyView);
+
+            //FrameLayout contentView;
+            //contentView = new FrameLayout()
+            //{
+            //    X = Application.GetRealWidth(205),
+            //    Y = Application.GetRealHeight(106),
+            //    Width = Application.GetRealWidth(160),
+            //    Height = Application.GetRealHeight(200),
+            //    BackgroundImagePath = "Public/ChooseRoomListbg.png",
+            //};
+            //dialogBodyView.AddChidren(contentView);
+
+            //VerticalScrolViewLayout roomListView;
+            //roomListView = new VerticalScrolViewLayout()
+            //{
+            //    X = Application.GetRealWidth(8),
+            //    Y = Application.GetRealHeight(15),
+            //    Width = Application.GetRealWidth(160),
+            //    Height = Application.GetRealHeight(45 * 4),
+            //};
+            //contentView.AddChidren(roomListView);
+
+            //Button btnAllRoom;
+            //btnAllRoom = new Button()
+            //{
+            //    X = Application.GetRealWidth(16),
+            //    Width = Application.GetRealWidth(128),
+            //    Height = Application.GetRealHeight(50),
+            //    TextID = StringId.All,
+            //    TextColor = CSS_Color.FirstLevelTitleColor,
+            //    SelectedTextColor = CSS_Color.MainColor,
+            //    TextSize = CSS_FontSize.SubheadingFontSize,
+            //    IsSelected = showedFunctionRoomId == "0",
+            //    TextAlignment = TextAlignment.CenterLeft,
+            //    Tag = "0"
+            //};
+            //roomListView.AddChidren(btnAllRoom);
+            //LoadEvent_ChangeShowedFunctionList(btnAllRoom, dialog, Language.StringByID(StringId.All));
+
+            //roomListView.AddChidren(new Button()
+            //{
+            //    Gravity = Gravity.CenterHorizontal,
+            //    Width = Application.GetRealWidth(112),
+            //    Height = Application.GetRealWidth(1),
+            //    BackgroundColor = CSS_Color.DividingLineColor,
+            //});
+            //foreach (var tempRoom in SpatialInfo.CurrentSpatial.RoomList)
+            //{
+
+            //    Button btnRoom = new Button()
+            //    {
+            //        X = Application.GetRealWidth(16),
+            //        Width = Application.GetRealWidth(128),
+            //        Height = Application.GetRealHeight(50),
+            //        Text = tempRoom.roomName,
+            //        TextColor = CSS_Color.FirstLevelTitleColor,
+            //        SelectedTextColor = CSS_Color.MainColor,
+            //        TextSize = CSS_FontSize.SubheadingFontSize,
+            //        TextAlignment = TextAlignment.CenterLeft,
+            //        IsSelected = showedFunctionRoomId == tempRoom.roomId,
+            //        Tag = tempRoom.roomId,
+            //    };
+            //    roomListView.AddChidren(btnRoom);
+            //    LoadEvent_ChangeShowedFunctionList(btnRoom, dialog, tempRoom.roomName);
+
+            //    roomListView.AddChidren(new Button()
+            //    {
+            //        Gravity = Gravity.CenterHorizontal,
+            //        Width = Application.GetRealWidth(112),
+            //        Height = Application.GetRealWidth(1),
+            //        BackgroundColor = CSS_Color.DividingLineColor,
+            //    });
+            //}
+            //dialogBodyView.MouseUpEventHandler = (sender, e) =>
+            //{
+            //    dialog.Close();
+            //};
+
+            //dialog.Show();
 
 
         }

--
Gitblit v1.8.0