黄学彪
2019-11-25 5727cf0b9b54da0a191dd1e23cb5abf21320fbff
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
using System;
using System.Collections.Generic;
using Shared.Common;
 
namespace Shared.Phone.Device.CommonForm
{
    public class SelectZone : FrameLayout
    {
        public Action<Common.Room> ZoneAction;
 
        private UIPickerView pickView;
 
        private List<string> floorList = new List<string> { };
        private List<string> roomList = new List<string> { };
        private List<string> roomIdList = new List<string> { };
        private string currentId;
        public SelectZone()
        {
        }
 
        /// <summary>
        /// Init
        /// </summary>
        public void Init()
        {
            var dialog = new FrameLayout()
            {
                BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor
            };
            AddChidren(dialog);
 
            dialog.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
 
            var backgroundFL = new FrameLayout
            {
                Y = Application.GetRealHeight(1115),
                Height = Application.GetRealHeight(805),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius = (uint)Application.GetRealHeight(20)
            };
            dialog.AddChidren(backgroundFL);
 
            backgroundFL.Animate = Animate.DownToUp;
 
            var topView = new FrameLayout
            {
                Height = Application.GetRealHeight(138)
            };
            backgroundFL.AddChidren(topView);
 
            var cancle = new Button
            {
                X = Application.GetRealWidth(80),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.GXCTextGrayColor,
                TextID = R.MyInternationalizationString.Cancel,
                TextSize = 16
            };
            topView.AddChidren(cancle);
 
            var title = new Button
            {
                Width = Application.GetRealWidth(300),
                Gravity = Gravity.CenterHorizontal,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor2,
                TextID = R.MyInternationalizationString.AddTo,
                TextSize = 16
            };
            topView.AddChidren(title);
 
            var confrim = new Button
            {
                X = Application.GetRealWidth(CommonFormResouce.AppRealWidth - 80 - 300),
                Width = Application.GetRealWidth(300),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.GXCTextSelectedColor2,
                TextID = R.MyInternationalizationString.Confrim,
                TextSize = 16
            };
            topView.AddChidren(confrim);
 
            pickView = new UIPickerView
            {
                Y = Application.GetRealHeight(20 + 138),
                Height = Application.GetRealHeight(450)
            };
            backgroundFL.AddChidren(pickView);
 
            foreach (var floor in Config.Instance.Home.FloorDics)
            {
                floorList.Add(floor.Value);
            }
            foreach (var room in Shared.Common.Room.Lists)
            {
                roomList.Add(room.Name);
                roomIdList.Add(room.Id);
            }
 
            if (floorList.Count == 0)
            {
                pickView.setNPicker(roomList, null, null);
                pickView.OnSelectChangeEvent += (l1, l2, l3) =>
                {
                    currentId = roomIdList[l1];
                };
            }
            else
            {
                pickView.setNPicker(floorList, roomList, null);
                pickView.OnSelectChangeEvent += (l1, l2, l3) =>
                {
                    currentId = roomIdList[l2];
                };
            }
 
            cancle.MouseUpEventHandler += Close;
            confrim.MouseUpEventHandler += Confrim_MouseEvent;
        }
 
        /// <summary>
        /// Close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void Close(object sender, MouseEventArgs mouseEventArgs)
        {
            RemoveFromParent();
        }
 
        /// <summary>
        /// Confrim_MouseEvent
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="mouseEventArgs"></param>
        private void Confrim_MouseEvent(object sender, MouseEventArgs mouseEventArgs)
        {
            if (Shared.Common.Room.CurrentRoom.GetRoomById(currentId) != null)
            {
                ZoneAction?.Invoke(Shared.Common.Room.CurrentRoom.GetRoomById(currentId));
            }
            RemoveFromParent();
        }
    }
}