gxc
2019-10-28 1c4904d77f484c075080942d87785481b52b6fb2
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.R;
using ZigBee.Device;
 
namespace Shared.Phone.Device.Logic
{
    public class AddScenePage : FrameLayout
    {
 
        Button roomname;
        public AddScenePage()
        {
            Tag = "Logic";
        }
        public void Show()
        {
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
 
            var topFrameLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(220),
                Y = Application.GetRealHeight(80),
            };
 
            AddChidren(topFrameLayout);
 
            var titleName = new Button
            {
                //Text = "添加场景",
                TextID = MyInternationalizationString.addscene,
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(150),
            };
            topFrameLayout.AddChidren(titleName);
 
            var back = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                X = Application.GetRealWidth(20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            };
            topFrameLayout.AddChidren(back);
            back.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
 
            roomname = new Button
            {
                Width = Application.GetMinRealAverage(300 + 300),
                Height = Application.GetMinRealAverage(80),
                X = Application.GetRealWidth(1080 - 300 - 30 - 300),
                Y = Application.GetRealHeight(120),
                TextAlignment = TextAlignment.CenterRight,
                //Text = "自定义房间",
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextID=MyInternationalizationString.customroom,
            };
            topFrameLayout.AddChidren(roomname);
 
            var middle = new VerticalScrolViewLayout();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 300);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            this.AddChidren(middle);
 
            roomname.MouseUpEventHandler += (sender, e) =>
            {
                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                this.AddChidren(flMain);
                flMain.MouseUpEventHandler += (sender2, e2) =>
                {
                    flMain.RemoveFromParent();
                };
                var roombj = new VerticalScrolViewLayout
                {
 
                    Width = Application.GetRealWidth(400),
                    Height = Application.GetRealHeight(600),
                    X = Application.GetRealWidth(1080 - 400 - 60),
                    Y = Application.GetRealHeight(220 + 30 + 80),
                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                    Radius = (uint)Application.GetRealHeight(30),
                };
                flMain.AddChidren(roombj);
                List<Common.Room> roomlist = new List<Common.Room>();
                roomlist.Clear();
                Common.Room customroom = new Common.Room();
                //虚拟一个房间加载本地所有场景;
                customroom.SceneUIList.AddRange(Common.Room.AllRoomSceneUIList);
                customroom.Name =Language.StringByID(MyInternationalizationString.customroom);
                roomlist.Add(customroom);
                roomlist.AddRange(Common.Room.Lists);
                foreach (var room in roomlist)
                {
                    var rowLayout = new RowLayout
                    {
                        Height = Application.GetRealHeight(150),
                    };
                    roombj.AddChidren(rowLayout);
 
                    var btnroomname = new Button
                    {
                        Width = Application.GetRealWidth(300),
                        Text = room.Name,
                        TextAlignment = TextAlignment.CenterLeft,
                        X = Application.GetRealWidth(30),
                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    };
                    rowLayout.AddChidren(btnroomname);
 
                    EventHandler<MouseEventArgs> roomclick = (sender1, e1) =>
                    {
 
                        flMain.RemoveFromParent();
                        roomname.Text = room.Name;
                        SceneView(middle, room.SceneUIList);
 
                    };
                    rowLayout.MouseUpEventHandler += roomclick;
                    btnroomname.MouseUpEventHandler += roomclick;
 
                }
               
            };
 
            SceneView(middle,Common.Room.AllRoomSceneUIList);
 
        }
 
 
        void SceneView(VerticalScrolViewLayout middle,List<SceneUI>scenelist)
        {
            middle.RemoveAll();
            foreach (var tempScene in scenelist)
            {
                var deviceRowLayout = new RowLayout
                {
                    Height = Application.GetRealHeight(180),
                };
                middle.AddChidren(deviceRowLayout);
 
                var btn = new Button
                {
                    Height = Application.GetRealHeight(180),
                    Width = LayoutParams.MatchParent,
 
                };
                deviceRowLayout.AddChidren(btn);
 
                var devicetypename = new Button
                {
                    Width = Application.GetRealWidth(600),
                    Text = tempScene.Name,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth(40),
                    //SelectedBackgroundColor = 0xfffe5e00,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                };
                deviceRowLayout.AddChidren(devicetypename);
 
                EventHandler<MouseEventArgs> sceneclick = (sender, e) =>
                {
                    Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                    if (actionsInfo.ContainsKey("LinkType"))
                    {
                        actionsInfo.Remove("LinkType");
                    }
                    if (actionsInfo.ContainsKey("DeviceAddr"))
                    {
                        actionsInfo.Remove("DeviceAddr");
                    }
                    actionsInfo.Add("LinkType", 2);
                    actionsInfo.Add("DeviceAddr", tempScene.Id);
 
                    LogicIfon.AddSceneactions(tempScene,actionsInfo);
                    var logicCommunalPage = new LogicCommunalPage();
                    UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                    UserView.HomePage.Instance.PageIndex += 1;
                    logicCommunalPage.Show(() => { });
                };
 
                deviceRowLayout.MouseUpEventHandler += sceneclick;
                btn.MouseUpEventHandler += sceneclick;
                devicetypename.MouseUpEventHandler += sceneclick;
 
            }
 
        }
 
 
    }
}