黄学彪
2020-04-02 9904031f5291daaf56985146bb671f25e18ebbdf
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
203
204
205
206
207
208
209
210
211
212
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.AddDelayTime);
            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(58),
                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,
                TextSize=15,
                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(58),
            };
            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);
 
            //分
            string strMinute = Language.StringByID(R.MyInternationalizationString.uMinute);
            //秒
            string strSecond = Language.StringByID(R.MyInternationalizationString.uSecond);
            var listfirst = new List<string>();
            var listSecond = new List<List<string>>();
            for (int i = 0; i <= 59; i++)
            {
                listfirst.Add(i.ToString().PadLeft(2, '0') + strMinute);
                var listTemp = new List<string>();
                for (int j = 0; j <= 59; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }
                    listTemp.Add(j.ToString().PadLeft(2, '0') + strSecond);
                }
                listSecond.Add(listTemp);
            }
            //加一个60分钟吧
            listfirst.Add("60" + strMinute);
            var listTemp2 = new List<string>() { "00" + strSecond };
            listSecond.Add(listTemp2);
 
            pickView.setPicker(listfirst, listSecond);
            pickView.setCurrentItems(totalSecond / 60, totalSecond % 60, 0);
            pickView.OnSelectChangeEvent += (value1, value2, value3) =>
            {
                int minute = Convert.ToInt32(listfirst[value1].Substring(0, 2));
                int second = Convert.ToInt32(listSecond[value1][value2].Substring(0, 2));
                totalSecond = minute * 60 + second;
            };
 
            var confirmBtn = new CommonForm.CompleteButton(1656, 907, 127);
            AddChidren(confirmBtn);
            confirmBtn.SetTitle(R.MyInternationalizationString.Save);
            confirmBtn.MouseUpEventHandler += (sender, e) =>
            {
                if (totalSecond == 0)
                {
                    RemoveFromParent();
                }
                else
                {
                    sceneTargetDevice.DelayTime = totalSecond;
                    selectedTimeAction?.Invoke(sceneTargetDevice);
                    RemoveFromParent();
                }
            };
        }
 
        #endregion
 
    }
}