wxr
2020-09-01 7d005a7618e3d7a80d8ede3baf6ecc4bf8019cd5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    public partial class SetSceneLocationPage :FrameLayout
    {
        FrameLayout bodyView;
        VerticalScrolViewLayout contentView;
        Function scene;
        Button lastButton;
        Action backAction;
        public SetSceneLocationPage(Function function, Action action)
        {
            backAction = action;
            bodyView = this;
            scene = function;
        }
 
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
            new TopViewDiv(bodyView, Language.StringByID(StringId.LocationManagement)).LoadTopView();
 
            contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(667 - 64),
            };
            bodyView.AddChidren(contentView);
 
            System.Collections.Generic.List<Room> rooms = new System.Collections.Generic.List<Room>();
            rooms.Add(new Room() { sid = "", name = Language.StringByID(StringId.WholeHouseScene),floorId = ""  });
            rooms.AddRange(DB_ResidenceData.rooms);
            foreach (var room in rooms)
            {
                var roomView = new FrameLayout()
                {
                    Height = Application.GetRealHeight(50),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                    Tag = "row"
                };
                contentView.AddChidren(roomView);
               
                Button btnRoomText = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Width = Application.GetRealWidth(280),
                    TextSize = CSS_FontSize.SubheadingFontSize,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = room.floorName + room.name,
                };
                roomView.AddChidren(btnRoomText);
 
                Button btnChoose = new Button()
                {
                    X = Application.GetRealWidth(331),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(28),
                    Height = Application.GetMinRealAverage(28),
                    UnSelectedImagePath = "Public/ChooseIcon.png",
                    SelectedImagePath = "Public/ChooseOnIcon.png",
                    Tag = "ChooseIcon"
                };
                roomView.AddChidren(btnChoose);
                if(scene.roomIdList.Contains(room.sid))
                {
                    btnChoose.IsSelected = true;
                    lastButton = btnChoose;
                }
                btnChoose.MouseUpEventHandler = (sender, e) => {
                    btnChoose.IsSelected = !btnChoose.IsSelected;
                    //LoadEvent_RoomSelected(room, btnChoose.IsSelected);
                };
                var btnLine = new Button()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Y = Application.GetRealHeight(49),
                    Height = Application.GetRealHeight(1),
                    Width = Application.GetRealWidth(343),
                    BackgroundColor = CSS_Color.DividingLineColor,
                };
                roomView.AddChidren(btnLine);
 
                LoadEvent_ChangeSceneLocation(room, btnChoose);
 
            }
        }
    }
 
    //===----------------
    public partial class SetSceneLocationPage
    {
        void LoadEvent_ChangeSceneLocation(Room room,Button btn)
        {
            btn.MouseUpEventHandler = (sender, e) => {
                if (lastButton != null)
                {
                    lastButton.IsSelected = false;
                }
                lastButton = btn;
                btn.IsSelected = true;
                scene.roomIdList = new System.Collections.Generic.List<string>();
                scene.roomIdList.Add(room.sid);
                this.RemoveFromParent();
                backAction();
            };
        }
    }
}