gxc
2019-10-28 f6b3446e3a4afc0f65814be87aaa0f5ea0c62d69
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
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
 
namespace Shared.Phone.Device.Category
{
    public class SelectDelayTime : FrameLayout
    {
        #region ◆ 变量____________________________
        /// <summary>
        /// bodyFrameLayout
        /// </summary>
        private FrameLayout bodyFrameLayout;
        /// <summary>
        /// totalSecond
        /// </summary>
        public int totalSecond;
        /// <summary>
        /// selectedTimeAction
        /// </summary>
        public Action<SceneTargetDeviceUI> selectedTimeAction;
 
        #endregion
 
        /// <summary>
        /// SelectDelayTime
        /// </summary>
        public SelectDelayTime()
        {
            BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
            //Tag = "categoryAddScene";
        }
        /// <summary>
        /// RemoveFromParent
        /// </summary>
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        /// <summary>
        /// sceneTargetDevice
        /// </summary>
        public SceneTargetDeviceUI sceneTargetDevice;
 
        /// <summary>
        /// Show
        /// </summary>
        public void Show()
        {
            if (sceneTargetDevice == null)
            {
                sceneTargetDevice = new SceneTargetDeviceUI { Type = 2 };
            }
            AddTop();
 
            AddBodyView();
        }
 
 
        #region Add____________________________________
        /// <summary>
        /// AddTop
        /// </summary>
        private void AddTop()
        {
            var top = new TopFrameLayout();
            AddChidren(top);
            top.InitTopview();
            top.SetTopTitle(R.MyInternationalizationString.AddScence);
            top.backButton.MouseUpEventHandler += (sender, e) =>
            {
                RemoveFromParent();
            };
        }
 
        /// <summary>
        /// AddBodyView
        /// </summary>
        private void AddBodyView()
        {
            bodyFrameLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(184),
                Height = Application.GetRealHeight(1737),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
            };
            AddChidren(bodyFrameLayout);
 
            var bg1 = new FrameLayout
            {
                Y = Application.GetRealHeight(118),
                Height = Application.GetMinRealAverage(207),
                Width = Application.GetMinRealAverage(207),
                Gravity = Gravity.CenterHorizontal,
                Radius = (uint)Application.GetMinRealAverage(207 / 2),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
            };
            bodyFrameLayout.AddChidren(bg1);
 
            var bg2 = new FrameLayout
            {
                Height = Application.GetMinRealAverage(184),
                Width = Application.GetMinRealAverage(184),
                Gravity = Gravity.Center,
                Radius = (uint)Application.GetMinRealAverage(184 / 2),
                BackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
            };
            bg1.AddChidren(bg2);
 
            var timeImg = new Button
            {
                Height = Application.GetMinRealAverage(124),
                Width = Application.GetMinRealAverage(124),
                Gravity = Gravity.Center,
                Radius = (uint)Application.GetRealHeight(124 / 2),
                UnSelectedImagePath = "Item/Timer.png"
            };
            bg1.AddChidren(timeImg);
 
            var tip = new Button
            {
                Y = Application.GetRealHeight(350),
                Width = Application.GetRealWidth(700),
                Height = Application.GetRealHeight(120),
                Gravity = Gravity.CenterHorizontal,
                TextID = R.MyInternationalizationString.SelectTimeForAction,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                IsMoreLines = true
            };
            bodyFrameLayout.AddChidren(tip);
 
            var midFL = new FrameLayout
            {
                Y = Application.GetRealHeight(611),
                Height = Application.GetRealHeight(1126),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
                Radius = (uint)Application.GetRealHeight(17),
            };
            bodyFrameLayout.AddChidren(midFL);
 
            var timeFL = new FrameLayout
            {
                Y = Application.GetRealHeight(127),
                Height = Application.GetRealHeight(1126 - 127),
                BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
            };
            midFL.AddChidren(timeFL);
 
            var pickView = new UIPickerView
            {
                Height = Application.GetRealHeight(153 * 3),
            };
            timeFL.AddChidren(pickView);
 
            var minuList = new List<int> { };
            var secList = new List<int> { };
            var minuStrList = new List<string> { };
            var secStrList = new List<string> { };
            for (int i = 0; i < 60; i++)
            {
                minuList.Add(i);
                minuStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Minute)}");
                secList.Add(i);
                secStrList.Add($"{i}{Language.StringByID(R.MyInternationalizationString.Second)}");
            }
 
            pickView.setNPicker(minuStrList, secStrList, null);
 
            pickView.setCurrentItems(totalSecond / 60, totalSecond % 60, 0);
 
            pickView.OnSelectChangeEvent += (l1, l2, l3) =>
            {
                totalSecond = minuList[l1] * 60 + secList[l2];
            };
 
            var confirmBtn = new CommonForm.CompleteButton(1656, 907, 127);
            AddChidren(confirmBtn);
            confirmBtn.SetTitle(R.MyInternationalizationString.Save);
            confirmBtn.MouseUpEventHandler += (sender, e) =>
            {
                sceneTargetDevice.DelayTime = totalSecond;
                selectedTimeAction?.Invoke(sceneTargetDevice);
                RemoveFromParent();
            };
        }
 
        #endregion
 
    }
}